/* Layout: a dark Khel ON desk under a warm lamp; the paper sheet is the only bright thing. */
:root {
  --desk: #141721;
  --desk-2: #1b1f2c;
  --panel: #20253a;
  --panel-2: #2a3049;
  --line: #363d5c;
  --ink: #f5f3ff;
  --muted: #a9abc6;
  --orange: #ff9a3c;
  --pink: #f04fa8;
  --violet: #8b5cf6;
  --teal: #2fd4c8;
  --paper: #fbf7ee;
  --paper-ink: #2f2a26;
  --lamp: rgba(255, 196, 120, 0.13);
  --scrim: rgba(8, 10, 18, 0.66);
  --display: "Outfit", "Trebuchet MS", system-ui, sans-serif;
  --body: "Nunito", "Segoe UI", system-ui, sans-serif;
  color-scheme: dark;
}
[hidden] { display: none !important; }
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; }
img { max-width: 100%; }
body { background: var(--desk); color: var(--ink); font-family: var(--body); font-size: 16px; -webkit-tap-highlight-color: transparent; }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--desk); }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
button:focus-visible, input:focus-visible, label:focus-within { outline: 3px solid var(--teal); outline-offset: 2px; border-radius: 10px; }
h1, h2, h3 { font-family: var(--display); text-wrap: balance; margin: 0; }
p { margin: 0; }

/* ---------- front door ---------- */
.home { max-width: 1180px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); padding-block: 14px 40px; display: flex; flex-direction: column; gap: 28px; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: baseline; gap: 2px; font-family: var(--display); font-weight: 800; font-size: 22px; letter-spacing: 0.01em; text-decoration: none; color: var(--ink); }
.brand img { display: block; height: 34px; width: auto; }
.brand .on { color: var(--orange); text-shadow: 0 0 14px rgba(255, 154, 60, 0.55); }
.top .tag { font-size: 13px; color: var(--muted); letter-spacing: 0.08em; text-transform: uppercase; font-weight: 700; }
.hero { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 28px; align-items: center; }
.hero h1 { font-size: clamp(36px, 6.4vw, 64px); font-weight: 800; line-height: 1.02; letter-spacing: -0.01em; }
.hero h1 em { font-style: normal; color: var(--orange); }
.hero p { color: var(--muted); font-size: 17px; line-height: 1.55; max-width: 34em; margin-top: 14px; }
.hero .facts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.chip { font-size: 13px; font-weight: 700; padding: 6px 11px; border-radius: 999px; background: var(--panel); color: var(--ink); border: 1px solid var(--line); }
.try { position: relative; aspect-ratio: 16 / 10; max-width: 100%; border-radius: 18px; overflow: hidden; background: radial-gradient(circle at 50% 40%, var(--lamp), transparent 70%), var(--desk-2); border: 1px solid var(--line); touch-action: none; }
.try .hint { z-index: 2; position: absolute; left: 22px; bottom: 18px; font-size: 13px; font-weight: 700; color: var(--paper-ink); background: rgba(251, 247, 238, 0.85); padding: 4px 10px; border-radius: 999px; pointer-events: none; transition: opacity .4s; }
.try .clear-try { z-index: 2; position: absolute; right: 20px; top: 18px; font-size: 12px; font-weight: 800; color: var(--paper-ink); background: rgba(251, 247, 238, 0.9); padding: 5px 10px; border-radius: 999px; }

