/* Khel ON Jigsaw — the "real table" look (option A, 19 Oct 2026) */
:root {
  --navy: #141721; --navy2: #1c2030; --navy3: #252a3d; --line: #333950;
  --ink: #f5f2ea; --muted: #a9aec2;
  --orange: #ff9a3c; --pink: #f04fa8; --purple: #8b5cf6; --teal: #2fd4c8; --gold: #ffcf4a;
  --grad: linear-gradient(90deg, #ff9a3c, #f04fa8 55%, #8b5cf6);
  --wood: repeating-linear-gradient(90deg, rgba(0,0,0,0) 0px, rgba(0,0,0,0) 196px, rgba(0,0,0,.26) 196px, rgba(0,0,0,.26) 198px),
          repeating-linear-gradient(176deg, rgba(255,255,255,.035) 0px, rgba(255,255,255,.035) 3px, rgba(0,0,0,.05) 3px, rgba(0,0,0,.05) 9px, rgba(0,0,0,0) 9px, rgba(0,0,0,0) 23px),
          linear-gradient(160deg, #94613b 0%, #7c4e2d 55%, #6b4226 100%);
  --top-h: 56px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--navy); color: var(--ink); }
body { font-family: Nunito, system-ui, sans-serif; font-size: 16px; line-height: 1.45; min-height: 100vh; overflow-x: hidden;
  cursor: default; -webkit-user-select: none; user-select: none; caret-color: transparent; -webkit-tap-highlight-color: transparent; }
html.playing, html.playing body { overflow: hidden; overscroll-behavior: none; height: 100%; }
h1, h2, h3, button { font-family: Outfit, Nunito, system-ui, sans-serif; }
button { cursor: pointer; font: inherit; font-family: Outfit, Nunito, system-ui, sans-serif; color: inherit; }
button:disabled { cursor: default; opacity: .5; }
[hidden] { display: none !important; }

/* header */
.top { display: flex; align-items: center; gap: 12px; height: var(--top-h); padding: 0 14px; border-bottom: 1px solid rgba(255,255,255,.08); position: sticky; top: 0; background: rgba(24,15,8,.94); z-index: 5; }
.top .home { display: flex; align-items: center; flex: none; }
.top .home img { display: block; height: 28px; width: auto; }
.top h1 { margin: 0; display: flex; flex-direction: column; min-width: 0; line-height: 1.05; }
.top h1 .jtitle { font-size: 20px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top h1 small { font-family: Nunito, sans-serif; font-size: 12px; font-weight: 700; color: #e6cfb3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud { flex: 1; display: flex; align-items: center; justify-content: center; gap: 12px; min-width: 0; }
.prog { width: min(240px, 26vw); height: 10px; border-radius: 99px; background: rgba(255,255,255,.18); overflow: hidden; }
.prog i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #ffb347, #ff9a3c); border-radius: 99px; transition: width .3s; }
.progtxt { font-weight: 800; font-size: 15px; white-space: nowrap; }
.timer { font-family: Outfit, sans-serif; font-weight: 700; font-size: 17px; font-variant-numeric: tabular-nums; }
.codechip { padding: 6px 12px; border-radius: 99px; border: 1.5px solid rgba(255,255,255,.22); background: transparent; color: #fff6ea; font-weight: 800; font-size: 14px; letter-spacing: .04em; white-space: nowrap; }
.codechip:hover { border-color: var(--teal); }
.tools { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.starcount { color: var(--gold); font-weight: 800; font-family: Outfit, sans-serif; white-space: nowrap; }
html.playing .tools { margin-left: 0; }
@media (max-width: 640px) {
  .top { gap: 8px; padding: 0 10px; }
  .top .home img { height: 24px; }
  .top h1 { flex: 0 1 auto; max-width: 30vw; }
  .top h1 .jtitle { font-size: 16px; }
  html.playing .top h1 small, html.playing .tools { display: none; }
  .prog { width: 70px; }
  .progtxt { font-size: 13px; }
  .codechip { padding: 5px 8px; font-size: 12px; }
  .timer { font-size: 15px; }
}
@media (max-width: 380px) { html.playing .top .home { display: none; } }

/* the table */
#play { position: fixed; left: 0; right: 0; top: var(--top-h); bottom: calc(var(--kd-h, 76px) + env(safe-area-inset-bottom, 0px)); }
#stage { position: absolute; inset: 0; overflow: hidden; background: var(--wood); touch-action: none; }
#world { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
#mat { position: absolute; left: 0; top: 0; width: 1500px; height: 1000px; border-radius: 6px; overflow: hidden;
  background: radial-gradient(ellipse at 50% 35%, #3d6555 0%, #2c4b3f 62%, #223a31 100%);
  box-shadow: inset 0 3px 16px rgba(0,0,0,.5), 0 0 0 10px rgba(0,0,0,.16), 0 26px 60px rgba(0,0,0,.35); }
#mat img { position: absolute; inset: 0; width: 100%; height: 100%; opacity: .2; pointer-events: none; }
#mat canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
#pieces { position: absolute; left: 0; top: 0; }
#pieces canvas { position: absolute; left: 0; top: 0; pointer-events: none; transform-origin: 0 0; }
#pieces canvas.lift { filter: drop-shadow(0 18px 14px rgba(0,0,0,.42)); }
#pieces canvas.snap { transition: transform .14s ease-out; }
#pieces canvas.glow { filter: drop-shadow(0 0 10px var(--gc)) drop-shadow(0 0 4px var(--gc)); }
#pieces canvas.hintme { animation: hint 1.4s ease-in-out 2; }
@keyframes hint { 50% { filter: drop-shadow(0 0 14px #fff6a8) drop-shadow(0 0 6px #fff6a8); } }

/* seat name chips, facing each player */
#chips { position: absolute; inset: 0; pointer-events: none; }
.chip { position: absolute; display: flex; align-items: center; gap: 8px; padding: 5px 14px 5px 6px; border-radius: 99px; background: rgba(20,12,6,.74); color: #fff6ea; font-weight: 800; font-size: 14px; white-space: nowrap; transform-origin: 50% 50%; }
.chip i { width: 22px; height: 22px; border-radius: 99px; flex: none; }
.chip.win { box-shadow: 0 0 0 3px #ffcf4a; }
@media (max-width: 640px) { .chip { font-size: 12px; padding: 3px 10px 3px 4px; } .chip i { width: 18px; height: 18px; } }

.zoomout { position: absolute; right: 12px; top: 12px; padding: 10px 16px; border-radius: 99px; border: 0; background: rgba(20,12,6,.8); color: #fff6ea; font-weight: 800; font-size: 14px; }
.coach { position: absolute; left: 50%; top: 12px; transform: translateX(-50%); width: min(560px, calc(100% - 24px)); padding: 14px 16px; border-radius: 18px; background: #fffaf1; color: #2a1a0e; box-shadow: 0 12px 30px rgba(0,0,0,.35); display: flex; gap: 12px; align-items: center; z-index: 3; }
.coach p { margin: 0; flex: 1; font-weight: 700; font-size: 16px; line-height: 1.4; }
.coach .ghost { color: #6b5340; border-color: #e2cfb6; }
.netnote { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); margin: 0; padding: 8px 16px; border-radius: 99px; background: rgba(20,12,6,.8); color: #fff6ea; font-weight: 800; font-size: 14px; white-space: nowrap; }

/* sheets */
.sheet { position: fixed; inset: 0; background: rgba(8,10,16,.72); display: flex; align-items: flex-end; justify-content: center; z-index: 950; padding: 10px; }
@media (min-width: 600px) { .sheet { align-items: center; } }
html.kl-open .sheet, html.ks-open .sheet { z-index: 2147482950; }
html.kl-open .toast, html.ks-open .toast { z-index: 2147482960; }
.cardui { width: 100%; max-width: 560px; max-height: calc(100dvh - 20px); overflow: auto; background: #fffaf1; color: #2a1a0e; border-radius: 24px; box-shadow: 0 24px 70px rgba(0,0,0,.5); }
.cbody { padding: 22px 22px 24px; }
.cbody h3 { margin: 0 0 8px; font-size: 28px; line-height: 1.1; }
.hint { color: #6b5340; font-size: 15px; margin: 10px 0 0; }
.row { display: flex; gap: 10px; margin-top: 14px; }
.row > * { flex: 1; }
.start { display: block; width: 100%; padding: 15px; border: 0; border-radius: 16px; background: #b84a17; color: #fff; font-size: 19px; font-weight: 800; box-shadow: 0 6px 18px rgba(184,74,23,.3); }
.start:hover { filter: brightness(1.06); }
.ghost { padding: 12px 14px; border-radius: 14px; border: 2px solid #e2cfb6; background: transparent; color: #2a1a0e; font-weight: 800; font-size: 15px; }
.ghost:hover { border-color: #b84a17; }
.ghost.small { padding: 8px 12px; font-size: 14px; flex: none; }
:focus-visible { outline: 3px solid #2fd4c8; outline-offset: 2px; }
.howlist { margin: 6px 0 0; padding-left: 22px; display: flex; flex-direction: column; gap: 10px; font-size: 16px; }
.howlist b { color: #8a3611; }
.badgelist { list-style: none; margin: 12px 0 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.badgelist li { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 14px; background: #f3e7d5; font-size: 14px; line-height: 1.3; }
.badgelist li .bi { font-size: 22px; flex: none; width: 34px; height: 34px; border-radius: 99px; display: flex; align-items: center; justify-content: center; background: #e2cfb6; color: #8a6a4a; font-family: Outfit, sans-serif; font-weight: 800; }
.badgelist li.got .bi { background: #ffcf4a; color: #5a3a00; }
.badgelist li:not(.got) { color: #8a7560; }
@media (max-width: 480px) { .badgelist { grid-template-columns: 1fr; } }

/* box lid */
.lidbox { display: flex; flex-direction: column; align-items: center; gap: 12px; max-width: min(900px, 100%); }
.lidbox img { width: min(900px, calc(100vw - 40px), calc((100dvh - 160px) * 1.5)); height: auto; border-radius: 10px; box-shadow: 0 0 0 8px #fffaf1, 0 30px 60px rgba(0,0,0,.5); background: #fffaf1; }
.lidbox p { margin: 6px 0 0; color: #fff; font-weight: 800; font-size: 17px; }
.lidbox .start { width: auto; padding: 12px 26px; }

/* finish */
.donecard { max-width: 640px; }
.donepic { padding: 16px 16px 0; }
.donepic canvas { display: block; width: 100%; height: auto; border-radius: 10px; box-shadow: 0 10px 26px rgba(0,0,0,.22); }
.kicker { margin: 0 0 4px; font-size: 13px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: #8a7560; }
.donesub { margin: 0; color: #6b5340; font-weight: 700; }
.donestars { margin: 8px 0 0; font-size: 26px; color: #e0a800; letter-spacing: 4px; }
.donestars small { font-size: 14px; color: #6b5340; letter-spacing: 0; font-weight: 700; margin-left: 6px; }
.donepl { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.donepl .pl { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 15px; }
.donepl .pl i { width: 22px; height: 22px; border-radius: 99px; flex: none; }
.donepl .pl .bar { flex: 1; height: 12px; border-radius: 99px; background: #f3e7d5; overflow: hidden; }
.donepl .pl .bar b { display: block; height: 100%; }
.donepl .pl span:last-child { min-width: 86px; text-align: right; color: #6b5340; font-weight: 700; font-size: 14px; }
#btnWho { margin-top: 10px; }
.row.three > * { padding-left: 8px; padding-right: 8px; }
@media (max-width: 480px) { .row.three { flex-wrap: wrap; } .row.three > * { flex: 1 1 40%; } }

/* code keypad */
.codecard { max-width: 440px; }
.slots { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 16px 0 6px; }
.slots .kh { font-family: Outfit, sans-serif; font-weight: 800; font-size: 30px; color: #8a7560; }
.slot { width: 50px; height: 62px; border-radius: 14px; background: #f3e7d5; display: flex; align-items: center; justify-content: center; font-family: Outfit, sans-serif; font-weight: 800; font-size: 32px; }
.slot.cur { box-shadow: inset 0 0 0 3px #b84a17; }
.err { min-height: 22px; margin: 0; text-align: center; color: #b42318; font-weight: 800; font-size: 14px; }
.keypad { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 6px; }
.keypad button { height: 56px; border-radius: 14px; border: 0; background: #f3e7d5; color: #2a1a0e; font-size: 24px; font-weight: 800; }
.keypad button:hover { background: #ead9c2; }

.toast { position: fixed; left: 50%; bottom: calc(var(--kd-h, 76px) + 24px); transform: translateX(-50%); z-index: 1200; max-width: min(640px, calc(100vw - 24px)); padding: 12px 20px; border-radius: 99px; background: #141721; color: #fff; font-weight: 800; font-size: 15px; box-shadow: 0 12px 30px rgba(0,0,0,.35); text-align: center; pointer-events: none; }

/* settings step: picture thumbnails */
#ks .ks-art-mini img { display: block; width: 100%; height: auto; aspect-ratio: 3 / 2; object-fit: cover; }
html.ks-open .toast { bottom: 24px; }
