/* Khel ON · Pathar Pop */
:root {
  --bg: var(--ko-bg, #141721); --bg2: var(--ko-bg-2, #1b1d2e); --panel: var(--ko-panel, #20223a);
  --line: var(--ko-line, rgba(255,255,255,.1)); --ink: var(--ko-ink, #f5f3ff); --dim: var(--ko-dim, #a9a8c6);
  --orange: var(--ko-orange, #ff9a3c); --pink: var(--ko-pink, #f04fa8); --purple: var(--ko-purple, #8b5cf6); --teal: var(--ko-teal, #2fd4c8);
  --gold: #ffd166;
  --grad: var(--ko-grad, linear-gradient(90deg, #ff9a3c, #f04fa8, #8b5cf6));
  --display: var(--ko-display, Outfit, "Segoe UI", system-ui, sans-serif);
  --body: var(--ko-body, Nunito, "Segoe UI", system-ui, sans-serif);
  --top-h: 61px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; background: var(--bg); color: var(--ink); font-family: var(--body); font-weight: 600;
  background-image: radial-gradient(120% 60% at 50% -10%, #2a1f4a 0%, transparent 60%);
  overflow-x: hidden; -webkit-tap-highlight-color: transparent;
}
body.playing { overflow: hidden; overscroll-behavior: none; }
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 3px solid var(--teal); outline-offset: 2px; }
[hidden] { display: none !important; }

/* Header */
.top { display: flex; align-items: center; gap: 10px; padding: 10px 12px; padding-top: max(10px, env(safe-area-inset-top)); position: sticky; top: 0; z-index: 5; background: rgba(20,23,33,.92); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line); }
.home { display: flex; align-items: center; min-height: 44px; flex: none; }
.home img { display: block; height: 28px; width: auto; }
.ttl { flex: 1; min-width: 0; }
.ttl .ctx { margin-top: 2px; }
.top h1 { margin: 0; font-family: var(--display); font-weight: 800; font-size: clamp(15px, 4.4vw, 22px); line-height: 1.05; min-width: 0; }
.top h1 span { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.tools { display: flex; align-items: center; gap: 6px; }
.icon { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); font-size: 17px; font-weight: 800; display: grid; place-items: center; padding: 0; }
.icon[aria-pressed="false"] { opacity: .55; }
.starcount { font-family: var(--display); font-weight: 800; color: var(--gold); font-size: 15px; padding: 0 4px; white-space: nowrap; }
.starcount.bump { animation: bump .5s ease; }
@keyframes bump { 40% { transform: scale(1.35); } }
@media (max-width: 400px) { .top { gap: 8px; } .tools { gap: 4px; } .home img { height: 24px; } }
@media (max-width: 359px) { .top { gap: 6px; padding-left: 10px; padding-right: 10px; } .starcount { display: none; } .home img { height: 22px; } }

/* Menu */
.menu { max-width: 760px; margin: 0 auto; padding: 12px 12px 28px; }
.hero { text-align: center; }
.hero-art { width: 100%; max-width: 420px; height: auto; display: block; margin: 0 auto; }
.tag { margin: 4px auto 12px; max-width: 34em; color: var(--dim); line-height: 1.4; }
.learn { display: block; width: 100%; padding: 14px; border-radius: 18px; border: 0; background: var(--teal); color: #0d1a1d; font-family: var(--display); font-weight: 800; font-size: 19px; box-shadow: 0 8px 24px rgba(47,212,200,.25); }
.learn small { display: block; font-family: var(--body); font-weight: 700; font-size: 13px; opacity: .8; }
.learn.done { background: var(--panel); color: var(--ink); border: 1px solid var(--line); box-shadow: none; padding: 10px; font-size: 16px; }
.menu h2 { font-family: var(--display); font-weight: 800; font-size: 18px; margin: 20px 0 10px; }
.modes { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.mode { position: relative; text-align: left; border: 2px solid var(--line); background: var(--panel); border-radius: 18px; padding: 12px 12px 26px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.mode::before { content: ''; position: absolute; left: 12px; right: 12px; top: 0; height: 4px; border-radius: 0 0 4px 4px; background: var(--c, var(--teal)); }
.mode b { font-family: var(--display); font-size: 18px; }
.mode span { color: var(--dim); font-size: 13.5px; line-height: 1.3; }
.mode:hover, .mode:focus-visible { border-color: var(--c, var(--teal)); }
.m-calm { --c: var(--teal); } .m-classic { --c: var(--pink); } .m-count { --c: var(--orange); } .m-turns { --c: var(--purple); }
.mstars { position: absolute; left: 12px; bottom: 7px; font-style: normal; color: var(--gold); font-size: 13px; letter-spacing: 1px; }
.opts { display: grid; gap: 8px; margin-top: 14px; }
.opt { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 8px 10px; }
.opt > span { font-weight: 800; }
.opt small { color: var(--dim); font-weight: 700; }
.opt.check { justify-content: flex-start; cursor: pointer; }
.opt.check input { width: 22px; height: 22px; accent-color: var(--teal); margin: 0; }
.seg { display: inline-flex; background: var(--bg2); border-radius: 12px; padding: 3px; gap: 2px; border: 1px solid var(--line); flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 7px 10px; border-radius: 9px; font-weight: 800; font-size: 14px; color: var(--dim); }
.seg button[aria-checked="true"] { background: var(--grad); color: #fff; }
.bests { margin-top: 14px; display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 6px; }
.bests div { background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; padding: 6px 10px; font-size: 13px; color: var(--dim); }
.bests b { display: block; color: var(--ink); font-family: var(--display); font-size: 16px; }
.foot { text-align: center; color: var(--dim); font-size: 13px; margin: 14px 0 0; }
.linkish { border: 0; background: none; color: var(--teal); font-weight: 800; text-decoration: underline; padding: 0; }
.hint { color: var(--dim); font-size: 13.5px; margin: 8px 2px; line-height: 1.4; }

/* Play */
.play { position: fixed; left: 0; right: 0; bottom: 0; top: calc(var(--top-h) + max(0px, env(safe-area-inset-top) - 10px)); }
.stage { position: absolute; inset: 0; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; }
#cv { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.hud { position: absolute; left: 0; right: 0; top: 0; display: flex; justify-content: space-between; align-items: flex-start; gap: 6px; padding: 8px 10px; pointer-events: none; }
.hud .hl, .hud .hr { display: flex; align-items: center; gap: 8px; }
.hud .hl { flex-direction: column; align-items: flex-start; gap: 0; }
.hscore { font-family: var(--display); font-weight: 800; font-size: 24px; line-height: 1; text-shadow: 0 2px 6px rgba(0,0,0,.6); }
.hwave { font-size: 13px; color: var(--dim); font-weight: 800; }
.hmid { flex: 1; text-align: center; font-family: var(--display); font-weight: 800; font-size: 15px; line-height: 1.2; min-width: 0; }
.hmid .want { display: inline-block; min-width: 44px; padding: 2px 10px; border-radius: 12px; background: var(--orange); color: #241303; font-size: 22px; }
.hmid .seq { display: block; font-size: 12px; color: var(--dim); margin-top: 3px; letter-spacing: .5px; }
.hmid .seq s { color: var(--teal); text-decoration: none; }
.hmid .clock { font-size: 20px; }
.hmid .who { display: block; font-size: 12px; color: var(--dim); }
.hshields { font-size: 18px; letter-spacing: 1px; color: var(--teal); text-shadow: 0 0 8px rgba(47,212,200,.5); white-space: nowrap; }
.hshields .gone { color: rgba(255,255,255,.18); text-shadow: none; }
.pausebtn { pointer-events: auto; font-size: 13px; letter-spacing: -2px; }
.coach { position: absolute; left: 50%; top: 56px; transform: translateX(-50%); width: min(92%, 420px); background: rgba(32,34,58,.94); border: 2px solid var(--teal); border-radius: 16px; padding: 10px 14px; pointer-events: none; text-align: center; }
.coach p { margin: 0; line-height: 1.35; font-size: 15px; }
.toast { position: absolute; left: 50%; top: 38%; transform: translate(-50%, -50%); font-family: var(--display); font-weight: 800; font-size: clamp(22px, 7vw, 38px); text-align: center; pointer-events: none; opacity: 0; transition: opacity .25s; text-shadow: 0 3px 14px rgba(0,0,0,.7); white-space: nowrap; }
.toast.show { opacity: 1; }
.toast small { display: block; font-size: .5em; color: var(--dim); }

/* Touch pad */
.pad { position: absolute; inset: 0; pointer-events: none; }
.stickzone { position: absolute; left: 0; top: 70px; bottom: 0; width: 58%; pointer-events: auto; }
.ztip { position: absolute; left: 50%; bottom: 22px; transform: translateX(-50%); color: rgba(255,255,255,.35); font-size: 13px; font-weight: 800; white-space: nowrap; transition: opacity .3s; }
.stickzone.active .ztip { opacity: 0; }
.stickbase { position: absolute; left: 82px; top: 60%; width: 104px; height: 104px; margin: -52px 0 0 -52px; border-radius: 50%; border: 2px solid rgba(47,212,200,.45); background: rgba(47,212,200,.08); opacity: .55; pointer-events: none; }
.stickzone.active .stickbase { opacity: 1; }
.knob { position: absolute; left: 50%; top: 50%; width: 46px; height: 46px; margin: -23px 0 0 -23px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #a8fff7, var(--teal)); box-shadow: 0 4px 12px rgba(0,0,0,.4); }
.btnzone { position: absolute; left: 12px; bottom: max(14px, env(safe-area-inset-bottom)); display: grid; grid-template-columns: 64px 64px; grid-template-rows: 64px 64px; gap: 10px; pointer-events: auto; }
.btnzone .thrust { grid-column: 1 / span 2; grid-row: 1; justify-self: center; }
.btnzone .turn { grid-row: 2; }
.pb { width: 64px; height: 64px; border-radius: 50%; border: 2px solid rgba(255,255,255,.18); background: rgba(32,34,58,.6); font-size: 22px; font-weight: 800; touch-action: none; padding: 0; color: var(--ink); }
.pb.on { background: rgba(47,212,200,.35); border-color: var(--teal); }
.pb.pop { position: absolute; right: 18px; bottom: max(22px, env(safe-area-inset-bottom)); width: 96px; height: 96px; font-family: var(--display); font-size: 22px; pointer-events: auto; background: radial-gradient(circle at 35% 30%, rgba(255,154,60,.75), rgba(240,79,168,.6)); border-color: rgba(255,255,255,.35); color: #fff; }
.pb.pop.on { transform: scale(.94); filter: brightness(1.2); }
.pad.stick .btnzone { display: none; }
.pad.buttons .stickzone { display: none; }

/* Sheets */
.sheet { position: fixed; inset: 0; z-index: 2147482950; display: grid; place-items: center; padding: 16px; background: rgba(8,9,16,.66); backdrop-filter: blur(3px); overflow-y: auto; }
.card { width: min(100%, 440px); background: var(--bg2); border: 1px solid var(--line); border-radius: 22px; padding: 18px; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.card h3 { margin: 0 0 8px; font-family: var(--display); font-weight: 800; font-size: 22px; }
.howlist { padding-left: 20px; margin: 8px 0; line-height: 1.45; }
.howlist li { margin-bottom: 8px; }
.row { display: flex; gap: 10px; }
.col { display: grid; gap: 8px; margin-top: 12px; }
.start { display: block; width: 100%; margin: 14px 0 0; padding: 14px; border: 0; border-radius: 18px; background: var(--grad); color: #fff; font-family: var(--display); font-weight: 800; font-size: 19px; box-shadow: 0 8px 24px rgba(240,79,168,.3); }
.col .start { margin: 0; }
.ghost { border: 1px solid var(--line); background: var(--panel); border-radius: 14px; padding: 11px 14px; font-weight: 800; }
.badgelist { list-style: none; padding: 0; margin: 8px 0; display: grid; gap: 6px; max-height: 55vh; overflow-y: auto; }
.badgelist li { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 12px; background: var(--panel); }
.badgelist li .bi { font-size: 24px; width: 32px; text-align: center; flex: none; }
.badgelist li b { display: block; font-family: var(--display); }
.badgelist li small { color: var(--dim); }
.badgelist li.locked { opacity: .45; }
.badgelist li.locked .bi { filter: grayscale(1); }
.endstars { font-size: 34px; color: var(--gold); margin: 0; letter-spacing: 4px; text-align: center; min-height: 1em; }
.endstars .dim { color: rgba(255,255,255,.15); }
.endstats { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; margin: 10px 0; }
.endstats dt { color: var(--dim); }
.endstats dd { margin: 0; font-family: var(--display); font-weight: 800; text-align: right; }
.ranks { padding-left: 24px; margin: 10px 0; font-family: var(--display); font-weight: 700; font-size: 17px; line-height: 1.6; }
.ranks b { color: var(--gold); }
.newbadges { list-style: none; padding: 0; margin: 6px 0 0; display: grid; gap: 6px; }
.newbadges li { padding: 8px 10px; border-radius: 12px; background: #2a2440; border: 1px solid var(--gold); font-weight: 800; }

@media (min-width: 900px) {
  .stickzone { width: 50%; }
}
@media (prefers-reduced-motion: reduce) {
  .toast { transition: none; }
}
.m-online { --c: var(--orange); }
.netboard { position: absolute; left: 10px; top: 58px; pointer-events: none; font-size: 12.5px; font-weight: 800; background: rgba(16,18,29,.6); border-radius: 12px; padding: 6px 9px; max-width: 60%; }
.netboard ol { list-style: none; margin: 0; padding: 0; }
.netboard li { display: flex; align-items: center; gap: 6px; line-height: 1.5; }
.netboard li i { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.netboard li span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--dim); }
.netboard li.me span { color: #fff; }
.netboard li b { font-variant-numeric: tabular-nums; margin-left: 8px; }
.netboard p { margin: 4px 0 0; color: var(--dim); font-weight: 700; }

/* ---------- mouse, caret and focus hygiene (no blinking text cursor, no accidental text highlight) ---------- */
html, body { caret-color: transparent; }
body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
#kn-panel input { caret-color: auto; -webkit-user-select: text; user-select: text; }
canvas { -webkit-user-select: none; user-select: none; touch-action: none; }
:focus:not(:focus-visible) { outline: none; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 3px solid #2fd4c8; outline-offset: 2px; }
/* while playing, the pointer hides once the mouse rests (or the keyboard is in use); any mouse move brings it back */
body.ptr-idle #play, body.ptr-idle #play * { cursor: none !important; }
/* desktop with a mouse: the touch stick and buttons would sit on the play field, so they only show once the screen is touched */
@media (hover: hover) and (pointer: fine) { body:not(.touched) .pad { display: none; } }
/* the online table pill would sit on the stick: it hides while flying (Pause leaves the table) */
body.playing .kn-pill { display: none; }
.sheet .card:focus { outline: none; }
.endstars:empty, .endstats:empty, .newbadges:empty { display: none; }

/* a card with no game or front door behind it sits on the same festival backdrop as the front door */
.sheet.solid { background: radial-gradient(70% 55% at 50% 0%, rgba(255,179,71,.14), transparent 70%), radial-gradient(60% 50% at 100% 100%, rgba(199,125,255,.18), transparent 70%), #141721; backdrop-filter: none; }
@media (min-width: 700px) { #how .card, #badges .card { width: min(100%, 560px); padding: 24px 28px; } .howlist { font-size: 16.5px; } }

/* ---------- desktop: a readable HUD over the big sky ---------- */
@media (min-width: 900px) {
  .hud { padding: 14px 20px; }
  .hscore { font-size: 34px; }
  .hwave { font-size: 15px; }
  .hmid { font-size: 18px; }
  .hmid .want { font-size: 28px; min-width: 56px; }
  .hmid .seq { font-size: 14px; }
  .hmid .clock { font-size: 26px; }
  .hmid .who { font-size: 14px; }
  .hshields { font-size: 24px; }
  .coach { top: 76px; width: min(92%, 520px); }
  .coach p { font-size: 17px; }
  .netboard { top: 80px; left: 20px; font-size: 14px; padding: 8px 12px; }
}

/* ---------- pointer: an arrow on things you cannot click, a hand on things you can; no text I-beam ---------- */
body, body * { cursor: default; }
button:not(:disabled), button:not(:disabled) *, a[href], a[href] *, [role="button"], label { cursor: pointer; }
#kn-panel input { cursor: text; }

/* header icons drawn as line icons (not emoji), the same family as the other arcade games */
.icon svg { width: 20px; height: 20px; display: block; color: var(--ink, #f4f1ea); }
/* desktop keyboard: the keys sit under the sky, quiet but always there; touch screens show the stick and buttons instead */
.keys { display: none; position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); margin: 0; padding: 7px 14px; border-radius: 999px; background: rgba(20,23,33,.62); border: 1px solid rgba(255,255,255,.08); color: #b9b8d4; font-size: 14px; font-weight: 700; white-space: nowrap; pointer-events: none; }
.keys kbd { display: inline-block; min-width: 24px; padding: 1px 6px; margin: 0 1px; border-radius: 6px; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.16); color: #fff; font: 800 13px inherit; font-family: inherit; text-align: center; }
@media (hover: hover) and (pointer: fine) { body:not(.touched) .keys { display: block; } }
/* the small cards (pause, end of a flight, hand over) read from the middle, like every other Khel ON card */
#pause .card, #end .card, #handoff .card { text-align: center; }
#pause .card h3, #end .card h3, #handoff .card h3 { font-size: 26px; margin-bottom: 10px; }
#end .endstats { text-align: left; }
.keys[hidden] { display: none !important; }

/* ---------- the shared game dock: the sky stops above it, the touch stick and POP sit above it ---------- */
html.kd-on .play { bottom: calc(var(--kd-h, 0px) + env(safe-area-inset-bottom, 0px)); }
.sp { display: none; }
/* ---------- desktop with a mouse (Option A): slim header, the sky big on the left, the side panel on the right ---------- */
body.desk { --sp-w: clamp(330px, 26vw, 410px); }
body.desk .top { padding-left: 24px; padding-right: 24px; gap: 16px; }
body.desk .ttl { padding-left: 16px; border-left: 1px solid rgba(255,255,255,.12); }
body.desk .top h1 { font-size: 22px; }
body.desk .play { left: 24px; right: calc(24px + var(--sp-w) + 20px); margin-top: 12px; bottom: calc(var(--kd-h, 0px) + 18px); border-radius: 22px; overflow: hidden; box-shadow: 0 0 0 1px rgba(255,255,255,.06); }
body.desk .sp { display: flex; position: fixed; right: 24px; width: var(--sp-w); top: calc(var(--sp-top, 61px) + 12px); bottom: calc(var(--kd-h, 0px) + 18px); overflow: hidden; }
body.desk .hud .hl, body.desk .hud .hr, body.desk #netBoard { display: none !important; }
body.desk:not(.keys-below) .keys { display: none !important; }
.sp-prog { height: 8px; margin: 14px 0 8px; border-radius: 9px; background: #151a29; overflow: hidden; }
.sp-prog i { display: block; height: 100%; width: 0; border-radius: 9px; background: linear-gradient(90deg, #ffb347, #c77dff); transition: width .3s; }
.sp-prog[hidden] { display: none; }
.sp-prog[hidden] + .sp-sub { margin-top: 12px; }
.sp-stat .sp-sh { display: inline-block; width: 15px; height: 15px; margin: 6px 5px 0 0; transform: rotate(45deg); border-radius: 3px; background: rgba(255,255,255,.14); }
.sp-stat .sp-sh.on { background: #2fd4c8; box-shadow: 0 0 10px rgba(47,212,200,.55); }
.sp-want { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.sp-want span { color: #9aa0bd; font-weight: 800; font-size: 15px; }
.sp-want b { min-width: 64px; padding: 4px 14px; border-radius: 16px; background: #ff9a3c; color: #241303; font: 800 40px/1.05 Outfit, system-ui, sans-serif; text-align: center; }
.sp-seq { display: flex; flex-wrap: wrap; gap: 8px; }
.sp-seq span { min-width: 40px; padding: 6px 10px; border-radius: 12px; background: #151a29; text-align: center; font: 800 18px Outfit, system-ui, sans-serif; color: #d9dbee; }
.sp-seq span.done { background: rgba(47,212,200,.16); color: #2fd4c8; text-decoration: line-through; }
.sp-seq span.now { box-shadow: inset 0 0 0 2px #ff9a3c; color: #fff; }
.sp-list.sp-goals li .sp-star { width: auto; min-width: 46px; padding: 0 6px; border-radius: 999px; background: #262c44; color: #ffd166; font-size: 12px; letter-spacing: 1px; }
.sp-goals li.done { opacity: 1; box-shadow: inset 0 0 0 2px rgba(255,209,102,.5); }
.sp-goals li b { color: #2fd4c8; font-size: 18px; }
