/* Khel ON Checkers */
:root {
  --navy: #141721;
  --navy2: #1d2131;
  --navy3: #272c40;
  --ink: #f4f2fb;
  --muted: #a9aec4;
  --orange: #ff9a3c;
  --pink: #f04fa8;
  --purple: #8b5cf6;
  --teal: #2fd4c8;
  --grad: linear-gradient(100deg, #ff9a3c 0%, #f04fa8 52%, #8b5cf6 100%);
  --light-sq: #ece6f7;
  --dark-sq: #3d3768;
  --radius: 18px;
  --head: 'Outfit', 'Lilita One', system-ui, sans-serif;
  --body: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--navy); color: var(--ink); }
body { font-family: var(--body); font-size: 16px; line-height: 1.45; -webkit-tap-highlight-color: transparent; overflow-x: hidden; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

#app { max-width: 620px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; padding: 0 16px calc(16px + env(safe-area-inset-bottom)); }

/* Top bar */
.topbar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; padding: calc(10px + env(safe-area-inset-top)) 0 8px; }
.home-link { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); text-decoration: none; font-weight: 800; font-size: 15px; justify-self: start; padding: 8px 6px 8px 0; min-height: 44px; }
.home-link svg { width: 20px; height: 20px; }
.home-link:hover, .home-link:focus-visible { color: var(--ink); }
.title { margin: 0; font-family: var(--head); font-weight: 800; font-size: 24px; letter-spacing: .3px; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.icon-btn { justify-self: end; width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--navy2); color: var(--ink); display: grid; place-items: center; cursor: pointer; }
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn .snd-off { display: none; }
.icon-btn[aria-pressed="false"] .snd-on { display: none; }
.icon-btn[aria-pressed="false"] .snd-off { display: block; color: var(--muted); }

.screen { display: none; flex: 1; flex-direction: column; gap: 14px; }
.screen.active { display: flex; }

/* Menu */
.hero { text-align: center; padding: 6px 0 2px; }
.hero-board { width: 132px; height: 132px; margin: 6px auto 10px; border-radius: 16px; position: relative; overflow: hidden;
  background: conic-gradient(var(--dark-sq) 0 25%, var(--light-sq) 0 50%, var(--dark-sq) 0 75%, var(--light-sq) 0) 0 0 / 66px 66px;
  box-shadow: 0 10px 30px rgba(139, 92, 246, .35); transform: rotate(-6deg); }
