/* =============================================================
   Treasure Island Escape Room — Bilingual 4th-Grade Web App
   Aesthetic: warm parchment, brass, deep ocean teal, ember gold.
   ============================================================= */

:root {
  --parchment: #f4e6c1;
  --parchment-dark: #d8c089;
  --ink: #2a1d0d;
  --ink-soft: #4d3920;
  --brass: #c89b3c;
  --brass-bright: #f0c75e;
  --ember: #c84a1f;
  --ember-bright: #f0671e;
  --ocean: #0d3a4f;
  --ocean-deep: #061b27;
  --sea-foam: #6dafc1;
  --good: #4a8f3a;
  --bad: #b73a2f;

  --shadow-deep: 0 18px 48px rgba(0,0,0,.45);
  --shadow-card: 0 12px 28px rgba(0,0,0,.35);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  font-family: 'DM Sans', system-ui, sans-serif;
  background: var(--ocean-deep);
  color: var(--ink);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

img { display: block; max-width: 100%; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }

.hidden { display: none !important; }

/* =============================================================
   Screens — full-bleed scenes
   ============================================================= */
.screen {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  animation: fadeIn .6s ease;
}
.screen.active { display: flex; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* Background image layer */
.title-bg, .room-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  z-index: 0;
}
.room-bg {
  filter: saturate(1.05) contrast(1.05);
}

/* Vignette overlay */
.title-overlay {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 30%, rgba(0,0,0,.55) 100%),
              linear-gradient(180deg, rgba(0,0,0,.25), rgba(0,0,0,.55));
  z-index: 1;
}
.title-overlay.dark { background: rgba(0,0,0,.7); }
.room-vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 35%, rgba(0,0,0,.5) 100%);
  z-index: 1;
  pointer-events: none;
}

/* =============================================================
   Title / Story cards
   ============================================================= */
