:root {
  --bg: #0b1220;
  --card: #111a2c;
  --text: #e5ecf7;
  --muted: #9fb1cd;
  --line: #263650;
  --primary: #22d3ee;
  --primary-strong: #06b6d4;
  --ok: #4ade80;
  --bad: #fb7185;
  --input-bg: #0d1628;
  --focus: #334155;
  --row-hover: #16243b;
  --progress-bg: #1c2940;
  --row-found-bg: #0f2920;
  --row-missed-bg: #2d1620;
  --hidden-name: #7f93b6;
}

body[data-theme="light"] {
  --bg: #f3f4f6;
  --card: #ffffff;
  --text: #111827;
  --muted: #4b5563;
  --line: #d1d5db;
  --primary: #0f766e;
  --primary-strong: #115e59;
  --ok: #166534;
  --bad: #b91c1c;
  --input-bg: #ffffff;
  --focus: #99f6e4;
  --row-hover: #f9fafb;
  --progress-bg: #e5e7eb;
  --row-found-bg: #f0fdf4;
  --row-missed-bg: #fef2f2;
  --hidden-name: #6b7280;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial,
    sans-serif;
}

.app-shell {
  width: min(1100px, 95vw);
  margin: 1rem auto;
  display: grid;
  gap: 0.9rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1rem;
}

h2 {
  margin: 0 0 0.8rem;
  font-size: 1rem;
}

.controls-grid {
  display: grid;
  grid-template-columns: 1.2fr auto 1.5fr auto 1fr;
  gap: 0.7rem;
  align-items: center;
}

label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.checkbox-line {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  white-space: nowrap;
}

.checkbox-line input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

input[type="number"],
input[type="text"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--text);
  padding: 0.62rem 0.75rem;
  font: inherit;
}

input[type="number"]:focus,
input[type="text"]:focus {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--primary);
}

button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  padding: 0.6rem 0.85rem;
  cursor: pointer;
}

button:hover:not(:disabled) {
  border-color: #3b4f73;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #04131d;
}

.primary:hover:not(:disabled) {
  background: var(--primary-strong);
  border-color: var(--primary-strong);
}

.ghost {
  background: color-mix(in srgb, var(--card) 72%, var(--line) 28%);
}

.button-row {
  margin-top: 0.7rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.mini-pill {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text);
}

.pool-preview {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
}

.status-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.status-value {
  margin: 0.2rem 0 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;
  font-size: clamp(1rem, 2vw, 1.3rem);
}

.is-warning .status-value {
  color: var(--bad);
}

.progress-track {
  margin: 0.7rem 0;
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: var(--progress-bg);
  overflow: hidden;
}

.progress-value {
  width: 0%;
  height: 100%;
  background: var(--primary);
  transition: width 180ms ease;
}

.guess-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.55rem;
}

.guess-dock {
  position: sticky;
  top: 0.55rem;
  z-index: 60;
  background: color-mix(in srgb, var(--card) 92%, var(--line) 8%);
  box-shadow: 0 8px 20px color-mix(in srgb, var(--bg) 78%, transparent);
}

.guess-dock-head {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
}

.guess-dock-stats {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  flex-wrap: wrap;
}

.guess-dock-stat {
  display: inline-flex;
  align-items: baseline;
  gap: 0.4rem;
}

.guess-dock-label {
  color: var(--muted);
  font-size: 0.8rem;
}

.guess-dock-score {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;
  font-size: 1rem;
}

.feedback {
  min-height: 1.2rem;
  margin: 0.5rem 0 0;
  font-size: 0.9rem;
  font-weight: 600;
}

.feedback.is-ok {
  color: var(--ok);
}

.feedback.is-bad {
  color: var(--bad);
}

.feedback.is-neutral {
  color: var(--muted);
}

.tip {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.players-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.6rem;
}

.player-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.55rem;
  background: color-mix(in srgb, var(--card) 86%, var(--line) 14%);
}

.player-row {
  margin: 0;
  display: flex;
  justify-content: space-between;
  gap: 0.55rem;
  padding: 0.18rem 0;
}

.player-k {
  color: var(--muted);
  font-size: 0.76rem;
}

.player-v {
  text-align: right;
  word-break: break-word;
  max-width: 68%;
}

.name-cell {
  font-weight: 700;
  word-break: break-word;
}

.name-hidden {
  color: var(--hidden-name);
  letter-spacing: 0.06em;
}

.name-found {
  color: var(--ok);
}

.name-missed {
  color: var(--bad);
}

.player-found {
  background: var(--row-found-bg);
}

.player-missed {
  background: var(--row-missed-bg);
}

.theme-switch {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.theme-switch-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 30%, transparent);
  flex-shrink: 0;
}

.theme-switch.is-animating .theme-switch-dot {
  animation: theme-dot-pop 380ms ease;
}

.theme-switch::after {
  content: "";
  position: absolute;
  inset: -140%;
  background: radial-gradient(circle, color-mix(in srgb, var(--primary) 30%, transparent) 0%, transparent 56%);
  opacity: 0;
  transform: scale(0.65);
  pointer-events: none;
}

.theme-switch.is-animating::after {
  animation: theme-ring 420ms ease;
}

.empty-row {
  text-align: center;
  color: var(--muted);
  padding: 0.9rem;
}

.meta {
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
}

@media (max-width: 920px) {
  .controls-grid {
    grid-template-columns: 1fr 1fr;
    align-items: end;
  }

  .players-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 600px) {
  .app-shell {
    width: min(96vw, 740px);
  }

  .status-grid {
    grid-template-columns: 1fr;
  }

  .guess-form {
    grid-template-columns: 1fr;
  }

  .players-grid {
    grid-template-columns: 1fr;
  }
}

@keyframes theme-dot-pop {
  0% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.4);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes theme-ring {
  0% {
    opacity: 0.55;
    transform: scale(0.4);
  }
  100% {
    opacity: 0;
    transform: scale(1);
  }
}
