/* Space Chess — Brain Boosters. Mobile-first (390px). */
:root {
  --earth: #22d3ee; --earth-ink: #a5f3fc; --earth-deep: #083344;
  --mars: #fb923c; --mars-ink: #fed7aa; --mars-deep: #431407;
  --gold: #fde047; --pink: #f472b6; --violet: #a78bfa; --lime: #a3e635; --danger: #f43f5e;
}
body.chess-page { overscroll-behavior: none; }
.chess-page .app { padding: calc(8px + var(--safe-t)) 8px calc(24px + var(--safe-b)); max-width: 460px; }
.cz-head { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.cz-head .back-link { margin: 0; padding: 0 12px; border-radius: 14px; background: rgba(255,255,255,.06); border: 1px solid var(--line); color: var(--ink); font-weight: 800; font-size: 15px; white-space: nowrap; }
.cz-title { flex: 1; min-width: 0; text-align: center; font-weight: 900; font-size: 22px; letter-spacing: .02em; margin: 0; line-height: 1.05;
  background: linear-gradient(90deg, var(--earth), var(--violet), var(--mars)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.cz-icon { min-width: 44px; min-height: 44px; border-radius: 14px; background: rgba(255,255,255,.06); border: 1px solid var(--line); font-size: 18px; font-weight: 900; display: grid; place-items: center; }
.cz-icon[aria-pressed="true"] { background: rgba(253,224,71,.18); border-color: rgba(253,224,71,.6); color: var(--gold); }
.cz-icon.abc { font-size: 13px; letter-spacing: .04em; }

.cz-status { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 4px 0; min-height: 40px; }
.turn-pill { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; font-weight: 900; font-size: 16px; border: 2px solid transparent; transition: box-shadow .3s, border-color .3s; }
.turn-pill .dot { width: 14px; height: 14px; border-radius: 50%; }
.turn-pill.w { color: var(--earth-ink); border-color: var(--earth); box-shadow: 0 0 18px rgba(34,211,238,.45); background: rgba(34,211,238,.1); }
.turn-pill.w .dot { background: var(--earth); box-shadow: 0 0 10px var(--earth); }
.turn-pill.b { color: var(--mars-ink); border-color: var(--mars); box-shadow: 0 0 18px rgba(251,146,60,.45); background: rgba(251,146,60,.1); }
.turn-pill.b .dot { background: var(--mars); box-shadow: 0 0 10px var(--mars); }
.turn-pill.thinking .dot { animation: blink .7s ease-in-out infinite; }
@keyframes blink { 50% { opacity: .2; } }
.meta-pill { font-size: 12px; font-weight: 800; color: var(--ink-soft); text-align: right; line-height: 1.2; }
.meta-pill b { color: var(--gold); }

.tray { display: flex; align-items: center; gap: 1px; min-height: 26px; padding: 0 4px; flex-wrap: wrap; }
.tray svg { width: 22px; height: 22px; }
.tray .adv { margin-left: 6px; font-size: 13px; font-weight: 900; color: var(--lime); }
.tray .lab { font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-soft); margin-right: 6px; }

/* ---------- board ---------- */
.board-shell { position: relative; padding: 5px; border-radius: 18px;
  background: linear-gradient(135deg, rgba(34,211,238,.7), rgba(167,139,250,.6) 50%, rgba(251,146,60,.7));
  box-shadow: 0 0 26px rgba(167,139,250,.35), var(--shadow); }
.board-shell.in-check { animation: shellcheck 1s ease-in-out 2; }
@keyframes shellcheck { 50% { box-shadow: 0 0 40px rgba(244,63,94,.85), var(--shadow); } }
.cz-board { position: relative; display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr); aspect-ratio: 1; width: 100%; border-radius: 13px; overflow: hidden;
  background:
    radial-gradient(1px 1px at 12% 18%, #fff 50%, transparent 51%), radial-gradient(1px 1px at 33% 72%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 57% 31%, #c7d2fe 50%, transparent 51%), radial-gradient(1px 1px at 78% 84%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 91% 12%, #a5f3fc 50%, transparent 51%), radial-gradient(1px 1px at 45% 52%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 22% 91%, #fde68a 50%, transparent 51%), radial-gradient(1px 1px at 67% 60%, #fff 50%, transparent 51%),
    radial-gradient(120% 90% at 20% 10%, rgba(99,102,241,.45), transparent 60%), radial-gradient(90% 80% at 90% 100%, rgba(236,72,153,.28), transparent 60%),
    #060b24; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
.sq { position: relative; display: grid; place-items: center; -webkit-tap-highlight-color: transparent; touch-action: manipulation; min-width: 0; min-height: 0; }
.sq.l { background: rgba(147,160,255,.30); box-shadow: inset 0 0 12px rgba(165,243,252,.22); }
.sq.d { background: rgba(10,16,52,.55); }
.sq .coord { position: absolute; font-size: 9px; font-weight: 800; color: rgba(226,232,255,.55); pointer-events: none; line-height: 1; }
.sq .coord.f { right: 2px; bottom: 2px; } .sq .coord.r { left: 2px; top: 2px; }
.sq.last { background-image: linear-gradient(rgba(253,224,71,.26), rgba(253,224,71,.26)); }
.sq.sel { background-image: linear-gradient(rgba(34,211,238,.45), rgba(34,211,238,.45)); box-shadow: inset 0 0 0 3px var(--gold), inset 0 0 18px rgba(253,224,71,.6); }
.sq.check { background-image: radial-gradient(circle, rgba(244,63,94,.95) 0%, rgba(244,63,94,.5) 45%, transparent 75%); animation: checkpulse 1s ease-in-out infinite; }
@keyframes checkpulse { 50% { box-shadow: inset 0 0 22px rgba(255,255,255,.55); } }
.sq.danger::before { content: ""; position: absolute; inset: 2px; border-radius: 8px; border: 2px dashed rgba(244,63,94,.9); animation: blink 1.2s ease-in-out infinite; pointer-events: none; }
.sq.helper::before { content: ""; position: absolute; inset: 2px; border-radius: 8px; box-shadow: 0 0 0 2px var(--lime), 0 0 14px rgba(163,230,53,.7); pointer-events: none; }
.sq.hint-from, .sq.hint-to { box-shadow: inset 0 0 0 3px var(--gold), inset 0 0 22px rgba(253,224,71,.8); animation: hintpulse 1s ease-in-out infinite; }
@keyframes hintpulse { 50% { box-shadow: inset 0 0 0 3px #fff, inset 0 0 26px rgba(253,224,71,1); } }
.sq .dot { position: absolute; width: 30%; height: 30%; border-radius: 50%; background: radial-gradient(circle, #fef9c3, var(--gold) 60%); box-shadow: 0 0 10px rgba(253,224,71,.9); pointer-events: none; animation: dotin .25s ease-out both; }
.sq .dot.risky { background: radial-gradient(circle, #fecdd3, var(--danger) 60%); box-shadow: 0 0 10px rgba(244,63,94,.9); }
.sq .ring { position: absolute; inset: 6%; border-radius: 50%; border: 4px solid var(--gold); box-shadow: 0 0 12px rgba(253,224,71,.9), inset 0 0 10px rgba(253,224,71,.6); pointer-events: none; animation: dotin .25s ease-out both; }
.sq .peek { position: absolute; width: 26%; height: 26%; border-radius: 50%; border: 3px solid var(--danger); pointer-events: none; }
.sq .xmark { position: absolute; font-size: 22px; font-weight: 900; color: var(--danger); text-shadow: 0 0 8px rgba(244,63,94,.9); pointer-events: none; }
@keyframes dotin { from { transform: scale(0); } }
.pc { width: 88%; height: 88%; position: relative; z-index: 2; pointer-events: none; overflow: visible; transition: transform .22s ease; }
.pc.w { --pf: url(#gEarth); --ps: #0b3b4a; --pa: #22d3ee; --pw: #06283a; filter: drop-shadow(0 0 4px rgba(34,211,238,.75)); }
.pc.b { --pf: url(#gMars); --ps: #4a1505; --pa: #fde047; --pw: #3a0d04; filter: drop-shadow(0 0 4px rgba(251,146,60,.8)); }
.sq.sel .pc { transform: scale(1.1) translateY(-4%); }
.sq .badge { position: absolute; right: 1px; top: 1px; z-index: 3; min-width: 15px; height: 15px; padding: 0 2px; border-radius: 5px; font-size: 11px; line-height: 15px; font-weight: 900; text-align: center; pointer-events: none; background: #0b1638; border: 1px solid; }
.sq .badge.w { color: var(--earth-ink); border-color: var(--earth); } .sq .badge.b { color: var(--mars-ink); border-color: var(--mars); }
.sq.shake { animation: shake .35s ease; }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

.check-banner { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%) scale(.6); z-index: 6; font-weight: 900; font-size: 34px; letter-spacing: .08em; color: #fff; padding: 6px 18px; border-radius: 16px;
  background: rgba(244,63,94,.85); box-shadow: 0 0 40px rgba(244,63,94,.9); opacity: 0; pointer-events: none; }
.check-banner.on { animation: banner 1.3s ease forwards; }
@keyframes banner { 15% { opacity: 1; transform: translate(-50%, -50%) scale(1.08); } 70% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 100% { opacity: 0; transform: translate(-50%, -50%) scale(.9); } }

/* ---------- coach ---------- */
.coach { display: grid; grid-template-columns: 40px 1fr; gap: 8px; align-items: start; margin: 8px 0 6px; padding: 9px 10px; border-radius: 16px; background: var(--bg-elev); border: 1px solid var(--line); min-height: 64px; }
.coach .bot { width: 40px; height: 40px; }
.coach .msg { font-size: 15px; line-height: 1.35; }
.coach .msg b { color: var(--gold); }
.coach .msg .why { display: block; color: var(--ink-soft); font-size: 13px; margin-top: 3px; }
.coach.warn { border-color: rgba(244,63,94,.7); box-shadow: 0 0 18px rgba(244,63,94,.3); }
.coach.tip { border-color: rgba(163,230,53,.55); }
.coach.good { border-color: rgba(253,224,71,.6); }
.coach .choices { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.coach .choices button { min-height: 40px; padding: 0 12px; border-radius: 12px; font-weight: 800; font-size: 14px; background: rgba(255,255,255,.08); border: 1px solid var(--line); }
.coach .choices button.go { background: linear-gradient(135deg, var(--gold), var(--pink)); color: #1a0b2e; border: 0; }

.controls { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 4px; }
.controls button { min-height: 52px; border-radius: 16px; background: rgba(255,255,255,.06); border: 1px solid var(--line); font-weight: 800; font-size: 13px; display: grid; place-items: center; line-height: 1.1; padding: 4px 2px; }
.controls button .i { font-size: 19px; display: block; }
.controls button:disabled { opacity: .35; }
.controls button:active:not(:disabled) { transform: scale(.96); }
.history { margin-top: 10px; border-radius: 16px; background: var(--bg-elev); border: 1px solid var(--line); padding: 0 12px; }
.history summary { min-height: 44px; display: flex; align-items: center; font-weight: 800; cursor: pointer; list-style: none; }
.history summary::-webkit-details-marker { display: none; }
.history ol { margin: 0 0 8px; padding-left: 28px; columns: 2; font-size: 14px; font-variant-numeric: tabular-nums; }
.history li span { display: inline-block; min-width: 54px; }
.history li .w { color: var(--earth-ink); } .history li .b { color: var(--mars-ink); }
.history .legend { font-size: 12px; color: var(--ink-soft); margin: 0 0 10px; }

/* ---------- overlays ---------- */
.sheet { position: fixed; inset: 0; z-index: 40; background: rgba(4,8,26,.86); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: calc(12px + var(--safe-t)) 12px calc(24px + var(--safe-b)); }
.sheet-inner { max-width: 440px; margin: 0 auto; }
.sheet h2 { margin: 6px 0 4px; font-size: 26px; font-weight: 900; background: linear-gradient(90deg, var(--earth), var(--violet), var(--mars)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.sheet .sub { color: var(--ink-soft); margin: 0 0 12px; font-size: 15px; }
.opt-label { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-soft); font-weight: 800; margin: 12px 2px 6px; }
.opt-grid { display: grid; gap: 8px; grid-template-columns: repeat(var(--n, 2), 1fr); }
.opt { min-height: 56px; border-radius: 16px; background: var(--bg-elev); border: 2px solid var(--line); font-weight: 800; font-size: 15px; padding: 8px 6px; line-height: 1.15; text-align: center; }
.opt small { display: block; font-weight: 600; font-size: 12px; color: var(--ink-soft); margin-top: 3px; }
.opt[aria-pressed="true"] { border-color: var(--gold); background: linear-gradient(135deg, rgba(253,224,71,.16), rgba(167,139,250,.16)); box-shadow: 0 0 16px rgba(253,224,71,.3); }
.opt.earth[aria-pressed="true"] { border-color: var(--earth); box-shadow: 0 0 16px rgba(34,211,238,.4); }
.opt.mars[aria-pressed="true"] { border-color: var(--mars); box-shadow: 0 0 16px rgba(251,146,60,.4); }
.launch { width: 100%; min-height: 64px; border-radius: 20px; margin-top: 16px; font-size: 22px; font-weight: 900; color: #1a0b2e;
  background: linear-gradient(135deg, var(--earth), var(--violet) 50%, var(--mars)); box-shadow: 0 10px 30px rgba(167,139,250,.45); }
.launch:active { transform: scale(.98); }
.ghost-btn { width: 100%; min-height: 52px; border-radius: 16px; margin-top: 10px; font-weight: 800; font-size: 16px; background: rgba(255,255,255,.06); border: 1px solid var(--line); }
.resume { width: 100%; min-height: 60px; border-radius: 18px; font-weight: 900; font-size: 18px; color: #052e16; background: linear-gradient(135deg, var(--lime), var(--earth)); margin-bottom: 4px; }

.promo-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 12px; }
.promo-grid button { aspect-ratio: 1; border-radius: 16px; background: var(--bg-elev); border: 2px solid var(--line); display: grid; place-items: center; padding: 4px; font-size: 11px; font-weight: 800; }
.promo-grid button svg { width: 70%; height: 70%; }
.promo-grid button:first-child { border-color: var(--gold); }

.result-card { text-align: center; margin-top: 18vh; padding: 22px 16px; border-radius: 26px; background: var(--bg-elev); border: 2px solid var(--gold); box-shadow: 0 0 40px rgba(253,224,71,.35); }
.result-card .big { font-size: 34px; font-weight: 900; margin: 4px 0; }
.result-card p { color: var(--ink-soft); margin: 6px 0 14px; }

/* academy */
.lesson-list { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.lesson-card { display: grid; grid-template-columns: 40px 1fr; gap: 8px; align-items: center; text-align: left; min-height: 64px; padding: 8px; border-radius: 16px; background: var(--bg-elev); border: 1px solid var(--line); font-weight: 800; font-size: 14px; line-height: 1.15; }
.lesson-card svg { width: 40px; height: 40px; }
.lesson-card .em { font-size: 28px; text-align: center; }
.lesson-card small { display: block; font-weight: 600; color: var(--ink-soft); font-size: 11px; }
.lesson-card.done { border-color: rgba(163,230,53,.6); }
.lesson-card.done small::after { content: " ✓ done"; color: var(--lime); font-weight: 800; }
.lesson-head { display: flex; align-items: center; gap: 8px; }
.lesson-head h2 { flex: 1; margin: 0; }
.lesson-board { max-width: 340px; margin: 10px auto; }
.lesson-text { font-size: 16px; line-height: 1.45; }
.lesson-text p { margin: 6px 0; }
.lesson-text b { color: var(--gold); }
.lesson-say { min-height: 46px; margin: 6px 0; padding: 8px 12px; border-radius: 14px; background: rgba(253,224,71,.1); border: 1px solid rgba(253,224,71,.4); color: #fef9c3; font-weight: 700; }
.lesson-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.lesson-btns button { min-height: 50px; border-radius: 14px; font-weight: 800; background: rgba(255,255,255,.07); border: 1px solid var(--line); }
.lesson-btns button.go { background: linear-gradient(135deg, var(--gold), var(--pink)); color: #1a0b2e; border: 0; }
.values-row { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; text-align: center; margin: 10px 0; }
.values-row svg { width: 100%; height: auto; aspect-ratio: 1; }
.values-row b { display: block; font-size: 18px; color: var(--gold); }
.values-row small { display: block; font-size: 10px; color: var(--ink-soft); }
.rule-list { display: grid; gap: 8px; margin: 10px 0; padding: 0; list-style: none; }
.rule-list li { padding: 10px 12px; border-radius: 14px; background: var(--bg-elev); border-left: 4px solid var(--lime); }
.rule-list li b { color: var(--lime); }

#fx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 60; }
@media (prefers-reduced-motion: reduce) { .sq.check, .sq.danger::before, .sq.hint-from, .sq.hint-to, .board-shell.in-check { animation: none !important; } }
@media (min-height: 900px) { .controls button { min-height: 56px; } }

/* Sprocket's deadpan commentary */
.coach .msg .wit, .wit { display:block; font-style:italic; font-size:13px; color:#c4b5fd; margin-top:4px; line-height:1.35; }
#result-wit { margin-top:8px; }