.cont { display: flex; align-items: center; gap: 16px; padding: 12px; border-radius: 18px; background: var(--panel); border: 1px solid var(--line); text-align: left; width: 100%; }
.cont img { width: 84px; height: 84px; border-radius: 10px; background: var(--paper); object-fit: cover; flex: none; }
.cont .t { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cont .t b { font-family: var(--display); font-size: 20px; }
.cont .t span { color: var(--muted); font-size: 14px; }
.cont .go { margin-left: auto; flex: none; background: var(--orange); color: #1a1206; font-weight: 800; padding: 10px 18px; border-radius: 999px; font-family: var(--display); }

.shelf { display: flex; flex-direction: column; gap: 12px; }
.shelf-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.shelf-head h2 { font-size: 24px; font-weight: 800; }
.shelf-head span { color: var(--muted); font-size: 14px; }
.row { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(150px, 180px); gap: 14px; overflow-x: auto; padding-bottom: 8px; scroll-snap-type: x proximity; scrollbar-width: thin; }
.card { display: flex; flex-direction: column; gap: 8px; text-align: left; scroll-snap-align: start; }
.card .pic { position: relative; aspect-ratio: 1; width: 100%; border-radius: 12px; overflow: hidden; background: var(--paper); box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35); transition: transform .2s; }
.card .pic img { width: 100%; height: 100%; display: block; }
.card:hover .pic { transform: translateY(-3px) rotate(-0.6deg); }
.card b { font-size: 15px; font-weight: 800; }
.card small { color: var(--muted); font-size: 13px; margin-top: -6px; }
.card .dot { position: absolute; right: 8px; top: 8px; font-size: 11px; font-weight: 800; padding: 3px 8px; border-radius: 999px; background: var(--teal); color: #062522; }
.foot { color: var(--muted); font-size: 14px; border-top: 1px solid var(--line); padding-top: 18px; display: flex; flex-wrap: wrap; gap: 6px 18px; }

/* ---------- play ---------- */
#play { position: fixed; inset: 0; display: flex; flex-direction: column; background: var(--desk); padding-top: env(safe-area-inset-top, 0px); padding-left: env(safe-area-inset-left, 0px); padding-right: env(safe-area-inset-right, 0px); z-index: 5; }
.stage { flex: 1; min-height: 0; display: flex; gap: 10px; padding: 10px 10px 0; }
.stage.stack { flex-direction: column; }
.seat { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; gap: 8px; }
.seat.wide { flex-direction: row-reverse; }
.area { flex: 1; min-height: 0; min-width: 0; position: relative; border-radius: 16px; overflow: hidden; background: radial-gradient(ellipse at 50% 35%, var(--lamp), transparent 65%), var(--desk-2); }
.area .name { position: absolute; left: 12px; top: 10px; z-index: 2; font-family: var(--display); font-weight: 700; font-size: 14px; color: var(--muted); pointer-events: none; }
.board { position: absolute; inset: 0; touch-action: none; user-select: none; -webkit-user-select: none; cursor: crosshair; }
.sheet { position: absolute; left: 0; top: 0; transform-origin: 0 0; background-color: var(--paper); background-size: 42.6667% auto; box-shadow: 0 1px 0 rgba(255, 255, 255, 0.4) inset, 0 14px 40px rgba(0, 0, 0, 0.55), 0 2px 6px rgba(0, 0, 0, 0.4); border-radius: 3px; }
.sheet canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.sheet .lines { pointer-events: none; }

/* tray: tools, colours, settings */
.tray { flex: none; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 8px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.tray .bar { display: flex; align-items: center; gap: 4px; }
.tool { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; color: var(--muted); position: relative; flex: none; }
.tool svg { width: 29px; height: 29px; }
.tool[aria-pressed="true"] { background: var(--panel-2); color: var(--ink); box-shadow: inset 0 0 0 2px var(--orange); }
.tool .lbl { display: none; }
.ibtn { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; color: var(--ink); flex: none; }
.ibtn svg { width: 24px; height: 24px; }
.ibtn:disabled { opacity: 0.35; cursor: default; }
.ibtn[aria-expanded="true"] { background: var(--panel-2); }
.spacer { flex: 1; }
.swatches { display: flex; gap: 3px; overflow-x: auto; overflow-y: hidden; height: 66px; align-items: flex-end; padding: 10px 4px 0; scrollbar-width: none; }
.swatches::-webkit-scrollbar { display: none; }
.sw { flex: none; width: 22px; height: 58px; padding: 0; transform: translateY(8px); transition: transform .15s ease; }
.sw svg { width: 22px; height: 58px; display: block; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.35)); }
.sw[aria-pressed="true"] { transform: translateY(-4px); }
.sw.custom { display: grid; place-items: center; width: 34px; height: 46px; transform: none; border-radius: 10px; border: 2px dashed var(--line); color: var(--muted); position: relative; overflow: hidden; }
.sw.custom input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }
.more { display: none; flex-direction: column; gap: 12px; padding: 6px 4px 4px; }
.tray.open .more { display: flex; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field .top-l { display: flex; justify-content: space-between; font-size: 14px; font-weight: 700; }
.field .top-l span:last-child { color: var(--muted); font-weight: 600; }
.field input[type=range] { width: 100%; accent-color: var(--orange); height: 28px; }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 14px; font-weight: 700; cursor: pointer; }
.toggle small { display: block; color: var(--muted); font-weight: 600; font-size: 12px; }
.toggle input { appearance: none; width: 44px; height: 26px; border-radius: 99px; background: var(--line); position: relative; flex: none; cursor: pointer; transition: background .2s; }
.toggle input::after { content: ""; position: absolute; left: 3px; top: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--ink); transition: transform .2s; }
.toggle input:checked { background: var(--teal); }
.toggle input:checked::after { transform: translateX(18px); }
.textbtn { font-weight: 800; font-size: 14px; padding: 9px 12px; border-radius: 10px; background: var(--panel-2); text-align: center; }
.textbtn.warn { color: var(--pink); }

