:root {
  color-scheme: dark;
  --panel: rgba(18, 21, 28, .82);
  --fg: #e8ecf3;
  --accent: #5cff9a;
  --red: #e0493d;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: #15181f; color: var(--fg);
  font: 14px/1.4 system-ui, -apple-system, Segoe UI, sans-serif;
}
#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
#hud { position: fixed; inset: 0; pointer-events: none; }
#hud > * { pointer-events: auto; }
.hidden { display: none !important; }

#side-panel {
  position: absolute; top: 12px; left: 12px; width: 290px; max-height: calc(100% - 24px);
  display: flex; flex-direction: column; gap: 10px; padding: 12px;
  background: var(--panel); backdrop-filter: blur(10px); border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, .08);
}
#side-panel header { display: flex; justify-content: space-between; align-items: baseline; }
h1 { font-size: 18px; margin: 0; }
#home-link { color: inherit; text-decoration: none; margin-right: 6px; opacity: .8; }
#home-link:hover { opacity: 1; }
#turn-indicator { font-size: 12px; opacity: .8; }

.card { padding: 8px 10px; border-radius: 8px; background: rgba(255,255,255,.05); border-left: 4px solid transparent; }
#card-red { border-left-color: var(--red); }
#card-black { border-left-color: #8890a0; }
.card.active { background: rgba(92, 255, 154, .12); }
.card input.name { background: transparent; border: 0; color: inherit; font-weight: 600; font-size: 15px; width: 100%; outline: none; }
.card .stats { display: flex; flex-wrap: wrap; gap: 10px; font-size: 12px; opacity: .85; }
.card .thinking { display: none; color: var(--accent); }
.card.thinking .thinking { display: inline; }

#move-list { flex: 1; overflow: auto; margin: 0; padding: 0 0 0 30px; min-height: 90px;
  font: 12px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace; }
#move-list li span { cursor: pointer; padding: 0 4px; border-radius: 4px; display: inline-block; min-width: 110px; }
#move-list li span:hover, #move-list span.current { background: rgba(255,255,255,.12); }

.buttons { display: flex; flex-wrap: wrap; gap: 6px; }
button {
  background: rgba(255,255,255,.1); color: var(--fg); border: 1px solid rgba(255,255,255,.12);
  border-radius: 6px; padding: 6px 10px; cursor: pointer; font: inherit;
}
button:hover { background: rgba(255,255,255,.18); }
button:disabled { opacity: .4; cursor: default; }
button.active, button.primary { background: var(--accent); color: #0c1a12; border-color: transparent; }

#view-controls {
  position: absolute; right: 12px; bottom: 12px; display: flex; flex-direction: column; gap: 8px;
  padding: 10px 12px; background: var(--panel); border-radius: 12px; backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,.08);
}
#view-controls label { display: flex; align-items: center; gap: 8px; font-size: 12px; }
#view-controls select { background: rgba(255,255,255,.08); color: inherit; border: 1px solid rgba(255,255,255,.15); border-radius: 6px; padding: 3px 6px; }
/* Native dropdown lists inherit the translucent select background inconsistently,
   which rendered options white-on-white. Force an opaque dark list everywhere. */
select option, select optgroup { background-color: #1c2029; color: var(--fg); }
.seg { display: flex; gap: 4px; }
.hint { position: absolute; right: 12px; top: 12px; font-size: 12px; opacity: .55; }

#toast {
  position: absolute; left: 50%; bottom: 28px; transform: translateX(-50%);
  background: rgba(0,0,0,.78); padding: 8px 14px; border-radius: 20px; opacity: 0;
  transition: opacity .2s; font-size: 13px; pointer-events: none !important;
}
#toast.show { opacity: 1; }

.modal { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.45); }
.dialog {
  background: #1c2029; padding: 22px 26px; border-radius: 14px; min-width: 340px; max-width: 460px;
  border: 1px solid rgba(255,255,255,.1); box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.dialog h2 { margin: 0 0 12px; }
.dialog .row { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 8px 0; }
.dialog select, .dialog input[type=text], .dialog input[type=number] {
  background: rgba(255,255,255,.08); color: inherit; border: 1px solid rgba(255,255,255,.15); border-radius: 6px; padding: 5px 8px;
}
.dialog .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
fieldset { border: 1px solid rgba(255,255,255,.12); border-radius: 8px; margin: 8px 0; padding: 6px 12px; line-height: 1.8; }
legend { font-size: 12px; opacity: .7; }
/* Appearance dialog (themes + style settings) */
.style-dialog { max-height: calc(100vh - 40px); overflow: auto; min-width: 400px; }
.style-dialog fieldset { line-height: 1.4; }
.style-dialog label.row { margin: 4px 0; font-size: 13px; cursor: default; }
.style-dialog label.row > span:first-child { flex: 1; }
.style-dialog input[type=range] { width: 150px; }
.style-dialog input[type=color] {
   width: 44px; height: 24px; padding: 0; border: 1px solid rgba(255,255,255,.2); border-radius: 4px;
   background: transparent; cursor: pointer;
}
.style-dialog output { width: 36px; text-align: right; font-size: 11px; opacity: .7; font-variant-numeric: tabular-nums; }