.title-card, .story-card {
  position: relative;
  z-index: 2;
  background: linear-gradient(180deg, #fdf3d6 0%, #f0d99a 100%);
  background-image:
    radial-gradient(circle at 20% 0%, rgba(200,155,60,.18) 0%, transparent 40%),
    radial-gradient(circle at 80% 100%, rgba(200,75,30,.14) 0%, transparent 40%),
    linear-gradient(180deg, #fdf3d6 0%, #f0d99a 100%);
  border: 3px solid var(--brass);
  border-radius: 18px;
  padding: 48px 56px;
  max-width: 720px;
  text-align: center;
  box-shadow: var(--shadow-deep), inset 0 0 60px rgba(180,130,50,.18);
  animation: cardPop .7s cubic-bezier(.2,1.2,.4,1) both;
}
.story-card { padding: 40px 48px; max-width: 760px; text-align: left; }
.story-card h2 { text-align: center; }
.story-card h3 { text-align: center; }
.victory-card {
  border-color: var(--brass-bright);
  box-shadow: var(--shadow-deep), 0 0 80px rgba(240,200,90,.6), inset 0 0 60px rgba(200,155,60,.25);
}

@keyframes cardPop {
  from { transform: translateY(40px) scale(.9); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

.bilingual-mark {
  font-family: 'Cinzel', serif;
  font-weight: 700;
  letter-spacing: 4px;
  color: var(--ember);
  font-size: 14px;
  margin-bottom: 12px;
}
.title-main {
  font-family: 'Pirata One', 'Cinzel', serif;
  font-size: 84px;
  line-height: 1;
  color: var(--ink);
  text-shadow: 0 3px 0 var(--brass), 0 6px 0 rgba(0,0,0,.2);
  letter-spacing: 1px;
}
.title-sub {
  font-family: 'Pirata One', serif;
  font-size: 38px;
  color: var(--ember);
  margin: 8px 0 22px;
  font-weight: 400;
  letter-spacing: 2px;
}
.title-tagline {
  font-size: 18px;
  color: var(--ink-soft);
  margin-bottom: 28px;
  line-height: 1.5;
}
.title-tagline em { color: var(--ember); font-style: normal; font-weight: 600; }

.title-meta {
  display: flex;
  justify-content: center;
  gap: 28px;
  flex-wrap: wrap;
  margin-bottom: 32px;
  font-weight: 500;
  color: var(--ink-soft);
}
.title-meta span {
  background: rgba(0,0,0,.05);
  padding: 8px 16px;
  border-radius: 10px;
  font-size: 14px;
}

.story-card h2 {
  font-family: 'Pirata One', serif;
  font-size: 44px;
  color: var(--ink);
  margin-bottom: 4px;
}
.story-card h3 {
  font-family: 'Pirata One', serif;
  font-size: 28px;
  color: var(--ember);
  margin-bottom: 20px;
  font-weight: 400;
}
.story-card p {
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink-soft);
  margin-bottom: 14px;
}
.story-card p em { color: var(--ember); font-weight: 600; font-style: normal; }
.story-card .story-rule {
  background: rgba(13,58,79,.06);
  border-left: 4px solid var(--ocean);
  padding: 10px 14px;
  border-radius: 8px;
  margin: 8px 0;
}

/* =============================================================
   Buttons
   ============================================================= */
.big-btn {
  display: inline-block;
  margin-top: 12px;
  padding: 18px 42px;
  font-family: 'Cinzel', serif;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 1.2px;
  background: linear-gradient(180deg, var(--ember-bright) 0%, var(--ember) 100%);
  color: #fff8e8;
  border-radius: 14px;
  border: 2px solid #8a2c11;
  box-shadow: 0 6px 0 #6d2110, 0 10px 24px rgba(0,0,0,.35);
  transition: transform .12s, box-shadow .12s;
  text-shadow: 0 1px 0 rgba(0,0,0,.25);
}
.big-btn:hover { transform: translateY(-2px); box-shadow: 0 8px 0 #6d2110, 0 14px 28px rgba(0,0,0,.4); }
.big-btn:active { transform: translateY(3px); box-shadow: 0 3px 0 #6d2110, 0 6px 14px rgba(0,0,0,.3); }

.small-btn {
  display: inline-block;
  margin-top: 14px;
  margin-left: 12px;
  padding: 10px 22px;
  font-family: 'DM Sans', sans-serif;
  font-weight: 500;
  font-size: 14px;
  background: transparent;
  color: var(--ink-soft);
  border: 2px solid var(--brass);
  border-radius: 10px;
  transition: all .15s;
}
.small-btn:hover { background: var(--brass); color: #fff; }

/* =============================================================
   HUD (top bar)
   ============================================================= */
.hud {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  background: linear-gradient(180deg, rgba(6,27,39,.95) 0%, rgba(6,27,39,.7) 100%);
  border-bottom: 2px solid var(--brass);
  z-index: 50;
  color: var(--parchment);
  backdrop-filter: blur(6px);
}
.hud-left, .hud-center, .hud-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.hud-center { flex: 1; justify-content: center; }
.hud-right { justify-content: flex-end; }

.room-pill {
  font-family: 'Cinzel', serif;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 1.5px;
  background: rgba(200,155,60,.18);
  border: 1px solid var(--brass);
  padding: 8px 18px;
  border-radius: 999px;
  color: var(--brass-bright);
}

.timer {
  font-family: 'Cinzel', serif;
  font-weight: 700;
  font-size: 32px;
  color: var(--brass-bright);
  text-shadow: 0 2px 0 rgba(0,0,0,.6), 0 0 12px rgba(240,200,90,.45);
  letter-spacing: 2px;
  font-variant-numeric: tabular-nums;
}
.timer.warn { color: var(--ember-bright); animation: pulse 1s infinite; }
.timer.crit { color: #ff5135; animation: pulse .5s infinite; }
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}

.hud-btn {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  background: rgba(255,255,255,.08);
  border-radius: 10px;
  color: var(--parchment);
  transition: background .15s;
}
.hud-btn:hover { background: rgba(240,200,90,.25); color: var(--brass-bright); }

/* =============================================================
   Parrot helper
   ============================================================= */
.parrot-btn {
  position: fixed;
  bottom: 14px;
  right: 14px;
  width: 96px;
  height: 96px;
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  background: radial-gradient(circle at 50% 40%, rgba(240,200,90,.4) 0%, transparent 70%);
  transition: transform .2s, opacity .2s;
  animation: parrotBob 3s ease-in-out infinite;
  opacity: .92;
}
.parrot-btn:hover, .parrot-btn:focus { transform: scale(1.08); opacity: 1; }
.parrot-btn img { width: 72px; height: 72px; object-fit: contain; filter: drop-shadow(0 6px 14px rgba(0,0,0,.5)); }
.parrot-label {
  font-family: 'Cinzel', serif;
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 1.5px;
  background: var(--brass);
  color: var(--ink);
  padding: 4px 10px;
  border-radius: 999px;
  margin-top: -8px;
  text-align: center;
  box-shadow: 0 3px 8px rgba(0,0,0,.3);
}
@keyframes parrotBob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

/* =============================================================
   Room headers
   ============================================================= */
.room-screen { padding-top: 64px; padding-bottom: 140px; flex-direction: column; justify-content: flex-start; align-items: stretch; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; }
.room-screen::-webkit-scrollbar { width: 10px; }
.room-screen::-webkit-scrollbar-track { background: rgba(0,0,0,0.3); }
.room-screen::-webkit-scrollbar-thumb { background: var(--brass); border-radius: 5px; }

.room-header {
  position: relative;
  z-index: 5;
  padding: 22px 32px 0;
  text-align: center;
  color: var(--parchment);
}
.room-num {
  font-family: 'Cinzel', serif;
  letter-spacing: 3px;
  font-size: 12px;
  color: var(--brass-bright);
  margin-bottom: 6px;
}
.room-name {
  font-family: 'Pirata One', serif;
  font-size: 48px;
  letter-spacing: 1px;
  text-shadow: 0 3px 0 rgba(0,0,0,.6), 0 0 24px rgba(0,0,0,.4);
  margin-bottom: 8px;
}
.room-task {
  display: inline-block;
  background: rgba(244,230,193,.92);
  color: var(--ink);
  padding: 12px 24px;
  border-radius: 12px;
  border: 2px solid var(--brass);
  font-size: 15px;
  line-height: 1.5;
  max-width: 720px;
  box-shadow: var(--shadow-card);
}
.room-task em { color: var(--ember); font-style: normal; font-weight: 600; }

/* =============================================================
   Hotspots (Room 1)
   ============================================================= */
.hotspot {
  position: absolute;
  z-index: 4;
  cursor: pointer;
  border-radius: 50%;
  transition: all .2s;
  background: radial-gradient(circle, rgba(240,200,90,.0) 0%, rgba(240,200,90,.0) 70%);
}
.hotspot:hover {
  background: radial-gradient(circle, rgba(240,200,90,.35) 0%, rgba(240,200,90,0) 70%);
  animation: hotpulse 1s ease infinite;
}
.hotspot.found {
  pointer-events: none;
  animation: foundFlash .8s ease;
}
@keyframes hotpulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}
@keyframes foundFlash {
  0% { background: radial-gradient(circle, rgba(240,200,90,1) 0%, rgba(240,200,90,0) 70%); }
  100% { background: transparent; }
}

.clue-tray {
  position: relative;
  z-index: 6;
  margin: 18px auto 8px;
  display: flex;
  gap: 14px;
  background: rgba(244,230,193,.96);
  padding: 14px 18px;
  border-radius: 14px;
  border: 2px solid var(--brass);
  box-shadow: var(--shadow-card);
  width: max-content;
  max-width: calc(100% - 32px);
  flex-wrap: wrap;
  justify-content: center;
}
.clue-slot {
  width: 88px;
  text-align: center;
}
.clue-empty {
  width: 76px; height: 76px;
  background: rgba(0,0,0,.08);
  border: 2px dashed var(--ink-soft);
  border-radius: 12px;
  display: grid; place-items: center;
  font-family: 'Pirata One', serif;
  font-size: 36px;
  color: var(--ink-soft);
  margin: 0 auto;
}
.clue-slot.found .clue-empty {
  background: linear-gradient(180deg, var(--brass-bright), var(--brass));
  border-color: var(--ember);
  color: #fff;
  animation: cardPop .5s cubic-bezier(.2,1.2,.4,1);
}
.clue-label { font-size: 12px; margin-top: 4px; color: var(--ink-soft); font-weight: 500; }

/* =============================================================
   Generic puzzle panel
   ============================================================= */
.puzzle-panel {
  position: relative;
  z-index: 5;
  margin: 22px auto;
  background: rgba(244,230,193,.96);
  border: 3px solid var(--brass);
  border-radius: 16px;
  padding: 24px 28px;
  max-width: 920px;
  width: calc(100% - 32px);
  box-shadow: var(--shadow-card);
  animation: cardPop .5s cubic-bezier(.2,1.2,.4,1) both;
}
.puzzle-panel.wide { max-width: 1200px; }
.puzzle-panel h3 {
  font-family: 'Pirata One', serif;
  font-size: 30px;
  color: var(--ink);
  margin-bottom: 10px;
}
.puzzle-panel p { font-size: 15px; line-height: 1.55; color: var(--ink-soft); margin-bottom: 12px; }
.puzzle-panel p em { color: var(--ember); font-style: normal; font-weight: 600; }

.riddle { font-size: 17px !important; }
.riddle-big {
  font-family: 'Cinzel', serif;
  font-weight: 700;
  font-size: 36px !important;
  letter-spacing: 16px;
  text-align: center;
  color: var(--ember);
  background: rgba(0,0,0,.06);
  padding: 16px;
  border-radius: 10px;
  margin: 14px 0 !important;
}

.code-input {
  display: block;
  margin: 14px auto;
  width: 240px;
  padding: 18px 24px;
  font-family: 'Cinzel', serif;
  font-size: 36px;
  text-align: center;
  letter-spacing: 14px;
  text-transform: uppercase;
  background: #fff;
  border: 3px solid var(--brass);
  border-radius: 12px;
  color: var(--ink);
}
.code-input:focus { outline: none; border-color: var(--ember); box-shadow: 0 0 0 4px rgba(240,103,30,.2); }

.hint-soft {
  text-align: center;
  font-size: 13px !important;
  color: var(--ink-soft);
  font-style: italic;
  margin-top: 8px !important;
}

.answer-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 12px;
}
.answer-btn {
  padding: 16px 18px;
  background: #fff;
  border: 2px solid var(--brass);
  border-radius: 12px;
  font-size: 15px;
  color: var(--ink);
  font-weight: 500;
  text-align: left;
  transition: all .15s;
  line-height: 1.4;
}
.answer-btn:hover { background: var(--brass-bright); border-color: var(--ember); transform: translateY(-2px); }
.answer-btn.correct { background: var(--good); color: #fff; border-color: var(--good); }
.answer-btn.wrong { background: var(--bad); color: #fff; border-color: var(--bad); animation: shake .4s; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

/* =============================================================
   Room 2 — Match game (drag & drop)
   ============================================================= */
.match-game {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 24px;
  margin-top: 12px;
}
.match-col { display: flex; flex-direction: column; gap: 10px; }
.match-card {
  padding: 14px 18px;
  background: linear-gradient(180deg, var(--brass-bright), var(--brass));
  border: 2px solid #8a6a1f;
  border-radius: 10px;
  font-family: 'Cinzel', serif;
  font-weight: 700;
  font-size: 17px;
  color: var(--ink);
  text-align: center;
  cursor: grab;
  box-shadow: 0 3px 0 #6d4f15, 0 6px 14px rgba(0,0,0,.2);
  transition: transform .12s;
  letter-spacing: 1px;
}
.match-card:hover { transform: translateY(-2px); }
.match-card.dragging { opacity: .4; transform: scale(.95); }
.match-card.placed {
  background: rgba(74,143,58,.2);
  color: var(--good);
  cursor: default;
  pointer-events: none;
  box-shadow: none;
  border-color: var(--good);
}

.match-slot {
  padding: 14px 18px;
  background: #fff;
  border: 2px dashed var(--brass);
  border-radius: 10px;
  min-height: 72px;
  display: flex;
  align-items: center;
  transition: all .15s;
}
.match-slot.over { background: rgba(240,200,90,.3); border-style: solid; transform: scale(1.02); }
.match-slot.solved {
  background: rgba(74,143,58,.12);
  border-color: var(--good);
  border-style: solid;
}
.match-text { font-size: 14px; line-height: 1.45; color: var(--ink); }
.match-text em { color: var(--ember); font-style: normal; font-weight: 500; }

.match-slot.solved::after {
  content: "✓";
  margin-left: auto;
  color: var(--good);
  font-size: 26px;
  font-weight: 700;
}

.r2-progress, .r3-progress {
  text-align: center;
  margin-top: 16px;
  font-family: 'Cinzel', serif;
  font-size: 16px;
  color: var(--ink-soft);
}

/* =============================================================
   Room 3 — Sort game
   ============================================================= */
.sort-game {
  display: grid;
  grid-template-columns: 1fr 2fr 1fr;
  gap: 18px;
  margin-top: 12px;
}
.sort-bin {
  padding: 14px;
  border-radius: 14px;
  border: 3px dashed;
  min-height: 380px;
  display: flex;
  flex-direction: column;
}
.sort-bin-good { background: rgba(74,143,58,.12); border-color: var(--good); }
.sort-bin-bad { background: rgba(183,58,47,.12); border-color: var(--bad); }
.sort-bin.over { background: rgba(240,200,90,.3); transform: scale(1.02); }
.sort-bin-title {
  font-family: 'Pirata One', serif;
  font-size: 26px;
  text-align: center;
  margin-bottom: 12px;
  color: var(--ink);
  line-height: 1.1;
}
.sort-bin-title em { font-size: 16px; color: var(--ember); font-style: normal; display: block; margin-top: 2px; }
.sort-bin-list { display: flex; flex-direction: column; gap: 8px; flex: 1; }

.sort-pool { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-content: start; }
.char-card {
  background: #fff;
  border: 2px solid var(--brass);
  border-radius: 12px;
  padding: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: grab;
  transition: transform .12s;
  box-shadow: 0 3px 8px rgba(0,0,0,.15);
}
.char-card:hover { transform: translateY(-2px); }
.char-card.dragging { opacity: .4; }
.char-card img {
  width: 56px; height: 56px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--brass);
  flex-shrink: 0;
}
.char-name {
  font-family: 'Cinzel', serif;
  font-weight: 700;
  font-size: 14px;
  color: var(--ink);
}
.char-action { font-size: 11px; color: var(--ink-soft); line-height: 1.3; }
.char-action em { color: var(--ember); font-style: normal; }

/* When dropped into bin */
.sort-bin .char-card { width: 100%; }

/* =============================================================
   Room 4 — Sequence
   ============================================================= */
.seq-game { display: flex; flex-direction: column; gap: 14px; margin-bottom: 14px; }
.seq-pool {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px;
  background: rgba(0,0,0,.04);
  border-radius: 10px;
  min-height: 80px;
}
.seq-track {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}
.seq-slot {
  background: #fff;
  border: 2px dashed var(--brass);
  border-radius: 10px;
  padding: 8px;
  min-height: 110px;
  display: flex;
  flex-direction: column;
  position: relative;
  transition: all .15s;
}
.seq-slot.over { background: rgba(240,200,90,.3); border-style: solid; }
.seq-num {
  font-family: 'Pirata One', serif;
  font-size: 26px;
  color: var(--ember);
  text-align: center;
}
.seq-label {
  font-size: 10px;
  text-align: center;
  color: var(--ink-soft);
  margin-bottom: 4px;
}
.seq-card {
  background: linear-gradient(180deg, var(--parchment) 0%, var(--parchment-dark) 100%);
  border: 2px solid var(--brass);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 11.5px;
  line-height: 1.3;
  color: var(--ink);
  cursor: grab;
  font-weight: 500;
  box-shadow: 0 2px 4px rgba(0,0,0,.1);
  transition: transform .12s;
  flex: 1;
  display: flex;
  align-items: center;
}
.seq-card:hover { transform: translateY(-2px); }
.seq-card.dragging { opacity: .4; }
.seq-card em { color: var(--ember); font-style: normal; display: block; margin-top: 3px; font-size: 10px; }
.seq-pool .seq-card { min-width: 160px; max-width: 200px; }
.seq-slot .seq-card { width: 100%; }

#r4-check { display: block; margin: 0 auto; }

.seq-slot.right { background: rgba(74,143,58,.18); border-color: var(--good); border-style: solid; }
.seq-slot.wrong { background: rgba(183,58,47,.18); border-color: var(--bad); border-style: solid; animation: shake .4s; }

/* =============================================================
   Room 5 — Audio quiz
   ============================================================= */
.audio-player-card {
  background: linear-gradient(180deg, rgba(13,58,79,.95), rgba(6,27,39,.95));
  color: var(--parchment);
  padding: 22px;
  border-radius: 14px;
  margin-bottom: 18px;
  text-align: center;
  border: 2px solid var(--brass);
}
.play-big {
  display: inline-block;
  padding: 18px 40px;
  background: linear-gradient(180deg, var(--brass-bright), var(--brass));
  color: var(--ink);
  border-radius: 12px;
  font-family: 'Cinzel', serif;
  font-weight: 700;
  font-size: 20px;
  letter-spacing: 1.5px;
  border: 2px solid #8a6a1f;
  box-shadow: 0 4px 0 #6d4f15;
  margin-bottom: 14px;
  transition: transform .12s;
}
.play-big:hover { transform: translateY(-2px); }
.play-big:active { transform: translateY(2px); box-shadow: 0 2px 0 #6d4f15; }
.audio-progress {
  height: 8px;
  background: rgba(255,255,255,.15);
  border-radius: 4px;
  overflow: hidden;
  margin: 8px auto;
  max-width: 460px;
}
.audio-bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--brass), var(--brass-bright));
  transition: width .2s linear;
}
.audio-player-card .hint-soft { color: var(--parchment) !important; opacity: .8; margin-bottom: 0 !important; }

.quiz-block {
  background: #fff;
  border-radius: 12px;
  padding: 18px 22px;
  margin-top: 14px;
  border: 2px solid var(--brass);
  animation: cardPop .4s cubic-bezier(.2,1.2,.4,1);
}
.quiz-block h3 {
  font-family: 'Cinzel', serif;
  font-size: 16px;
  color: var(--ember);
  letter-spacing: 1.5px;
  margin-bottom: 8px !important;
}
.quiz-block > p { font-size: 17px; color: var(--ink); font-weight: 500; }

/* =============================================================
   Room 6 — Quote game
   ============================================================= */
.quote-game { display: flex; flex-direction: column; gap: 14px; }
.quote-list { display: flex; flex-direction: column; gap: 12px; }
.quote-card {
  background: #fff;
  border: 2px solid var(--brass);
  border-radius: 12px;
  padding: 14px 18px;
  display: grid;
  grid-template-columns: 50px 1fr;
  gap: 12px;
  align-items: start;
}
.quote-num {
  font-family: 'Pirata One', serif;
  font-size: 36px;
  color: var(--ember);
  text-align: center;
  line-height: 1;
}
.quote-text {
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  font-style: italic;
  font-weight: 500;
}
.quote-text em { color: var(--ember); font-weight: 500; }
.quote-options {
  grid-column: 2;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 6px;
  margin-top: 8px;
}
.quote-options button {
  padding: 10px 8px;
  background: #fdf3d6;
  border: 2px solid var(--brass);
  border-radius: 8px;
  font-size: 13px;
  color: var(--ink);
  font-weight: 600;
  cursor: pointer;
  transition: all .12s;
}
.quote-options button:hover { background: var(--brass-bright); transform: translateY(-2px); }
.quote-options button.picked-good { background: var(--good); color: #fff; border-color: var(--good); pointer-events: none; }
.quote-options button.picked-bad { background: var(--bad); color: #fff; border-color: var(--bad); animation: shake .4s; }

.combo-lock {
  background: linear-gradient(180deg, rgba(13,58,79,.95), rgba(6,27,39,.95));
  color: var(--parchment);
  border-radius: 14px;
  padding: 22px 28px;
  text-align: center;
  border: 3px solid var(--brass-bright);
  margin-top: 12px;
  animation: cardPop .5s;
}
.combo-lock h3 { color: var(--brass-bright) !important; }
.combo-lock p { color: var(--parchment) !important; }
.combo-lock p em { color: var(--brass-bright) !important; }
.combo-lock .code-input { background: rgba(255,255,255,.95); }

/* =============================================================
   Modals
   ============================================================= */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn .25s;
  padding: 20px;
}
.modal-card {
  position: relative;
  background: linear-gradient(180deg, #fdf3d6 0%, #f0d99a 100%);
  border: 3px solid var(--brass);
  border-radius: 16px;
  padding: 32px 36px;
  max-width: 600px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-deep);
  animation: cardPop .35s cubic-bezier(.2,1.2,.4,1);
}
.modal-card h2 {
  font-family: 'Pirata One', serif;
  font-size: 36px;
  color: var(--ink);
  margin-bottom: 14px;
}
.modal-card p, .modal-card li {
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink-soft);
  margin-bottom: 8px;
}
.modal-card ul { list-style: none; padding: 12px 0; }
.modal-card li {
  padding-left: 20px;
  position: relative;
}
.modal-card li::before {
  content: "⚓";
  position: absolute;
  left: 0;
  color: var(--ember);
}
.modal-close {
  position: absolute;
  top: 8px; right: 14px;
  width: 36px; height: 36px;
  font-size: 28px;
  color: var(--ink-soft);
  font-weight: 700;
  cursor: pointer;
}
.modal-close:hover { color: var(--ember); }

.hint-card { text-align: center; padding-top: 56px; }
.hint-parrot {
  width: 110px;
  height: 110px;
  object-fit: contain;
  margin: -90px auto 0;
  filter: drop-shadow(0 6px 14px rgba(0,0,0,.4));
  animation: parrotBob 2.5s ease-in-out infinite;
}
.hint-card #hint-text {
  font-size: 17px;
  line-height: 1.6;
  color: var(--ink);
  background: rgba(255,255,255,.6);
  padding: 18px 22px;
  border-radius: 12px;
  margin: 14px 0;
  border-left: 5px solid var(--ember);
  text-align: left;
}
.hint-card #hint-text em { color: var(--ember); font-style: normal; font-weight: 600; }
.hint-meta {
  font-family: 'Cinzel', serif;
  font-size: 13px;
  letter-spacing: 1.5px;
  color: var(--ink-soft);
  margin-bottom: 14px;
}
.hint-actions { display: flex; gap: 10px; justify-content: center; align-items: center; }

/* =============================================================
   Toast
   ============================================================= */
.toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ocean-deep);
  color: var(--brass-bright);
  padding: 14px 28px;
  border-radius: 12px;
  border: 2px solid var(--brass);
  font-family: 'Cinzel', serif;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 1px;
  box-shadow: var(--shadow-deep);
  z-index: 100;
  animation: toastIn .3s cubic-bezier(.2,1.2,.4,1);
}
@keyframes toastIn {
  from { transform: translateX(-50%) translateY(30px); opacity: 0; }
  to { transform: translateX(-50%) translateY(0); opacity: 1; }
}

