/* 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: 57px;
}
* { 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 img { display: block; height: 28px; width: auto; }
.top h1 { flex: 1; 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: 36px; height: 36px; 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); } }

/* 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: var(--top-h); }
.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: 20; 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; }
}
