/* Barfi Drop — Khel ON brand: navy, orange→pink→purple gradient, teal; Outfit + Nunito (self-hosted) */
:root {
  --navy: #141721; --navy2: #1c2030; --navy3: #262b3f; --line: #343a52;
  --ink: #f4f1ea; --dim: #a9adc2;
  --orange: #ff9a3c; --pink: #f04fa8; --purple: #8b5cf6; --teal: #2fd4c8; --gold: #f2c14e;
  --grad: linear-gradient(100deg, var(--orange), var(--pink) 55%, var(--purple));
  --head: 'Outfit', 'Lilita One', 'Nunito', system-ui, sans-serif;
  --body: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --r: 16px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--navy); color: var(--ink); font-family: var(--body); }
body { overflow-x: hidden; overscroll-behavior: none; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
.hidden { display: none !important; }

#app { max-width: 560px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; padding: 0 16px env(safe-area-inset-bottom); }
.bar { display: flex; align-items: center; gap: 10px; height: 52px; flex: none; }
.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; text-align: center; }
.bar::after { content: ''; flex: none; width: 84px; } /* keeps the title centred against the logo */
.title { margin: 0; text-align: center; font-family: var(--head); font-size: 20px; font-weight: 800; letter-spacing: .3px; line-height: 1.1; }
html.kd-on #app { min-height: calc(100dvh - var(--kd-h, 0px)); }
.bar-btns { display: flex; gap: 4px; }
.icon-btn { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; }
.icon-btn:active { background: var(--navy3); }
.icon-btn svg { width: 24px; height: 24px; fill: var(--ink); }
#btn-sound .snd-off { display: none; }
#btn-sound.muted .snd-on { display: none; }
#btn-sound.muted .snd-off { display: inline; }

/* ---------- menu ---------- */
#menu { padding-bottom: 24px; }
.hero { text-align: center; margin: 2px 0 10px; }
#hero-canvas { width: 100%; max-width: 360px; height: auto; aspect-ratio: 8 / 3; display: block; margin: 0 auto; }
.tag { margin: 6px 0 0; color: var(--dim); font-size: 15px; }
.mode { width: 100%; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; text-align: left; background: var(--navy2); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; margin: 8px 0; min-height: 64px; }
button.mode:active { transform: scale(.985); }
.mode.learn { background: linear-gradient(var(--navy2), var(--navy2)) padding-box, var(--grad) border-box; border: 2px solid transparent; }
.m-ico { font-size: 26px; width: 34px; text-align: center; flex: none; }
.m-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.m-txt b { font-family: var(--head); font-size: 18px; }
.m-txt small { color: var(--dim); font-size: 13.5px; }
.m-best { color: var(--gold); font-size: 13px; font-weight: 700; margin-top: 2px; }
.m-best:empty { display: none; }
.m-go { font-size: 28px; color: var(--dim); flex: none; }
.mode .lv { flex-basis: 100%; }
.opt-row, .sub { display: flex; align-items: center; gap: 10px; margin: 10px 2px 4px; }
.sub { margin: -2px 0 10px 48px; }
.opt-label { color: var(--dim); font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; }
.seg { display: flex; gap: 6px; flex: 1; }
.seg button { flex: 1; min-height: 44px; border-radius: 12px; background: var(--navy3); border: 1px solid var(--line); font-weight: 800; font-size: 14.5px; padding: 6px 8px; }
.seg button small { font-weight: 600; color: var(--dim); }
.seg button.on { background: var(--teal); color: var(--navy); border-color: var(--teal); }
.seg button.on small { color: var(--navy); }
.lv button { background: var(--navy); }
.lv button:active { background: var(--grad); }
.lv .star-mini { color: var(--gold); font-size: 11px; display: block; }
.menu-foot { display: flex; gap: 10px; margin-top: 14px; }
.link-btn { flex: 1; min-height: 48px; border-radius: 12px; background: var(--navy2); border: 1px solid var(--line); font-weight: 800; }