/* =============================================================
   Stat grid (victory)
   ============================================================= */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  margin: 28px 0;
}
.stat {
  background: rgba(0,0,0,.06);
  border-radius: 12px;
  padding: 18px;
  border: 2px solid var(--brass);
}
.stat-num {
  font-family: 'Cinzel', serif;
  font-size: 32px;
  font-weight: 700;
  color: var(--ember);
  margin-bottom: 4px;
}
.stat-label {
  font-size: 12px;
  letter-spacing: 1.5px;
  color: var(--ink-soft);
  text-transform: uppercase;
}

/* =============================================================
   Confetti / sparkle layer (used on victory)
   ============================================================= */
.sparkle {
  position: fixed;
  pointer-events: none;
  z-index: 300;
  width: 14px;
  height: 14px;
  background: radial-gradient(circle, var(--brass-bright) 0%, transparent 70%);
  border-radius: 50%;
  animation: sparkle 1.6s ease-out forwards;
}
@keyframes sparkle {
  0% { transform: translate(0,0) scale(0); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(1.5); opacity: 0; }
}

/* =============================================================
   Responsive
   ============================================================= */
@media (max-width: 900px) {
  .title-main { font-size: 56px; }
  .title-sub { font-size: 28px; }
  .room-name { font-size: 32px; }
  .match-game { grid-template-columns: 1fr; }
  .sort-game { grid-template-columns: 1fr; }
  .sort-bin { min-height: 200px; }
  .seq-track { grid-template-columns: repeat(3, 1fr); }
  .quote-options { grid-template-columns: 1fr 1fr; }
  .answer-grid { grid-template-columns: 1fr; }
  .parrot-btn { width: 100px; height: 100px; bottom: 12px; right: 12px; }
  .parrot-btn img { width: 78px; height: 78px; }
  .title-card, .story-card { padding: 28px 24px; }
  .puzzle-panel { padding: 18px; }
  .stat-grid { grid-template-columns: 1fr; }
}

