/* Chiga — bright, game-like UI. Tokens first. */
:root {
  --sky: #E6F5FF; --sky-2: #CDE8FA; --white: #FFFFFF; --ink: #1B1F3B; --muted: #4A5578; --line: #E1E8F2;
  --blue: #1E5BD8; --blue-d: #123E9E; --blue-l: #3A72E6; --sea: #2BB3E8; --sea-l: #3EC1EF;
  --sun: #FFC83D; --sun-d: #D99A00; --grass: #3CC97A; --grass-d: #1F8A52; --grass-l: #E3F8EC;
  --coral: #FF6B57; --coral-l: #FFE9E6; --coral-d: #B42318; --flame: #FF7A2F; --flame-l: #FFF1E6;
  --purple: #7A5CFF; --purple-l: #EFEAFF; --purple-d: #5B3FD6; --amber-l: #FFF4D6; --amber-d: #8A5A00;
  --night: #1B1F3B; --night-2: #252A55; --night-3: #3A406F;
  --f-display: 'Baloo 2', 'Trebuchet MS', system-ui, sans-serif;
  --f-body: 'Nunito', 'Segoe UI', system-ui, sans-serif;
  --r: 20px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--sky); color: var(--ink); font-family: var(--f-body); font-size: 16px; line-height: 1.5; min-height: 100vh; }
h1, h2, h3 { font-family: var(--f-display); line-height: 1.1; margin: 0; text-wrap: balance; }
h1 { font-size: clamp(28px, 4vw, 40px); }
h2 { font-size: 24px; }
h3 { font-size: 19px; }
p { margin: 0; }
a { color: var(--blue); }
a:hover { color: var(--blue-d); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--sun); outline-offset: 2px; }
[hidden] { display: none !important; }

