/* Khel ON — Pallanguzhi */
:root {
  --navy: #121521;
  --navy-2: #1c2133;
  --navy-3: #262b3f;
  --line: rgba(255,255,255,.09);
  --text: #f4f2fb;
  --muted: #a9aec4;
  --orange: #ff9a3c;
  --pink: #f04fa8;
  --purple: #8b5cf6;
  --teal: #2fd4c8;
  --grad: linear-gradient(100deg, var(--orange), var(--pink) 55%, var(--purple));
  --wood-1: #8a4f2a;
  --wood-2: #6d3b1d;
  --wood-3: #4e2913;
  --pit: #3a1e0e;
  --head: 'Outfit', 'Lilita One', 'Nunito', system-ui, sans-serif;
  --body: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --pit-size: min(calc((100vw - 32px - 16px - 6 * 5px) / 7), 84px);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--navy); color: var(--text); }
body {
  font-family: var(--body); font-size: 16px; line-height: 1.4;
  min-height: 100vh; min-height: 100dvh; overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
  background: var(--navy);
}
button { font: inherit; color: inherit; cursor: pointer; }
.hidden { display: none !important; }
#app { margin: 0 auto; padding: 0 12px 12px; }

/* top bar: game name + one line of context (all controls live in the dock at the bottom) */
.bar { position: relative; z-index: 20; display: flex; align-items: center; gap: 8px; min-height: 56px; margin: 0 -12px; padding: 8px 16px; background: var(--navy); border-bottom: 1px solid rgba(255,255,255,.07); }
.bar::after { content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--grad); opacity: .7; }
.bar-t { display: flex; align-items: baseline; gap: 14px; min-width: 0; }
.bar-title { margin: 0; font-family: var(--head); font-size: 24px; font-weight: 800; white-space: nowrap; }
.ctx { margin: 0; color: var(--muted); font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.ctx:empty { display: none; }

/* buttons */
.btn { border: 0; border-radius: 14px; min-height: 48px; padding: 0 20px; font-weight: 800; font-size: 16px; }
.btn-primary { background: var(--grad); color: #fff; box-shadow: 0 6px 20px rgba(240,79,168,.3); }
.btn-teal { background: var(--teal); color: #0b2b29; }
.btn-ghost { background: var(--navy-3); color: var(--text); border: 1px solid var(--line); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .4; cursor: default; }
.btn-wide { width: 100%; margin: 10px 0 0; min-height: 54px; font-size: 17px; }
.link { background: none; border: 0; color: var(--teal); font-weight: 700; text-decoration: none; min-height: 44px; padding: 0 6px; display: inline-flex; align-items: center; }

/* menu */
.hero { text-align: center; padding: 22px 0 6px; }
.hero-board { width: 220px; margin: 0 auto 14px; display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; padding: 9px; border-radius: 40px; background: linear-gradient(180deg, var(--wood-1), var(--wood-2)); box-shadow: inset 0 2px 0 rgba(255,255,255,.18), 0 10px 26px rgba(0,0,0,.4); }
.hero-board span { aspect-ratio: 1; border-radius: 50%; background: radial-gradient(circle at 50% 35%, #2a1408, var(--pit)); box-shadow: inset 0 3px 5px rgba(0,0,0,.6); position: relative; }
.hero-board span::after { content: ''; position: absolute; inset: 32%; border-radius: 50%; background: var(--orange); opacity: .9; animation: seedpop 3.6s infinite; }
.hero-board span:nth-child(3n)::after { background: var(--pink); animation-delay: .4s; }
.hero-board span:nth-child(3n+1)::after { background: var(--teal); animation-delay: .9s; }
.hero-board span:nth-child(4n)::after { background: var(--purple); animation-delay: 1.5s; }
@keyframes seedpop { 0%, 70%, 100% { transform: scale(1); } 80% { transform: scale(1.35); } }
.hero-title { font-family: var(--head); font-size: 38px; line-height: 1.05; margin: 0; font-weight: 800; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero-sub { color: var(--muted); margin: 8px auto 10px; max-width: 30em; }
.stars-pill { display: inline-flex; align-items: center; gap: 4px; min-height: 36px; padding: 0 14px; border-radius: 99px; background: var(--navy-3); border: 1px solid var(--line); font-size: 14px; color: var(--muted); cursor: pointer; }
.stars-pill b { color: #ffd166; }
.card { background: var(--navy-2); border: 1px solid var(--line); border-radius: 20px; padding: 14px 14px 16px; margin-top: 14px; }
.card-h { font-family: var(--head); font-size: 14px; letter-spacing: .6px; text-transform: uppercase; color: var(--muted); margin: 6px 2px 8px; font-weight: 700; }
.seg { display: grid; gap: 6px; margin-bottom: 8px; }
.seg-2 { grid-template-columns: 1fr 1fr; }
.seg-4 { grid-template-columns: repeat(4, 1fr); }
.seg button { min-height: 46px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--navy-3); font-weight: 700; padding: 6px 4px; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.15; }
.seg button small { font-weight: 600; color: var(--muted); font-size: 12px; margin-top: 2px; }
.seg button[aria-checked="true"] { border-color: var(--teal); background: rgba(47,212,200,.13); box-shadow: 0 0 0 1px var(--teal) inset; }
.seg-sm { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; }
.seg-sm button { min-height: 40px; padding: 0 12px; flex: none; font-size: 14px; }
.more { margin: 4px 0 8px; }
.more summary { min-height: 44px; display: flex; align-items: center; color: var(--teal); font-weight: 700; cursor: pointer; list-style: none; }
.more summary::-webkit-details-marker { display: none; }
.more summary::before { content: '+'; display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--teal); margin-right: 8px; font-size: 15px; }
.more[open] summary::before { content: '–'; }
.opt { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.opt > span { font-weight: 700; color: var(--muted); font-size: 14px; }
body.m-kalah .classic-only, body.m-classic .kalah-only { display: none; }
.menu-links { display: flex; justify-content: center; flex-wrap: wrap; gap: 4px 14px; margin-top: 12px; }
.fine { text-align: center; color: var(--muted); font-size: 13px; margin: 8px 0 0; }

/* game */
.haul.bump b { display: inline-block; animation: bump .5s; }
@keyframes bump { 40% { transform: scale(1.35); color: #ffd166; } }
.gp-p .haul b { font: 800 24px/1 var(--head); }
.chip.c0 { background: var(--orange); }
.chip.c1 { background: var(--purple); }
.gp-p.thinking .gp-av { animation: blink .5s infinite; }
@keyframes blink { 50% { opacity: .45; } }
.table { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; border-radius: 22px; }
.row-lab { margin: 0; font-weight: 800; font-size: 13px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.gp-btn.ghost { background: transparent; color: var(--text); border: 2px solid rgba(255,255,255,.18); box-shadow: none; }
.gp-btn.ghost:disabled { border-color: rgba(255,255,255,.08); background: transparent; }
#turnBox { flex-direction: column; align-items: stretch; }
.gp-act.controls { display: flex; flex-direction: row; gap: 10px; }
.gp-act.controls .gp-btn { flex: 1; }
.gp-moves li:nth-child(n+4) { display: none; }
.coach.gp-hint p { margin: 0; }
.board-wrap { position: relative; margin: 6px 0; }
.board { position: relative; display: grid; gap: 5px; padding: 8px; border-radius: calc(var(--pit-size) * .6); background: repeating-linear-gradient(95deg, rgba(255,255,255,.03) 0 6px, transparent 6px 15px), linear-gradient(180deg, var(--wood-1), var(--wood-2) 60%, var(--wood-3)); box-shadow: inset 0 2px 0 rgba(255,255,255,.2), inset 0 -3px 0 rgba(0,0,0,.25), 0 14px 30px rgba(0,0,0,.45); }
.board.classic { grid-template-columns: repeat(7, var(--pit-size)); justify-content: center; }
.board.kalah { --pit-size: min(calc((100vw - 32px - 16px - 7 * 5px) / 8), 76px); grid-template-columns: repeat(8, var(--pit-size)); justify-content: center; }
@media (min-width: 760px) { .board.classic { --pit-size: 84px; } .board.kalah { --pit-size: 76px; } }
.board .divider { grid-column: 1 / -1; height: 0; }
.board { --pit-h: var(--pit-size); }
@media (max-width: 560px) { .board { --pit-h: calc(var(--pit-size) * 1.5); } .board-wrap { margin: 16px 0; } }
.pit { position: relative; width: var(--pit-size); height: var(--pit-h); border-radius: 50% / 42%; border: 0; padding: 0; background: radial-gradient(circle at 50% 30%, #2b1509, var(--pit) 70%); box-shadow: inset 0 4px 8px rgba(0,0,0,.65), 0 1px 0 rgba(255,255,255,.12); overflow: visible; }
.pit .seeds { position: absolute; inset: 12%; border-radius: 50%; overflow: hidden; }
.pit .s { position: absolute; width: calc(var(--pit-size) * .17); height: calc(var(--pit-size) * .135); border-radius: 50%; box-shadow: inset -1px -1px 0 rgba(0,0,0,.3), inset 1px 1px 0 rgba(255,255,255,.35); transform: translate(-50%, -50%) rotate(var(--r, 0deg)); }
.pit .n { position: absolute; left: 50%; bottom: -3px; transform: translateX(-50%); min-width: 22px; height: 18px; padding: 0 5px; border-radius: 9px; background: rgba(20,23,33,.92); color: #fff; font-family: var(--head); font-weight: 800; font-size: 12px; line-height: 18px; text-align: center; pointer-events: none; border: 1px solid rgba(255,255,255,.12); }
.pit.zero .n { opacity: .45; }
.pit.store { height: calc(var(--pit-h) * 2 + 5px); border-radius: calc(var(--pit-size) / 2); grid-row: span 2; }
.pit.store .seeds { inset: 10% 14%; border-radius: calc(var(--pit-size) / 2.5); }

.pit.store::before { content: attr(data-label); position: absolute; top: 8px; left: 0; right: 0; text-align: center; font-size: 10px; font-weight: 800; letter-spacing: 0; color: rgba(255,255,255,.7); }
@media (max-width: 560px) { .pit.store::before { font-size: 9px; } }
@media (min-width: 760px) { .pit.store::before { font-size: 12.5px; top: 10px; } }
.pit.store .n { font-size: 14px; height: 22px; line-height: 22px; min-width: 28px; bottom: 4px; }
.pit.rest { background: repeating-linear-gradient(45deg, rgba(0,0,0,.25) 0 4px, transparent 4px 8px), radial-gradient(circle at 50% 30%, #3b2516, #2a170b 70%); opacity: .6; }
.pit.rest .n { display: none; }
.pit.rest::after { content: 'rest'; position: absolute; inset: 0; display: grid; place-items: center; font-size: 10px; font-weight: 800; color: rgba(255,255,255,.55); letter-spacing: .5px; }
.pit.playable { cursor: pointer; box-shadow: inset 0 4px 8px rgba(0,0,0,.65), 0 0 0 2.5px var(--teal), 0 0 14px rgba(47,212,200,.55); animation: glow 1.6s infinite; }
@keyframes glow { 50% { box-shadow: inset 0 4px 8px rgba(0,0,0,.65), 0 0 0 2.5px var(--teal), 0 0 4px rgba(47,212,200,.2); } }
.pit.hinted { box-shadow: inset 0 4px 8px rgba(0,0,0,.65), 0 0 0 3.5px #ffd166, 0 0 18px rgba(255,209,102,.8); animation: none; }
.pit.cur { box-shadow: inset 0 4px 8px rgba(0,0,0,.65), 0 0 0 3px #fff; }
.pit.pulse { animation: pulse .25s; }
@keyframes pulse { 50% { transform: scale(1.08); } }
.pit.mark-empty { box-shadow: inset 0 4px 8px rgba(0,0,0,.65), 0 0 0 3px rgba(255,255,255,.5); }
.pit.mark-cap { box-shadow: inset 0 4px 8px rgba(0,0,0,.65), 0 0 0 3.5px #ffd166, 0 0 20px rgba(255,209,102,.9); }
.pit.mark-pasu { box-shadow: inset 0 4px 8px rgba(0,0,0,.65), 0 0 0 3.5px var(--pink), 0 0 20px rgba(240,79,168,.9); }
.pit:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.toast { position: absolute; z-index: 5; pointer-events: none; font-family: var(--head); font-weight: 800; font-size: 15px; white-space: nowrap; padding: 3px 9px; border-radius: 99px; background: #fff; color: var(--navy); transform: translate(-50%, -50%); animation: rise 1.1s forwards; box-shadow: 0 4px 14px rgba(0,0,0,.35); }
.toast.pasu { background: var(--pink); color: #fff; }
.toast.cap { background: #ffd166; }
.toast.relay { background: var(--teal); color: #0b2b29; }
@keyframes rise { 0% { opacity: 0; transform: translate(-50%, -20%) scale(.7); } 15% { opacity: 1; transform: translate(-50%, -60%) scale(1.05); } 100% { opacity: 0; transform: translate(-50%, -180%) scale(1); } }
.hand { position: absolute; z-index: 6; width: 34px; height: 34px; margin: -17px 0 0 -17px; border-radius: 50%; background: #fff; color: var(--navy); display: grid; place-items: center; font-family: var(--head); font-weight: 800; font-size: 15px; box-shadow: 0 6px 16px rgba(0,0,0,.45); transition: left .12s ease-out, top .12s ease-out; pointer-events: none; }
.hand::before { content: ''; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid var(--teal); }

/* overlays */
.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(8,10,16,.72); display: grid; place-items: center; padding: 16px; animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.sheet { position: relative; width: 100%; max-width: 420px; max-height: calc(100dvh - 32px); overflow: auto; background: var(--navy-2); border: 1px solid var(--line); border-radius: 22px; padding: 22px 18px 18px; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.6); }
.sheet h2 { font-family: var(--head); font-size: 28px; margin: 4px 0 6px; }
.res-score { font-family: var(--head); font-size: 22px; margin: 0 0 6px; }
.res-score .c0 { color: var(--orange); } .res-score .c1 { color: #b493ff; }
.res-note { color: var(--muted); margin: 6px 0; }
.res-stars { font-size: 40px; letter-spacing: 6px; color: var(--navy-3); margin: 6px 0; }
.res-stars span.on { color: #ffd166; animation: starin .5s backwards; text-shadow: 0 0 16px rgba(255,209,102,.6); }
.res-stars span.on:nth-child(2) { animation-delay: .2s; } .res-stars span.on:nth-child(3) { animation-delay: .4s; }
@keyframes starin { from { transform: scale(0) rotate(-90deg); } }
.res-badges { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 8px 0; }
.sheet-btns { display: flex; gap: 8px; justify-content: center; margin-top: 14px; flex-wrap: wrap; }
.sheet-btns .btn { flex: 1; min-width: 120px; }
.badge { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px; border-radius: 99px; background: var(--navy-3); border: 1px solid var(--line); font-weight: 700; font-size: 14px; }
.badge-ico { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--grad); color: #fff; font-size: 14px; font-family: var(--head); font-weight: 800; flex: none; }
.badge-list { list-style: none; padding: 0; margin: 10px 0 0; text-align: left; display: grid; gap: 8px; }
.badge-list li { display: flex; gap: 12px; align-items: center; padding: 8px 10px; border-radius: 14px; background: var(--navy-3); }
.badge-list li.locked { opacity: .45; }
.badge-list li.locked .badge-ico { background: #3b4058; }
.badge-list b { display: block; }
.badge-list small { color: var(--muted); }
.confetti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; border-radius: 22px; }
.confetti i { position: absolute; top: -10px; width: 8px; height: 12px; border-radius: 2px; animation: fall 1.8s ease-in forwards; }
@keyframes fall { to { transform: translateY(420px) rotate(540deg); opacity: 0; } }

/* how to play */
.sheet-how { text-align: left; }
.sheet-how .seg { margin-bottom: 12px; justify-content: center; }
.slide h3 { font-family: var(--head); font-size: 22px; margin: 4px 0 8px; }
.slide p { margin: 6px 0; }
.mini { display: flex; gap: 4px; justify-content: center; margin: 12px 0 8px; padding: 6px; border-radius: 22px; background: linear-gradient(180deg, var(--wood-1), var(--wood-2)); width: max-content; max-width: 100%; margin-left: auto; margin-right: auto; }
.mini span { width: 30px; height: 30px; border-radius: 50%; background: var(--pit); box-shadow: inset 0 3px 5px rgba(0,0,0,.6); display: grid; place-items: center; font-family: var(--head); font-weight: 800; font-size: 13px; color: #fff; }
.mini span.h { box-shadow: inset 0 3px 5px rgba(0,0,0,.6), 0 0 0 2.5px var(--teal); }
.mini span.y { box-shadow: inset 0 3px 5px rgba(0,0,0,.6), 0 0 0 2.5px #ffd166; }
.mini span.p { box-shadow: inset 0 3px 5px rgba(0,0,0,.6), 0 0 0 2.5px var(--pink); }
.mini span.e { box-shadow: inset 0 3px 5px rgba(0,0,0,.6), 0 0 0 2px rgba(255,255,255,.5); }
.mini-cap { text-align: center; color: var(--muted); font-size: 13px; margin: 0 0 6px; }
.how-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 14px; }
.dots { display: flex; gap: 6px; }
.dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--navy-3); }
.dots i.on { background: var(--teal); }

@media (min-width: 700px) {
  .pit .n { font-size: 14px; height: 22px; line-height: 22px; min-width: 26px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
}

/* No text caret, no text selection, no tap flash anywhere in the game (mouse double-clicks and caret browsing included).
   The only real text box is the online table-code field, which keeps its caret. Keyboard focus rings stay (:focus-visible). */
html, body { caret-color: transparent; -webkit-tap-highlight-color: transparent; }
body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
input[type=text], input:not([type]), textarea, .kn-in { caret-color: auto; -webkit-user-select: text; user-select: text; }
button, [role=button], [role=radio], a, svg, canvas, img { -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
img, svg image { -webkit-user-drag: none; }

/* ---------- front door era: pointer only on things you can click, sheets above the front door ---------- */
html, body, body * { cursor: default; }
button:not(:disabled), button:not(:disabled) *, a[href], a[href] *, .pit.playable, .pit.playable * { cursor: pointer; }
.pit:disabled, .pit:disabled * { cursor: default; }
html.kl-open .overlay { z-index: 2147482950; }

/* ---------- Option A layout: the board on its table (left), side panel filling the rest, the dock at the bottom ---------- */
:root { --hdr: 56px; }
.overlay { padding-bottom: calc(16px + var(--kd-h, 0px)); }
.sheet { max-height: calc(100dvh - 32px - var(--kd-h, 0px)); }
#game:not(.hidden) { display: flex; flex-direction: column; gap: 10px; padding-top: 10px; }
.table { padding: 10px 0; }
@media (max-width: 899px) {
  #game:not(.hidden) { min-height: calc(100dvh - var(--hdr) - var(--kd-h, 0px) - 22px); justify-content: center; max-width: 620px; margin: 0 auto; }
  .bar { justify-content: center; }
  .bar-t { flex-direction: column; align-items: center; gap: 0; }
  .bar-title { font-size: 21px; }
  .ctx { font-size: 13px; }
  .row-lab { font-size: 11px; }
  .gp-turn { gap: 8px; }
  .gp-act.controls { gap: 8px; }
  .gp-act .gp-btn { min-height: 42px; padding: 0 14px; font-size: 15px; }
  .gp-turn .coach p { font-size: 14px; }
  .gp-players ul { grid-auto-flow: row; grid-template-columns: 1fr 1fr; }
  .gp-p .haul b { font-size: 18px; }
  .gp-players .gp-p { grid-template-columns: 18px minmax(0, 1fr) auto; grid-template-rows: auto; }
  .gp-players .gp-stat { grid-column: 3; grid-row: 1; }
}
@media (min-width: 900px) {
  :root { --hdr: 64px; }
  #app { padding: 0 28px; }
  .bar { min-height: 64px; margin: 0 -28px; padding: 8px 28px; }
  #game:not(.hidden) { display: grid; grid-template-columns: minmax(0, 1fr) clamp(380px, 36vw, 600px); column-gap: 28px; padding: 20px 0; height: calc(100dvh - var(--hdr) - var(--kd-h, 0px)); align-items: stretch; }
  .table { background: radial-gradient(120% 90% at 50% 40%, #222842, #1a1e30); border-radius: 22px; padding: 18px; min-height: 0; gap: 10px; }
  .row-lab { font-size: 14px; }
  .board.classic, .board.kalah { --pit-size: min(150px, calc((100vw - 56px - 28px - clamp(380px, 36vw, 600px) - 36px - 70px) / 7.4), calc((100dvh - var(--hdr) - var(--kd-h, 0px) - 40px - 36px - 110px) / 3.3)); --pit-h: min(calc(var(--pit-size) * 1.8), calc((100dvh - var(--hdr) - var(--kd-h, 0px) - 40px - 36px - 110px) / 2)); gap: 8px; padding: 12px; }
  .board.kalah { --pit-size: min(132px, calc((100vw - 56px - 28px - clamp(380px, 36vw, 600px) - 36px - 80px) / 8.4), calc((100dvh - var(--hdr) - var(--kd-h, 0px) - 40px - 36px - 110px) / 3.3)); }
  .pit .n { font-size: 16px; height: 26px; line-height: 26px; min-width: 32px; border-radius: 13px; bottom: -6px; }
  .pit.store .n { font-size: 18px; height: 30px; line-height: 30px; min-width: 38px; }
  .pit.store::before { font-size: 13px; top: 12px; }
  .hand { width: 44px; height: 44px; margin: -22px 0 0 -22px; font-size: 18px; }
  .toast { font-size: 18px; padding: 5px 12px; }
  .gp-side { height: 100%; min-height: 0; }
  .gp-grid { overflow: auto; }
  .gp-turn .coach p { font-size: 16px; }
}
