/* style.css — chunky, storybook UI shell around the canvas world. */

:root {
  --ink: #2a2438;
  --cream: #fffaf0;
  --card: #ffffff;
  --sun: #ffd23f;
  --sky: #4aa3e0;
  --leaf: #63c76a;
  --berry: #f2545b;
  --plum: #8e6ed6;
  --shadow: 0 6px 0 rgba(42, 36, 56, .18);
  --font: "Baloo 2", "Segoe UI Rounded", "Nunito", "Trebuchet MS", system-ui, sans-serif;
}

* { box-sizing: border-box; }

/* explicit display rules below would otherwise beat the default [hidden] rule */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: linear-gradient(180deg, #bfe8ff 0%, #d9f2c4 55%, #ffe9b8 100%);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.muted { color: #6c6480; font-size: 13px; }

/* ── HUD ─────────────────────────────────────────────────────────────── */

#hud {
  width: min(1000px, 96vw);
  margin: 14px 0 6px;
  padding: 8px 14px;
  background: var(--cream);
  border: 3px solid var(--ink);
  border-radius: 18px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.hud-left { display: flex; align-items: center; gap: 10px; }
#hud-avatar { width: 48px; height: 48px; }
#hud-name { font-weight: 700; font-size: 17px; line-height: 1.1; }
.hud-right { display: flex; align-items: center; gap: 8px; }

.chip {
  background: #fff;
  border: 2.5px solid var(--ink);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
}
.chip.pop { animation: pop .45s ease; }
@keyframes pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.22) rotate(-4deg); background: var(--sun); }
  100% { transform: scale(1); }
}

/* ── buttons ─────────────────────────────────────────────────────────── */