/* wide panel (tablet landscape, computer) */
.seat.wide .tray { width: 300px; overflow-y: auto; padding: 14px; gap: 12px; }
.seat.wide .tray .bar { flex-wrap: wrap; }
.seat.wide .tray .pname { display: block; }
.tray .pname { display: none; font-family: var(--display); font-weight: 800; font-size: 20px; }
.stage.two .tray .pname { display: block; font-size: 14px; color: var(--muted); padding: 0 4px; }
.seat.wide .tools4 { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; width: 100%; }
.seat.wide .tool { width: 100%; height: 64px; flex-direction: column; display: flex; align-items: center; justify-content: center; gap: 2px; }
.seat.wide .tool .lbl { display: block; font-size: 12px; font-weight: 700; }
.seat.wide .swatches { flex-wrap: wrap; height: auto; overflow: visible; row-gap: 0; padding-top: 12px; }
.seat.wide .more { display: flex; }
.seat.wide .moreb { display: none; }
.tools4 { display: flex; gap: 2px; }

/* dock (own one in the standalone build; the site uses the shared Khel ON dock) */
html.kd-on #play { bottom: calc(var(--kd-h) + env(safe-area-inset-bottom, 0px)); }
html.kd-on #dock { display: none; }
.dock { flex: none; display: flex; justify-content: center; gap: 0; padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px)); background: var(--desk); overflow-x: auto; scrollbar-width: none; }
.dock::-webkit-scrollbar { display: none; }
.dock button { display: flex; flex-direction: column; align-items: center; gap: 2px; flex: 1 1 0; min-width: 0; max-width: 92px; padding: 6px 2px; border-radius: 12px; color: var(--muted); font-size: 12px; font-weight: 700; line-height: 1.15; text-align: center; }
.dock button svg { width: 24px; height: 24px; color: var(--ink); }
.dock button:hover { background: var(--panel); color: var(--ink); }
.dock .stop svg { color: var(--pink); }