/* =============================================================
   Language toggle (HUD + title screen)
   ============================================================= */
.lang-toggle {
  display: inline-flex;
  background: rgba(0,0,0,.35);
  border: 1px solid var(--brass);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
  margin-right: 8px;
}
.lang-toggle .lang-btn {
  font-family: 'Cinzel', serif;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 1.5px;
  padding: 6px 14px;
  border-radius: 999px;
  color: var(--parchment);
  background: transparent;
  transition: all .18s ease;
  min-width: 44px;
}
.lang-toggle .lang-btn[aria-pressed="true"] {
  background: linear-gradient(180deg, var(--brass-bright), var(--brass));
  color: var(--ink);
  box-shadow: 0 2px 6px rgba(0,0,0,.3), inset 0 1px 0 rgba(255,255,255,.4);
}
.lang-toggle .lang-btn:hover { color: var(--brass-bright); }
.lang-toggle .lang-btn[aria-pressed="true"]:hover { color: var(--ink); }

/* Title-screen variant — larger pills */
.title-lang-toggle {
  position: absolute;
  top: 22px;
  right: 22px;
  z-index: 5;
  display: inline-flex;
  background: rgba(6,27,39,.85);
  border: 2px solid var(--brass);
  border-radius: 999px;
  padding: 4px;
  gap: 2px;
  box-shadow: 0 4px 14px rgba(0,0,0,.4);
}
.title-lang-toggle .lang-btn {
  font-family: 'Cinzel', serif;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 1.5px;
  padding: 8px 18px;
  border-radius: 999px;
  color: var(--parchment);
  background: transparent;
  transition: all .18s ease;
}
.title-lang-toggle .lang-btn[aria-pressed="true"] {
  background: linear-gradient(180deg, var(--brass-bright), var(--brass));
  color: var(--ink);
  box-shadow: 0 2px 6px rgba(0,0,0,.3), inset 0 1px 0 rgba(255,255,255,.4);
}
.title-lang-toggle .lang-btn:hover { color: var(--brass-bright); }
.title-lang-toggle .lang-btn[aria-pressed="true"]:hover { color: var(--ink); }