.btn {
  font-family: var(--font);
  font-weight: 700;
  font-size: 15px;
  color: var(--ink);
  background: var(--sun);
  border: 3px solid var(--ink);
  border-radius: 14px;
  padding: 7px 16px;
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(42, 36, 56, .25);
  transition: transform .08s, box-shadow .08s;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(42, 36, 56, .25); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn.ghost { background: #fff; font-size: 13px; padding: 5px 12px; }
.btn.big { font-size: 21px; padding: 12px 34px; border-radius: 18px; }
.btn.leaf { background: var(--leaf); }
.btn.sky { background: var(--sky); color: #fff; }
.btn.plum { background: var(--plum); color: #fff; }

/* ── scenes ──────────────────────────────────────────────────────────── */

main { width: min(1000px, 96vw); flex: 1; padding-bottom: 30px; }
.scene { animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } }

.title-card { text-align: center; margin: 24px 0 6px; }
.title-card h1 {
  font-size: clamp(38px, 7vw, 62px);
  margin: 0;
  letter-spacing: -1px;
  text-shadow: 0 4px 0 #fff, 0 7px 0 rgba(42, 36, 56, .2);
}
.title-card h1 span { color: var(--berry); }
.title-card .sub { margin: 2px 0 0; font-size: 17px; color: #574f6b; }

/* avatar picker */
.avatar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 14px;
  margin: 18px 0;
}
.avatar-card {
  background: var(--card);
  border: 3px solid var(--ink);
  border-radius: 20px;
  padding: 10px 8px 12px;
  text-align: center;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform .12s, background .12s;
}
.avatar-card:hover { transform: translateY(-4px) rotate(-1deg); }
.avatar-card.selected { background: var(--sun); transform: translateY(-4px); }
.avatar-card canvas { width: 108px; height: 108px; display: block; margin: 0 auto; }
.avatar-card .who { font-weight: 700; font-size: 18px; }
.avatar-card .blurb { font-size: 12px; color: #6c6480; min-height: 30px; padding: 0 4px; }
.avatar-card .tag {
  display: inline-block; font-size: 11px; font-weight: 700;
  background: var(--leaf); color: #fff; border-radius: 999px; padding: 1px 9px;
}

.avatar-footer {
  display: flex; align-items: flex-end; justify-content: center; gap: 18px;
  flex-wrap: wrap; margin: 4px 0 22px;
}
.name-field { display: flex; flex-direction: column; gap: 4px; font-weight: 700; font-size: 14px; }
.name-field input {
  font-family: var(--font); font-size: 18px; padding: 9px 14px;
  border: 3px solid var(--ink); border-radius: 14px; width: 220px; background: #fff;
}
.name-field input:focus { outline: 3px solid var(--sun); }

.soon-panel {
  background: rgba(255, 255, 255, .72);
  border: 3px dashed #a79cc0;
  border-radius: 20px;
  padding: 14px 18px;
  max-width: 660px;
  margin: 0 auto;
}
.soon-panel h3 { margin: 0 0 4px; font-size: 18px; }
.soon-panel p { margin: 0; font-size: 14px; color: #574f6b; line-height: 1.45; }
.soon-row { display: flex; gap: 10px; margin-top: 10px; }
.soon {
  font-size: 26px; width: 46px; height: 46px; display: grid; place-items: center;
  background: #efeaf6; border: 2.5px dashed #a79cc0; border-radius: 14px;
  filter: grayscale(.7); opacity: .8;
}

/* world stage */
.stage-wrap { position: relative; margin-top: 6px; }
#stage {
  width: 100%;
  aspect-ratio: 960 / 600;
  display: block;
  border: 4px solid var(--ink);
  border-radius: 22px;
  box-shadow: var(--shadow);
  background: #7ec850;
  cursor: pointer;
}
.prompt {
  position: absolute; left: 50%; bottom: 58px; transform: translateX(-50%);
  cursor: pointer; user-select: none; touch-action: manipulation;
  background: var(--cream); border: 3px solid var(--ink); border-radius: 16px;
  padding: 8px 18px; font-weight: 700; font-size: 17px;
  display: flex; align-items: center; gap: 10px;
  box-shadow: var(--shadow); animation: bob 1.4s ease-in-out infinite;
}
@keyframes bob { 50% { transform: translateX(-50%) translateY(-5px); } }
kbd {
  font-family: var(--font); font-size: 12px; background: var(--ink); color: #fff;
  border-radius: 6px; padding: 2px 7px;
}
.controls-hint {
  text-align: center; font-size: 13px; color: #574f6b; margin-top: 8px;
}

/* ── overlay panels (classroom, cafeteria, booths) ───────────────────── */

.overlay {
  position: fixed; inset: 0; background: rgba(42, 36, 56, .55);
  display: grid; place-items: center; padding: 18px; z-index: 40;
  backdrop-filter: blur(2px);
}
.overlay-card {
  background: var(--cream);
  border: 4px solid var(--ink);
  border-radius: 24px;
  box-shadow: 0 12px 0 rgba(42, 36, 56, .3);
  width: min(920px, 96vw);
  max-height: 92vh;
  overflow: auto;
  animation: rise .22s ease;
}
@keyframes rise { from { transform: translateY(20px) scale(.97); opacity: 0; } }

.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 20px; border-bottom: 3px solid var(--ink);
  position: sticky; top: 0; background: var(--cream); z-index: 2;
}
.panel-head h2 { margin: 0; font-size: 24px; }
.panel-head .where { font-size: 13px; color: #6c6480; }
.panel-body { padding: 18px 20px 22px; }

.cols { display: grid; grid-template-columns: 1fr 260px; gap: 18px; }
@media (max-width: 760px) { .cols { grid-template-columns: 1fr; } }

.card {
  background: #fff; border: 3px solid var(--ink); border-radius: 18px;
  padding: 16px; box-shadow: 0 4px 0 rgba(42, 36, 56, .15);
}
.card + .card { margin-top: 14px; }
.card h3 { margin: 0 0 8px; font-size: 17px; }

/* exercise card */
.ex-label { font-size: 12px; font-weight: 700; color: #6c6480; text-transform: uppercase; letter-spacing: .5px; }
.ex-prompt { font-size: 22px; line-height: 1.45; margin: 8px 0 14px; }
.ex-prompt i { color: #40406b; }
.opts { display: flex; flex-wrap: wrap; gap: 10px; }
.opt {
  font-family: var(--font); font-size: 19px; font-weight: 700;
  background: #fff; border: 3px solid var(--ink); border-radius: 14px;
  padding: 10px 20px; cursor: pointer; box-shadow: 0 4px 0 rgba(42, 36, 56, .2);
}
.opt:hover { background: #fff3cd; }
.opt.right { background: var(--leaf); color: #fff; }
.opt.wrong { background: var(--berry); color: #fff; }
.opt:disabled { cursor: default; }

.answer-row { display: flex; gap: 10px; flex-wrap: wrap; }
.answer-row input {
  font-family: var(--font); font-size: 20px; padding: 10px 14px; flex: 1; min-width: 220px;
  border: 3px solid var(--ink); border-radius: 14px;
}
.answer-row input:focus { outline: 3px solid var(--sun); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.chipword {
  font-family: var(--font); font-size: 18px; font-weight: 700;
  background: #fff; border: 3px solid var(--ink); border-radius: 12px;
  padding: 7px 14px; cursor: pointer;
}
.chipword.used { opacity: .3; cursor: default; }
.slot {
  min-height: 52px; border: 3px dashed #a79cc0; border-radius: 14px;
  padding: 8px; display: flex; gap: 8px; flex-wrap: wrap; background: #fff;
}

.verdict { margin-top: 14px; font-size: 18px; font-weight: 700; }
.verdict.ok { color: #2f8f3f; }
.verdict.no { color: #c9433a; }
.verdict small { display: block; font-weight: 400; color: #574f6b; font-size: 14px; margin-top: 3px; }

/* cafeteria */
.menu-board {
  background: #3f6b4f; color: #fff8e6; border: 6px solid #a5673f; border-radius: 16px;
  padding: 14px 18px; columns: 250px 2; column-gap: 26px;
}
.menu-board h4 {
  margin: 8px 0 4px; font-size: 15px; color: var(--sun); letter-spacing: 1px;
  text-transform: uppercase; break-after: avoid;
}
.menu-line { display: flex; justify-content: space-between; gap: 10px; font-size: 15px; padding: 3px 0; break-inside: avoid; }
.menu-line .fr { display: block; line-height: 1.25; }
.menu-line .en { display: block; color: #bcd8c4; font-size: 11.5px; }
.menu-line > span:last-child { white-space: nowrap; }
.menu-line.tasted .fr::after { content: '✓'; color: var(--sun); }

.tray { display: grid; place-items: center; min-height: 210px; }
.tray canvas { width: 190px; height: 190px; }
.tray .said { font-size: 22px; font-weight: 700; margin-top: 2px; }
.tray .en { color: #6c6480; font-size: 14px; }
.waiter { display: flex; gap: 12px; align-items: flex-start; }
.waiter .bubble {
  background: #fff; border: 3px solid var(--ink); border-radius: 16px 16px 16px 4px;
  padding: 10px 14px; font-size: 16px; flex: 1;
}
.waiter .face { font-size: 40px; line-height: 1; }
.sugg { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.sugg button {
  font-family: var(--font); font-size: 14px; background: #fff3cd;
  border: 2.5px solid var(--ink); border-radius: 999px; padding: 4px 12px; cursor: pointer;
}

/* fair */
.booth-head { display: flex; align-items: center; gap: 14px; }
.booth-head .glyph { font-size: 46px; }
.streak { font-size: 15px; font-weight: 700; color: #6c6480; }
.prize-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.prize {
  background: #fff; border: 3px solid var(--ink); border-radius: 18px; padding: 12px;
  text-align: center; box-shadow: 0 4px 0 rgba(42, 36, 56, .15);
}
.prize .g { font-size: 46px; }
.prize .fr { font-weight: 700; font-size: 16px; }
.prize .en { font-size: 12px; color: #6c6480; margin-bottom: 8px; }
.prize.owned { background: #eaf7ea; }

.toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 60;
  display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: var(--ink); color: #fff; border-radius: 999px; padding: 8px 20px;
  font-weight: 700; font-size: 15px; animation: rise .2s ease;
  box-shadow: 0 5px 0 rgba(0, 0, 0, .25);
}
.toast.win { background: var(--leaf); }
.toast.lock { background: var(--plum); }

/* ── v1: login scene ─────────────────────────────────────────────────── */
.login-card {
  max-width: 420px; margin: 26px auto; padding: 28px 30px;
  display: flex; flex-direction: column; gap: 14px; text-align: center;
  background: #fffdf6; border-radius: 22px;
  box-shadow: 0 8px 0 rgba(87, 61, 28, .12);
}
.login-card .muted { margin: -4px 0 4px; font-size: 13px; color: #877e9b; }

/* Focused student activities */
:focus-visible { outline: 4px solid #285d9a; outline-offset: 4px; }
.avatar-card { font: inherit; color: inherit; }
.welcome-places, .activity-nav { display:flex; flex-wrap:wrap; justify-content:center; gap:14px; margin:20px 0; }
.welcome-places span { padding:12px 18px; background:#ffffffa8; border-radius:18px; }
.practice { max-width:680px; margin:auto; }
.practice-welcome { display:flex; align-items:center; gap:16px; margin:0 0 20px; }
.practice-welcome > span { font-size:42px; }
.practice-welcome h3 { margin:0 0 4px; font-size:21px; }
.practice-welcome p { margin:0; color:#574f6b; line-height:1.5; }
.practice .card { padding:26px; }
.practice .opts { display:grid; grid-template-columns:1fr 1fr; }
.activity-nav .btn { min-height:44px; }
@media(max-width:600px) {
  #hud { flex-wrap:wrap; } .hud-right { flex-wrap:wrap; }
  .overlay { padding:6px; } .panel-head,.panel-body { padding:14px; }
  .practice .card { padding:16px; } .practice .opts { grid-template-columns:1fr; }
  .answer-row input { min-width:0; width:100%; } .panel-head h2 { font-size:21px; }
}
@media(prefers-reduced-motion:reduce) { *, *::before, *::after { animation:none!important; transition:none!important; } }