/* sheets (dialogs) */
.scrim { position: fixed; inset: 0; z-index: 1000; background: var(--scrim); display: flex; align-items: flex-end; justify-content: center; padding: 16px; padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px)); }
@media (min-width: 700px) { .scrim { align-items: center; } }
.box { width: 100%; max-width: 520px; max-height: 88%; overflow-y: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 22px; padding: 22px; display: flex; flex-direction: column; gap: 16px; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6); }
.box h3 { font-size: 24px; font-weight: 800; }
.box p { color: var(--muted); line-height: 1.5; }
.box ul { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; line-height: 1.45; }
.box li b { color: var(--ink); }
.btns { display: flex; flex-direction: column; gap: 10px; }
.btn { font-family: var(--display); font-weight: 700; font-size: 17px; padding: 14px 18px; border-radius: 14px; background: var(--panel-2); text-align: left; display: flex; align-items: center; gap: 12px; }
.btn small { display: block; font-family: var(--body); font-weight: 600; font-size: 13px; color: var(--muted); }
.btn.primary { background: var(--orange); color: #1a1206; }
.btn.primary small { color: #4a2e10; }
.btn svg { width: 26px; height: 26px; flex: none; }
.preview { width: 100%; max-width: 280px; aspect-ratio: 1; border-radius: 12px; background: var(--paper); align-self: center; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4); }
.result { width: 100%; border-radius: 12px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4); }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pair figure { margin: 0; display: flex; flex-direction: column; gap: 6px; align-items: center; font-weight: 700; font-size: 14px; }
.pair img { width: 100%; border-radius: 10px; }
.breathe { width: 140px; height: 140px; border-radius: 50%; align-self: center; background: radial-gradient(circle, var(--teal), transparent 70%); animation: breathe 9s ease-in-out infinite; opacity: .8; }
.breathe-t { text-align: center; font-family: var(--display); font-size: 18px; color: var(--ink) !important; }
@keyframes breathe { 0%, 100% { transform: scale(0.55); } 45%, 55% { transform: scale(1); } }
.toast { z-index: 1100 !important; position: fixed; left: 50%; top: calc(14px + env(safe-area-inset-top, 0px)); transform: translateX(-50%); z-index: 30; background: var(--ink); color: var(--desk); font-weight: 700; font-size: 14px; padding: 10px 16px; border-radius: 12px; max-width: min(440px, calc(100% - 32px)); text-align: center; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); }

@media (max-width: 760px) {
  .hero { grid-template-columns: minmax(0, 1fr); }
  .dock button { font-size: 10.5px; }
  .tray .bar { gap: 2px; }
  .tool { width: 40px; }
  .ibtn { width: 38px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* colouring with friends online: their sheets beside yours */
.friends { flex: none; width: 220px; display: flex; flex-direction: column; gap: 10px; overflow-y: auto; min-height: 0; scrollbar-width: thin; }
.fcard { display: flex; flex-direction: column; gap: 6px; padding: 8px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); text-align: left; transition: opacity .4s; }
.fcard canvas { width: 100%; aspect-ratio: 1; height: auto; border-radius: 6px; display: block; box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35); }
.fcard span { display: flex; flex-direction: column; min-width: 0; }
.fcard b { font-family: var(--display); font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fcard small { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fcard.away { opacity: .45; }
.fwait { display: flex; flex-direction: column; gap: 8px; padding: 14px; border-radius: 14px; border: 2px dashed var(--line); color: var(--muted); font-size: 14px; line-height: 1.4; }
.fwait b { color: var(--ink); font-family: var(--display); font-size: 16px; }
.pgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.pcell { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 700; text-align: center; }
.pcell img { width: 100%; aspect-ratio: 1; border-radius: 8px; background: var(--paper); }
.pcell.cur img { outline: 3px solid var(--orange); outline-offset: 2px; }
.stage.online { flex-direction: row; }
@media (max-width: 760px), (max-aspect-ratio: 1/1) {
  .stage.online { flex-direction: column; }
  .stage.online .friends { order: -1; width: auto; flex-direction: row; overflow-x: auto; overflow-y: hidden; height: 96px; gap: 8px; }
  .stage.online .fcard { flex: none; flex-direction: row; align-items: center; width: 168px; padding: 6px; }
  .stage.online .fcard canvas { width: 80px; flex: none; }
  .stage.online .fwait { flex-direction: row; align-items: center; flex-wrap: wrap; padding: 8px 12px; gap: 4px 10px; width: 100%; }
  .stage.online .fwait span { display: none; }
}
