@font-face {
  font-family: Fraunces;
  src: url("/fonts/fraunces.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: Fraunces;
  src: url("/fonts/fraunces-italic.woff2") format("woff2");
  font-weight: 100 900;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: Outfit;
  src: url("/fonts/outfit.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --ink: #10181b;
  --panel: #1a2a2e;
  --panel-2: #24383d;
  --line: rgba(244, 236, 220, 0.14);
  --foam: #f4efe4;
  --muted: #b7c4bc;
  --lantern: #e4a15a;
  --lantern-2: #f0c48a;
  --coral: #e07a5f;
  --sea: #2f6d62;
  --light: #f0d9b5;
  --dark: #b58863;
  --serif: Fraunces, "Iowan Old Style", Palatino, "Palatino Linotype", serif;
  --sans: Outfit, "Avenir Next", "Segoe UI", sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100dvh;
  font-family: var(--sans);
  font-size: 1.02rem;
  line-height: 1.45;
  color: var(--foam);
  background:
    radial-gradient(920px 480px at -10% -20%, rgba(228, 161, 90, 0.18), transparent 55%),
    radial-gradient(820px 520px at 110% -10%, rgba(47, 109, 98, 0.5), transparent 48%),
    var(--ink);
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
img { max-width: 100%; }
::selection { background: var(--lantern); color: #1b140e; }
:focus-visible { outline: 2px solid var(--lantern-2); outline-offset: 3px; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.skip {
  position: absolute;
  left: 1rem;
  top: -4rem;
  background: var(--lantern);
  color: #1b140e;
  padding: 0.5rem 0.8rem;
  border-radius: 999px;
  z-index: 40;
}
.skip:focus { top: 0.6rem; }

.shell {
  width: min(1120px, calc(100% - 1.4rem));
  margin: 0 auto;
  padding: 0.4rem 0 calc(2.2rem + env(safe-area-inset-bottom));
}
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 8;
  padding: 0.7rem 0 0.85rem;
  background: linear-gradient(#10181b, rgba(16, 24, 27, 0.92) 72%, transparent);
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  color: inherit;
  text-decoration: none;
  font-family: var(--serif);
  font-size: 1.45rem;
  font-weight: 560;
  letter-spacing: -0.03em;
}
.mark { width: 1.7rem; height: 1.7rem; color: var(--lantern); display: grid; }
.mark svg { width: 100%; height: 100%; fill: currentColor; }
.top-actions { display: flex; align-items: center; gap: 0.55rem; }
.conn {
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.conn.on { color: #b7d7c4; }
.conn.off { color: #f0b0a2; }

h1, h2, .san, .brand {
  font-family: var(--serif);
}
fieldset { border: 0; margin: 0; padding: 0; min-inline-size: 0; }
.side h1 {
  font-size: clamp(2.1rem, 5vw, 3.2rem);
  line-height: 0.95;
  overflow-wrap: anywhere;
}
h1 {
  font-weight: 560;
  letter-spacing: -0.045em;
  line-height: 0.88;
  font-size: clamp(4rem, 12vw, 7.2rem);
  margin: 0.1rem 0 0.6rem;
}
h2 { font-weight: 560; letter-spacing: -0.03em; margin: 0; }
.lede, .note, .help, .site-foot { color: var(--muted); }
.lede {
  font-size: 1.15rem;
  max-width: 38rem;
  margin: 0 0 1.4rem;
}
.eyebrow {
  margin: 0.6rem 0 0;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 0.78rem;
  color: var(--lantern-2);
}
.frieze { display: flex; gap: 0.15rem; margin: 0.2rem 0 1.2rem; }
.frieze .piece { position: relative; inset: auto; width: clamp(2.6rem, 8vw, 3.5rem); height: clamp(2.6rem, 8vw, 3.5rem); animation: float 5.5s ease-in-out infinite; }
.frieze .piece:nth-child(2n) { animation-delay: -1.4s; }
.frieze .piece:nth-child(3n) { animation-delay: -2.6s; }
@keyframes float { 50% { transform: translateY(-7px); } }

.choice-grid { display: grid; gap: 0.85rem; }
.choice {
  text-align: left;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent 42%),
    var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 1.25rem 1.2rem 1.15rem;
  min-height: 11.5rem;
  display: grid;
  align-content: space-between;
  gap: 1.2rem;
  transition: border-color 160ms ease, transform 160ms ease;
}
.choice:hover { border-color: rgba(228, 161, 90, 0.75); transform: translateY(-2px); }
.choice h2 { font-size: 2rem; }
.choice p { margin: 0.35rem 0 0; color: var(--muted); }
.choice .go { color: var(--lantern-2); font-size: 0.95rem; }

.panel {
  width: min(42rem, 100%);
  margin: 0.4rem auto 0;
  background: rgba(26, 42, 46, 0.88);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 1.2rem 1.15rem 1.25rem;
}
.panel h1 { font-size: clamp(2.6rem, 7vw, 4.2rem); }
.back {
  background: none;
  border: 0;
  padding: 0;
  color: var(--lantern-2);
  margin-bottom: 0.4rem;
}
.field { display: grid; gap: 0.35rem; margin: 0.85rem 0; }
.field span, .legend { font-size: 0.92rem; color: var(--muted); }
input[type="text"] {
  width: 100%;
  font-size: 1rem;
  padding: 0.78rem 0.85rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.22);
}
.segmented, .diffs { display: grid; gap: 0.5rem; }
.segmented { grid-template-columns: repeat(3, 1fr); }
.diffs { grid-template-columns: 1fr; }
label.segment, label.diff {
  display: grid;
  gap: 0.15rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.7rem 0.75rem;
  background: rgba(0, 0, 0, 0.12);
}
label.segment { text-align: center; }
label.diff { grid-template-columns: auto 1fr; align-items: center; }
label.segment:has(input:checked), label.diff:has(input:checked) {
  border-color: var(--lantern);
  background: rgba(228, 161, 90, 0.12);
}
label input { accent-color: var(--lantern); }
.diff strong { display: block; }
.diff small { color: var(--muted); display: block; margin-top: 0.15rem; }
.meter { display: flex; gap: 0.2rem; margin-top: 0.35rem; }
.meter i { width: 0.7rem; height: 0.35rem; border-radius: 99px; background: rgba(244, 239, 228, 0.25); display: block; }
.meter i.on { background: var(--lantern); }
.form-error { color: #ffc2b6; min-height: 1.2rem; margin: 0.2rem 0 0.6rem; }
.note { font-size: 0.92rem; }

.btn {
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 0.72rem 1.05rem;
  background: transparent;
  line-height: 1.1;
}
.btn.primary { background: var(--lantern); color: #1b140e; font-weight: 650; }
.btn.primary:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.ghost { border-color: var(--line); }
.btn.danger { border-color: rgba(224, 122, 95, 0.7); color: #ffc3b6; }
.btn.block { width: 100%; }
.row-actions, .modal-actions, .result-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.action-bar { position: sticky; bottom: 0.35rem; z-index: 4; padding-top: 0.4rem; }

.layout { display: grid; gap: 1rem; align-items: start; }
.board-column { width: min(100%, 680px); justify-self: center; }
.board-frame {
  position: relative;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), transparent 28%),
    #3a271c;
  border-radius: 16px;
  padding: 0.7rem 0.7rem 0.45rem;
  box-shadow: 0 24px 50px rgba(0, 0, 0, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.16);
}
.board-grid {
  display: grid;
  grid-template-columns: 1.05rem 1fr;
  grid-template-rows: 1fr 1.05rem;
  gap: 0.15rem;
}
.ranks { grid-column: 1; grid-row: 1; display: grid; grid-template-rows: repeat(8, 1fr); }
.files { grid-column: 2; grid-row: 2; display: grid; grid-template-columns: repeat(8, 1fr); }
.ranks, .files { color: #f0e0c8; font-size: 0.72rem; }
.ranks span, .files span { display: grid; place-items: center; }
.squares {
  grid-column: 2;
  grid-row: 1;
  position: relative;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  aspect-ratio: 1;
  border-radius: 4px;
  overflow: hidden;
}
.square {
  position: relative;
  border: 0;
  padding: 0;
  background: transparent;
}
.square.light { background: var(--light); }
.square.dark { background: var(--dark); }
.square.last.light { background: #f3d48a; }
.square.last.dark { background: #d7a15d; }
.square.selected { box-shadow: inset 0 0 0 3px #f0c48a; }
.square.check { box-shadow: inset 0 0 0 3px #c44832; animation: checkpulse 1.3s ease-in-out infinite; }
@keyframes checkpulse { 50% { box-shadow: inset 0 0 0 4px #e07058; } }
.piece { position: absolute; inset: 3.5%; z-index: 1; pointer-events: none; }
.piece img { width: 100%; height: 100%; display: block; user-select: none; }
.piece.loose { position: absolute; z-index: 4; inset: auto; }
.hint { position: absolute; inset: 0; z-index: 2; pointer-events: none; display: grid; place-items: center; }
.hint::after {
  content: "";
  width: 30%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: rgba(32, 22, 14, 0.32);
}
.hint.capture::after {
  width: 86%;
  background: transparent;
  box-shadow: inset 0 0 0 0.28rem rgba(32, 22, 14, 0.38);
}

.player-bar {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-height: 3rem;
  margin: 0.35rem 0;
}
.avatar {
  width: 2.3rem;
  height: 2.3rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #23484a;
  font-family: var(--serif);
  flex: none;
}
.player-bar .meta { min-width: 0; }
.player-bar strong { display: block; }
.player-bar .sub { color: var(--muted); font-size: 0.86rem; }
.turn-dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--lantern);
  box-shadow: 0 0 0 4px rgba(228, 161, 90, 0.18);
  margin-left: auto;
  flex: none;
}
.captures { display: flex; flex-wrap: wrap; margin-left: auto; }
.captures .piece { position: relative; inset: auto; width: 1.15rem; height: 1.15rem; }
.thinking { color: var(--lantern-2); font-size: 0.86rem; margin-left: auto; }
.thinking i {
  display: inline-block;
  width: 0.28rem;
  height: 0.28rem;
  margin-left: 0.15rem;
  border-radius: 50%;
  background: currentColor;
  animation: blink 1s infinite;
}
.thinking i:nth-child(2) { animation-delay: 0.15s; }
.thinking i:nth-child(3) { animation-delay: 0.3s; }
@keyframes blink { 50% { opacity: 0.25; } }

.side {
  background: rgba(26, 42, 46, 0.75);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 0.95rem;
  display: grid;
  gap: 0.8rem;
}
.status-line { margin: 0; font-size: 1.15rem; }
.seats { display: grid; gap: 0.45rem; }
.seat {
  display: flex;
  gap: 0.7rem;
  align-items: center;
  padding: 0.55rem 0.6rem;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.16);
}
.seat .sub { color: var(--muted); font-size: 0.86rem; }
.banner {
  border-radius: 14px;
  padding: 0.75rem 0.8rem;
  background: rgba(228, 161, 90, 0.12);
  border: 1px solid rgba(228, 161, 90, 0.35);
}
.banner p { margin: 0 0 0.6rem; }
.move-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: min(42vh, 24rem);
  overflow: auto;
}
.move-row {
  display: grid;
  grid-template-columns: 2rem 1fr 1fr;
  gap: 0.35rem;
  padding: 0.22rem 0.3rem;
  align-items: baseline;
}
.move-row:nth-child(odd) { background: rgba(255, 255, 255, 0.03); }
.idx { color: var(--muted); font-size: 0.85rem; }
.san { font-size: 1.12rem; }
.san.now { color: var(--lantern-2); }
.result-token { padding: 0.45rem 0.3rem 0.1rem; color: var(--muted); }
.empty { color: var(--muted); margin: 0.2rem 0; }
.chat-log {
  max-height: 16rem;
  overflow: auto;
  display: grid;
  gap: 0.35rem;
  padding-right: 0.2rem;
}
.chat-line { margin: 0; }
.chat-line .who { color: var(--lantern-2); margin-right: 0.35rem; }
.chat-line.system { color: var(--muted); font-size: 0.92rem; }
.chat-form { display: flex; gap: 0.45rem; }
.chat-form input { flex: 1; }

.result-card {
  position: absolute;
  z-index: 6;
  left: 50%;
  top: 46%;
  width: min(22rem, calc(100% - 1.4rem));
  transform: translate(-50%, -50%);
  background: #f6efe2;
  color: #1c1612;
  border-radius: 18px;
  padding: 1.15rem 1.05rem 1rem;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.38);
  animation: rise 420ms ease both;
}
.result-card h2 { font-size: clamp(2.2rem, 6vw, 3rem); line-height: 0.92; margin: 0.1rem 0 0.35rem; }
.result-card p { margin: 0 0 0.85rem; color: #4d4338; }
.kicker {
  margin: 0;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.75rem;
  color: #8a5a32;
}
.result-card .btn.ghost { color: #1c1612; border-color: rgba(28, 22, 18, 0.28); }
@keyframes rise {
  from { opacity: 0; transform: translate(-50%, -42%) scale(0.96); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.modal-back {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(8, 12, 14, 0.66);
  display: grid;
  place-items: center;
  padding: 1rem;
}
.modal {
  width: min(26rem, 100%);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 1.1rem;
}
.modal h2 { font-size: 2rem; margin-bottom: 0.35rem; }
.modal p { margin-top: 0; color: var(--muted); }
.promo-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.4rem; margin-bottom: 0.8rem; }
.promo {
  display: grid;
  justify-items: center;
  gap: 0.15rem;
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.35rem 0.2rem 0.45rem;
}
.promo .piece { position: relative; inset: auto; width: 2.8rem; height: 2.8rem; }
.toasts {
  position: fixed;
  left: 50%;
  bottom: calc(1rem + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 35;
  display: grid;
  gap: 0.4rem;
  width: min(24rem, calc(100% - 1.5rem));
}
.toast {
  background: #f6efe2;
  color: #1c1612;
  border-radius: 12px;
  padding: 0.7rem 0.85rem;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.28);
}
.help { margin-top: 1.5rem; }
.help summary { cursor: pointer; color: var(--foam); }
.help li { margin: 0.3rem 0; }
.site-foot { margin-top: 1.6rem; font-size: 0.82rem; }
.site-foot a { color: var(--lantern-2); }

@media (min-width: 800px) {
  .choice-grid { grid-template-columns: 1fr 1fr; }
  .diffs { grid-template-columns: 1fr; }
}
@media (min-width: 980px) {
  .layout { grid-template-columns: minmax(280px, 680px) minmax(280px, 390px); }
  .board-column { width: min(100%, calc(100dvh - 8.5rem)); justify-self: start; }
  .lobby .side { position: sticky; top: 4.2rem; }
}
@media (max-width: 979px) {
  .lobby .side { order: -1; }
  .move-list { max-height: 16rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
