:root {
  --bg: #f4f6f8; --col: #e9edf1; --card: #ffffff; --text: #1b2430; --muted: #5b6776;
  --accent: #1f6feb; --accent-hover: #1858c0; --border: #dbe1e8;
  --won: #16a34a; --won-bg: #e7f6ec; --lost: #dc2626; --lost-bg: #fdecec;
  --drop: #dbe7fd; --shadow: 0 1px 2px rgba(16, 24, 40, .08);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f141a; --col: #161d25; --card: #1d2630; --text: #e8edf2; --muted: #9aa7b5;
    --accent: #4c8dff; --accent-hover: #6aa0ff; --border: #2a3542;
    --won: #4ade80; --won-bg: #12301e; --lost: #f87171; --lost-bg: #3a1717;
    --drop: #1e3354; --shadow: none;
  }
}
:root[data-theme="dark"] {
  --bg: #0f141a; --col: #161d25; --card: #1d2630; --text: #e8edf2; --muted: #9aa7b5;
  --accent: #4c8dff; --accent-hover: #6aa0ff; --border: #2a3542;
  --won: #4ade80; --won-bg: #12301e; --lost: #f87171; --lost-bg: #3a1717;
  --drop: #1e3354; --shadow: none;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px;
}
button, select, input, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }

.btn {
  border: 1px solid var(--border); background: var(--card); border-radius: 8px;
  padding: 6px 10px; cursor: pointer; line-height: 1.2; white-space: nowrap;
}
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.won { color: var(--won); }
.btn.won:hover { background: var(--won-bg); border-color: var(--won); }
.btn.lost { color: var(--lost); }
.btn.lost:hover { background: var(--lost-bg); border-color: var(--lost); }
.btn:focus-visible, select:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

select, input[type="search"], textarea {
  border: 1px solid var(--border); background: var(--card); border-radius: 8px; padding: 6px 8px;
}

.state { max-width: 460px; margin: 15vh auto; padding: 0 16px; text-align: center; color: var(--muted); }
.state h2 { color: var(--text); }
.error { color: var(--lost); }

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 8px;
  max-width: calc(100% - 32px); z-index: 10;
}

dialog {
  border: 1px solid var(--border); border-radius: 12px; background: var(--card); color: var(--text);
  width: min(420px, calc(100% - 32px)); padding: 20px;
}
dialog::backdrop { background: rgba(0, 0, 0, .4); }
dialog h3 { margin: 0 0 4px; }
dialog p { margin: 0 0 12px; color: var(--muted); }
dialog textarea { width: 100%; min-height: 80px; resize: vertical; }
dialog .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }
