:root {
  --bg0: #1a1f18;
  --bg1: #242b20;
  --ink: #e8eadf;
  --muted: #9aa38c;
  --accent: #c4a35a;
  --accent-dim: #8a7340;
  --light: #e8dcc4;
  --dark: #6b8f5a;
  --last: rgba(196, 163, 90, 0.45);
  --select: rgba(255, 220, 100, 0.55);
  --check: rgba(200, 60, 50, 0.55);
  --hint: rgba(20, 20, 20, 0.35);
  --capture: rgba(200, 60, 50, 0.75);
  --panel: #2c3428;
  --danger: #c45a5a;
  --ok: #7aaf6a;
  --font-display: "Fraunces", "Palatino Linotype", Palatino, serif;
  --font-body: "Source Sans 3", "Segoe UI", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(ellipse at 20% 0%, #2e3a28 0%, transparent 50%),
    radial-gradient(ellipse at 90% 80%, #3a3020 0%, transparent 45%),
    var(--bg0);
  color: var(--ink);
  font-family: var(--font-body);
}

body {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.25rem 1rem 2.5rem;
}

h1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  letter-spacing: 0.02em;
  margin: 0 0 0.25rem;
  color: var(--accent);
}

.tagline {
  margin: 0 0 1.5rem;
  color: var(--muted);
  font-size: 0.95rem;
}

#app {
  width: min(100%, 520px);
}

.panel {
  background: color-mix(in srgb, var(--panel) 92%, black);
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.panel h2 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  margin: 0 0 0.75rem;
  font-weight: 550;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.75rem;
}

.row:last-child {
  margin-bottom: 0;
}

label {
  color: var(--muted);
  font-size: 0.9rem;
}

select {
  background: var(--bg1);
  color: var(--ink);
  border: 1px solid var(--accent-dim);
  border-radius: 6px;
  padding: 0.4rem 0.6rem;
  font: inherit;
}

button {
  font: inherit;
  cursor: pointer;
  border-radius: 8px;
  border: 1px solid var(--accent-dim);
  background: linear-gradient(180deg, #3a4434, #2a3226);
  color: var(--ink);
  padding: 0.55rem 0.9rem;
  transition: border-color 0.15s, transform 0.1s;
}

button:hover:not(:disabled) {
  border-color: var(--accent);
}

button:active:not(:disabled) {
  transform: translateY(1px);
}

button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

button.primary {
  background: linear-gradient(180deg, #5a4a28, #3d331c);
  border-color: var(--accent);
  color: #fff8e8;
}

button.danger {
  border-color: var(--danger);
  color: #ffd0d0;
}

.hint {
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.4;
  margin: 0.5rem 0 0;
}

.clocks {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.clock {
  background: var(--bg1);
  border-radius: 8px;
  padding: 0.65rem 0.85rem;
  border: 1px solid transparent;
  font-variant-numeric: tabular-nums;
}

.clock .label {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.clock .time {
  font-family: var(--font-display);
  font-size: 1.6rem;
}

.clock.active {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 40%, transparent);
}

.clock.to-move {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 40%, transparent);
}

.clocks.untimed .time {
  font-size: 1.75rem;
}

.clock.low .time {
  color: var(--danger);
}

#status {
  font-size: 1.05rem;
  min-height: 1.4em;
  margin: 0 0 0.25rem;
}

#wins,
#net-status {
  color: var(--muted);
  font-size: 0.88rem;
  min-height: 1.2em;
  margin: 0 0 0.5rem;
}

#board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  width: 100%;
  aspect-ratio: 1;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
  margin: 0.75rem 0 1rem;
  user-select: none;
}

.square {
  position: relative;
  border: none;
  border-radius: 0;
  padding: 0;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  font-size: clamp(1.5rem, 7vw, 2.6rem);
  line-height: 1;
  background: var(--light);
  color: #1a1a1a;
}

.square.dark {
  background: var(--dark);
}

.square.last-move {
  box-shadow: inset 0 0 0 999px var(--last);
}

.square.selected {
  box-shadow: inset 0 0 0 999px var(--select);
}

.square.check {
  box-shadow: inset 0 0 0 999px var(--check);
}

.square.move-hint::after {
  content: "";
  position: absolute;
  width: 28%;
  height: 28%;
  border-radius: 50%;
  background: var(--hint);
  pointer-events: none;
}

.square.capture-hint::after {
  content: "";
  position: absolute;
  inset: 6%;
  border-radius: 50%;
  border: 3px solid var(--capture);
  pointer-events: none;
}

.piece {
  pointer-events: none;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.25));
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

[hidden] {
  display: none !important;
}

#invite-box {
  margin-top: 0.75rem;
}

#invite-box input {
  flex: 1;
  min-width: 0;
  background: var(--bg0);
  border: 1px solid var(--accent-dim);
  border-radius: 6px;
  color: var(--ink);
  padding: 0.45rem 0.6rem;
  font-size: 0.8rem;
}

#promotion {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: grid;
  place-items: center;
  z-index: 20;
}

#promotion[hidden] {
  display: none;
}

#promotion .card {
  background: var(--panel);
  border: 1px solid var(--accent);
  border-radius: 12px;
  padding: 1rem 1.25rem;
  text-align: center;
}

#promo-choices {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  margin-top: 0.75rem;
}

#promo-choices button {
  font-size: 2rem;
  width: 3.2rem;
  height: 3.2rem;
  padding: 0;
}

footer {
  margin-top: 1.5rem;
  color: var(--muted);
  font-size: 0.8rem;
  text-align: center;
}
