:root{
  --bg-top: #E9F1F6;
  --bg-bottom: #C8DAE5;
  --ink: #1E2F40;
  --ink-soft: #64768A;
  --card-bg: #FFFFFF;
  --accent: #2F5770;
  --accent-soft: #E3EEF4;
  --line: rgba(30,47,64,.08);
  --radius: 20px;
  --shadow: 0 16px 34px rgba(21,36,49,.10);
  --font-ar: 'Tajawal', sans-serif;
  --font-body: var(--font-ar);

  --tool: #2E8A5B;
  --tool-dark: #1E5E3D;
  --tool-soft: #DDF3E4;
  --heart: #D85A30;
  --gold: #F0C56B;
  --gold-dark: #B8860B;
}

*{ box-sizing:border-box; }
html,body{ min-height:100%; margin:0; }
body{
  background: linear-gradient(160deg, rgba(233,241,246,.92) 0%, rgba(200,218,229,.92) 100%), var(--bg-bottom);
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--font-body);
  line-height:1.6;
  -webkit-font-smoothing:antialiased;
  overflow-x:hidden;
}
a{ color:inherit; }
.hidden{ display:none !important; }

/* ===== topbar ===== */
.topbar-inner{
  max-width: 1100px; margin: 0 auto;
  padding: 22px 24px 0;
  display:flex; align-items:center; justify-content:space-between;
  flex-wrap:wrap; row-gap:12px;
}
.back-link{
  display:flex; align-items:center; gap:8px;
  font-size:14px; font-weight:700; color:var(--ink-soft);
  text-decoration:none;
}
.back-link:hover{ color:var(--accent); }
.back-link svg{ width:18px; height:18px; flex:none; }
[dir="rtl"] .back-link svg{ transform:scaleX(-1); }

.auth-wrap{ position:relative; }
.auth-btn{
  display:flex; align-items:center; gap:8px;
  border:1px solid var(--line); background:var(--card-bg);
  border-radius:999px; padding:8px 14px 8px 8px;
  cursor:pointer; font-family:inherit; color:var(--ink);
  box-shadow:0 2px 8px rgba(21,36,49,.06);
  font-size:.85rem; font-weight:600;
}
.auth-btn:hover{ background:var(--accent-soft); }
.auth-avatar{
  width:28px; height:28px; border-radius:50%;
  background:var(--tool); color:#fff;
  display:flex; align-items:center; justify-content:center; flex-shrink:0;
  font-size:12px; font-weight:800;
}
.auth-avatar-img{ width:28px; height:28px; border-radius:50%; object-fit:cover; flex-shrink:0; }
.auth-menu{
  position:absolute; top:calc(100% + 10px); inset-inline-end:0;
  background:var(--card-bg); border:1px solid var(--line); border-radius:16px;
  box-shadow:var(--shadow); min-width:180px; padding:8px; z-index:30;
}
.auth-menu-item{
  display:flex; align-items:center; gap:8px; width:100%;
  padding:10px 12px; border-radius:10px; background:none; border:none;
  cursor:pointer; font-family:inherit; font-size:.88rem; color:var(--ink); text-align:start;
}
.auth-menu-item:hover{ background:var(--accent-soft); }

/* ===== hero (subjects screen) ===== */
.hero{ max-width:640px; margin:0 auto; padding:26px 24px 6px; text-align:center; }
.hero-icon{ width:64px; height:64px; margin:0 auto 12px; }
.hero h1{ font-weight:900; font-size:clamp(1.4rem, 3.2vw, 1.9rem); margin:0 0 8px; color:var(--ink); }
.hero p{ font-size:14px; color:var(--ink-soft); margin:0 auto; max-width:460px; line-height:1.8; }

/* ===== subjects grid ===== */
.subjects-grid{
  max-width:760px; margin:24px auto 60px; padding:0 24px;
  display:grid; grid-template-columns:repeat(auto-fit,minmax(180px,1fr)); gap:16px;
}
.subject-card{
  background:var(--card-bg); border-radius:var(--radius); box-shadow:var(--shadow);
  border:1px solid var(--line); padding:22px 16px; text-align:center; cursor:pointer;
  transition:transform .18s ease;
}
.subject-card:hover{ transform:translateY(-4px); }
.subject-card.locked{ opacity:.55; cursor:default; }
.subject-card.locked:hover{ transform:none; }
.subject-icon{ width:56px; height:56px; margin:0 auto 12px; }
.subject-name{ font-weight:800; font-size:14.5px; color:var(--ink); }
.subject-status{ font-size:11.5px; color:var(--tool); font-weight:700; margin-top:6px; }
.subject-status.soon{ color:var(--ink-soft); }

