:root {
  --bg: #161a22;
  --panel: #1c212c;
  --panel-2: #262d3b;
  --text: #ff2bd6; /* Tron-style neon pink, as is the accent */
  --muted: #9aa0ad;
  --accent: #ff2bd6;
  --good: #4fd18b;
  --bad: #ef5d5d;
  --light-sq: #dfe5f2;
  --dark-sq: #6f7d9c;
  --white-piece: #00e8f0;
  --black-piece: #3d8bff;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 14px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif; }
button, input, select { font: inherit; color: inherit; }
button { background: var(--panel-2); border: 1px solid #3a3f50; border-radius: 6px; padding: 6px 10px; cursor: pointer; }
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); color: #1b1e27; border-color: var(--accent); font-weight: 600; }
button.link { background: none; border: none; color: var(--muted); padding: 4px 0; text-decoration: underline; }
input, select { background: #0f1117; border: 1px solid #3a3f50; border-radius: 6px; padding: 6px 8px; min-width: 0; }

#app { display: flex; height: calc(100% - var(--dock-h, 0px)); }
#stage { position: relative; flex: 1; min-width: 0; }
#view { display: block; width: 100%; height: 100%; touch-action: none; }
#hud { position: absolute; top: 12px; left: 12px; right: 12px; pointer-events: none; display: flex; justify-content: space-between; gap: 12px; }
#turn-banner { background: rgba(20,22,30,.8); padding: 6px 12px; border-radius: 6px; font-weight: 600; }
#hover-label { background: rgba(20,22,30,.8); padding: 6px 12px; border-radius: 6px; font-family: ui-monospace, monospace; }
#hover-label:empty { display: none; }
#zoom-ctrls { position: absolute; top: 56px; right: 12px; display: flex; flex-direction: column; gap: 4px; }
#zoom-ctrls button { width: 34px; height: 34px; padding: 0; font-size: 20px; line-height: 1; background: rgba(28,33,44,.9); }
#help-tip { position: absolute; bottom: 8px; left: 140px; right: 12px; text-align: right; color: var(--muted); font-size: 12px; pointer-events: none; }
kbd { border: 1px solid #555; border-radius: 3px; padding: 0 4px; font-size: 11px; }

#panel { width: 320px; flex: none; background: var(--panel); overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 14px; border-left: 1px solid #2c3040; }
#panel h1 { margin: 0; font-size: 20px; }
#panel h1 span { color: var(--accent); font-weight: 500; }
#panel h2 { margin: 0 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
section { display: flex; flex-direction: column; gap: 8px; }
.tabs { display: flex; gap: 4px; }
.tabs button { flex: 1; }
.tabs button.active { background: var(--accent); color: #1b1e27; border-color: var(--accent); }
#online-box, #online-setup, #online-room { display: flex; flex-direction: column; gap: 8px; }
[hidden] { display: none !important; }
.join-row { display: flex; gap: 6px; }
.join-row input { flex: 1; }
#join-code { text-transform: uppercase; letter-spacing: .15em; }
#net-status { color: var(--muted); font-size: 13px; }
#status { font-size: 16px; font-weight: 600; }
#status.check { color: var(--bad); }
.captured { min-height: 20px; font-size: 18px; letter-spacing: 2px; }
#view-controls label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 13px; }
.row { display: flex; gap: 6px; }
.row button { flex: 1; }
#moves { margin: 0; padding-left: 28px; max-height: 180px; overflow-y: auto; font-family: ui-monospace, monospace; font-size: 12px; }
#moves li.w::marker { color: var(--text); }
#moves li.b { color: var(--muted); }
#actions { flex-direction: row; }
#actions button { flex: 1; }
#chat-log { max-height: 120px; overflow-y: auto; font-size: 13px; background: #0f1117; border-radius: 6px; padding: 6px 8px; min-height: 40px; }
#chat-log .me { color: var(--accent); }
#chat-form input { width: 100%; }
#rules { color: var(--muted); font-size: 13px; }
#rules summary { cursor: pointer; color: var(--text); }
#rules ul { padding-left: 18px; }

#levels-dock { position: fixed; left: 0; right: 0; bottom: 0; background: var(--panel); border-top: 1px solid #2c3040; }
#levels-toggle { position: absolute; top: -30px; left: 12px; border-bottom-left-radius: 0; border-bottom-right-radius: 0; padding: 4px 10px; font-size: 12px; }
#levels { display: flex; gap: 10px; overflow-x: auto; padding: 8px 12px; }
#levels-dock.collapsed #levels { display: none; }
.level { flex: none; }
.level-title { font-size: 11px; color: var(--muted); text-align: center; cursor: pointer; margin-bottom: 2px; }
.level.focused .level-title { color: var(--accent); font-weight: 700; }
.level-grid { display: grid; grid-template-columns: repeat(8, 14px); grid-template-rows: repeat(8, 14px); border: 1px solid #3a3f50; }
.level.focused .level-grid { border-color: var(--accent); }
.cell { width: 14px; height: 14px; font-size: 12px; line-height: 14px; text-align: center; cursor: pointer; user-select: none; }
.cell.light { background: var(--light-sq); }
.cell.dark { background: var(--dark-sq); }
.cell.pw { color: var(--white-piece); text-shadow: 0 0 2px #000, 0 0 1px #000; }
.cell.pb { color: var(--black-piece); text-shadow: 0 0 2px #fff, 0 0 1px #fff; }
.cell.sel { outline: 2px solid var(--accent); outline-offset: -2px; }
.cell.last { box-shadow: inset 0 0 0 7px #ff2bd655; }
.cell.target { background: var(--good); box-shadow: inset 0 0 0 2px #0006; }
.cell.target.cap { background: var(--bad); }
.cell.target.preview { background: #7fb4ff; }
.cell.threat { background-image: radial-gradient(circle, #ff3366 0 3px, transparent 3.5px); }
.cell.incheck { background: var(--bad); }

dialog { background: var(--panel); color: var(--text); border: 1px solid #3a3f50; border-radius: 10px; }
dialog::backdrop { background: rgba(0,0,0,.5); }
.promo-choices { display: flex; gap: 8px; }
.promo-choices button { font-size: 16px; }

@media (max-width: 800px) {
  #app { flex-direction: column; height: auto; }
  #stage { height: 60vh; flex: none; }
  #panel { width: auto; border-left: none; padding-bottom: 180px; }
  #help-tip { display: none; }
}

#rules-box label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 13px; }
#rules-box label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); }
#rules-box select:disabled, #rules-box input:disabled { opacity: .55; }
#rules-note { color: var(--muted); font-size: 12px; }
#facing-picker { position: absolute; top: 56px; left: 12px; width: min(250px, calc(100% - 24px)); background: rgba(28,33,44,.92); border: 1px solid var(--accent); border-radius: 8px; padding: 7px 9px; display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
#facing-picker button { padding: 4px 9px; font-size: 13px; }
.fp-title { font-weight: 700; }
.fp-hint { color: var(--muted); font-size: 12px; }
.fp-hint .legend { display: block; }
.fp-group { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-top: 2px; }
.fp-grid { display: flex; flex-wrap: wrap; gap: 4px; }
.fp-grid button { font-family: ui-monospace, monospace; font-size: 12px; padding: 4px 7px; min-width: 48px; }
.fp-grid button.current { border-color: var(--accent); color: var(--accent); }
.fp-grid button.active { background: var(--accent); color: #1b1e27; }

.muted { color: var(--muted); font-size: 12px; }
button.wide { width: 100%; }
#account-box { background: var(--panel-2); border-radius: 8px; padding: 10px; }
.guest-note { margin: 0 0 6px; color: var(--muted); font-size: 13px; }
.acct-row { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.acct-actions { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.acct-item { display: flex; justify-content: space-between; align-items: center; gap: 6px; padding: 6px 0; border-top: 1px solid #333a4d; font-size: 13px; }
.acct-item.my-turn b { color: var(--accent); }
.acct-item span { display: flex; gap: 4px; }
#acct-game { background: var(--panel-2); border-radius: 8px; padding: 8px 10px; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
#clocks { display: flex; flex-direction: column; gap: 4px; }
.clock { background: rgba(20,22,30,.85); padding: 4px 12px; border-radius: 6px; font-family: ui-monospace, monospace; font-size: 18px; min-width: 150px; display: flex; justify-content: space-between; border: 1px solid transparent; }
.clock .who { font-family: system-ui, sans-serif; font-size: 12px; color: var(--muted); align-self: center; }
.clock.running { border-color: var(--accent); }
.clock.low .t { color: var(--bad); }
#hud { align-items: flex-start; }
#review-bar { position: absolute; bottom: 34px; left: 50%; transform: translateX(-50%); background: rgba(28,33,44,.95); border: 1px solid var(--accent); border-radius: 10px; padding: 8px 12px; display: flex; flex-direction: column; gap: 6px; align-items: center; max-width: calc(100% - 24px); }
#review-title { font-size: 13px; font-weight: 600; text-align: center; }
#rv-pos { font-family: ui-monospace, monospace; align-self: center; min-width: 70px; text-align: center; }
#toast { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); background: var(--panel-2); border: 1px solid var(--accent); padding: 8px 14px; border-radius: 8px; z-index: 50; max-width: 90vw; }
#tc-custom label { flex: 1; }
#tc-custom input { width: 100%; }
.wide-dialog { width: min(720px, calc(100vw - 32px)); max-height: 85vh; }
dialog h2 { margin: 0 0 8px; font-size: 18px; }
dialog label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 13px; margin: 8px 0; }
dialog input { width: 100%; }
.dlg-head { display: flex; justify-content: space-between; align-items: center; }
.auth-sec { border-top: 1px solid #333a4d; padding: 10px 0; display: flex; flex-direction: column; gap: 6px; }
.auth-label { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.provider-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 6px; }
.auth-msg { font-size: 13px; min-height: 1em; }
.auth-msg.ok { color: var(--good); }
.auth-msg.err { color: var(--bad); }
.pf-head h2 { margin: 0; }
.pf-tabs { margin: 10px 0; }
.stat-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin-bottom: 10px; }
.stat { background: var(--panel-2); border-radius: 8px; padding: 10px; }
.stat-v { font-size: 22px; font-weight: 700; }
.stat-l { font-size: 12px; color: var(--muted); }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.stat-table h3 { font-size: 13px; margin: 6px 0; }
.stat-table table { width: 100%; font-size: 13px; border-collapse: collapse; }
.stat-table td { padding: 2px 4px; border-top: 1px solid #333a4d; }
.stat-table td:last-child { text-align: right; color: var(--muted); }
.game-list { display: flex; flex-direction: column; }
.game-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 0; border-top: 1px solid #333a4d; }
.game-row span { display: flex; gap: 4px; flex: none; }

.fp-current { font-weight: 600; color: var(--accent); }