.hp { position: absolute; width: 50px; height: 50px; border-radius: 50%; }
.hp.a { background: radial-gradient(circle at 35% 30%, #ffc27f, var(--orange) 55%, #d9661b); }
.hp.b { background: radial-gradient(circle at 35% 30%, #a6fff6, var(--teal) 55%, #149a92); }
.hero-board .hp:nth-child(1) { left: 8px; top: 74px; }
.hero-board .hp:nth-child(2) { left: 74px; top: 8px; }
.hero-board .hp:nth-child(3) { left: 74px; top: 74px; }
.hero-board .hp:nth-child(4) { left: 8px; top: 8px; opacity: 0; }
.hp .crown { position: absolute; inset: 12px; width: 26px; height: 26px; }
.tagline { margin: 0 0 4px; font-family: var(--head); font-size: 20px; font-weight: 700; }
.stars-total { color: var(--muted); font-weight: 700; }
.stars-total b { color: var(--ink); }
.star-ico { color: #ffd257; }
.link-btn { background: none; border: 0; padding: 6px 2px; color: var(--teal); font-weight: 800; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.link-btn b { color: var(--teal); }

.card { background: var(--navy2); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.card.slim { padding: 10px 16px; }
.card h2 { margin: 0; font-family: var(--head); font-size: 20px; }
.card h3 { margin: 0 0 6px; font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; font-weight: 800; }
.mode-note { margin: -4px 0 0; color: var(--muted); font-size: 14px; min-height: 1.4em; }

.seg { display: flex; gap: 6px; background: var(--navy); border-radius: 14px; padding: 4px; }
.seg button { flex: 1; min-height: 46px; border: 0; border-radius: 11px; background: transparent; color: var(--muted); font-weight: 800; cursor: pointer; padding: 6px 4px; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.15; }
.seg button small { font-weight: 700; font-size: 11px; opacity: .85; }
.seg button[aria-checked="true"] { background: var(--navy3); color: var(--ink); box-shadow: inset 0 0 0 2px var(--teal); }
#colourSeg button { flex-direction: row; gap: 6px; flex-wrap: wrap; }
#colourSeg button small { flex-basis: 100%; text-align: center; }
.lvstars { color: #ffd257; letter-spacing: 1px; min-height: 13px; }

.dot { display: inline-block; width: 16px; height: 16px; border-radius: 50%; flex: none; }
.dot.a { background: var(--orange); }
.dot.b { background: var(--teal); }

.toggles { gap: 4px; display: flex; flex-direction: column; }
.tog { display: flex; align-items: center; gap: 12px; min-height: 44px; cursor: pointer; font-weight: 700; }
.tog small { color: var(--muted); font-weight: 600; }
.tog input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.tog .sw { width: 46px; height: 28px; border-radius: 14px; background: var(--navy3); position: relative; flex: none; transition: background .2s; }
.tog .sw::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .2s; }
.tog input:checked + .sw { background: var(--teal); }
.tog input:checked + .sw::after { transform: translateX(18px); }
.tog input:focus-visible + .sw { outline: 3px solid var(--orange); outline-offset: 2px; }

.btn { border: 0; border-radius: 14px; min-height: 48px; padding: 10px 18px; font-weight: 800; font-size: 17px; cursor: pointer; width: 100%; }
.btn.big { min-height: 56px; font-size: 20px; font-family: var(--head); }
.btn.grad { background: var(--grad); color: #fff; box-shadow: 0 6px 20px rgba(240, 79, 168, .35); }
.btn.ghost { background: var(--navy3); color: var(--ink); }
.btn:active { transform: translateY(1px); }
.fine { text-align: center; color: var(--muted); font-size: 13px; margin: 2px 0 8px; }

/* Game */
#game { gap: 8px; }
.strip { display: flex; justify-content: space-between; align-items: center; min-height: 40px; padding: 4px 12px; border-radius: 12px; background: var(--navy2); transition: box-shadow .2s; }
.strip.turn { box-shadow: inset 0 0 0 2px var(--teal); }
.strip .who { display: flex; align-items: center; gap: 8px; font-weight: 800; min-width: 0; }
.strip .who b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.strip .left { display: flex; gap: 2px; flex-wrap: nowrap; justify-content: flex-end; flex: none; }
.strip .left i { width: 8px; height: 8px; border-radius: 50%; display: block; flex: none; }
.strip .left i.k { box-shadow: 0 0 0 2px #ffd257; }

.board-wrap { position: relative; width: 100%; max-width: min(100%, calc(100dvh - 300px), 560px); min-width: 280px; margin: 0 auto; align-self: center; }
@supports not (height: 100dvh) { .board-wrap { max-width: min(100%, calc(100vh - 300px), 560px); } }
.board { position: relative; width: 100%; aspect-ratio: 1; border-radius: 12px; overflow: hidden; touch-action: manipulation; user-select: none; -webkit-user-select: none;
  box-shadow: 0 0 0 4px var(--navy3), 0 14px 40px rgba(0, 0, 0, .45); }
.sq { position: absolute; width: 12.5%; height: 12.5%; }
.sq.l { background: var(--light-sq); }
.sq.d { background: var(--dark-sq); cursor: pointer; }
.sq.last { background: #5a4f93; }
.sq .num { position: absolute; left: 3px; top: 1px; font-size: 9px; color: rgba(255, 255, 255, .28); font-weight: 700; pointer-events: none; }
.sq.dest::after { content: ''; position: absolute; inset: 32%; border-radius: 50%; background: var(--teal); opacity: .85; animation: pulse 1.1s ease-in-out infinite; }
.sq.dest.cap::after { background: var(--orange); inset: 28%; }
.sq.hint { box-shadow: inset 0 0 0 4px #ffd257; }
@keyframes pulse { 50% { transform: scale(.75); opacity: .55; } }

.pc { position: absolute; width: 12.5%; height: 12.5%; display: grid; place-items: center; pointer-events: none; transition: left .2s ease-in-out, top .2s ease-in-out, opacity .25s, transform .25s; z-index: 2; }
.pc .disc { width: 80%; height: 80%; border-radius: 50%; position: relative; box-shadow: 0 4px 0 rgba(0, 0, 0, .35), 0 6px 10px rgba(0, 0, 0, .3); }
.pc .disc::before { content: ''; position: absolute; inset: 16%; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .45); }
.pc.a .disc { background: radial-gradient(circle at 35% 30%, #ffc27f, var(--orange) 55%, #d9661b); }
.pc.b .disc { background: radial-gradient(circle at 35% 30%, #a6fff6, var(--teal) 55%, #149a92); }
.pc .crown { position: absolute; inset: 24%; width: 52%; height: 52%; display: none; }
.pc.k .crown { display: block; }
.pc.sel .disc { transform: translateY(-4px) scale(1.06); box-shadow: 0 0 0 3px #fff, 0 10px 16px rgba(0, 0, 0, .4); }
.pc.must .disc { animation: glow 1s ease-in-out infinite; }
@keyframes glow { 50% { box-shadow: 0 0 0 4px #ffd257, 0 4px 0 rgba(0, 0, 0, .35); } }
.pc.threat .disc { box-shadow: 0 0 0 3px #ff4d6d, 0 4px 0 rgba(0, 0, 0, .35); }
.pc.gone { opacity: 0; transform: scale(.4); }
.pc.moving { z-index: 5; }
.pc.crowned .disc { animation: crown .6s ease-out; }
@keyframes crown { 40% { transform: scale(1.25) rotate(-8deg); } }

.thinking { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); background: rgba(20, 23, 33, .82); border-radius: 20px; padding: 10px 16px; display: flex; gap: 6px; z-index: 9; pointer-events: none; }
.thinking span { width: 9px; height: 9px; border-radius: 50%; background: var(--teal); animation: bob 1s infinite; }
.thinking span:nth-child(2) { animation-delay: .15s; }
.thinking span:nth-child(3) { animation-delay: .3s; }
@keyframes bob { 50% { transform: translateY(-6px); opacity: .5; } }

.coach { display: flex; gap: 10px; align-items: flex-start; background: var(--navy2); border-radius: 14px; padding: 10px 12px; min-height: 58px; }
.coach p { margin: 0; font-weight: 700; font-size: 15px; }
.coach-face { width: 34px; height: 34px; flex: none; border-radius: 50%; background: var(--grad); position: relative; }
.coach-face::before, .coach-face::after { content: ''; position: absolute; top: 12px; width: 5px; height: 6px; border-radius: 3px; background: #fff; }
.coach-face::before { left: 10px; }
.coach-face::after { right: 10px; }
.coach.flash { animation: flash .6s; }
@keyframes flash { 30% { box-shadow: 0 0 0 3px #ffd257; } }

.controls { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.ctl { min-height: 56px; border: 0; border-radius: 14px; background: var(--navy2); color: var(--ink); font-weight: 800; font-size: 13px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; cursor: pointer; }
.ctl svg { width: 22px; height: 22px; }
.ctl:disabled { opacity: .4; cursor: default; }

/* How / badges */
.prose p, .prose li { margin: 0; }
.prose ol { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 8px; }
.prose .small { font-size: 14px; color: var(--muted); }
.badge-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.badge-list li { background: var(--navy); border-radius: 14px; padding: 12px 10px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.badge-list li b { font-size: 14px; }
.badge-list li span { font-size: 12px; color: var(--muted); }
.badge-list li.locked { opacity: .45; }
.badge-list .bico, .res-badges .bico { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; font-size: 22px; background: var(--grad); color: #fff; }
.badge-list li.locked .bico { background: var(--navy3); }

/* Result */
.modal { position: fixed; inset: 0; background: rgba(8, 9, 14, .7); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal-card { background: var(--navy2); border-radius: 22px; padding: 22px 18px 16px; width: 100%; max-width: 380px; text-align: center; display: flex; flex-direction: column; gap: 10px; animation: pop .35s ease-out; }
@keyframes pop { from { transform: scale(.85); opacity: 0; } }
.modal-card h2 { margin: 0; font-family: var(--head); font-size: 28px; }
.modal-card p { margin: 0; color: var(--muted); font-weight: 700; }
.res-art { display: flex; justify-content: center; gap: 8px; }
.res-art .disc { width: 54px; height: 54px; border-radius: 50%; }
.res-art .a { background: radial-gradient(circle at 35% 30%, #ffc27f, var(--orange) 55%, #d9661b); }
.res-art .b { background: radial-gradient(circle at 35% 30%, #a6fff6, var(--teal) 55%, #149a92); }
.res-stars { font-size: 40px; letter-spacing: 6px; color: var(--navy3); min-height: 0; }
.res-stars .on { color: #ffd257; display: inline-block; animation: starIn .4s backwards; }
.res-stars .on:nth-child(2) { animation-delay: .2s; }
.res-stars .on:nth-child(3) { animation-delay: .4s; }
@keyframes starIn { from { transform: scale(0) rotate(-90deg); } }
.res-badges { display: flex; flex-direction: column; gap: 6px; }
.res-badges div { display: flex; align-items: center; gap: 10px; background: var(--navy); border-radius: 12px; padding: 8px 10px; text-align: left; font-weight: 800; }
.res-badges .bico { width: 36px; height: 36px; font-size: 18px; flex: none; }

.toast { position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--navy3); color: var(--ink); padding: 10px 16px; border-radius: 14px; font-weight: 800; box-shadow: 0 8px 24px rgba(0, 0, 0, .4); z-index: 60; max-width: calc(100% - 32px); text-align: center; }

@media (max-width: 380px) {
  .title { font-size: 21px; }
  .home-link span { font-size: 14px; }
  .ctl { font-size: 12px; min-height: 52px; }
  .coach p { font-size: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
