:root{
  --bg0:#faf9f6;
  --bg1:#f5f3ee;
  --card:#ffffff;
  --ink:#1f2937;
  --muted:#6b7280;
  --navy:#263238;
  --teal:#009688;
  --coral:#ff7043;
  --ok:#16a34a;
  --bad:#dc2626;
  --r2xl:18px;
  --shadow: 0 10px 30px rgba(0,0,0,.10);
  --shadow2: 0 6px 18px rgba(0,0,0,.12);
  --shadow3: 0 20px 50px rgba(0,0,0,.15);
  --t120:120ms;
  --t150:150ms;
  --t200:200ms;
  --t300:300ms;
  --glow: 0 0 0 3px rgba(0,150,136,.14);
  --focus: 0 0 0 4px rgba(0,150,136,.20);
  --gridline: rgba(0,0,0,.08);
  --mono: ui-monospace, Menlo, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark){
  :root{
    --bg0:#0b1220;
    --bg1:#0f172a;
    --card:#111c33;
    --ink:#e5e7eb;
    --muted:#a1a1aa;
    --gridline: rgba(255,255,255,.10);
  }
}

html[data-contrast="high"]{
  --bg0:#000;
  --bg1:#000;
  --card:#000;
  --ink:#fff;
  --muted:#fff;
}

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Inter, Arial, sans-serif;
  color:var(--ink);
  background: linear-gradient(180deg, var(--bg0), var(--bg1));
}

.app{
  min-height:100%;
  display:flex;
  justify-content:center;
  padding: clamp(12px, 2.2vw, 22px);
}

.shell{
  width:min(1200px, 100%);
  display:grid;
  grid-template-rows:auto 1fr auto;
  gap: 14px;
}

.topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 12px;
  padding: 12px 14px;
  background: var(--card);
  border: 2px solid var(--gridline);
  border-radius: 18px;
  box-shadow: var(--shadow2);
  flex-wrap: wrap;
}

.brand{ display:flex; gap:10px; align-items:center; }
.logo{
  width:44px; height:44px; border-radius: 16px;
  background: linear-gradient(135deg, var(--navy), rgba(0,150,136,.95));
  color:#fff; display:grid; place-items:center;
  font-weight: 950;
}
.titleblock .title{ font-weight: 950; font-size:16px; }
.titleblock .sub{ color:var(--muted); font-size:11px; margin-top:2px; }

.hud{ display:flex; flex-wrap:wrap; gap:10px; justify-content:flex-end; align-items:center; }

.pill{
  display:flex; align-items:center; gap:8px;
  padding: 8px 10px;
  border-radius: 999px;
  background: rgba(0,0,0,.04);
  border: 2px solid var(--gridline);
  font-size: 12.5px;
}
.pill b{ font-weight:950; }

.btn{
  border:0;
  cursor:pointer;
  font-weight: 900;
  padding: 10px 12px;
  border-radius: 14px;
  background: var(--navy);
  color:#fff;
  box-shadow: var(--shadow2);
  transition: transform var(--t150) ease, filter var(--t150) ease;
}
.btn:hover{ filter: brightness(1.05); transform: translateY(-2px); }
.btn:active{ transform: translateY(0px) scale(.98); }
.btn.small{ padding: 8px 10px; border-radius: 12px; font-size: 12.5px; }
.btn.secondary{ background: rgba(0,0,0,.04); color: var(--ink); border: 2px solid var(--gridline); box-shadow:none; }
.btn.teal{ background: var(--teal); }
.btn.coral{ background: var(--coral); }
.btn.ghost{ background: transparent; color: var(--ink); border: 2px dashed rgba(0,0,0,.22); box-shadow:none; }

.main{
  background: var(--card);
  border: 2px solid var(--gridline);
  border-radius: 18px;
  box-shadow: var(--shadow);
  overflow:hidden;
}

.scene{ padding: clamp(14px, 2.1vw, 20px); display:none; }
.scene.active{ display:block; }

.grid{ display:grid; gap:14px; }
.grid.cols2{ grid-template-columns: 1.2fr .8fr; }
@media (max-width: 900px){ .grid.cols2{ grid-template-columns: 1fr; } }

.card{
  background: var(--card);
  border: 2px solid var(--gridline);
  border-radius: 18px;
  box-shadow: var(--shadow2);
  padding: 14px;
}

.card h2{ margin:0 0 8px 0; font-size:18px; }
.card p{ margin:0; color:var(--muted); line-height:1.35; font-size:14px; }

.row{ display:flex; flex-wrap:wrap; gap:10px; align-items:center; }

.prompt{
  padding: 14px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(0,150,136,.12), transparent 65%);
  border: 2px solid rgba(0,150,136,.22);
}
.prompt .kicker{ font-size: 12px; font-weight: 950; color: var(--teal); text-transform: uppercase; }
.prompt .q{ margin-top: 8px; font-size: 18px; font-weight: 950; line-height: 1.25; }

