/* =====================================================================
 * رحلة الادخار عبر عُمان — التنسيقات
 * ===================================================================== */
:root {
  --green: #1b6b4a;
  --green-2: #2e7d32;
  --red: #c1121f;
  --gold: #f2b705;
  --sand: #f6ecd2;
  --ink: #1f2a2e;
  --muted: #5d6b70;
  --card: #ffffff;
  --line: #e6dcc4;
  --radius: 18px;
  --shadow: 0 10px 30px rgba(31, 42, 46, .18);
  --font: 'Cairo', 'Tajawal', 'Segoe UI', Tahoma, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: #9fd3e6;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font-family: inherit; font-size: 1rem; }
.hidden { display: none !important; }

.screen { position: fixed; inset: 0; display: none; }
.screen.active { display: block; }

/* ---------------- الأزرار ---------------- */
.btn {
  border: 0; border-radius: 14px; padding: .7rem 1.2rem; cursor: pointer;
  font-weight: 700; transition: transform .12s, box-shadow .12s, background .2s;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn:disabled { opacity: .6; cursor: wait; }
.btn.big { width: 100%; padding: .9rem 1.2rem; font-size: 1.1rem; }
.btn.primary { background: linear-gradient(180deg, #23875d, var(--green)); color: #fff; box-shadow: 0 6px 0 #0f4a32; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.gold { background: linear-gradient(180deg, #ffd23f, #e0a800); color: #3b2a00; box-shadow: 0 6px 0 #9a7300; }
.btn.ghost { background: transparent; color: var(--green); border: 2px solid var(--green); }
.btn.ghost.light { color: #fff; border-color: #fff; }
.btn:focus-visible, .icon-btn:focus-visible, .option:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

.icon-btn {
  width: 42px; height: 42px; border-radius: 12px; border: 0; cursor: pointer;
  background: rgba(255, 255, 255, .9); font-size: 1.2rem; box-shadow: 0 3px 10px rgba(0, 0, 0, .12);
}
.icon-btn:hover { background: #fff; }

/* ---------------- شاشة التسجيل ---------------- */
#screen-register { overflow-y: auto; }
.register-bg {
  position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(circle at 15% 20%, rgba(255, 255, 255, .5) 0 6%, transparent 7%),
    radial-gradient(circle at 85% 80%, rgba(242, 183, 5, .35) 0 10%, transparent 11%),
    linear-gradient(160deg, #1b6b4a 0%, #2a9d8f 45%, #f4d58d 100%);
}
.register-card {
  width: min(520px, calc(100% - 32px)); margin: 32px auto; background: var(--card);
  border-radius: 24px; padding: 28px 26px 18px; box-shadow: var(--shadow);
  border-top: 8px solid var(--red);
}
.logo { font-size: 3.4rem; text-align: center; line-height: 1; animation: spin 4s ease-in-out infinite; }
@keyframes spin { 0%, 100% { transform: rotateY(0); } 50% { transform: rotateY(180deg); } }
.register-card h1 { text-align: center; margin: .4rem 0 .2rem; color: var(--green); font-size: 1.9rem; font-weight: 800; }
.lead { text-align: center; color: var(--muted); line-height: 1.8; margin: .2rem 0 1rem; }
form label { display: block; font-weight: 700; margin-bottom: .8rem; }
form input, form select {
  display: block; width: 100%; margin-top: .35rem; padding: .75rem .9rem; border-radius: 12px;
  border: 2px solid var(--line); background: #fffdf7; color: var(--ink);
}
form input:focus, form select:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px rgba(27, 107, 74, .15); }
.form-error { color: var(--red); min-height: 1.2em; margin: .2rem 0 .6rem; font-weight: 600; }
.hint { color: var(--muted); font-size: .85rem; text-align: center; margin: .8rem 0 0; }
.resume-box { background: var(--sand); border-radius: 14px; padding: 14px; text-align: center; margin-bottom: 1rem; }
.resume-box .row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.howto { margin-top: 1rem; background: #f7f9f8; border-radius: 12px; padding: .6rem .9rem; }
.howto summary { cursor: pointer; font-weight: 700; color: var(--green); }
.howto li { margin: .35rem 0; line-height: 1.7; }
.reg-footer { text-align: center; margin-top: 1rem; font-size: .85rem; }
.reg-footer a { color: var(--muted); }

/* ---------------- شاشة اللعب ---------------- */
.map { position: absolute; inset: 0; }
.map canvas { display: block; touch-action: none; }
.labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.map-fallback { position: absolute; inset: 80px 16px auto 16px; background: #fff; border-radius: 12px; padding: 12px; text-align: center; }

.map-label {
  position: absolute; top: 0; left: 0; white-space: nowrap; pointer-events: none;
  font-weight: 700; will-change: transform;
}
.map-label.station {
  pointer-events: auto; cursor: pointer; background: rgba(255, 255, 255, .92); padding: 2px 9px 2px 7px;
  border-radius: 999px; font-size: .78rem; box-shadow: 0 2px 6px rgba(0, 0, 0, .18); color: var(--ink);
}
.map-label.station .ico { margin-left: 4px; }
.map-label.station.done { background: #e8f5e9; color: #1b5e20; }
.map-label.station.locked { opacity: .82; }
.map-label.station.current { background: var(--gold); color: #3b2a00; font-size: .9rem; animation: bob 1.4s ease-in-out infinite; }
@keyframes bob { 50% { margin-top: -4px; } }
.map-label.gov {
  font-size: .78rem; color: #fff; background: var(--c, #333); padding: 2px 10px; border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .2); opacity: .95;
}
.map-label.region { color: rgba(60, 60, 60, .55); font-size: 1rem; letter-spacing: 1px; }
.map-label.region.sea { color: rgba(255, 255, 255, .85); font-style: italic; text-shadow: 0 1px 2px rgba(0, 0, 0, .25); }
.map-label.region.small { font-size: .78rem; }

.hud {
  position: absolute; top: 12px; right: 12px; left: 12px; display: flex; align-items: center; gap: 12px;
  background: rgba(255, 255, 255, .88); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-radius: 16px; padding: 8px 12px; box-shadow: var(--shadow); z-index: 5;
}
.hud-player { display: flex; align-items: center; gap: 8px; min-width: 0; }
.hud-player > div { min-width: 0; }
.avatar { font-size: 1.8rem; background: var(--sand); border-radius: 50%; width: 46px; height: 46px; display: grid; place-items: center; flex: none; }
.hud-name { font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 180px; }
.hud-sub { color: var(--muted); font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-progress { flex: 1; min-width: 80px; }
.bar { height: 10px; background: #e7e2d3; border-radius: 99px; overflow: hidden; margin-top: 4px; }
.bar-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--green-2), var(--gold)); border-radius: 99px; transition: width .8s; }
.hud-score {
  display: flex; align-items: center; gap: 6px; font-weight: 800; font-size: 1.3rem;
  background: #fff6d6; border: 2px solid var(--gold); padding: 2px 12px; border-radius: 999px;
}
.hud-actions { display: flex; gap: 6px; }

.station-card {
  position: absolute; top: 92px; right: 12px; width: 340px; max-height: calc(100% - 104px); overflow-y: auto;
  background: rgba(255, 255, 255, .96); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); z-index: 4;
}
.gov-chip { display: inline-block; color: #fff; font-weight: 700; font-size: .85rem; padding: 3px 12px; border-radius: 999px; }
.station-card h2 { margin: .5rem 0 .3rem; font-size: 1.45rem; color: var(--ink); }
.fact { line-height: 1.8; color: #34444a; margin: 0 0 .7rem; }
.card-status { background: var(--sand); border-radius: 12px; padding: 8px 10px; font-size: .9rem; margin-bottom: .9rem; line-height: 1.7; }
.station-card .btn.big + .btn.big { margin-top: 8px; }
.journey { list-style: none; display: grid; grid-template-columns: repeat(11, 1fr); gap: 5px; padding: 0; margin: 14px 0 0; }
.journey li {
  height: 14px; border-radius: 4px; background: #ddd; cursor: pointer; position: relative;
  border-bottom: 3px solid var(--c);
}
.journey li.done { background: var(--green-2); }
.journey li.current { background: var(--gold); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 4px rgba(242, 183, 5, .35); } }

.toast {
  position: absolute; bottom: 22px; left: 50%; transform: translate(-50%, 30px); opacity: 0;
  background: rgba(31, 42, 46, .92); color: #fff; padding: 10px 18px; border-radius: 12px; z-index: 20;
  transition: all .3s; pointer-events: none; max-width: calc(100% - 32px); text-align: center; font-weight: 600;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------------- نافذة الاختبار ---------------- */
.modal {
  position: fixed; inset: 0; background: rgba(15, 30, 25, .55); display: grid; place-items: center;
  z-index: 30; padding: 16px; animation: fade .2s;
}
@keyframes fade { from { opacity: 0; } }
.modal-card {
  width: min(620px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; background: #fff;
  border-radius: 22px; padding: 18px 20px 22px; box-shadow: var(--shadow); border-top: 8px solid var(--green);
  animation: pop .25s ease-out;
}
@keyframes pop { from { transform: scale(.94); opacity: 0; } }
.quiz-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.quiz-head h3 { margin: 0; font-size: 1.3rem; }
.quiz-meta { display: flex; justify-content: space-between; color: var(--muted); font-size: .88rem; margin-top: 10px; }
.dots { display: flex; gap: 6px; margin: 8px 0 4px; }
.dots span { flex: 1; height: 8px; border-radius: 99px; background: #e6e6e6; }
.dots span.now { background: var(--gold); }
.dots span.ok { background: var(--green-2); }
.dots span.no { background: var(--red); }
.quiz-q { font-size: 1.2rem; font-weight: 700; line-height: 1.8; margin: 12px 0; }
.options { display: grid; gap: 10px; }
.option {
  display: flex; align-items: center; gap: 10px; text-align: right; width: 100%; padding: 12px 14px;
  border-radius: 14px; border: 2px solid var(--line); background: #fffdf7; cursor: pointer; line-height: 1.6;
  transition: border-color .15s, background .15s, transform .1s; color: var(--ink);
}
.option:hover:not(:disabled) { border-color: var(--green); background: #f1faf5; }
.option:disabled { cursor: default; }
.option .letter {
  flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: var(--sand); font-weight: 800;
}
.option.right { border-color: var(--green-2); background: #e8f5e9; }
.option.right .letter { background: var(--green-2); color: #fff; }
.option.wrong { border-color: var(--red); background: #fdecea; animation: shake .35s; }
.option.wrong .letter { background: var(--red); color: #fff; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.feedback { margin: 14px 0 10px; padding: 12px 14px; border-radius: 12px; line-height: 1.8; }
.feedback.ok { background: #e8f5e9; color: #1b5e20; }
.feedback.no { background: #fff4e5; color: #7a4100; }
#quiz-next { width: 100%; }
.quiz-result { text-align: center; padding: 10px 4px; }
.result-emoji { font-size: 4rem; }
.quiz-result h3 { font-size: 1.5rem; margin: .3rem 0; }
.quiz-result p { color: var(--muted); line-height: 1.8; }
.result-points { font-size: 1.8rem; font-weight: 800; color: #9a7300; margin: .4rem 0 1rem; }

/* ---------------- الشهادة ---------------- */
#screen-finish { background: linear-gradient(160deg, #1b6b4a, #2a9d8f); overflow-y: auto; padding: 24px 16px; }
#screen-finish.active { display: block; }
.certificate { width: min(760px, 100%); margin: 0 auto; background: #fffdf5; border-radius: 10px; padding: 14px; box-shadow: var(--shadow); }
.cert-border {
  border: 6px double var(--gold); border-radius: 6px; padding: 26px 20px; text-align: center;
  background: radial-gradient(circle at center, #fff 0, #fffaf0 70%);
}
.cert-top { font-size: 2.6rem; }
.cert-border h2 { color: var(--green); font-size: 2rem; margin: .2rem 0 .6rem; font-weight: 800; }
.cert-border p { line-height: 1.9; margin: .3rem 0; }
.cert-name { font-size: 2.1rem; font-weight: 800; color: var(--red); margin: .4rem 0; border-bottom: 2px dashed var(--gold); display: inline-block; padding: 0 20px 4px; }
.cert-score { margin-top: 1rem; font-size: 1.25rem; }
.cert-score b { color: var(--green); font-size: 1.5rem; }
.cert-rank { color: #9a7300; font-weight: 700; margin-top: .4rem; }
.cert-date { color: var(--muted); margin-top: .8rem; font-size: .9rem; }
.finish-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin: 18px auto; }

/* ---------------- احتفال ---------------- */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 50; overflow: hidden; }
.confetti i { position: absolute; top: -12px; width: 9px; height: 14px; border-radius: 2px; animation: fall linear forwards; }
@keyframes fall { to { top: 105vh; transform: rotate(720deg) translateX(40px); } }

/* ---------------- الجوال ---------------- */
@media (max-width: 760px) {
  .hud { flex-wrap: wrap; gap: 8px; padding: 8px; top: 8px; right: 8px; left: 8px; }
  .hud-player { flex: 1; }
  .hud-progress { order: 5; flex-basis: 100%; }
  .hud-actions { gap: 4px; }
  .icon-btn { width: 36px; height: 36px; font-size: 1rem; }
  .avatar { width: 38px; height: 38px; font-size: 1.4rem; }
  .hud-name { max-width: 110px; }
  .hud-score { font-size: 1.05rem; padding: 2px 10px; }
  .station-card {
    top: auto; bottom: 0; right: 0; left: 0; width: auto; max-height: 46vh;
    border-radius: 20px 20px 0 0; padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
  }
  .station-card h2 { font-size: 1.2rem; }
  .fact { font-size: .9rem; line-height: 1.7; }
  .toast { bottom: auto; top: 120px; }
  .quiz-q { font-size: 1.05rem; }
}

/* ---------------- الطباعة (الشهادة فقط) ---------------- */
@media print {
  body { background: #fff; overflow: visible; }
  .screen { position: static; display: none !important; }
  #screen-finish { display: block !important; background: none; padding: 0; }
  .finish-actions, .confetti, .modal { display: none !important; }
  .certificate { box-shadow: none; width: 100%; }
}
