:root {
  --bg: #1d1a24; --panel: rgba(28, 23, 36, .9); --panel-solid: #241e2e; --line: rgba(255,255,255,.12);
  --text: #f6efe6; --muted: #b8aebf; --accent: #ff9a4a; --accent-2: #ffcf6b; --danger: #e5574d;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font: 15px/1.4 system-ui, -apple-system, Segoe UI, sans-serif; }
#app canvas { display: block; }
button { font: inherit; color: var(--text); background: rgba(255,255,255,.08); border: 1px solid var(--line); border-radius: 10px; padding: 7px 12px; cursor: pointer; }
button:hover { background: rgba(255,255,255,.16); }
button.primary { background: var(--accent); color: #2a1608; border-color: transparent; font-weight: 650; }
button.primary:hover { background: var(--accent-2); }
button.accent { border-color: var(--accent); color: var(--accent-2); }
button.danger { color: #ffb3ad; border-color: rgba(229,87,77,.5); }
button.active { background: var(--accent); color: #2a1608; }
input, select { font: inherit; color: var(--text); background: rgba(0,0,0,.3); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; }
input[type=color] { padding: 0; width: 38px; height: 30px; border: none; background: none; vertical-align: middle; }
label { display: block; margin: 8px 0; color: var(--muted); font-size: 13px; }
label input:not([type=color]), label select { display: block; width: 100%; margin-top: 4px; }
label.inline { display: inline-flex; align-items: center; gap: 6px; margin: 4px 10px 4px 0; }
.label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; margin: 14px 0 6px; }
.muted { color: var(--muted); } .small { font-size: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.center { justify-content: center; }
.row h2, .row h3 { flex: 1; margin: 0; }

#hud { position: fixed; top: 0; left: 0; right: 0; display: flex; gap: 6px; align-items: center; padding: 10px 14px; background: linear-gradient(rgba(20,16,28,.85), rgba(20,16,28,0)); flex-wrap: wrap; }
#hud .brand { font-weight: 800; letter-spacing: .02em; margin-right: 10px; font-size: 17px; }
#hud #roomName { color: var(--accent-2); font-weight: 600; }
#hud .spacer { flex: 1; }
#online { position: fixed; top: 58px; right: 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; font-size: 13px; max-width: 220px; }
#online b { color: var(--accent-2); }
#online div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#prompt { position: fixed; left: 50%; bottom: 120px; transform: translateX(-50%); background: var(--panel); border: 1px solid var(--accent); border-radius: 999px; padding: 8px 18px; font-weight: 600; pointer-events: none; }
#prompt kbd { background: var(--accent); color: #2a1608; border-radius: 6px; padding: 1px 7px; margin-right: 8px; font-family: inherit; }
#emotes { position: fixed; right: 14px; bottom: 14px; display: flex; gap: 6px; }
#emotes button { font-size: 20px; padding: 6px 10px; }
#chat { position: fixed; left: 14px; bottom: 36px; width: min(380px, calc(100vw - 28px)); }
#chatLog { max-height: 180px; overflow-y: auto; display: flex; flex-direction: column; gap: 3px; margin-bottom: 6px; font-size: 14px; text-shadow: 0 1px 3px #000; }
#chatLog .sys { color: var(--accent-2); font-style: italic; }
#chatLog b { color: var(--accent-2); }
#chatInput { width: 100%; background: var(--panel); }
#help { position: fixed; left: 14px; bottom: 10px; font-size: 12px; color: var(--muted); text-shadow: 0 1px 3px #000; }
#toast { position: fixed; top: 64px; left: 50%; transform: translateX(-50%); background: var(--panel-solid); border: 1px solid var(--accent); padding: 8px 16px; border-radius: 10px; }

.modal { position: fixed; inset: 0; background: rgba(10,8,14,.55); display: grid; place-items: center; z-index: 10; padding: 16px; }
.modal[hidden], [hidden] { display: none !important; }
.card { background: var(--panel-solid); border: 1px solid var(--line); border-radius: 18px; padding: 22px 24px; width: min(440px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.card h1 { margin: 0 0 4px; }
.x { padding: 4px 10px; }
.swatches, .chips { display: flex; gap: 6px; flex-wrap: wrap; }
.swatches button { width: 30px; height: 30px; border-radius: 50%; padding: 0; border: 2px solid transparent; }
.swatches button.on { border-color: #fff; box-shadow: 0 0 0 2px var(--accent); }
.chips button.on { background: var(--accent); color: #2a1608; }
#setupGo { width: 100%; margin-top: 18px; padding: 11px; }

#homesList { display: flex; flex-direction: column; gap: 8px; }
.home-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: rgba(255,255,255,.05); border-radius: 12px; }
.home-row div { flex: 1; } .home-row small { color: var(--muted); display: block; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #6bd16b; margin-right: 4px; }
#inviteLink { flex: 1; min-width: 0; }

#edit { position: fixed; top: 58px; left: 14px; width: 300px; max-height: calc(100vh - 120px); overflow-y: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; z-index: 5; }
#edit h3 { margin: 0; }
#palette { display: grid; grid-template-columns: repeat(2, 1fr); gap: 5px; }
#palette button { font-size: 13px; padding: 6px 8px; text-align: left; }
#editDone { width: 100%; margin-top: 12px; }
body.editing #chat, body.editing #help { display: none; }

.c4card { width: min(480px, 100%); }
.seats { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 10px 0; }
.seat { min-width: 150px; font-weight: 600; }
.seat.red { border-color: #e4413a; } .seat.yellow { border-color: #f2c230; }
.seat.turn { box-shadow: 0 0 0 3px var(--accent-2); }
#c4status { text-align: center; min-height: 22px; margin-bottom: 8px; font-weight: 600; color: var(--accent-2); }
#c4grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; background: #2552c4; padding: 10px; border-radius: 14px; margin-bottom: 12px; }
#c4grid .cell { aspect-ratio: 1; border-radius: 50%; background: #132c6e; cursor: pointer; transition: transform .1s; }
#c4grid .cell.p1 { background: #e4413a; } #c4grid .cell.p2 { background: #f2c230; }
#c4grid .cell.win { box-shadow: 0 0 0 3px #fff, 0 0 14px #fff; }
#c4grid.can .col-hover { filter: brightness(1.35); }

.pbwrap { display: flex; gap: 18px; align-items: stretch; max-height: calc(100vh - 32px); }
#pbCanvas { height: min(720px, calc(100vh - 40px)); aspect-ratio: 400/720; border-radius: 14px; border: 2px solid #4ef0ff55; box-shadow: 0 0 40px #b46bff55; background: #0d0824; }
.pbside { background: var(--panel-solid); border-radius: 16px; padding: 16px 18px; width: 220px; display: flex; flex-direction: column; }
.pbside h2 { margin: 0; color: #ffd84e; letter-spacing: .08em; }
#pbScore { font-size: 32px; font-weight: 800; font-variant-numeric: tabular-nums; }
#pbScores { margin: 0; padding-left: 22px; font-size: 13px; flex: 1; overflow: auto; }
#pbScores li span { color: var(--muted); }
.touch { display: none; gap: 6px; margin: 8px 0; } .touch button { flex: 1; padding: 14px 4px; }
#pbClose { margin-top: 8px; }
@media (pointer: coarse) { .touch { display: flex; } }
@media (max-width: 700px) {
  #help, #online { display: none; }
  .pbwrap { flex-direction: column; align-items: center; }
  #pbCanvas { height: min(560px, 62vh); }
  .pbside { width: 100%; max-width: 340px; }
  #pbScores, .pbside .small, .pbside h2 { display: none; }
  #edit { width: calc(100vw - 28px); max-height: 46vh; }
}

/* game table menu */
#tableGames { display: flex; flex-direction: column; gap: 10px; }
.tg { display: flex; gap: 12px; align-items: center; padding: 12px 14px; background: rgba(255,255,255,.05); border: 1px solid var(--line); border-radius: 14px; }
.tg .ico { font-size: 28px; width: 36px; text-align: center; }
.tg div { flex: 1; } .tg small { display: block; color: var(--muted); }
.tg .live { color: #7dff8a; font-weight: 600; }
.tg-clear { background: none; border: none; color: var(--muted); text-decoration: underline; padding: 4px 0; font-size: 13px; align-self: flex-start; }
/* full game over the world */
#gameFrame { position: fixed; inset: 0; z-index: 20; display: flex; flex-direction: column; background: #000; }
.gf-bar { display: flex; align-items: center; gap: 12px; padding: 6px 10px; background: var(--panel-solid); border-bottom: 1px solid var(--line); }
.gf-bar b { color: var(--accent-2); }
#gfFrame { flex: 1; border: 0; width: 100%; background: #111; }