/* ===== stage map ===== */
.map-topbar{
  max-width:600px; margin:0 auto; padding:20px 24px 0;
  display:flex; align-items:center; justify-content:space-between;
}
.ghost-btn{
  border:1.5px solid var(--line); background:var(--card-bg); color:var(--ink-soft);
  font-family:inherit; font-weight:700; font-size:13px;
  padding:9px 16px; border-radius:999px; cursor:pointer; display:flex; align-items:center; gap:6px;
}
.ghost-btn:hover{ background:var(--accent-soft); }
.ghost-btn svg{ width:16px; height:16px; }
[dir="rtl"] .ghost-btn svg{ transform:scaleX(-1); }
.map-title{ font-weight:900; font-size:15px; color:var(--ink); }

.map-wrap{
  position:relative; max-width:600px; margin:0 auto 60px; padding:36px 20px 60px;
  overflow:hidden;
}
.map-bg-symbol{
  position:absolute; font-size:70px; font-weight:900; color:#fff; opacity:.5;
  pointer-events:none; z-index:0;
}
.map-bg-symbol.s1{ top:10px; inset-inline-end:16px; }
.map-bg-symbol.s2{ bottom:60px; inset-inline-start:8px; font-size:50px; }
.map-bg-symbol.s3{ top:220px; inset-inline-end:40px; font-size:40px; }

.stage-path{ position:relative; z-index:1; display:flex; flex-direction:column; align-items:center; }

.stage-node-row{ display:flex; align-items:center; gap:14px; margin-bottom:6px; }
.stage-node-row.align-start{ align-self:flex-start; }
.stage-node-row.align-end{ align-self:flex-end; }