/* layout */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 24px; background: var(--white); border-bottom: 3px solid var(--sky-2); position: sticky; top: 0; z-index: 20; }
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; }
.brand b { font-family: var(--f-display); font-weight: 800; font-size: 28px; color: var(--blue); }
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav a { padding: 8px 14px; border-radius: 14px; font-weight: 800; text-decoration: none; color: var(--ink); }
.nav a.on { background: var(--blue); color: var(--white); }
.chips { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; font-weight: 800; font-size: 14px; background: var(--sky); white-space: nowrap; }
.chip.flame { background: var(--flame-l); color: #C2410C; }
.chip.xp { background: var(--purple-l); color: var(--purple-d); }
.chip.ok { background: var(--grass-l); color: var(--grass-d); }
.chip.bad { background: var(--coral-l); color: var(--coral-d); }
.chip.warn { background: var(--amber-l); color: var(--amber-d); }
.chip.dark { background: var(--ink); color: var(--white); }
.wrap { max-width: 1180px; margin: 0 auto; padding: 24px 20px 64px; }
.narrow { max-width: 520px; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 22px; align-items: start; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.stack { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.card { background: var(--white); border-radius: var(--r); padding: 20px 22px; }
.card.flat { box-shadow: 0 3px 0 var(--line); }
.muted { color: var(--muted); font-weight: 700; }
.small { font-size: 14px; }
.tiny { font-size: 12px; }
.center { text-align: center; }
.eyebrow { font-weight: 800; font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
@media (max-width: 860px) { .grid2, .grid3, .grid4 { grid-template-columns: 1fr; } .topbar { padding: 10px 16px; } }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: none; cursor: pointer; text-decoration: none; padding: 12px 22px; border-radius: 16px; font-family: var(--f-display); font-weight: 800; font-size: 19px; background: var(--blue); color: var(--white); box-shadow: 0 5px 0 var(--blue-d); transition: transform .08s; min-height: 44px; }
.btn:hover { color: var(--white); }
.btn:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--blue-d); }
.btn.sun { background: var(--sun); color: var(--ink); box-shadow: 0 5px 0 var(--sun-d); }
.btn.green { background: var(--grass); box-shadow: 0 5px 0 var(--grass-d); }
.btn.dark { background: var(--ink); box-shadow: 0 5px 0 #000; }
.btn.ghost { background: var(--white); color: var(--ink); box-shadow: 0 0 0 2px var(--sky-2) inset; }
.btn.ghost:hover { color: var(--ink); }
.btn.sm { font-family: var(--f-body); font-size: 14px; padding: 7px 12px; border-radius: 12px; box-shadow: none; min-height: 36px; }
.btn.big { font-size: 24px; padding: 16px 32px; border-radius: 18px; }
.btn[disabled] { opacity: .5; cursor: default; }
.linkbtn { background: none; border: none; color: var(--blue); font-weight: 800; cursor: pointer; padding: 0; }

/* forms */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-weight: 800; }
.input, select.input, textarea.input { width: 100%; padding: 12px 14px; border-radius: 14px; border: 3px solid var(--sky-2); background: var(--white); font-weight: 700; min-height: 48px; }
.input:focus { border-color: var(--blue); outline: none; }
.form { display: flex; flex-direction: column; gap: 14px; }
.msg { padding: 12px 14px; border-radius: 14px; font-weight: 700; }
.msg.err { background: var(--coral-l); color: var(--coral-d); }
.msg.ok { background: var(--grass-l); color: var(--grass-d); }
.tabs { display: flex; background: var(--sky); border-radius: 16px; padding: 4px; }
.tabs button { flex: 1; border: none; background: none; padding: 10px; border-radius: 12px; font-weight: 800; cursor: pointer; }
.tabs button.on { background: var(--white); box-shadow: 0 2px 0 var(--sky-2); }

/* hero / today */
.hero { background: var(--blue); color: var(--white); border-radius: 28px; padding: 28px 30px; display: flex; gap: 20px; align-items: center; box-shadow: 0 8px 0 var(--blue-d); }
.hero h1 { color: var(--white); }
.hero .pill { padding: 6px 12px; border-radius: 999px; background: var(--blue-l); font-weight: 800; font-size: 14px; }
.hero .eyebrow { color: #BFD6FF; }
.mascot { flex: none; }
.bar { height: 14px; border-radius: 999px; background: var(--sky); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--grass); border-radius: 999px; transition: width .5s; }
.bar.blue > i { background: var(--sea); }
.bar.amber > i { background: #FFB020; }
.bar.red > i { background: var(--coral); }
.quest { border: 3px solid var(--sky-2); border-radius: 18px; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.quest.done { border-color: var(--grass); }
.weekdots { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; text-align: center; font-weight: 800; font-size: 13px; }
.weekdots span.d { display: block; width: 30px; height: 30px; margin: 4px auto 0; border-radius: 50%; background: var(--sky); }
.weekdots span.d.on { background: var(--flame); }
.weekdots span.d.today { box-shadow: 0 0 0 3px var(--flame) inset; }
.badge { border-radius: 16px; padding: 10px; text-align: center; font-weight: 800; font-size: 14px; background: var(--purple-l); color: var(--purple-d); }
.tasklist { display: flex; flex-direction: column; gap: 10px; }
.task { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-radius: 16px; background: var(--sky); font-weight: 800; text-decoration: none; color: var(--ink); }
.task:hover { color: var(--ink); background: var(--sky-2); }

/* map */
.sea { position: relative; background: var(--sea-l); border-radius: 28px; overflow: hidden; min-height: 560px; }
.island { position: absolute; display: flex; align-items: center; justify-content: center; gap: 4px; border-radius: 50% 50% 46% 54%; font-family: var(--f-display); font-weight: 800; color: var(--white); font-size: 26px; border: none; }
.island.done { background: var(--grass); box-shadow: 0 8px 0 #E8C77A; }
.island.cur { background: var(--sun); color: var(--ink); box-shadow: 0 0 0 7px var(--white), 0 10px 0 7px var(--sun-d); font-size: 36px; }
.island.locked { background: #A9C7D6; box-shadow: 0 8px 0 #8AA9B8; }
.island.mock { border-radius: 14px; background: var(--ink); color: var(--sun); font-size: 18px; }
.modrow { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 14px; background: #F1F4F8; font-weight: 800; }
.modrow.passed { background: var(--grass-l); }
.modrow.open { background: var(--sky); box-shadow: 0 0 0 3px var(--blue) inset; }
.modrow.boss { background: var(--ink); color: var(--white); }

/* play */
.playtop { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.playtop .bar { flex: 1; min-width: 160px; height: 18px; background: var(--sky-2); }
.qcard { background: var(--white); border-radius: 26px; padding: 26px; display: flex; flex-direction: column; gap: 18px; }
.qprompt { font-family: var(--f-display); font-size: clamp(22px, 2.6vw, 30px); line-height: 1.3; white-space: pre-line; }
.opts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 700px) { .opts { grid-template-columns: 1fr; } }
.opt { display: flex; align-items: center; gap: 12px; text-align: left; padding: 14px 16px; border-radius: 18px; border: 3px solid var(--sky-2); background: var(--white); box-shadow: 0 5px 0 var(--sky-2); font-weight: 800; font-size: 18px; cursor: pointer; min-height: 56px; }
.opt .k { flex: none; width: 34px; height: 34px; border-radius: 10px; background: var(--sky); display: inline-flex; align-items: center; justify-content: center; }
.opt.sel { border-color: var(--blue); box-shadow: 0 5px 0 var(--blue); }
.opt.right { border-color: var(--grass); background: var(--grass-l); box-shadow: 0 5px 0 var(--grass); }
.opt.wrong { border-color: var(--coral); background: var(--coral-l); box-shadow: 0 5px 0 var(--coral); }
.opt[disabled] { cursor: default; }
.passage { background: var(--white); color: var(--ink); border-radius: 22px; padding: 22px; max-height: 70vh; overflow: auto; white-space: pre-line; line-height: 1.75; font-size: 16px; }
.playgrid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.playgrid.solo { grid-template-columns: minmax(0, 860px); justify-content: center; }
@media (max-width: 900px) { .playgrid { grid-template-columns: 1fr; } }
.feedback { border-radius: 22px; padding: 18px 22px; display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.feedback.ok { background: #C9F2DA; }
.feedback.no { background: #FFD9D3; }
.feedback.wait { background: var(--amber-l); }
.combo { background: var(--flame); color: var(--white); font-family: var(--f-display); font-size: 20px; padding: 6px 14px; border-radius: 999px; font-weight: 800; }
.combo.pop { animation: pop .35s ease; }
@keyframes pop { 0% { transform: scale(1); } 50% { transform: scale(1.3); } 100% { transform: scale(1); } }
.palette { display: flex; flex-wrap: wrap; gap: 6px; }
.palette button { width: 38px; height: 38px; border-radius: 10px; border: 2px solid var(--sky-2); background: var(--white); font-weight: 800; cursor: pointer; font-size: 13px; }
.palette button.ans { background: var(--sky-2); }
.palette button.flag { border-color: var(--flame); }
.palette button.cur { border-color: var(--blue); box-shadow: 0 0 0 2px var(--blue); }
.boss { background: var(--night); color: var(--white); }
.boss .card { background: var(--night-2); color: var(--white); }
.boss .muted { color: #9AA6D6; }
.boss .qcard { color: var(--ink); }
.boss .bar { background: var(--night-3); }
.bossbar { position: sticky; top: 0; z-index: 30; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; background: var(--night); padding: 10px 0; border-bottom: 2px solid var(--night-3); }
.boss .bossbar .bar { height: 10px; }
@media (max-width: 900px) { .boss .playgrid > [style*="sticky"] { position: static !important; } .boss .passage { max-height: 40vh; } }
.lesson-point { border-radius: 18px; background: var(--sky); padding: 16px 18px; display: flex; flex-direction: column; gap: 8px; }
.lesson-point ul { margin: 0; padding-left: 20px; font-weight: 600; }
.trap { background: var(--coral-l); color: var(--coral-d); border-radius: 12px; padding: 8px 12px; font-weight: 700; font-size: 15px; }
.flash { perspective: 1000px; }
.flash .face { min-height: 220px; border-radius: 26px; background: var(--white); display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 26px; gap: 10px; box-shadow: 0 6px 0 var(--sky-2); }
.flash .face.rare { box-shadow: 0 0 0 4px var(--purple) inset, 0 6px 0 var(--purple-d); }
.flash .front { font-family: var(--f-display); font-size: 32px; }
.loader { display: flex; flex-direction: column; align-items: center; gap: 18px; padding: 60px 20px; text-align: center; }
.bob { animation: bob 1.2s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-12px); } }
.victory { background: var(--grass); color: var(--white); border-radius: 30px; padding: 30px; display: flex; flex-direction: column; gap: 12px; position: relative; overflow: hidden; }
.victory.lose { background: var(--coral); }
.victory h1 { color: var(--white); font-size: clamp(40px, 6vw, 64px); }
.result-item { border-radius: 18px; border: 3px solid var(--sky-2); padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.result-item.wrong { border-color: #FFD9D3; }
.result-item.half { border-color: #FFE3A3; }
.ans { padding: 3px 10px; border-radius: 8px; font-weight: 800; font-size: 14px; }
.ans.you { background: var(--coral-l); color: var(--coral-d); }
.ans.ok { background: var(--grass-l); color: #1F7A48; }
table.t { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
table.t th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 8px 6px; }
table.t td { padding: 10px 6px; border-top: 1px solid var(--line); font-weight: 700; }
.tablebox { overflow-x: auto; }
.stat .v { font-family: var(--f-display); font-weight: 800; font-size: 32px; font-variant-numeric: tabular-nums; }
.admin-shell { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: calc(100vh - 70px); }
.admin-nav { background: var(--night); padding: 20px 14px; display: flex; flex-direction: column; gap: 4px; }
.admin-nav a { color: var(--white); text-decoration: none; padding: 10px 12px; border-radius: 12px; font-weight: 800; }
.admin-nav a.on { background: #2E3570; }
.admin-nav a:hover { color: var(--sun); }
@media (max-width: 860px) { .admin-shell { grid-template-columns: 1fr; } .admin-nav { flex-direction: row; flex-wrap: wrap; } }
.modal-bg { position: fixed; inset: 0; background: rgba(27,31,59,.55); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal { background: var(--white); border-radius: 24px; padding: 24px; max-width: 460px; width: 100%; display: flex; flex-direction: column; gap: 14px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: var(--white); padding: 12px 18px; border-radius: 14px; font-weight: 800; z-index: 60; max-width: calc(100% - 32px); }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 70; }
.levelup { position: fixed; inset: 0; background: rgba(27,31,59,.8); z-index: 65; display: flex; align-items: center; justify-content: center; padding: 16px; }
.levelup .inner { background: var(--sun); border-radius: 30px; padding: 34px; text-align: center; max-width: 440px; display: flex; flex-direction: column; gap: 12px; align-items: center; animation: pop .5s ease; }
@media (prefers-reduced-motion: reduce) { .bob, .combo.pop, .levelup .inner { animation: none; } .bar > i { transition: none; } }

/* on/off switch (admin AI toggle) */
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 800; font-size: 14px; }
.switch input { appearance: none; -webkit-appearance: none; width: 42px; height: 24px; border-radius: 999px; background: var(--line); position: relative; cursor: pointer; transition: background .2s; margin: 0; }
.switch input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: left .2s; }
.switch input:checked { background: var(--grass); }
.switch input:checked::after { left: 21px; }
/* Support Chiga (donation) */
.support { background: linear-gradient(135deg, #FFF4D6, #FFE9E6); }
.paypal-btn { display: inline-flex; align-items: center; gap: 8px; background: #FFC439; color: #003087 !important; font-weight: 800; text-decoration: none; padding: 12px 22px; border-radius: 14px; box-shadow: 0 4px 0 #D9A21E; }
.paypal-btn:hover { filter: brightness(1.05); }
