:root {
  color-scheme: dark;
  --ink: #f4efe4;
  --muted: #cfc6b4;
  --felt: #163026;
  --felt-2: #1e3a2c;
  --line: rgba(244, 239, 228, 0.16);
  --brass: #e2b657;
  --brass-ink: #2a2112;
  --danger: #f0d0c8;
  --ok: #b7e0c4;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
  --serif: "Iowan Old Style", Palatino, "Palatino Linotype", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-family: var(--sans);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(1200px 500px at 50% -10%, rgba(226, 182, 87, 0.16), transparent 55%),
    var(--felt);
  color: var(--ink);
}

body {
  padding:
    env(safe-area-inset-top)
    env(safe-area-inset-right)
    calc(1.25rem + env(safe-area-inset-bottom))
    env(safe-area-inset-left);
}

button, input, select { font: inherit; color: inherit; }

button { cursor: pointer; }

a { color: var(--brass); }

.shell { width: min(100% - 1.5rem, 58rem); margin: 0 auto; }

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 0 0.4rem;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  text-decoration: none;
  color: inherit;
}

.brand strong {
  font-family: var(--serif);
  font-size: 1.45rem;
  font-weight: 600;
  letter-spacing: -0.03em;
}

.brand span, .eyebrow {
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.nav { display: flex; gap: 0.5rem; }

.panel {
  background: rgba(20, 40, 32, 0.72);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 1rem;
}

h1 {
  font-family: var(--serif);
  font-size: clamp(2rem, 8vw, 3.2rem);
  line-height: 0.95;
  font-weight: 600;
  letter-spacing: -0.04em;
  margin: 0.2rem 0 0.6rem;
}

.lede { color: var(--muted); margin: 0 0 1rem; font-size: 1.02rem; }

label { display: block; font-size: 0.82rem; color: var(--muted); margin-bottom: 0.35rem; }

.field { margin-bottom: 0.85rem; }

input[type="text"], select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 48px;
  padding: 0.7rem 0.8rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.22);
  font-size: 16px;
}

.field, .side, .panel, .table-layout, .moves { min-width: 0; }

details.position { margin-top: 0.8rem; max-width: 100%; }
details.position summary { color: var(--muted); cursor: pointer; }
.fen {
  display: block;
  margin-top: 0.45rem;
  overflow-wrap: anywhere;
  word-break: break-all;
  font-size: 0.78rem;
  line-height: 1.35;
}
body { overflow-x: hidden; }

.choices { display: flex; gap: 0.4rem; flex-wrap: wrap; }

.choices label {
  margin: 0;
  color: var(--ink);
  min-height: 44px;
  padding: 0.55rem 0.8rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.choices input { accent-color: var(--brass); }

.btn {
  min-height: 48px;
  padding: 0.7rem 1rem;
  border-radius: 999px;
  border: 1px solid transparent;
  background: var(--brass);
  color: var(--brass-ink);
  font-weight: 650;
}

.btn.secondary, .btn.ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}

.btn.danger { background: transparent; color: var(--danger); border-color: rgba(240, 208, 200, 0.4); }

.btn.wide { width: 100%; }

.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.row { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.table-layout { display: grid; gap: 0.9rem; }

.board-frame {
  width: min(100%, 40rem);
  margin: 0 auto;
  touch-action: none;
}

#board { width: 100%; }

.status-line {
  min-height: 1.4rem;
  font-family: var(--serif);
  font-size: 1.25rem;
  margin: 0.2rem 0 0.6rem;
}

.seats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-bottom: 0.7rem;
}

.seat {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.55rem 0.7rem;
  min-height: 52px;
}

.seat.on { border-color: rgba(226, 182, 87, 0.7); }

.seat small { display: block; color: var(--muted); letter-spacing: 0.06em; text-transform: uppercase; font-size: 0.68rem; }

.banner {
  border-radius: 12px;
  padding: 0.7rem 0.8rem;
  background: rgba(226, 182, 87, 0.12);
  border: 1px solid rgba(226, 182, 87, 0.35);
  margin-bottom: 0.7rem;
}

.banner.error { background: rgba(140, 58, 50, 0.25); border-color: rgba(240, 208, 200, 0.4); }

.moves {
  display: grid;
  grid-template-columns: auto 1fr 1fr;
  gap: 0.25rem 0.6rem;
  max-height: 16rem;
  overflow: auto;
  font-variant-numeric: tabular-nums;
}

.moves span { padding: 0.15rem 0; }

.moves .num { color: var(--muted); }

.score { margin-top: 0.8rem; }

.meta { color: var(--muted); font-size: 0.88rem; }

.list { display: flex; flex-direction: column; gap: 0.6rem; }

.card-link {
  display: block;
  text-decoration: none;
  color: inherit;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.8rem;
  background: rgba(0, 0, 0, 0.15);
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 1.6rem;
  padding: 0 0.55rem;
  border-radius: 999px;
  background: rgba(244, 239, 228, 0.1);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.chip.yourturn { background: var(--brass); color: var(--brass-ink); }

.chip.finished { color: var(--muted); }

.footer {
  margin-top: 1.4rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.check { color: #f3c1b6; }

.cm-chessboard .markers .marker.marker-last {
  fill: #e2b657;
  opacity: 0.78;
}

.cm-chessboard .markers .marker.marker-last-frame {
  stroke: #f3d48a;
  stroke-width: 2.6px;
  opacity: 1;
  fill: none;
}

@media (min-width: 900px) {
  .table-layout { grid-template-columns: minmax(0, 40rem) minmax(16rem, 20rem); align-items: start; }
  .side { position: sticky; top: 0.6rem; }
}
