/* Chess. Dark walnut room, one brass accent, one typeface. */
:root {
  --bg: #0e0c0b; --bg2: #161210; --card: #1b1714; --card2: #221d19; --line: rgba(255, 240, 220, 0.08); --line2: rgba(255, 240, 220, 0.14);
  --ink: #f2ebe2; --muted: #a39a90; --dim: #6f675f; --a: #e2a64b; --a2: #f3c47a; --bad: #e5574a; --good: #6cc489;
  --r: 14px; --font: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font: 15px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
body { overflow: hidden; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 1px solid var(--line2); background: var(--card2); border-radius: 10px; padding: 9px 14px; transition: background 0.15s, border-color 0.15s, transform 0.12s; }
button:hover:not(:disabled) { background: #2b2420; border-color: rgba(255, 240, 220, 0.22); }
button:active:not(:disabled) { transform: scale(0.97); }
button:disabled { opacity: 0.38; cursor: default; }
button.primary { background: var(--a); color: #1a1209; border-color: transparent; font-weight: 650; }
button.primary:hover:not(:disabled) { background: var(--a2); }
button.ghost { background: transparent; }
button.small { padding: 5px 10px; font-size: 13px; }
input { background: #120f0d; border: 1px solid var(--line2); border-radius: 10px; padding: 9px 12px; outline: none; min-width: 0; }
input:focus { border-color: var(--a); }
.k { text-transform: uppercase; letter-spacing: 0.12em; font-size: 11px; color: var(--muted); font-weight: 600; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }
#app { height: 100%; }
.screen { height: 100%; }

/* ------------------------------------------------------------------ home */
#home { overflow-y: auto; padding: clamp(18px, 4vw, 56px) clamp(16px, 4vw, 56px) 32px; max-width: 1180px; margin: 0 auto;
  background: radial-gradient(1200px 600px at 70% -10%, rgba(226, 166, 75, 0.09), transparent 60%); }
.brand { display: flex; gap: 18px; align-items: center; margin-bottom: 28px; }
.brand .logo { width: 64px; height: 64px; fill: var(--a); filter: drop-shadow(0 6px 18px rgba(226, 166, 75, 0.25)); }
.brand h1 { margin: 0; font-size: clamp(34px, 5vw, 52px); letter-spacing: -0.03em; line-height: 1; font-weight: 750; }
.brand p { margin: 6px 0 0; color: var(--muted); }
.resume { display: flex; gap: 14px; align-items: center; width: 100%; text-align: left; padding: 14px 18px; margin-bottom: 18px; border-radius: var(--r); background: linear-gradient(90deg, rgba(226, 166, 75, 0.14), rgba(226, 166, 75, 0.03)); border-color: rgba(226, 166, 75, 0.3); }
.resume .arrow { margin-left: auto; color: var(--a); font-size: 18px; }
.modes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.mode { background: linear-gradient(180deg, var(--card), #171310); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; display: flex; flex-direction: column; gap: 16px; box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25); }
.mode-h h2 { margin: 6px 0 0; font-size: 21px; letter-spacing: -0.01em; }
.tag { font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--a); font-weight: 650; }
.copy { margin: 0; color: var(--muted); }
.field { display: flex; flex-direction: column; gap: 8px; }
.field label { font-size: 12px; color: var(--muted); font-weight: 550; }
.mode .primary { margin-top: auto; padding: 12px; font-size: 16px; }
.seg { display: flex; background: #120f0d; border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 3px; }
.seg.wrap { flex-wrap: wrap; }
.seg button { flex: 1; border: 0; background: transparent; padding: 7px 8px; font-size: 13px; color: var(--muted); border-radius: 8px; white-space: nowrap; }
.seg button.on { background: var(--card2); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line2); }
.levels { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.levels button { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px; font-size: 12px; color: var(--muted); background: #120f0d; border-color: var(--line); }
.levels button svg { width: 26px; height: 26px; }
.levels button.on { color: var(--ink); border-color: var(--a); background: rgba(226, 166, 75, 0.1); }
.hintline { margin: 0; font-size: 13px; color: var(--muted); min-height: 1.4em; }
.join { display: flex; gap: 8px; }
.join input { flex: 1; text-transform: uppercase; letter-spacing: 0.16em; font-weight: 600; }
.foot { margin-top: 26px; color: var(--dim); font-size: 13px; text-align: center; }

/* ------------------------------------------------------------------ game */
#game { display: grid; grid-template-columns: minmax(0, 1fr) 340px;
  grid-template-rows: auto auto minmax(0, 1fr) auto auto auto;
  grid-template-areas: "stage top" "stage room" "stage moves" "stage chat" "stage actions" "stage bot";
  column-gap: 0; background: var(--bg); }
#game > .pbar#pTop { grid-area: top; } #game > .pbar#pBot { grid-area: bot; }
.stage { grid-area: stage; position: relative; min-height: 0; overflow: hidden;
  background: radial-gradient(80% 70% at 50% 45%, #1c1612, var(--bg)); }
.boardwrap { position: absolute; inset: 0; }
.bhost { position: absolute; inset: 0; }
.bhost canvas { display: block; }
#b2 { display: flex; align-items: center; justify-content: center; padding: 18px; }
#roomBox { grid-area: room; } .moves { grid-area: moves; } .actions { grid-area: actions; } .chat { grid-area: chat; }
#game > :not(.stage) { border-left: 1px solid var(--line); background: var(--bg2); }
.pbar { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-rows: auto auto; column-gap: 10px; align-items: center; padding: 14px 16px; }
.pbar .dot { grid-row: 1 / 3; width: 30px; height: 30px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18); position: relative; }
.pbar .dot.w { background: radial-gradient(circle at 35% 30%, #fffaf0, #d9cdb3); }
.pbar .dot.b { background: radial-gradient(circle at 35% 30%, #4b3f37, #120d0b); }
.pbar .dot.off::after { content: ''; position: absolute; right: -2px; bottom: -2px; width: 10px; height: 10px; border-radius: 50%; background: var(--bad); box-shadow: 0 0 0 2px var(--bg2); }
.pbar .dot.on::after { content: ''; position: absolute; right: -2px; bottom: -2px; width: 10px; height: 10px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 2px var(--bg2); }
.pbar .pname { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pbar .pname small { color: var(--muted); font-weight: 500; margin-left: 6px; }
.pbar .caps { grid-column: 2; display: flex; align-items: center; min-height: 18px; color: var(--muted); font-size: 12px; }
.pbar .caps svg { width: 17px; height: 17px; margin-right: -5px; }
.pbar .caps b { margin-left: 9px; font-weight: 600; color: var(--muted); }
.pbar .clock { grid-row: 1 / 3; grid-column: 3; font-variant-numeric: tabular-nums; font-size: 22px; font-weight: 650; padding: 5px 11px; border-radius: 9px; background: #120f0d; color: var(--muted); min-width: 86px; text-align: center; letter-spacing: 0.01em; }
.pbar .clock:empty { display: none; }
.pbar.turn .clock { background: var(--ink); color: #15110e; }
.pbar.turn .pname::before { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--a); margin-right: 8px; vertical-align: 2px; }
.pbar.low .clock { background: var(--bad); color: #fff; }
#pTop { border-bottom: 1px solid var(--line); } #pBot { border-top: 1px solid var(--line); }
.room { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.room b { letter-spacing: 0.14em; font-size: 16px; color: var(--a); }
.moves { overflow-y: auto; padding: 8px 10px; display: grid; grid-template-columns: 40px 1fr 1fr; align-content: start; font-variant-numeric: tabular-nums; font-size: 14px; }
.moves .n { color: var(--dim); padding: 4px 6px; }
.moves .m { padding: 4px 8px; border-radius: 6px; }
.moves .m.cur { background: rgba(226, 166, 75, 0.16); color: var(--a2); font-weight: 600; }
.moves .empty { grid-column: 1 / -1; color: var(--dim); padding: 10px 6px; font-size: 13px; }
.actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; padding: 10px 12px; border-top: 1px solid var(--line); }
.actions button { padding: 8px 4px; font-size: 13px; }
.actions button.lit { border-color: var(--a); color: var(--a2); }
.chat { border-top: 1px solid var(--line); padding: 8px 12px 10px; display: flex; flex-direction: column; gap: 6px; }
.chatlog { max-height: 110px; overflow-y: auto; font-size: 13px; display: flex; flex-direction: column; gap: 2px; }
.chatlog .c b { font-weight: 650; margin-right: 6px; }
.chatlog .c.sys { color: var(--dim); font-style: italic; }
.chat form { display: flex; gap: 6px; } .chat input { flex: 1; padding: 7px 10px; } .chat button { padding: 7px 12px; }

.banner { position: absolute; left: 50%; top: 18px; transform: translateX(-50%); background: rgba(20, 16, 13, 0.86); backdrop-filter: blur(8px); border: 1px solid var(--line2); border-radius: 999px; padding: 9px 16px; display: flex; align-items: center; gap: 12px; font-size: 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4); white-space: nowrap; max-width: calc(100% - 24px); z-index: 2; }
.banner button { padding: 4px 11px; font-size: 13px; border-radius: 999px; }
.banner .spin { width: 14px; height: 14px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.2); border-top-color: var(--a); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------------ 2D board */
.b2 { position: relative; width: min(100%, calc(100vh - 36px)); aspect-ratio: 1; max-height: 100%; border-radius: 6px; overflow: hidden; box-shadow: 0 0 0 8px #2c1a10, 0 0 0 9px #c9a25a55, 0 30px 70px rgba(0, 0, 0, 0.6); user-select: none; touch-action: none; }
.b2-sq { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr); }
.b2 .s { position: relative; }
.b2 .s.l { background: #e6cfa3; } .b2 .s.d { background: #8a5a37; }
.b2 .s span { position: absolute; font-size: clamp(8px, 1.5vmin, 12px); font-weight: 650; opacity: 0.8; }
.b2 .s.l span { color: #8a5a37; } .b2 .s.d span { color: #e6cfa3; }
.b2 .cf { right: 4px; bottom: 2px; } .b2 .cr { left: 4px; top: 2px; }
.b2-hl, .b2-pc { position: absolute; inset: 0; pointer-events: none; }
.b2 .h, .b2 .p { position: absolute; left: 0; top: 0; width: 12.5%; height: 12.5%; }
.b2 .p { transition: transform 0.2s cubic-bezier(0.3, 0.7, 0.3, 1), opacity 0.25s; will-change: transform; }
.b2 .p.nodur, .b2 .p.drag { transition: none; }
.b2 .p.drag { z-index: 5; filter: drop-shadow(0 10px 10px rgba(0, 0, 0, 0.45)); }
.b2 .p.gone { opacity: 0; }
.b2 .h.last { background: rgba(242, 184, 75, 0.4); }
.b2 .h.sel { background: rgba(255, 207, 107, 0.55); }
.b2 .h.hint { background: rgba(98, 182, 255, 0.42); }
.b2 .h.check { background: radial-gradient(circle, rgba(255, 60, 40, 0.95) 0%, rgba(220, 30, 20, 0.5) 45%, transparent 72%); }
.b2 .h.dot::after { content: ''; position: absolute; inset: 37%; border-radius: 50%; background: rgba(26, 18, 12, 0.38); }
.b2 .h.cap::after { content: ''; position: absolute; inset: 4%; border-radius: 50%; box-shadow: inset 0 0 0 5px rgba(26, 18, 12, 0.38); }
.pc { width: 100%; height: 100%; display: block; overflow: visible; }
.pc.pw { fill: #f7f0e3; stroke: #2a211c; stroke-width: 3.2; stroke-linejoin: round; filter: drop-shadow(0 2px 1.5px rgba(0, 0, 0, 0.35)); }
.pc.pb { fill: #2a221d; stroke: #0b0807; stroke-width: 3.2; stroke-linejoin: round; filter: drop-shadow(0 2px 1.5px rgba(0, 0, 0, 0.35)); }
.pc .d { fill: none; stroke-width: 2.6; } .pc.pb .d { stroke: #8c7a6b; }
.pc .e { stroke: none; } .pc.pw .e { fill: #2a211c; } .pc.pb .e { fill: #cdbba6; }

/* ------------------------------------------------------------------ sheets */
.sheet { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(6, 5, 4, 0.55); backdrop-filter: blur(3px); z-index: 20; padding: 16px; animation: fade 0.2s ease-out; }
.sheet .card { background: linear-gradient(180deg, #221c18, #18130f); border: 1px solid var(--line2); border-radius: 18px; padding: 26px; width: min(440px, 100%); box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6); text-align: center; animation: pop 0.28s cubic-bezier(0.2, 1.4, 0.4, 1); }
.sheet h3 { margin: 6px 0 4px; font-size: 30px; letter-spacing: -0.02em; }
.sheet .row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 20px; }
.promo { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 14px; }
.promo button { aspect-ratio: 1; padding: 8px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: scale(0.92); opacity: 0; } }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #2a231e; border: 1px solid var(--line2); padding: 10px 16px; border-radius: 12px; z-index: 30; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); font-size: 14px; max-width: calc(100% - 32px); }

/* ------------------------------------------------------------------ phone / narrow */
@media (max-width: 900px) {
  body { overflow: auto; }
  .modes { grid-template-columns: 1fr; }
  #game { height: auto; min-height: 100%; grid-template-columns: 1fr; grid-template-rows: auto auto auto auto auto auto auto;
    grid-template-areas: "top" "stage" "bot" "actions" "room" "chat" "moves"; align-content: start; }
  #game > :not(.stage) { border-left: 0; }
  .stage { height: min(100vw * 1.02, 72vh); }
  #b2 { padding: 12px; }
  .b2 { width: min(100%, 72vh - 24px); }
  .moves { max-height: 220px; grid-template-columns: 34px 1fr 1fr 34px 1fr 1fr; }
  .pbar { padding: 10px 14px; }
  .pbar .clock { font-size: 19px; min-width: 76px; }
  .actions { grid-template-columns: repeat(4, 1fr); }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
.stage::after { content: ''; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(120% 90% at 50% 45%, transparent 55%, rgba(0, 0, 0, 0.45)); }

/* ------------------------------------------------------------------ Honk Party login (sq-loader.js / hub sso.js)
   "Your name" or "Log in / Register" under the name field, restyled to the walnut room: brass hairline buttons,
   a recessed "playing as" plate. Gold (--sq-gold) stays reserved for verified account names. */
#home .sq-gate { gap: 10px; }
#home .sq-or { gap: 8px; font-size: 12px; opacity: 1; color: var(--dim); flex-wrap: nowrap; }
#home .sq-or > span { opacity: 1; }
#home .sq-or > span:first-child { flex: 1; display: flex; align-items: center; gap: 10px; text-transform: uppercase; letter-spacing: 0.12em; font-size: 10.5px; font-weight: 600; }
#home .sq-or > span:first-child::after { content: ''; flex: 1; height: 1px; background: var(--line2); }
#home .sq-or > span:nth-of-type(2) { display: none; }
#home .sq-btn { color: var(--a); border: 1px solid rgba(226, 166, 75, 0.35); border-radius: 8px; padding: 5px 11px; font-size: 12.5px; font-weight: 600; line-height: 1.2; letter-spacing: 0.01em; transition: background 0.15s, border-color 0.15s; }
#home .sq-btn:hover { background: rgba(226, 166, 75, 0.1); border-color: var(--a); filter: none; }
#home .sq-btn:focus-visible { outline: 2px solid var(--a); outline-offset: 2px; }
#home .sq-me { background: #120f0d; border: 1px solid var(--line2); border-left: 2px solid var(--sq-gold, #ffc53d); border-radius: 10px; padding: 9px 12px; gap: 10px; flex-wrap: nowrap; }
#home .sq-me small { opacity: 1; color: var(--muted); text-transform: uppercase; letter-spacing: 0.12em; font-size: 10.5px; font-weight: 600; white-space: nowrap; }
#home .sq-me .sq-verified { font-size: 15px; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
#home .sq-me .sq-btn { margin-left: auto; color: var(--muted); border-color: var(--line2); opacity: 1; padding: 4px 9px; font-size: 12px; font-weight: 500; white-space: nowrap; }
#home .sq-me .sq-btn:hover { color: var(--ink); background: #2b2420; }
.pbar .pname .sq-verified, .chatlog .sq-verified, .banner .sq-verified, .sheet .sq-verified { color: var(--sq-gold, #ffc53d) !important; }
@media (max-width: 380px) { #home .sq-me small { display: none; } }
.hintline a { color: #e2a64b; text-decoration: none; } .hintline a:hover { text-decoration: underline; }
