:root {
  --font: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  --ink: #2a1a4a;
  --gold: #ffd77a;
  --gold2: #ffb547;
  --panel: rgba(28, 22, 70, 0.92);
  --line: rgba(190, 200, 255, 0.25);
}
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: #0b0f2e; color: #fff; font-family: var(--font);
  -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent;
}
canvas#game { position: fixed; inset: 0; display: block; touch-action: none; }
#ui { position: fixed; inset: 0; pointer-events: none; }
#ui > * { pointer-events: auto; }
#loading { position: fixed; inset: 0; display: grid; place-items: center; font: 800 28px var(--font); color: var(--gold); background: #0b0f2e; pointer-events: none; transition: opacity 0.3s; }
#ui:not(:empty) ~ #loading { opacity: 0; }
button { font-family: var(--font); cursor: pointer; touch-action: manipulation; }

/* top bar */
.top { position: absolute; left: 10px; right: 10px; top: 8px; display: flex; justify-content: space-between; align-items: flex-start; pointer-events: none; }
.top > * { pointer-events: auto; }
.top .right { display: flex; gap: 8px; align-items: center; }
.pill { display: flex; align-items: center; gap: 8px; height: 46px; padding: 0 14px 0 6px; border-radius: 23px; background: rgba(255, 255, 255, 0.1); border: 1px solid var(--line); color: #fff; }
.pill.chapter { padding-left: 2px; text-align: left; }
.pill .mini { width: 44px; height: 44px; }
.pill .ctext { display: flex; flex-direction: column; line-height: 1.1; }
.pill .ctext b { font-size: 16px; }
.pill .ctext small { font-size: 12px; opacity: 0.75; white-space: nowrap; }
.pill.coins { padding: 0 14px; font-size: 18px; }
.dust { color: var(--gold); margin-right: 3px; text-shadow: 0 0 8px rgba(255, 210, 120, 0.8); }
.round { width: 46px; height: 46px; border-radius: 50%; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.1); color: #fff; display: grid; place-items: center; padding: 0; }
.round:active { transform: scale(0.94); }
.round.big { position: absolute; flex-direction: column; align-content: center; gap: 0; background: rgba(40, 34, 100, 0.85); box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35); }
.round.big small { font-size: 11px; font-weight: 700; line-height: 1; margin-top: 1px; }
.round.big .vid { font-size: 9px; color: var(--gold); }
.round.hint { color: var(--gold); }
.round.daily { position: relative; color: #ffe7a8; }
.round.daily[hidden] { display: none; }
.round.daily .dot { position: absolute; top: 4px; right: 4px; width: 10px; height: 10px; border-radius: 50%; background: #ff6b8a; box-shadow: 0 0 8px #ff6b8a; display: none; }
.round.daily.fresh .dot { display: block; }
.round.daily.fresh { animation: glow 1.6s ease-in-out infinite; }
.round.hint small { color: #fff; }
.round.dim { opacity: 0.55; }
.jar .jaricon { position: relative; width: 20px; height: 24px; border: 2px solid #bfe3ff; border-top-width: 4px; border-radius: 4px 4px 7px 7px; overflow: hidden; }
.jar .jaricon i { position: absolute; left: 0; right: 0; bottom: 0; background: linear-gradient(#bfe3ff, #7fb8ff); transition: height 0.3s; }
.jar.full { animation: glow 1.2s ease-in-out infinite; border-color: var(--gold); }
@keyframes glow { 50% { box-shadow: 0 0 22px rgba(255, 215, 122, 0.9); } }
.goal { margin: 2px 0 6px; color: var(--gold); font-weight: 700; font-size: 15px; }
.round.nudge { animation: glow 1.1s ease-in-out infinite; }

/* toast and lesson bubble */
.toast { position: absolute; left: 50%; top: 66px; transform: translate(-50%, -10px); padding: 8px 16px; border-radius: 18px; background: var(--panel); border: 1px solid var(--line); font-size: 15px; opacity: 0; transition: opacity 0.2s, transform 0.2s; pointer-events: none !important; white-space: nowrap; }
.toast.on { opacity: 1; transform: translate(-50%, 0); }
.tip { position: absolute; max-width: 300px; padding: 9px 14px; border-radius: 14px; background: #fff; color: var(--ink); font-weight: 700; font-size: 15px; line-height: 1.25; text-align: center; opacity: 0; transition: opacity 0.2s; pointer-events: none !important; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35); }
.tip.on { opacity: 1; animation: bob 1.6s ease-in-out infinite; }
.tip::after { content: ""; position: absolute; left: var(--ax, 50%); width: 0; height: 0; border: 8px solid transparent; transform: translateX(-50%); }
.tip.down::after { top: 100%; border-top-color: #fff; }
.tip.up::after { bottom: 100%; border-bottom-color: #fff; }
@keyframes bob { 50% { transform: translateY(-4px); } }

/* windows */
.back { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(6, 6, 24, 0.55); opacity: 0; transition: opacity 0.25s; }
.back.on { opacity: 1; }
.box { width: min(440px, calc(100vw - 28px)); max-height: calc(100vh - 28px); overflow: auto; box-sizing: border-box; padding: 18px 18px 16px; border-radius: 22px; background: var(--panel); border: 1px solid var(--line); text-align: center; box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5); }
.box h2 { margin: 2px 0 6px; font-size: 24px; color: var(--gold); }
.box .sub { margin: 4px 0 10px; opacity: 0.85; font-size: 15px; }
.box canvas.sky { width: 100%; max-width: 360px; aspect-ratio: 44 / 30; display: block; margin: 0 auto; }
.reward { font-size: 30px; font-weight: 800; margin: 6px 0 12px; }
.row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.btn { min-width: 130px; height: 50px; padding: 0 18px; border: 0; border-radius: 25px; background: linear-gradient(#ffe39e, var(--gold2)); color: var(--ink); font-weight: 800; font-size: 17px; box-shadow: 0 4px 0 #b9741e; }
.btn:active { transform: translateY(2px); box-shadow: 0 2px 0 #b9741e; }
.btn.alt { background: linear-gradient(#cfe9ff, #7fb8ff); box-shadow: 0 4px 0 #3c6fb5; }
.btn .vid { font-size: 13px; }
.btn:disabled { opacity: 0.6; }
.btn.tog { background: rgba(255, 255, 255, 0.12); color: #fff; box-shadow: none; border: 1px solid var(--line); }
.toggles { display: flex; gap: 10px; justify-content: center; margin: 8px 0; }
.how { text-align: left; font-size: 14px; line-height: 1.4; opacity: 0.9; }
.how p { margin: 8px 0; }
.stats { font-size: 13px; opacity: 0.7; }
.map .cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; margin: 8px 0 12px; max-height: 52vh; overflow: auto; padding: 2px; }
.card { display: flex; flex-direction: column; align-items: center; padding: 6px 4px; border-radius: 14px; background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line); }
.card canvas { width: 100%; max-width: 160px; aspect-ratio: 4 / 3; }
.card b { font-size: 14px; }
.card small { font-size: 12px; opacity: 0.7; }
.card.locked { opacity: 0.55; }
