/* ============================================================
   Bangkok theme
   Light = "Bangkok sunset": frangipani cream, taxi pink, temple gold,
           orange & green temple-roof tiles, jungle greens.
   Dark  = "Bangkok night": indigo sky, neon pink, lit condo windows.
   Consonant class colours stay blue / orange / green (mid / high / low).
   ============================================================ */
:root {
  --bg: #fff7ea;
  --bg-glow-1: rgba(232, 40, 125, .10);
  --bg-glow-2: rgba(31, 122, 77, .10);
  --bg-glow-3: rgba(232, 160, 20, .12);
  --surface: #ffffff;
  --surface-2: #fcefdc;
  --text: #2b1633;
  --muted: #7a6672;
  --border: #f0dcc6;
  --accent: #d81b72;        /* Bangkok taxi pink */
  --accent-2: #b0125c;
  --accent-soft: #fde1ee;
  --accent-text: #ffffff;
  --gold: #c9930e;          /* temple gilding */
  --gold-soft: #fcefc7;
  --saffron: #e8751a;       /* monks' robes */
  --saffron-dark: #b8550c;
  --jungle: #1f7a4d;
  --teal: #12a594;
  --mid: #1f5fbf;  --mid-soft: #e0eafb;
  --high: #d9661a; --high-soft: #fde7d3;
  --low: #2e8b3e;  --low-soft: #dff3e1;
  --danger: #c62828;
  --good: #2e8b3e;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(80, 30, 60, .06), 0 8px 24px rgba(120, 50, 70, .08);
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --display: 'Prompt', 'Inter', system-ui, sans-serif;
  --thai: 'Noto Sans Thai Looped', 'Noto Sans Thai', 'Leelawadee UI', Tahoma, sans-serif;
  --sunset: linear-gradient(90deg, #d81b72, #e8751a 55%, #e8b020);

  /* scene colours: sunset over the Chao Phraya */
  --sky-top: #f59bc3; --sky-mid: #fdb98a; --sky-bot: #ffe2a3;
  --sun: #fff1c2; --sun-op: .95; --stars: 0;
  --city-far: #e9a3ad; --city-near: #b8677f; --window: #ffe9a8; --win-op: .45; --neon: #ff4fa3; --glow-op: .35;
  --temple: #fff3e2; --temple-line: #c9930e; --temple-shadow: #b8677f; --wall: #ffffff;
  --roof: #db5a1f; --roof2: #2f7d4f;
  --river: #74b9b0; --river-hi: #d6f1ec;
  --street: #5e4050; --street-line: #ffd66b;
  --tuk: #1565c0; --tuk-roof: #ffc928; --tuk-seat: #7b1f45; --glass: #cde9f2; --tire: #2b1a26;
  --umbrella: #e53f7e; --umbrella-2: #ffffff; --cart: #e9e2d6; --steam: #ffffff;
  --boat: #8a4b2a;
  --stage: #7b1f45; --crowd: #4a2a40;
  --leaf: #2e8b57; --leaf-3: #5dbb63; --leaf-vein: #1f6b45; --palm: #3b9c5a; --trunk: #8a6a4a;
  --plumeria: #ffffff; --plumeria-edge: #f3d9a8; --plumeria-c: #ffc83d;
  --orchid: #a64ac9; --orchid-lip: #f7d046; --bougain: #e2338c; --lotus: #f49ac1; --lotus-edge: #d8679a;
  --skin: #c98d5e; --bowl: #2b1a26;
  --wire: #6b4a57; --bulb-glow: 0px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #120c24;
    --bg-glow-1: rgba(255, 79, 163, .14);
    --bg-glow-2: rgba(18, 200, 170, .08);
    --bg-glow-3: rgba(245, 196, 81, .07);
    --surface: #1d1636; --surface-2: #2a2148; --text: #f7efff; --muted: #b4a7c9; --border: #352a57;
    --accent: #ff5fae; --accent-2: #ff8cc6; --accent-soft: #3d1a3a; --accent-text: #2a0a1c;
    --gold: #f5c451; --gold-soft: #3b2f14; --saffron: #ff9a3c; --saffron-dark: #c86a1c; --jungle: #4fc985; --teal: #3ee6c8;
    --mid: #82aaff; --mid-soft: #1e2850; --high: #ffa45c; --high-soft: #45291a; --low: #6bdb8a; --low-soft: #173a26;
    --danger: #ff7a7a; --good: #6bdb8a;
    --shadow: 0 1px 2px rgba(0,0,0,.35), 0 8px 28px rgba(0,0,0,.35);
    --sunset: linear-gradient(90deg, #ff5fae, #ff9a3c 55%, #f5c451);

    --sky-top: #0b0820; --sky-mid: #2a1650; --sky-bot: #6b2a6b;
    --sun: #fff4d6; --sun-op: .85; --stars: .9;
    --city-far: #2b2150; --city-near: #1a1338; --window: #ffd36b; --win-op: .95; --neon: #ff4fa3; --glow-op: 1;
    --temple: #f0dfb4; --temple-line: #f5c451; --temple-shadow: #5a3c20; --wall: #f6e8c6;
    --roof: #c2441d; --roof2: #23704a;
    --river: #1b2350; --river-hi: #ff5fae;
    --street: #0d0a1a; --street-line: #f5c451;
    --tuk: #2979ff; --tuk-roof: #ffc928; --tuk-seat: #ff5fae; --glass: #3a4f7a; --tire: #05030c;
    --umbrella: #ff4f9a; --umbrella-2: #ffe7f2; --cart: #9a90b8; --steam: #ffffff;
    --boat: #6b3a22; --stage: #ff5fae; --crowd: #05030c;
    --leaf: #1f6b45; --leaf-3: #2e8b57; --leaf-vein: #134a30; --palm: #23704a; --trunk: #4a3526;
    --plumeria: #fff8e7; --plumeria-edge: #e9cf98; --plumeria-c: #ffc83d;
    --orchid: #c77dff; --orchid-lip: #ffd84d; --bougain: #ff3d9a; --lotus: #ff9cc9; --lotus-edge: #ff5fae;
    --skin: #b07a50; --bowl: #05030c;
    --wire: #5a4a7a; --bulb-glow: 4px;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; color: var(--text);
  background:
    radial-gradient(900px 500px at 100% -10%, var(--bg-glow-1), transparent 60%),
    radial-gradient(700px 500px at -10% 40%, var(--bg-glow-2), transparent 60%),
    radial-gradient(800px 400px at 60% 110%, var(--bg-glow-3), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  font: 16px/1.55 var(--font);
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
  min-height: 100vh;
}
.th { font-family: var(--thai); }
a { color: var(--accent); }
button { font: inherit; color: inherit; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; font-family: var(--display); font-weight: 600; }
h1 { font-size: 1.75rem; letter-spacing: -.01em; }
h2 { font-size: 1.2rem; }
p { margin: 0 0 1rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .7rem 16px; background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(12px);
}
.topbar::after { /* jasmine and marigold garland (phuang malai) */
  content: ''; position: absolute; left: 0; right: 0; bottom: -10px; height: 12px; pointer-events: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='60' height='12'%3E%3Cpath d='M0 3 Q15 11 30 3 Q45 11 60 3' stroke='%2363a35a' stroke-width='1.2' fill='none'/%3E%3Ccircle cx='6' cy='5.5' r='2.6' fill='%23fffdf4' stroke='%23e9d8b0' stroke-width='.5'/%3E%3Ccircle cx='12' cy='7.5' r='2.6' fill='%23fffdf4' stroke='%23e9d8b0' stroke-width='.5'/%3E%3Ccircle cx='19' cy='8.6' r='3.4' fill='%23f39a1c'/%3E%3Ccircle cx='26' cy='8' r='2.6' fill='%23fffdf4' stroke='%23e9d8b0' stroke-width='.5'/%3E%3Ccircle cx='31' cy='7.2' r='2.8' fill='%23d6245e'/%3E%3Ccircle cx='37' cy='8' r='2.6' fill='%23fffdf4' stroke='%23e9d8b0' stroke-width='.5'/%3E%3Ccircle cx='43' cy='8.6' r='3.4' fill='%23f39a1c'/%3E%3Ccircle cx='50' cy='7.5' r='2.6' fill='%23fffdf4' stroke='%23e9d8b0' stroke-width='.5'/%3E%3Ccircle cx='56' cy='5.5' r='2.6' fill='%23fffdf4' stroke='%23e9d8b0' stroke-width='.5'/%3E%3C/svg%3E") repeat-x;
}
.brand { display: flex; align-items: center; gap: .55rem; text-decoration: none; color: var(--text); }
.brand-mark { width: 34px; height: 34px; flex: none; }
.brand-th { font-family: var(--display); font-weight: 700; font-size: 1.3rem; background: var(--sunset); -webkit-background-clip: text; background-clip: text; color: transparent; }
.brand-en { font-family: var(--display); font-weight: 500; font-size: .9rem; color: var(--muted); }
.nav { display: flex; gap: .25rem; }
.nav a {
  text-decoration: none; color: var(--muted); font-weight: 500; padding: .45rem .85rem; border-radius: 999px;
  font-family: var(--display); display: inline-flex; align-items: center; gap: .35rem;
}
.nav a svg { width: 18px; height: 18px; }
.nav a:hover { color: var(--text); background: var(--surface-2); }
.nav a.active { color: var(--accent-text); background: var(--accent); box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 35%, transparent); }

@media (max-width: 720px) {
  /* backdrop-filter would trap the fixed bottom nav inside the top bar */
  .topbar { backdrop-filter: none; background: var(--bg); }
  .nav {
    position: fixed; left: 0; right: 0; bottom: 0; justify-content: space-around;
    background: var(--surface); border-top: 1px solid var(--border);
    padding: .35rem .25rem calc(.35rem + env(safe-area-inset-bottom));
    box-shadow: 0 -6px 20px rgba(0,0,0,.08);
  }
  .nav a { flex-direction: column; gap: .1rem; padding: .35rem .5rem; font-size: .72rem; border-radius: 12px; }
  .nav a svg { width: 22px; height: 22px; }
  .brand-en { display: none; }
}
@media (min-width: 721px) { body { padding-bottom: 0; } .nav a svg { display: none; } }

.container { max-width: 1000px; margin: 0 auto; padding: 1.6rem 16px 1.25rem; outline: none; }

/* ---------- Home hero ---------- */
.hero-banner {
  position: relative; border-radius: 26px; overflow: hidden; margin-bottom: 1.25rem;
  box-shadow: var(--shadow); border: 1px solid var(--border);
  height: clamp(250px, 42vw, 400px);
}
.hero-banner .scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.hero-copy {
  position: absolute; left: 18px; top: 18px; max-width: min(430px, calc(100% - 36px));
  background: color-mix(in srgb, var(--surface) 82%, transparent); backdrop-filter: blur(8px);
  border: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
  border-radius: 18px; padding: .9rem 1.1rem;
}
.hero-copy h1 { margin: 0 0 .2rem; font-size: clamp(1.35rem, 3.6vw, 2rem); }
.hero-copy h1 .th { background: var(--sunset); -webkit-background-clip: text; background-clip: text; color: transparent; font-weight: 700; }
.hero-copy p { margin: 0; font-size: .95rem; color: var(--muted); }
@media (max-width: 520px) {
  .hero-banner { height: 300px; }
  .hero-copy { padding: .7rem .9rem; left: 12px; top: 12px; }
  .hero-copy p { font-size: .85rem; }
}

/* ---------- Cards & layout ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem 1.1rem; box-shadow: var(--shadow);
}
.grid { display: grid; gap: .9rem; }
.grid-2 { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .75rem; margin-bottom: 1.4rem; }
.stat { display: flex; align-items: center; gap: .75rem; padding: .85rem 1rem; }
.stat .ico { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; flex: none; }
.stat .ico svg { width: 30px; height: 30px; }
.stat .num { font-family: var(--display); font-size: 1.55rem; font-weight: 700; line-height: 1.1; }
.stat .lbl { color: var(--muted); font-size: .8rem; line-height: 1.25; }
.ico.pink { background: var(--accent-soft); } .ico.gold { background: var(--gold-soft); }
.ico.green { background: var(--low-soft); } .ico.orange { background: var(--high-soft); }
.section { margin-bottom: 1.75rem; }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }

a.tile { display: block; text-decoration: none; color: var(--text); transition: transform .15s, border-color .15s, box-shadow .15s; overflow: hidden; padding: 0; }
a.tile:hover { border-color: var(--accent); transform: translateY(-3px); box-shadow: 0 14px 30px color-mix(in srgb, var(--accent) 18%, transparent); }
.tile .art { position: relative; height: 128px; overflow: hidden; border-bottom: 1px solid var(--border); }
.tile .art .vignette { width: 100%; height: 100%; display: block; }
.tile .art .big {
  position: absolute; left: 12px; bottom: 8px; font-family: var(--thai); font-size: 1.6rem; font-weight: 700; line-height: 1.2;
  color: #fff; text-shadow: 0 2px 10px rgba(40, 10, 40, .55), 0 0 2px rgba(40, 10, 40, .6);
}
.tile .body { padding: .85rem 1.1rem 1rem; }
.tile .body h2 { margin-bottom: .2rem; }
.tile .body p { margin: 0; }
.tile.hot .art::after { content: 'Due'; position: absolute; right: 10px; top: 10px; background: var(--accent); color: var(--accent-text); font: 600 .75rem var(--display); padding: .15rem .6rem; border-radius: 999px; }
.tile:not(:has(.art)) { padding: 1rem 1.1rem; }

/* page header with an illustration */
.page-head {
  display: grid; grid-template-columns: 1fr minmax(160px, 260px); gap: 1rem; align-items: stretch;
  margin-bottom: 1.25rem; padding: 0; overflow: hidden;
}
.page-head .copy { padding: 1.1rem 1.2rem; display: flex; flex-direction: column; justify-content: center; }
.page-head .copy p { margin-bottom: .5rem; }
.page-head .copy > :last-child { margin-bottom: 0; }
.page-head .art { min-height: 130px; position: relative; }
.page-head .art .vignette { position: absolute; inset: 0; width: 100%; height: 100%; }
@media (max-width: 600px) {
  .page-head { grid-template-columns: 1fr; gap: 0; }
  .page-head .art { order: -1; min-height: 120px; }
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: .4rem; justify-content: center;
  border: 1px solid var(--border); background: var(--surface); padding: .55rem 1.05rem;
  border-radius: 999px; cursor: pointer; font-weight: 500; text-decoration: none; color: var(--text);
  min-height: 42px; font-family: var(--display); transition: transform .1s, filter .1s, background .1s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 30%, transparent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.rec { border-color: var(--danger); color: var(--danger); }
.btn.rec.on { background: var(--danger); color: #fff; }
.btn:disabled { opacity: .45; cursor: default; }
.btn svg { width: 18px; height: 18px; }
.chips { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: 1rem; }
.chip {
  border: 1px solid var(--border); background: var(--surface); border-radius: 999px; text-decoration: none; color: var(--text);
  padding: .35rem .9rem; cursor: pointer; font-size: .9rem; font-family: var(--display);
}
.chip:hover { border-color: var(--gold); }
.chip.on { background: var(--gold); color: #2b1633; border-color: var(--gold); }

/* ---------- Alphabet grid ---------- */
.letters { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: .55rem; }
.letter {
  border: 1px solid var(--border); background: var(--surface); border-radius: 16px; cursor: pointer;
  padding: .55rem .25rem .5rem; text-align: center; position: relative; overflow: hidden;
  border-top: 4px solid currentColor; transition: transform .12s, box-shadow .12s;
}
.letter:hover { transform: translateY(-2px); box-shadow: 0 8px 18px color-mix(in srgb, currentColor 22%, transparent); }
.letter .glyph { font-family: var(--thai); font-size: 2.3rem; line-height: 1.35; display: block; }
.letter .sub { font-size: .72rem; color: var(--muted); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.letter.obsolete { opacity: .5; }
.letter .dot { position: absolute; top: 7px; right: 7px; width: 8px; height: 8px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 0 2px var(--surface); }
.cls-mid  { color: var(--mid); }
.cls-high { color: var(--high); }
.cls-low  { color: var(--low); }
.badge { display: inline-block; padding: .12rem .6rem; border-radius: 999px; font-size: .78rem; font-weight: 600; font-family: var(--display); }
.badge.mid  { background: var(--mid-soft);  color: var(--mid); }
.badge.high { background: var(--high-soft); color: var(--high); }
.badge.low  { background: var(--low-soft);  color: var(--low); }
.legend { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; align-items: center; }

/* ---------- Table ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: .6rem .5rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { font-size: .78rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.table .th { font-size: 1.5rem; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover { background: var(--surface-2); }
.table tr:last-child td { border-bottom: none; }

/* ---------- Word list ---------- */
.words { display: grid; gap: .55rem; }
.word {
  display: grid; grid-template-columns: 1fr auto; gap: .25rem 1rem; align-items: center;
  padding: .75rem 1rem; cursor: pointer; border-left: 4px solid var(--accent);
  transition: transform .12s, border-color .12s;
}
.word:nth-child(4n+2) { border-left-color: var(--gold); }
.word:nth-child(4n+3) { border-left-color: var(--jungle); }
.word:nth-child(4n+4) { border-left-color: var(--saffron); }
.word:hover { transform: translateX(3px); }
.word .t { font-family: var(--thai); font-size: 1.4rem; font-weight: 600; }
.word .r { color: var(--accent); font-size: .9rem; font-weight: 500; }
.word .e { color: var(--muted); font-size: .9rem; }

/* ---------- Flashcard ---------- */
.flash-wrap { max-width: 540px; margin: 0 auto; }
.flash {
  position: relative; overflow: hidden;
  min-height: 300px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; cursor: pointer; gap: .5rem; padding: 2rem 1rem;
}
.flash > * { position: relative; }
.flash .deco { position: absolute; inset: 0; pointer-events: none; }
.flash .deco svg { position: absolute; }
.flash .t { font-family: var(--thai); font-size: clamp(2.6rem, 12vw, 4.2rem); font-weight: 700; line-height: 1.3; }
.flash .r { font-size: 1.25rem; color: var(--accent); font-weight: 600; }
.flash .e { font-size: 1.1rem; }
.flash .hint { color: var(--muted); font-size: .85rem; }
.progress { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin: .75rem 0 1rem; }
.progress > div { height: 100%; background: var(--sunset); border-radius: 999px; transition: width .25s; }
.grade { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin-top: 1rem; }

/* ---------- Quiz ---------- */
.options { display: grid; gap: .55rem; margin-top: 1rem; }
.option {
  text-align: left; padding: .9rem 1.1rem; border: 1px solid var(--border); background: var(--surface);
  border-radius: 14px; cursor: pointer; font-size: 1.05rem; box-shadow: var(--shadow);
  transition: transform .1s, border-color .1s;
}
.option:hover:not(:disabled) { border-color: var(--accent); transform: translateY(-1px); }
.option.right { border-color: var(--good); background: var(--low-soft); animation: pop .3s ease; }
.option.wrong { border-color: var(--danger); background: var(--high-soft); animation: shake .3s ease; }
.option:disabled { cursor: default; }
.q-prompt { font-family: var(--thai); font-size: clamp(2.6rem, 12vw, 3.9rem); font-weight: 700; text-align: center; }
@keyframes pop { 50% { transform: scale(1.03); } }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

/* ---------- Sheet (detail dialog) ---------- */
.sheet {
  border: none; padding: 0; border-radius: 24px; width: min(520px, calc(100vw - 24px));
  background: var(--surface); color: var(--text); box-shadow: 0 24px 70px rgba(30, 5, 30, .4); overflow: hidden;
}
.sheet::backdrop { background: rgba(25, 8, 30, .55); backdrop-filter: blur(3px); }
.sheet-inner { padding: 1.5rem; }
.sheet .sheet-art { height: 84px; margin: -1.5rem -1.5rem 0; position: relative; overflow: hidden; }
.sheet .sheet-art svg { width: 100%; height: 100%; display: block; }
.sheet .hero { text-align: center; margin: -36px auto 1rem; position: relative; }
.sheet .hero .t {
  font-family: var(--thai); font-size: 4.5rem; line-height: 1.25; font-weight: 700;
  display: inline-block; min-width: 1.6em; padding: 0 .25em; background: var(--surface); border-radius: 20px;
  box-shadow: var(--shadow); border: 1px solid var(--border);
}
.sheet .hero .sub { font-family: var(--thai); font-size: 1.4rem; margin-top: .4rem; }
.sheet .hero .r { color: var(--accent); font-weight: 600; font-size: 1.1rem; }
.sheet dl { display: grid; grid-template-columns: auto 1fr; gap: .35rem 1rem; margin: 0 0 1rem; }
.sheet dt { color: var(--muted); font-size: .9rem; }
.sheet dd { margin: 0; }
.close-x { position: absolute; top: .5rem; right: .5rem; z-index: 2; border: none; background: color-mix(in srgb, var(--surface) 80%, transparent); font-size: 1.5rem; cursor: pointer; color: var(--text); width: 40px; height: 40px; border-radius: 50%; }
.close-x:hover { background: var(--surface); }

/* ---------- Speak panel ---------- */
.speak { border-top: 1px dashed var(--border); padding-top: 1rem; }
.speak h3 { font-size: .95rem; }
.speak .row { margin-bottom: .5rem; }
.speak .status { font-size: .85rem; color: var(--muted); min-height: 1.3em; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(92px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px);
  background: var(--text); color: var(--bg); padding: .65rem 1rem; border-radius: 14px; opacity: 0;
  pointer-events: none; transition: .2s; max-width: calc(100vw - 32px); font-size: .9rem; z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.note {
  background: var(--gold-soft); border: 1px solid color-mix(in srgb, var(--gold) 35%, transparent);
  border-radius: 14px; padding: .8rem 1rem; font-size: .92rem; margin-bottom: 1rem;
}
.empty { text-align: center; padding: 2rem 1rem; }
.empty .vignette { width: min(320px, 100%); height: 150px; border-radius: 16px; margin-bottom: 1rem; }

/* ---------- Footer skyline ---------- */
.foot { margin-top: 1rem; height: 90px; overflow: hidden; opacity: .55; pointer-events: none; }
.foot svg { width: 100%; height: 100%; display: block; }
.foot { --city-far: color-mix(in srgb, var(--accent) 22%, var(--bg)); --temple: color-mix(in srgb, var(--accent) 22%, var(--bg)); --temple-line: transparent; --temple-shadow: transparent; --gold: color-mix(in srgb, var(--accent) 22%, var(--bg)); --palm: color-mix(in srgb, var(--jungle) 45%, var(--bg)); --trunk: color-mix(in srgb, var(--jungle) 45%, var(--bg)); }

/* ---------- Game layer: HUD, XP, combos, rewards, lore ---------- */
.hud { display: flex; align-items: center; gap: .5rem; }
.hud-level { display: flex; align-items: center; gap: .45rem; text-decoration: none; color: var(--text); font: 600 .85rem var(--display); }
.hud-level .lv { background: var(--gold-soft); color: var(--gold); padding: .15rem .55rem; border-radius: 999px; }
.hud-bar { width: 64px; height: 7px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.hud-bar > span { display: block; height: 100%; background: var(--sunset); border-radius: 999px; transition: width .5s; }
.hud-btn { border: 1px solid var(--border); background: var(--surface); width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; color: var(--muted); }
.hud-btn svg { width: 18px; height: 18px; }
.hud-btn:hover { color: var(--text); }

.xpbar { height: 12px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin-top: .45rem; }
.xpbar > div { height: 100%; background: var(--sunset); border-radius: 999px; transition: width 1s cubic-bezier(.2,.8,.2,1); }
.xpbar.thin { height: 7px; }

.hero-card { display: grid; grid-template-columns: auto 1fr; gap: 1.25rem; align-items: center; padding: 1.1rem 1.25rem; }
.ring {
  --p: 0; width: 108px; height: 108px; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(var(--accent) calc(var(--p) * 1%), var(--surface-2) 0);
}
.ring > div { width: 84px; height: 84px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; align-content: center; text-align: center; line-height: 1.1; }
.ring strong { font: 700 1.5rem var(--display); }
.ring span { font-size: .72rem; color: var(--muted); }
.big-btn { font-size: 1.05rem; padding: .7rem 1.4rem; }
@media (max-width: 520px) { .hero-card { grid-template-columns: 1fr; justify-items: center; text-align: center; } .hero-right { width: 100%; } }

.combo { display: inline-block; font-weight: 700; color: var(--saffron); animation: pop .3s ease; }
.option.pop { animation: comboPop .35s ease; }
@keyframes comboPop { 40% { transform: scale(1.06); box-shadow: 0 0 0 6px color-mix(in srgb, var(--good) 25%, transparent); } }

.float-xp {
  position: fixed; z-index: 60; pointer-events: none; transform: translate(-50%, 0);
  font: 800 1.1rem var(--display); color: var(--gold); text-shadow: 0 2px 8px rgba(0,0,0,.25);
  animation: floatUp 1s ease-out forwards;
}
@keyframes floatUp { from { opacity: 0; transform: translate(-50%, 0) scale(.8); } 15% { opacity: 1; transform: translate(-50%, -10px) scale(1.15); } to { opacity: 0; transform: translate(-50%, -60px) scale(1); } }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 70; }

.reward { max-width: 560px; margin: 0 auto; text-align: center; }
.reward-cheer { font: 700 1.6rem var(--thai); background: var(--sunset); -webkit-background-clip: text; background-clip: text; color: transparent; animation: pop .5s ease; }
.reward-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; margin: 1rem 0; }
.rs { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: .8rem .4rem; box-shadow: var(--shadow); }
.rs .n { font: 800 1.6rem var(--display); }
.rs.xp .n { color: var(--gold); }
.rs .l { font-size: .78rem; color: var(--muted); }
.level-card { text-align: left; margin-bottom: 1rem; }

.lore-card { text-align: left; }
.lore-card.unlocked { border: 2px solid var(--gold); animation: pop .5s ease .3s both; }
.lore-card.locked { opacity: .65; border-style: dashed; }
.lore-tag { font: 700 .72rem var(--display); text-transform: uppercase; letter-spacing: .05em; color: var(--gold); margin-bottom: .4rem; }
.lore-head { display: flex; align-items: center; gap: .6rem; margin-bottom: .4rem; }
.lore-head h2 { margin: 0; }
.lore-icon { font-size: 1.8rem; line-height: 1; }
.lore-card p { margin: 0; }

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