/* =============================================================
   Room 3 char-info wrapper (new structure)
   ============================================================= */
.char-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}
.char-info .char-name {
  font-family: 'Pirata One', serif;
  font-size: 20px;
  color: var(--ink);
  line-height: 1.1;
  margin-bottom: 4px;
}
.char-info .char-action {
  font-size: 13px;
  line-height: 1.35;
  color: var(--ink-soft);
}

/* Sort-bin sub-text under bilingual labels */
.bin-sub {
  display: block;
  font-family: 'DM Sans', sans-serif;
  font-size: 12px;
  font-weight: 400;
  color: var(--ink-soft);
  letter-spacing: 0;
  margin-top: 2px;
}

/* Room 4 sequence card text element (new) */
.seq-card-text {
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink);
}

/* =============================================================
   iPad-specific tweaks (portrait + landscape)
   ============================================================= */
@media (min-width: 768px) and (max-width: 1366px) {
  /* Make room screens scroll comfortably with breathing room above the parrot */
  .room-screen { padding-bottom: 130px; }
  .puzzle-panel { margin-bottom: 24px; }
  /* HUD compact a bit so language toggle fits */
  .hud { padding: 0 14px; }
  .timer { font-size: 28px; }
  .hud-btn { width: 36px; height: 36px; }
}

