@font-face { font-family: Fredoka; font-weight: 500; font-display: swap; src: url(fonts/fredoka-latin-500-normal.woff2) format('woff2'); }
@font-face { font-family: Fredoka; font-weight: 600; font-display: swap; src: url(fonts/fredoka-latin-600-normal.woff2) format('woff2'); }
@font-face { font-family: Fredoka; font-weight: 700; font-display: swap; src: url(fonts/fredoka-latin-700-normal.woff2) format('woff2'); }
@font-face { font-family: Nunito; font-weight: 600; font-display: swap; src: url(fonts/nunito-latin-600-normal.woff2) format('woff2'); }
@font-face { font-family: Nunito; font-weight: 700; font-display: swap; src: url(fonts/nunito-latin-700-normal.woff2) format('woff2'); }
@font-face { font-family: Nunito; font-weight: 800; font-display: swap; src: url(fonts/nunito-latin-800-normal.woff2) format('woff2'); }

:root {
  color-scheme: dark;
  --bg: #151530;
  --bg2: #1f1f45;
  --card: #2a2a5a;
  --card2: #34346c;
  --line: #45458a;
  --ink: #f4f3ff;
  --muted: #b9b7e6;
  --coral: #ff6b6b;
  --teal: #22d3b6;
  --yellow: #ffd23f;
  --violet: #9b7bff;
  --blue: #4c9dff;
  --pink: #ff7ac6;
  --good: #2bd67b;
  --bad: #ff5d73;
  --radius: 18px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: radial-gradient(1200px 600px at 10% -10%, #2b2470 0%, transparent 60%), radial-gradient(900px 500px at 110% 10%, #12456b 0%, transparent 55%), var(--bg);
  background-attachment: fixed;
  color: var(--ink);
  font: 600 17px/1.45 Nunito, system-ui, sans-serif;
  min-height: 100vh;
}
h1, h2, h3, .display { font-family: Fredoka, Nunito, system-ui, sans-serif; font-weight: 600; letter-spacing: .2px; margin: 0; }
h1 { font-size: 34px; }
h2 { font-size: 24px; }
h3 { font-size: 19px; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--teal); }
.wrap { max-width: 880px; margin: 0 auto; padding-block: 16px 48px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.small { font-size: 14px; color: var(--muted); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.hidden { display: none !important; }

/* chunky buttons */
.btn {
  border: 0; border-radius: 14px; padding: 12px 20px; min-height: 48px;
  background: var(--card2); box-shadow: 0 4px 0 #1a1a3d; font-family: Fredoka, Nunito, sans-serif; font-weight: 600; font-size: 18px;
  transition: transform .06s, box-shadow .06s, filter .15s; display: inline-flex; align-items: center; gap: 8px; justify-content: center;
}
.btn:hover { filter: brightness(1.1); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #1a1a3d; }
.btn:focus-visible, .tile:focus-visible, .chip:focus-visible { outline: 3px solid var(--yellow); outline-offset: 3px; }
.btn.primary { background: var(--teal); color: #08261f; box-shadow: 0 4px 0 #11806d; }
.btn.coral { background: var(--coral); color: #2b0909; box-shadow: 0 4px 0 #a83a3a; }
.btn.yellow { background: var(--yellow); color: #2d2300; box-shadow: 0 4px 0 #a88613; }
.btn.ghost { background: transparent; box-shadow: none; border: 2px solid var(--line); }
.btn.small { min-height: 38px; padding: 6px 12px; font-size: 15px; border-radius: 11px; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.icon { width: 22px; height: 22px; flex: none; }
.btn.small .icon { width: 18px; height: 18px; }

/* top bar */
.topbar { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.page-title { margin: 0 0 14px; font-size: 26px; line-height: 1.2; }
@media (max-width: 560px) { .topbar .brand h1 { font-size: 24px; } .xpbar { width: 50px; } .stat { padding: 4px 9px; font-size: 14px; } }
.brand { display: flex; align-items: center; gap: 10px; }
.logo { width: 44px; height: 44px; border-radius: 13px; background: linear-gradient(135deg, var(--coral), var(--violet)); display: grid; place-items: center; font: 700 22px Fredoka, sans-serif; box-shadow: 0 4px 0 #3a2a7a; }
.stat { background: var(--bg2); border: 2px solid var(--line); border-radius: 999px; padding: 5px 12px; display: inline-flex; gap: 6px; align-items: center; font-weight: 800; font-size: 15px; }
.stat .icon { width: 18px; height: 18px; }
.xpbar { height: 8px; width: 90px; background: #0e0e24; border-radius: 99px; overflow: hidden; }
.xpbar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--yellow), var(--coral)); }

/* cards and grids */
.panel { background: var(--bg2); border: 2px solid var(--line); border-radius: var(--radius); padding: 18px; }
.month { display: none; }
.month:first-of-type { margin-top: 4px; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.tile {
  text-align: left; border: 0; border-radius: var(--radius); padding: 16px; background: var(--card);
  box-shadow: 0 5px 0 #17173a; display: flex; flex-direction: column; gap: 8px; min-height: 120px; position: relative;
  transition: transform .08s;
}
.tile:hover { transform: translateY(-2px); }
.tile:active { transform: translateY(3px); box-shadow: 0 2px 0 #17173a; }
.tile .num { font: 700 13px Nunito, sans-serif; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.tile .ttl { font: 600 19px/1.2 Fredoka, sans-serif; }
.tile .meta { margin-top: auto; display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); }
.stars { display: inline-flex; gap: 2px; }
.stars .icon { width: 18px; height: 18px; }
.meter { height: 7px; background: #0e0e24; border-radius: 99px; overflow: hidden; flex: 1; }
.meter > i { display: block; height: 100%; background: var(--teal); }
.game-tile { min-height: 150px; }
.game-tile .badge { width: 52px; height: 52px; border-radius: 15px; display: grid; place-items: center; }
.game-tile .badge .icon { width: 30px; height: 30px; }
.game-tile p { margin: 0; color: var(--muted); font-size: 15px; }
.g-learn .badge { background: var(--blue); }
.g-match .badge { background: var(--pink); }
.g-streak .badge { background: var(--coral); }
.g-gap .badge { background: var(--violet); }
.g-spell .badge { background: var(--teal); }
.g-boss { background: linear-gradient(135deg, #3d2d84, #6a2a6d); }
.g-boss .badge { background: var(--yellow); color: #2d2300; }
.done-dot { position: absolute; top: 12px; right: 12px; background: var(--good); color: #062; border-radius: 99px; padding: 2px 9px; font-size: 12px; font-weight: 800; }

/* game area */
.gamebar { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.progress { flex: 1; height: 14px; background: #0e0e24; border-radius: 99px; overflow: hidden; }
.progress > i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--teal), var(--blue)); transition: width .3s; }
.prompt-card { background: var(--card); border-radius: 22px; padding: 22px; box-shadow: 0 6px 0 #17173a; margin-bottom: 16px; }
.prompt-label { font: 800 13px Nunito, sans-serif; text-transform: uppercase; letter-spacing: 1.2px; color: var(--muted); margin-bottom: 6px; }
.prompt-text { font-size: 21px; line-height: 1.4; }
.big-word { font: 600 40px/1.1 Fredoka, sans-serif; word-break: break-word; }
.pos { display: inline-block; background: var(--bg2); border-radius: 99px; padding: 2px 10px; font-size: 14px; color: var(--muted); }
.choices { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
@media (max-width: 560px) { .choices { grid-template-columns: 1fr; } h1 { font-size: 28px; } .big-word { font-size: 32px; } }
.choice {
  border: 0; border-radius: 16px; padding: 14px 16px; min-height: 64px; text-align: left; background: var(--card2);
  box-shadow: 0 4px 0 #1a1a3d; font-size: 18px; font-weight: 700; transition: transform .06s;
}
.choice:active { transform: translateY(3px); box-shadow: 0 1px 0 #1a1a3d; }
.choice.def { font-size: 16px; font-weight: 600; }
.choice.right { background: var(--good); color: #032b14; box-shadow: 0 4px 0 #128a49; }
.choice.wrong { background: var(--bad); color: #2b0510; box-shadow: 0 4px 0 #a32a3c; animation: shake .35s; }
.choice.gone { opacity: .2; pointer-events: none; }
.choice[disabled] { cursor: default; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
@keyframes pop { 0% { transform: scale(.6); opacity: 0; } 70% { transform: scale(1.08); } 100% { transform: scale(1); opacity: 1; } }
.pop { animation: pop .35s ease-out; }
.feedback { min-height: 30px; margin: 14px 0 0; font-weight: 800; font-size: 18px; }
.feedback.good { color: var(--good); }
.feedback.bad { color: var(--bad); }
.blank { display: inline-block; min-width: 90px; border-bottom: 3px solid var(--yellow); color: var(--yellow); text-align: center; }
.tools { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

/* flashcards */
.flip { perspective: 1200px; cursor: pointer; margin-bottom: 16px; }
.flip-inner { position: relative; display: grid; min-height: 290px; transition: transform .45s; transform-style: preserve-3d; }
.flip.on .flip-inner { transform: rotateY(180deg); }
.face { grid-area: 1 / 1; position: relative; backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: 24px; padding: 24px; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; gap: 12px; box-shadow: 0 6px 0 #17173a; }
.face.front { background: linear-gradient(135deg, #3b3b85, #2a2a5a); }
.face.back { background: #f7f5ff; color: #1d1b3f; transform: rotateY(180deg); font-size: 18px; }
.face.back .ex { color: #4a4780; font-style: italic; }
.face.back b { color: #6b3fe0; }
.face .tap { font-size: 14px; color: var(--muted); }

/* match */
.match { display: grid; grid-template-columns: 1fr 1.6fr; gap: 12px; }
.match .col { display: flex; flex-direction: column; gap: 10px; }
.mcard { border: 0; border-radius: 14px; padding: 12px 14px; background: var(--card2); box-shadow: 0 4px 0 #1a1a3d; text-align: left; font-weight: 700; min-height: 56px; }
.mcard.def { font-weight: 600; font-size: 15px; }
.mcard.sel { outline: 3px solid var(--yellow); }
.mcard.right { background: var(--good); color: #032b14; animation: pop .3s; opacity: .55; pointer-events: none; }
.mcard.wrong { background: var(--bad); color: #2b0510; animation: shake .35s; }
@media (max-width: 560px) { .match { grid-template-columns: 1fr 1.4fr; gap: 8px; } .mcard { padding: 10px; font-size: 15px; } .mcard.def { font-size: 13px; } }

/* spell */
.slots { display: flex; flex-wrap: wrap; gap: 6px 18px; justify-content: center; margin: 8px 0 18px; }
.slots .wordgrp { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.slot { width: 40px; height: 50px; border-radius: 10px; background: #0e0e24; border: 2px solid var(--line); display: grid; place-items: center; font: 600 24px Fredoka, sans-serif; text-transform: lowercase; }
.slot.filled { background: var(--card2); border-color: var(--teal); cursor: pointer; }
.slot.hinted { border-color: var(--yellow); color: var(--yellow); }
.slot.next { border-color: var(--yellow); }
.letters { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.letter { width: 48px; height: 54px; border: 0; border-radius: 12px; background: var(--violet); color: #fff; font: 600 24px Fredoka, sans-serif; box-shadow: 0 4px 0 #5a3fb8; text-transform: lowercase; }
.letter:active { transform: translateY(3px); box-shadow: 0 1px 0 #5a3fb8; }
.letter.used { visibility: hidden; }
@media (max-width: 560px) { .slot { width: 30px; height: 40px; font-size: 19px; } .letter { width: 42px; height: 48px; } }

/* results */
.result { text-align: center; padding: 26px 18px; }
.result .big { font: 700 64px Fredoka, sans-serif; line-height: 1; }
.result .stars .icon { width: 46px; height: 46px; }
.result .stars { gap: 8px; margin: 10px 0; }
.result .row { justify-content: center; margin-top: 20px; }
.xp-gain { color: var(--yellow); font: 600 24px Fredoka, sans-serif; }

/* word list */
.wl { display: grid; gap: 10px; }
.wl .w { background: var(--card); border-radius: 14px; padding: 12px 14px; }
.wl .w h3 { display: inline; margin-right: 8px; }
.wl .w p { margin: 6px 0 0; }
.wl .w .ex { color: var(--muted); font-style: italic; }
.mastered { color: var(--good); font-size: 13px; font-weight: 800; }

/* overlays (also used by engage.js) */
.overlay { position: fixed; inset: 0; background: rgba(8, 8, 25, .75); display: grid; place-items: center; z-index: 50; padding: 16px; }
.overlay .card { background: var(--bg2); border: 2px solid var(--line); border-radius: 20px; padding: 22px; max-width: 420px; width: 100%; }
.overlay input, select { font: inherit; padding: 10px 12px; border-radius: 12px; border: 2px solid var(--line); background: #0e0e24; color: var(--ink); }
.overlay button { border: 0; border-radius: 12px; padding: 10px 18px; background: var(--teal); color: #08261f; font-weight: 800; }
select { width: 100%; }
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 60; width: 100%; height: 100%; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--yellow); color: #2d2300; padding: 10px 18px; border-radius: 99px; font: 600 17px Fredoka, sans-serif; z-index: 70; box-shadow: 0 4px 0 #a88613; animation: pop .3s; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

.wrap:has(> .month) { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.wrap:has(> .month) > :not(.grid) { grid-column: 1 / -1; }
.wrap:has(> .month) > .grid { display: contents; }

.tile.locked { opacity: .45; }
.tile.locked .ttl::before { content: "\1F512  "; }