.stage-node{
  width:70px; height:70px; border-radius:50%;
  display:flex; align-items:center; justify-content:center; flex:none;
  cursor:pointer; border:none; position:relative;
}
.stage-node.current{ width:82px; height:82px; border:3px solid #fff; }
.stage-node.locked{ cursor:default; }
.stage-node svg{ width:32px; height:32px; }
.stage-node.current svg{ width:36px; height:36px; }

.stage-info{ min-width:0; }
.stage-name{ font-weight:800; font-size:13.5px; color:var(--ink); }
.stage-node-row.locked .stage-name{ color:var(--ink-soft); }
.stage-stars{ display:flex; gap:2px; margin-top:4px; }
.stage-stars svg{ width:15px; height:15px; }
.stage-status-text{ font-size:11px; font-weight:700; margin-top:4px; }

.connector-svg{ display:block; margin:-6px 0; }

/* ===== play view ===== */
.play-wrap{ max-width:520px; margin:0 auto; padding:20px 24px 60px; }
.play-topbar{ display:flex; align-items:center; gap:10px; margin-bottom:8px; }
.icon-only-btn{
  border:none; background:var(--card-bg); color:var(--ink-soft); width:36px; height:36px;
  border-radius:50%; cursor:pointer; font-size:16px; box-shadow:0 2px 6px rgba(21,36,49,.08); flex:none;
}
.lives-row{ display:flex; gap:4px; flex:none; }
.lives-row svg{ width:22px; height:22px; }
.progress-track{ flex:1; height:8px; background:#EEF2F5; border-radius:999px; overflow:hidden; }
.progress-fill{ height:100%; background:var(--accent); border-radius:999px; transition:width .25s ease; }
.progress-count{ font-size:11.5px; color:var(--ink-soft); font-weight:700; flex:none; }

.timer-wrap{ display:flex; justify-content:center; margin-bottom:-30px; position:relative; z-index:2; }
.timer-circle{
  width:60px; height:60px; border-radius:50%; background:#fff;
  border:5px solid var(--gold); display:flex; align-items:center; justify-content:center;
  box-shadow:0 4px 10px rgba(30,47,64,.12); transition:border-color .3s ease;
}
.timer-circle.warn{ border-color:var(--heart); }
.timer-circle span{ font-size:20px; font-weight:900; color:var(--gold-dark); }
.timer-circle.warn span{ color:var(--heart); }

.question-card{
  background:var(--card-bg); border-radius:var(--radius); box-shadow:var(--shadow);
  border:1px solid var(--line); padding:24px 22px;
}
.question-prompt{
  background:var(--accent-soft); border-radius:14px; padding:34px 18px 20px;
  margin-bottom:20px; text-align:center; font-size:16.5px; font-weight:800; color:var(--ink); line-height:1.7;
}

/* answer types */
.mcq-grid{ display:grid; grid-template-columns:1fr 1fr; gap:12px; }
.mcq-grid.single-col{ grid-template-columns:1fr; }
.mcq-option{
  background:var(--accent-soft); border:none; border-bottom:4px solid rgba(30,47,64,.1);
  border-radius:14px; padding:16px 14px; display:flex; align-items:center; gap:10px;
  cursor:pointer; text-align:start; font-family:inherit;
}
.mcq-option .opt-letter{
  width:26px; height:26px; border-radius:50%; background:#fff; border:1.5px solid rgba(30,47,64,.15);
  color:var(--ink-soft); font-size:12px; font-weight:800; display:flex; align-items:center; justify-content:center; flex:none;
}
.mcq-option .opt-text{ font-size:17px; font-weight:700; color:var(--ink); }
.mcq-option.correct{ background:var(--tool-soft); border-bottom-color:var(--tool); }
.mcq-option.correct .opt-letter{ background:var(--tool); color:#fff; border-color:var(--tool); }
.mcq-option.correct .opt-text{ color:var(--tool-dark); }
.mcq-option.wrong{ background:#FBE4E9; border-bottom-color:#B1345A; }
.mcq-option.wrong .opt-letter{ background:#B1345A; color:#fff; border-color:#B1345A; }
.mcq-option.wrong .opt-text{ color:#B1345A; }
.mcq-option:disabled{ cursor:default; }

.fill-row{ display:flex; gap:10px; }
.fill-input{
  flex:1; font-family:inherit; font-size:17px; font-weight:700; color:var(--ink);
  background:var(--accent-soft); border:1.5px solid var(--line); border-radius:14px; padding:14px 16px; text-align:center;
}
.fill-input:focus{ outline:none; border-color:var(--tool); box-shadow:0 0 0 4px var(--tool-soft); }
.fill-check-btn{
  border:none; background:var(--tool); color:#fff; font-family:inherit; font-weight:800; font-size:14px;
  padding:0 22px; border-radius:14px; cursor:pointer; border-bottom:4px solid var(--tool-dark);
}

.match-grid{ display:grid; grid-template-columns:1fr 1fr; gap:10px; }
.match-item{
  border-radius:12px; padding:12px 10px; font-size:13px; font-weight:700; text-align:center; cursor:pointer;
  background:var(--accent-soft); border:1.5px solid transparent;
}
.match-item.left-item{ background:#FBEAF0; color:#993556; }
.match-item.right-item{ color:var(--ink); }
.match-item.selected{ border-color:var(--accent); box-shadow:0 0 0 3px var(--accent-soft); }
.match-item.matched{ background:var(--tool-soft); color:var(--tool-dark); cursor:default; opacity:.7; }
.match-item.wrong-flash{ background:#FBE4E9; color:#B1345A; }

.feedback-bubble{
  margin-top:16px; border-radius:12px; padding:12px 16px; display:flex; align-items:center; gap:10px;
  font-size:14px; font-weight:800;
}
.feedback-bubble.correct{ background:var(--tool-soft); color:var(--tool-dark); }
.feedback-bubble.wrong{ background:#FBE4E9; color:#B1345A; }
.feedback-icon{ width:26px; height:26px; border-radius:50%; display:flex; align-items:center; justify-content:center; flex:none; color:#fff; font-size:14px; }
.feedback-bubble.correct .feedback-icon{ background:var(--tool); }
.feedback-bubble.wrong .feedback-icon{ background:#B1345A; }

/* ===== pressable (3D) buttons ===== */
.pressable-btn{
  border:none; font-family:inherit; font-weight:800; font-size:14px;
  padding:13px 26px; border-radius:999px; cursor:pointer;
  transition: transform .08s ease;
}
.pressable-btn:active{ transform:translateY(3px); }
.pressable-btn.primary{ background:var(--tool); color:#fff; border-bottom:4px solid var(--tool-dark); }
.pressable-btn.secondary{ background:#fff; color:var(--tool); border:1.5px solid var(--tool); border-bottom:4px solid var(--tool); }
.pressable-btn.primary:active{ border-bottom-width:1px; }
.full-width{ width:100%; }
.text-btn{
  border:none; background:none; color:var(--ink-soft); font-family:inherit; font-weight:700;
  font-size:13px; cursor:pointer; text-decoration:underline; padding:8px 4px;
}

/* ===== result view ===== */
.result-wrap{ max-width:460px; margin:40px auto 60px; padding:0 24px; }
.result-card{
  background: linear-gradient(160deg, var(--bg-top), var(--bg-bottom));
  border-radius:var(--radius); box-shadow:var(--shadow); padding:38px 24px; text-align:center;
  position:relative; overflow:hidden;
}
.result-trophy{ width:80px; height:80px; margin:0 auto 16px; }
.result-stars{ display:flex; justify-content:center; gap:4px; margin-bottom:14px; }
.result-stars svg{ width:30px; height:30px; }
.result-stars svg.mid{ width:36px; height:36px; margin-top:-4px; }
.result-headline{ font-size:17px; font-weight:900; color:var(--ink); margin-bottom:4px; }
.result-sub{ font-size:12.5px; color:var(--ink-soft); margin-bottom:22px; }
.result-actions{ display:flex; flex-direction:column; gap:10px; align-items:center; }
.result-actions .pressable-btn{ min-width:200px; }

.site-footer{ text-align:center; color:var(--ink-soft); font-size:.82rem; padding:20px 20px 40px; }

a:focus-visible, button:focus-visible, input:focus-visible{
  outline:2px solid var(--tool); outline-offset:2px;
}

/* ===== auth modal ===== */
.modal-overlay{
  position:fixed; inset:0; background:rgba(20,30,40,.45); z-index:100;
  display:flex; align-items:center; justify-content:center; padding:20px;
}
.modal-card{
  background:var(--card-bg); border-radius:var(--radius); box-shadow:var(--shadow);
  padding:26px 24px; max-width:360px; width:100%; position:relative;
}
.modal-close{
  position:absolute; top:14px; inset-inline-end:14px; border:none; background:none;
  font-size:20px; color:var(--ink-soft); cursor:pointer; line-height:1;
}
.modal-card h3{ margin:0 0 4px; font-size:16.5px; font-weight:900; color:var(--ink); }
.modal-sub{ font-size:12.5px; color:var(--ink-soft); margin:0 0 16px; }
.auth-error{ background:#FDECEC; color:#B1345A; font-size:12px; padding:8px 12px; border-radius:8px; margin-bottom:12px; }
#authForm .field{ margin-bottom:10px; display:flex; flex-direction:column; gap:6px; }
#authForm label{ font-size:12.5px; font-weight:700; color:var(--ink-soft); }
.field-input{
  width:100%; font-family:inherit; font-size:14px; color:var(--ink);
  background:var(--accent-soft); border:1.5px solid var(--line); border-radius:12px; padding:10px 12px;
}
.field-input:focus{ outline:none; border-color:var(--tool); box-shadow:0 0 0 4px var(--tool-soft); }
.google-btn{
  width:100%; display:flex; align-items:center; justify-content:center; gap:8px;
  padding:11px; border-radius:999px; border:1.5px solid var(--line); background:var(--card-bg);
  color:var(--ink); font-weight:700; cursor:pointer; font-family:inherit; font-size:13.5px; margin-top:6px;
}
.google-btn:hover{ background:var(--accent-soft); }
.modal-divider{ text-align:center; color:var(--ink-soft); font-size:11.5px; margin:14px 0; }
.modal-switch{ text-align:center; margin-top:14px; font-size:12.5px; color:var(--ink-soft); }
.modal-switch button{ background:none; border:none; color:var(--tool); font-weight:800; cursor:pointer; font-family:inherit; }

@media (max-width:420px){
  .question-prompt{ font-size:15px; padding:30px 14px 16px; }
  .mcq-option .opt-text{ font-size:15px; }
  .stage-node{ width:60px; height:60px; }
  .stage-node.current{ width:70px; height:70px; }
}

@media (prefers-reduced-motion:reduce){
  *{ transition:none !important; }
}