/* iPad portrait specifically (820x1180) */
@media (max-width: 900px) and (orientation: portrait) {
  .lang-toggle .lang-btn { padding: 6px 10px; font-size: 11px; min-width: 38px; }
  .title-lang-toggle { top: 14px; right: 14px; }
  .title-lang-toggle .lang-btn { padding: 6px 14px; font-size: 12px; }
  .timer { font-size: 24px; }
  .hud-right { gap: 6px; }
}

/* Make sure puzzle panels (cipher / code lock) sit above the parrot */
#r2-cipher, #r6-lock, #r1-question { margin-bottom: 32px; }

/* Don't let parrot block the bottom-right unlock buttons on tablets */
@media (max-width: 1180px) {
  .parrot-btn { width: 84px; height: 84px; bottom: 10px; right: 10px; opacity: .82; }
  .parrot-btn img { width: 64px; height: 64px; }
  .parrot-label { font-size: 10px; padding: 3px 8px; }
}

/* =============================================================
   SCORING — HUD pill, score pop, warnings (added v2)
   ============================================================= */
.score-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: 'Cinzel', serif;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 1px;
  background: rgba(200,155,60,.18);
  border: 1px solid var(--brass);
  padding: 8px 14px;
  border-radius: 999px;
  color: var(--brass-bright);
  transition: background .25s, border-color .25s, color .25s;
  white-space: nowrap;
}
.score-pill .star { font-size: 14px; }
.score-pill .num { font-variant-numeric: tabular-nums; min-width: 36px; text-align: right; }
.score-pill.low {
  background: rgba(240,103,30,.22);
  border-color: var(--ember-bright);
  color: var(--ember-bright);
}
.score-pill.crit {
  background: rgba(255,81,53,.28);
  border-color: #ff5135;
  color: #ff8a78;
  animation: pulse 1s infinite;
}