.answers{ margin-top:12px; display:grid; gap:10px; }
.choice{
  padding: 12px 12px;
  border-radius: 18px;
  border: 2px solid var(--gridline);
  background: rgba(0,0,0,.04);
  cursor:pointer;
  font-weight: 850;
  transition: transform var(--t150) ease, border-color var(--t150) ease;
}
.choice:hover{ transform: translateY(-1px); border-color: rgba(0,150,136,.35); box-shadow: var(--glow); }
.choice[aria-selected="true"]{ border-color: rgba(0,150,136,.60); box-shadow: var(--focus); }
.choice.correct{ border-color: rgba(22,163,74,.65); background: rgba(22,163,74,.10); }
.choice.wrong{ border-color: rgba(220,38,38,.55); background: rgba(220,38,38,.08); }

.feedback{
  margin-top: 12px;
  padding: 12px;
  border-radius: 18px;
  border: 2px solid var(--gridline);
  background: rgba(0,0,0,.04);
}
.feedback.ok{ border-color: rgba(22,163,74,.55); background: rgba(22,163,74,.10); }
.feedback.bad{ border-color: rgba(220,38,38,.45); background: rgba(220,38,38,.08); }
.feedback .hdr{ font-weight: 950; }
.feedback .txt{ margin-top: 6px; color:var(--muted); line-height: 1.35; font-size:13px; }

.map{
  display:flex; gap:10px; flex-wrap:wrap;
  padding: 10px 12px;
  border-radius: 18px;
  border: 2px solid var(--gridline);
  background: rgba(0,0,0,.03);
}
.node{
  display:flex; align-items:center; gap:8px;
  padding: 8px 10px;
  border-radius: 999px;
  border: 2px solid var(--gridline);
  background: var(--card);
  font-weight: 900;
  font-size: 12.5px;
}
.node.active{ border-color: rgba(0,150,136,.45); box-shadow: var(--glow); }
.node.done{ opacity:.88; }

.battle{ display:grid; gap: 12px; }
.hpbar{
  width:100%;
  height: 14px;
  border-radius: 999px;
  border: 2px solid var(--gridline);
  background: rgba(0,0,0,.04);
  overflow:hidden;
}
.hpfill{
  height:100%;
  width:50%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--teal), rgba(0,150,136,.65));
  transition: width var(--t200) ease;
}
.hpfill.enemy{ background: linear-gradient(90deg, var(--coral), rgba(255,112,67,.65)); }

.floaters{ position: relative; min-height: 24px; }
.floater{
  position:absolute;
  left: 0;
  top: 0;
  font-weight: 950;
  font-size: 13px;
}

.tokens{ display:flex; flex-wrap:wrap; gap:10px; }
.token{
  padding: 10px 12px;
  border-radius: 14px;
  border: 2px solid var(--gridline);
  background: rgba(0,0,0,.04);
  font-weight: 950;
  font-size:13px;
  cursor: grab;
  transition: transform var(--t150) ease;
}
.token:hover{ box-shadow: var(--glow); }
.token.selected{ border-color: rgba(0,150,136,.60); box-shadow: var(--focus); background: rgba(0,150,136,.08); }

.zone{
  min-height: 56px;
  border-radius: 18px;
  border: 2px dashed rgba(0,0,0,.22);
  background: linear-gradient(180deg, rgba(38,50,56,.04), transparent 55%);
  padding: 10px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 10px;
}
.zone.over{ border-color: rgba(0,150,136,.55); box-shadow: var(--focus); }
.zone strong{ font-weight: 950; }
.zone .slot{ flex: 1; display:flex; align-items:center; justify-content:flex-end; gap:8px; }
.slot .placed{
  padding: 8px 10px;
  border-radius: 12px;
  border: 2px solid rgba(0,150,136,.35);
  background: rgba(0,150,136,.08);
  font-weight: 950;
  font-size:12px;
}

.backdrop{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.35);
  display:flex;
  align-items:center;
  justify-content:center;
  padding: 14px;
  z-index: 30;
}
.modal{
  width: min(700px, 100%);
  background: var(--card);
  border-radius: 18px;
  border: 2px solid var(--gridline);
  box-shadow: var(--shadow3);
  padding: 16px;
  max-height: 85vh;
  overflow-y: auto;
}
.modal h3{ margin:0 0 10px 0; font-size: 16px; }

.footer{
  display:flex;
  justify-content:space-between;
  gap: 10px;
  flex-wrap:wrap;
  padding: 10px 4px 0 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}
kbd{
  padding: 2px 6px;
  border-radius: 8px;
  border: 1px solid rgba(0,0,0,.18);
  background: var(--card);
  color: var(--ink);
  font-weight: 900;
  font-size: 11px;
}
