:root {
  color-scheme: dark;
  --bg: #0c1116;
  --panel: #141b22;
  --panel-2: #19222b;
  --line: #2b3946;
  --text: #f2f4ee;
  --muted: #aeb8bf;
  --dark-cell: #202a35;
  --light-cell: #e8e1d0;
  --red: #d13f45;
  --blue: #3d80df;
  --green: #35a46d;
  --gold: #e6b94a;
  --target: #55c581;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
select,
input {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  background:
    radial-gradient(circle at 25% 15%, rgba(64, 118, 132, 0.24), transparent 32rem),
    linear-gradient(145deg, #0c1116 0%, #11191f 54%, #0d1218 100%);
}

.board-stage {
  min-width: 0;
  display: grid;
  place-items: center;
  padding: clamp(12px, 2.5vw, 32px);
}

#board {
  width: min(92vmin, calc(100vw - 368px));
  height: min(92vmin, calc(100vw - 368px));
  max-width: 980px;
  max-height: 980px;
  min-width: 320px;
  min-height: 320px;
  display: block;
  cursor: pointer;
  touch-action: manipulation;
}

.side-panel {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 22px;
  border-left: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(20, 27, 34, 0.92);
  backdrop-filter: blur(18px);
}

.brand-bar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.76rem;
  text-transform: uppercase;
  font-weight: 700;
}

h1 {
  margin: 0;
  font-size: 1.4rem;
  line-height: 1.1;
  font-weight: 760;
}

.turn-badge {
  min-width: 64px;
  padding: 7px 10px;
  border-radius: 999px;
  text-align: center;
  font-size: 0.78rem;
  font-weight: 800;
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.turn-badge.red {
  color: #fff2f2;
  background: rgba(209, 63, 69, 0.28);
}

.turn-badge.blue {
  color: #eef5ff;
  background: rgba(61, 128, 223, 0.28);
}

.turn-badge.green {
  color: #edfff6;
  background: rgba(53, 164, 109, 0.28);
}

.status {
  min-height: 74px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.35;
}

.control-group {
  display: grid;
  gap: 8px;
}

label,
.panel-title,
.captured-grid span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 760;
  text-transform: uppercase;
}

select {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #101820;
}

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

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

button {
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #101820;
  color: var(--text);
  cursor: pointer;
  font-weight: 760;
}

button:hover:not(:disabled),
button:focus-visible {
  border-color: rgba(230, 185, 74, 0.75);
  outline: none;
}

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

.captured-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.captured-grid div {
  min-width: 0;
  min-height: 78px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(16, 24, 32, 0.72);
}

.captured-grid output {
  display: block;
  min-height: 32px;
  margin-top: 8px;
  font-size: 1rem;
  line-height: 1.3;
  word-break: break-word;
}

.move-log-panel {
  min-height: 0;
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 10px;
}

#move-log {
  min-height: 0;
  flex: 1;
  margin: 0;
  padding: 0 0 0 20px;
  overflow: auto;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.45;
}

#move-log li {
  padding: 6px 0;
}

dialog {
  width: min(340px, calc(100vw - 32px));
  padding: 18px;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 20px 70px rgba(0, 0, 0, 0.5);
}

dialog::backdrop {
  background: rgba(2, 5, 8, 0.62);
}

dialog h2 {
  margin: 0 0 14px;
  font-size: 1rem;
}

.promotion-options {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.promotion-options button {
  min-height: 56px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2rem;
  line-height: 1;
}

@media (max-width: 880px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(360px, 1fr) auto;
  }

  .side-panel {
    min-height: 0;
    border-left: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
  }

  #board {
    width: min(96vw, 72vh);
    height: min(96vw, 72vh);
    min-width: 300px;
    min-height: 300px;
  }

  .move-log-panel {
    max-height: 190px;
  }
}

@media (max-width: 520px) {
  .side-panel {
    padding: 16px;
    gap: 14px;
  }

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

  h1 {
    font-size: 1.18rem;
  }
}