/* Score pop — fades up from HUD score pill */
.score-pop {
  position: fixed;
  top: 110px;
  left: 26%;
  transform: translateX(-50%);
  font-family: 'Cinzel', serif;
  font-weight: 800;
  font-size: 36px;
  letter-spacing: 1px;
  pointer-events: none;
  z-index: 200;
  text-shadow: 0 2px 0 rgba(0,0,0,.7), 0 0 14px rgba(0,0,0,.4);
  animation: scorePopAnim 1.4s ease-out forwards;
}
.score-pop.pos { color: #6cd96c; }
.score-pop.neg { color: #ff7561; }
@keyframes scorePopAnim {
  0%   { opacity: 0; transform: translate(-50%, 16px) scale(.7); }
  18%  { opacity: 1; transform: translate(-50%, 0) scale(1.05); }
  60%  { opacity: 1; transform: translate(-50%, -16px) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -42px) scale(.95); }
}

/* Warning banner */
.warning-banner {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 180;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 22px;
  border-radius: 999px;
  border: 2px solid;
  font-family: 'Lora', serif;
  font-weight: 600;
  font-size: 15px;
  max-width: calc(100vw - 32px);
  box-shadow: 0 8px 28px rgba(0,0,0,.45);
  animation: warnSlideDown .4s ease-out;
}
.warning-banner .warn-icon { font-size: 20px; }
.warning-banner.mild {
  background: linear-gradient(180deg, #6b4a14 0%, #4a3010 100%);
  color: #fff3c8;
  border-color: #f0c75e;
}
.warning-banner.urgent {
  background: linear-gradient(180deg, #863916 0%, #5a230d 100%);
  color: #ffe1cf;
  border-color: #f0671e;
  animation: warnSlideDown .4s ease-out, pulse 1.4s infinite;
}
.warning-banner.teacher {
  background: linear-gradient(180deg, #b03020 0%, #6a1a0e 100%);
  color: #fff5f0;
  border-color: #ff5135;
  animation: warnSlideDown .4s ease-out, pulse .9s infinite;
}
@keyframes warnSlideDown {
  0%   { opacity: 0; transform: translate(-50%, -32px); }
  100% { opacity: 1; transform: translate(-50%, 0); }
}

/* =============================================================
   VICTORY — score headline + stars
   ============================================================= */
.score-headline {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin: 14px 0 22px;
}
.score-headline-num {
  font-family: 'Cinzel', serif;
  font-weight: 800;
  font-size: clamp(48px, 8vw, 76px);
  color: var(--brass-bright);
  letter-spacing: 2px;
  text-shadow: 0 2px 0 rgba(0,0,0,.6), 0 0 22px rgba(240,200,90,.5);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.score-headline-lbl {
  font-family: 'Cinzel', serif;
  letter-spacing: 3px;
  font-size: 13px;
  text-transform: uppercase;
  color: var(--parchment);
  opacity: .8;
}
.score-stars {
  font-size: 32px;
  letter-spacing: 4px;
  filter: drop-shadow(0 2px 8px rgba(240,200,90,.6));
}

/* =============================================================
   TEACHER REPORT MODAL
   ============================================================= */
.report-card {
  max-width: 640px;
  text-align: left;
}
.report-card h2 {
  text-align: center;
  margin-bottom: 4px;
}
.report-card .report-tag {
  text-align: center;
  margin: 0 0 18px;
  font-style: italic;
  opacity: .82;
}
.report-card h3 {
  font-family: 'Cinzel', serif;
  font-size: 15px;
  letter-spacing: 1.5px;
  color: #6b3a14;
  margin: 18px 0 8px;
  text-transform: uppercase;
}
.report-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 22px;
  background: rgba(120, 80, 30, 0.10);
  border: 1px solid rgba(120, 80, 30, 0.35);
  border-radius: 12px;
  padding: 14px 18px;
  margin-bottom: 8px;
}
.report-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 4px 0;
  font-family: 'Lora', serif;
  font-size: 14px;
}
.report-row strong {
  font-family: 'Cinzel', serif;
  color: #6b3a14;
  font-variant-numeric: tabular-nums;
  font-size: 16px;
}
.report-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 12px;
  font-family: 'Lora', serif;
  font-size: 14px;
}
.report-table th, .report-table td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid rgba(120, 80, 30, 0.25);
}
.report-table th {
  font-family: 'Cinzel', serif;
  font-size: 11px;
  letter-spacing: 1.5px;
  color: #6b3a14;
  text-transform: uppercase;
}
.report-table td {
  color: #2a1f12;
  font-variant-numeric: tabular-nums;
}
.report-table tbody tr:hover { background: rgba(120, 80, 30, 0.10); }
.report-note {
  background: rgba(240,200,90,.28);
  border-left: 3px solid var(--brass);
  padding: 10px 14px;
  border-radius: 6px;
  font-style: italic;
  margin: 8px 0 16px;
  color: #2a1f12;
}

/* =============================================================
   BOOK EXCERPTS MODAL
   ============================================================= */
.book-card {
  max-width: 720px;
  text-align: left;
}
.book-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}
.book-icon {
  font-size: 36px;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,.4));
}
.book-card h2 { margin: 0; }
.book-sub {
  margin: 2px 0 0;
  font-style: italic;
  opacity: .85;
  font-size: 14px;
}