/* ---------- play ---------- */
#play { flex: 1; display: flex; flex-direction: column; min-height: 0; user-select: none; -webkit-user-select: none; touch-action: none; }
.hud { display: flex; gap: 8px; flex: none; }
.hud-cell { flex: 1; background: var(--navy2); border-radius: 12px; padding: 4px 10px; display: flex; align-items: baseline; justify-content: space-between; gap: 6px; }
.hud-cell span { color: var(--dim); font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .5px; }
.hud-cell b { font-family: var(--head); font-size: 18px; font-variant-numeric: tabular-nums; }
.stage { flex: 1; display: flex; flex-direction: column; justify-content: center; min-height: 0; }
.sp { display: none; }
.arena { flex: none; margin: auto 0; display: flex; justify-content: center; align-items: flex-start; gap: 6px; padding: 8px 0; min-height: 0; }
.side { width: 52px; flex: none; display: flex; flex-direction: column; gap: 8px; }
.box { background: var(--navy2); border-radius: 12px; padding: 4px 0 6px; text-align: center; }
.box span { display: block; font-size: 12px; color: var(--dim); font-weight: 800; text-transform: uppercase; letter-spacing: .5px; }
.box canvas { display: block; margin: 2px auto 0; }
.opp span { color: var(--pink); text-transform: none; letter-spacing: 0; padding: 0 2px; overflow-wrap: anywhere; line-height: 1.15; }
.who { background: var(--navy2); border-radius: 12px; padding: 6px 2px; text-align: center; font-size: 12px; font-weight: 800; }
.who .em { font-size: 26px; display: block; }
.tray-wrap { position: relative; flex: none; }
.tray { display: block; border-radius: 14px; box-shadow: 0 0 0 3px #3a3f57, 0 0 0 5px rgba(242,193,78,.55), 0 10px 30px rgba(0,0,0,.45); background: #0f1119; }
.junk-meter { position: absolute; left: -9px; bottom: 0; width: 5px; height: 100%; border-radius: 3px; background: rgba(255,255,255,.06); overflow: hidden; }
.junk-meter i { position: absolute; bottom: 0; left: 0; right: 0; height: 0; background: linear-gradient(var(--orange), var(--pink)); transition: height .2s; }
.pop { position: absolute; left: 0; right: 0; top: 34%; text-align: center; pointer-events: none; font-family: var(--head); font-weight: 900; font-size: 26px; color: #fff; text-shadow: 0 2px 0 rgba(0,0,0,.35), 0 0 18px var(--pink); opacity: 0; }
.pop.show { animation: pop 1.1s ease-out forwards; }
@keyframes pop { 0% { opacity: 0; transform: scale(.6); } 15% { opacity: 1; transform: scale(1.08); } 70% { opacity: 1; transform: translateY(-14px) scale(1); } 100% { opacity: 0; transform: translateY(-34px); } }
.coach { position: absolute; left: 6px; right: 6px; top: 26%; background: rgba(20,23,33,.94); border: 2px solid var(--teal); border-radius: 14px; padding: 10px 12px; font-weight: 800; font-size: 15.5px; line-height: 1.3; text-align: center; pointer-events: none; }
.coach small { display: block; font-weight: 600; color: var(--dim); font-size: 13px; margin-top: 3px; }

.pad { flex: none; display: flex; flex-direction: column; gap: 8px; padding: 4px 0 10px; }
.pad-row { display: flex; gap: 8px; }
.pb { flex: 1; height: 54px; border-radius: 14px; background: var(--navy3); border: 1px solid var(--line); display: grid; place-items: center; touch-action: none; font-weight: 900; font-size: 14px; }
.pb svg { width: 28px; height: 28px; fill: var(--ink); }
.pb.big { height: 60px; }
.pb.big svg { width: 36px; height: 36px; }
.pb.small { font-size: 14px; color: var(--teal); }
.pb.drop { background: var(--grad); border: 0; display: flex; gap: 4px; justify-content: center; align-items: center; }
.pb.drop small { font-weight: 900; font-size: 14px; }
.pb:active, .pb.held { filter: brightness(1.35); transform: scale(.97); }
.pb.hint { animation: hint 1s ease-in-out infinite; }
@keyframes hint { 0%, 100% { box-shadow: 0 0 0 0 rgba(47,212,200,.0); } 50% { box-shadow: 0 0 0 4px var(--teal), 0 0 22px var(--teal); } }
.pb:disabled { opacity: .35; }

/* ---------- overlays ---------- */
.overlay { position: fixed; inset: 0; background: rgba(8,10,16,.72); backdrop-filter: blur(4px); display: grid; place-items: center; padding: 16px; z-index: 2147482950; }
/* a card with no game or front door behind it sits on the same festival backdrop as the front door */
.overlay.solid { background: radial-gradient(70% 55% at 50% 0%, rgba(255,201,74,.14), transparent 70%), radial-gradient(60% 50% at 100% 100%, rgba(139,92,246,.16), transparent 70%), #141721; backdrop-filter: none; }
.card { width: 100%; max-width: 380px; max-height: calc(100dvh - 32px); overflow-y: auto; background: var(--navy2); border: 1px solid var(--line); border-radius: 22px; padding: 22px 18px 18px; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.card h2 { font-family: var(--head); font-size: 26px; margin: 4px 0 6px; }
.card h2.grad { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.card p { color: var(--dim); margin: 6px 0 12px; line-height: 1.4; }
.card .big-emoji { font-size: 46px; }
.stars { font-size: 38px; letter-spacing: 6px; margin: 4px 0 6px; }
.stars i { font-style: normal; color: #3a3f57; display: inline-block; }
.stars i.on { color: var(--gold); animation: star .5s backwards; text-shadow: 0 0 16px rgba(242,193,78,.6); }
.stars i.on:nth-child(2) { animation-delay: .25s; } .stars i.on:nth-child(3) { animation-delay: .5s; }
@keyframes star { from { transform: scale(0) rotate(-60deg); } to { transform: scale(1) rotate(0); } }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0; }
.stats div { background: var(--navy); border-radius: 12px; padding: 8px; }
.stats span { display: block; color: var(--dim); font-size: 12px; font-weight: 800; text-transform: uppercase; }
.stats b { font-family: var(--head); font-size: 20px; }
.newbest, .card .newbest { color: var(--gold); font-weight: 900; margin: 4px 0; }
.btns { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.btn { min-height: 50px; border-radius: 14px; font-weight: 900; font-size: 16.5px; background: var(--navy3); border: 1px solid var(--line); }
.btn.primary { background: var(--grad); border: 0; color: #fff; }
.earned { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 8px 0; }
.chip { background: var(--navy); border: 1px solid var(--gold); color: var(--gold); border-radius: 999px; padding: 4px 10px; font-size: 13px; font-weight: 800; }
.badge-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; text-align: left; margin: 10px 0; }
.badge { background: var(--navy); border-radius: 12px; padding: 8px 10px; display: flex; gap: 8px; align-items: center; opacity: .45; }
.badge.got { opacity: 1; box-shadow: inset 0 0 0 1px var(--gold); }
.badge .bi { font-size: 24px; }
.badge b { display: block; font-size: 13.5px; }
.badge small { color: var(--dim); font-size: 12px; line-height: 1.2; display: block; }
.howto { text-align: left; margin: 6px 0; padding-left: 18px; color: var(--ink); line-height: 1.45; }
.howto li { margin: 4px 0; }
.howto kbd { background: var(--navy); border: 1px solid var(--line); border-radius: 6px; padding: 0 5px; font-size: 13px; }
.board-list { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; }
.board-list div { display: flex; justify-content: space-between; align-items: center; background: var(--navy); border-radius: 12px; padding: 8px 12px; font-weight: 800; }
.board-list div.win { box-shadow: inset 0 0 0 2px var(--gold); }
.board-list .em { font-size: 22px; margin-right: 8px; }
.handoff .big-emoji { font-size: 72px; }
@media (min-height: 760px) { .pb { height: 60px; } .pb.big { height: 66px; } }
/* tall phones: the tray is as wide as it can be, so spend the spare height on bigger thumb buttons */
@media (min-height: 820px) and (max-width: 520px) { .pb { height: 66px; border-radius: 16px; } .pb.big { height: 76px; } .pad { gap: 10px; padding-bottom: 14px; } }
@media (prefers-reduced-motion: reduce) { .pop.show, .stars i.on, .pb.hint { animation: none; opacity: 1; } }

.tut .side .box.next-box canvas { visibility: hidden; }
.opp span small { display: block; font-size: 12px; color: var(--dim); }
@media (min-width: 420px) { .side { width: 64px; } }
@media (max-width: 345px) { .bar { gap: 8px; } .icon-btn { width: 40px; height: 40px; } .title { letter-spacing: 0; } .home img { height: 21px; } .title { font-size: 17px; } .hud-cell { padding: 4px 7px; } }

/* ---------- 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; }
/* the online table pill would sit on the Left button: it hides while a game is on screen (Pause leaves the table) */
#app:has(#play:not(.hidden)) ~ .kn-pill { display: none; }
#ov-card:focus { outline: none; }
.card.wide { max-width: 560px; }
@media (min-width: 700px) { .card.wide { padding: 26px 30px 24px; } .card.wide .howto { font-size: 16.5px; } }

/* ---------- desktop with a mouse (Option A): slim header, the tray big on the left, the side panel on the right ---------- */
#app.desk-play { max-width: none; padding: 0 24px; --sp-w: clamp(330px, 26vw, 410px); }
#app.desk-play .bar { height: 62px; gap: 16px; }
#app.desk-play .bar::after { display: none; }
#app.desk-play .ttl { text-align: left; padding-left: 16px; border-left: 1px solid rgba(255,255,255,.12); }
#app.desk-play .title { text-align: left; font-size: 22px; }
#play.desk { flex: none; display: grid; grid-template-columns: minmax(0, 1fr) var(--sp-w); gap: 20px; height: calc(100dvh - 62px - var(--kd-h, 0px) - 18px); margin-bottom: 18px; }
#play.desk .hud, #play.desk .pad, #play.desk #opp { display: none; }
#play.desk .side { width: 150px; gap: 14px; }
#play.desk .box { border-radius: 18px; padding: 12px 10px 12px; background: rgba(28,33,51,.92); box-shadow: 0 0 0 1px rgba(255,255,255,.06); }
#play.desk .box span { font-size: 12.5px; letter-spacing: .09em; color: #9aa0bd; }
#play.desk .who { border-radius: 18px; font-size: 15px; padding: 12px 6px; background: rgba(28,33,51,.92); }
#play.desk .who .em { font-size: 34px; }
#play.desk.tut .side.right { visibility: hidden; }
#play.desk .stage { position: relative; min-height: 0; border-radius: 22px; overflow: hidden; display: grid; place-items: center;
  background: radial-gradient(60% 70% at 50% 45%, rgba(255,201,74,.10), transparent 70%), radial-gradient(50% 60% at 100% 100%, rgba(240,79,168,.10), transparent 70%), radial-gradient(rgba(255,255,255,.05) 1.2px, transparent 1.4px) 0 0 / 26px 26px, #171b2b;
  box-shadow: 0 0 0 1px rgba(255,255,255,.05); }
#play.desk .arena { margin: 0; padding: 0; gap: 28px; }
#play.desk.keys-below .arena { margin-bottom: 40px; }
#play.desk .junk-meter { left: -14px; width: 7px; }
#play.desk .sp { display: flex; height: 100%; overflow: hidden; }
.keys-hint { display: none; }
#play.desk.keys-below .keys-hint { display: block; position: absolute; left: 0; right: 0; bottom: 10px; margin: 0; text-align: center; color: var(--dim); font-size: 14px; font-weight: 700; pointer-events: none; }
.keys-hint kbd { display: inline-block; min-width: 24px; padding: 1px 6px; margin: 0 1px; border-radius: 6px; background: var(--navy2); border: 1px solid var(--line); color: var(--ink); font: 800 13px var(--body); text-align: center; }
#play.desk .coach { font-size: 17px; padding: 12px 14px; }
#play.desk .pop { font-size: 34px; }

.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, #ffc94a, #f04fa8); transition: width .3s; }
.sp-prog[hidden] { display: none; }
.sp-prog[hidden] + .sp-sub { margin-top: 12px; }
.sp-opp { display: flex; gap: 14px; align-items: flex-start; }
.sp-opp canvas { flex: none; border-radius: 10px; box-shadow: 0 0 0 2px #3a3f57; }
.sp-opp-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.sp-opp-info .sp-sub { font-size: 13.5px; color: #9aa0bd; }

/* ---------- 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; }

/* the same Khel ON logo as the front door, not a dot and plain text */
.home img { display: block; height: 28px; width: auto; }
@media (max-width: 345px) { .home img { height: 22px; } }