.book-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(200,155,60,.3);
}
.book-tab {
  font-family: 'Cinzel', serif;
  font-size: 12px;
  letter-spacing: 1.2px;
  font-weight: 700;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(60, 35, 12, 0.12);
  border: 1.5px solid #8a6020;
  color: #5a3a14;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
  text-transform: uppercase;
}
.book-tab:hover {
  background: rgba(200,155,60,.32);
  color: #2a1a05;
  border-color: var(--brass);
}
.book-tab.active {
  background: var(--brass);
  border-color: var(--brass);
  color: #1a0e08;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.book-content {
  background: linear-gradient(180deg, #f5e6c8 0%, #ead7b0 100%);
  color: #2a1f12;
  border-radius: 12px;
  padding: 22px 26px;
  font-family: 'Lora', serif;
  font-size: 16px;
  line-height: 1.65;
  border: 1px solid #c8a96a;
  box-shadow: inset 0 0 30px rgba(120,80,30,.18);
  max-height: 50vh;
  overflow-y: auto;
}
.book-content h3 {
  font-family: 'Cinzel', serif;
  color: #6b3a14;
  font-size: 18px;
  letter-spacing: 1.5px;
  margin: 0 0 12px;
  text-transform: none;
}
.book-content p { margin: 0 0 10px; }
.book-content strong { color: #5a2c0a; }
.book-content em { color: #6b3a14; }
.book-content ul, .book-content ol {
  margin: 8px 0 12px;
  padding-left: 22px;
}
.book-content ul { list-style: disc; }
.book-content ol { list-style: decimal; }
.book-content ul::before, .book-content ol::before { display: none; }
.book-content li {
  margin: 4px 0;
  padding: 0;
  color: #2a1f12;
}
.book-content li::before { display: none; }

.book-footnote {
  font-size: 13px;
  font-style: italic;
  text-align: center;
  margin: 12px 0 14px;
  opacity: .82;
}

/* iPad / tablet adjustments */
@media (max-width: 900px) {
  .score-pill { font-size: 12px; padding: 6px 10px; }
  .score-pop { font-size: 28px; top: 132px; left: 22%; }
  .warning-banner { font-size: 13px; padding: 10px 16px; top: 64px; }
  .report-summary { grid-template-columns: 1fr; gap: 4px 0; }
  .book-tabs { gap: 4px; }
  .book-tab { font-size: 11px; padding: 6px 10px; }
  .book-content { font-size: 15px; padding: 18px 20px; max-height: 44vh; }
  .score-headline-num { font-size: 56px; }
}
@media (max-width: 600px) {
  .hud-left { gap: 8px; }
  .score-pill .num { min-width: 30px; }
  .book-content { max-height: 38vh; }
}
