/* JC ITLAB Chess Battle - page styles */

@font-face {
  font-family: "Lilita One";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../assets/fonts/lilita-one.woff2") format("woff2");
}
@font-face {
  font-family: "Outfit";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../assets/fonts/outfit.woff2") format("woff2");
}

:root {
  --ink: #16202e;
  --ink-soft: #556173;
  --ink-faint: #7d8796;
  --paper: #f6f1e7;
  --card: #fffdf8;
  --card-warm: #fbf6ec;
  --line: #e5dccb;
  --line-strong: #d6c9b2;
  --accent: #e8871e;
  --accent-deep: #b45f0b;
  --accent-soft: #fbe6c8;
  --teal: #0f766e;
  --teal-soft: #d9f0ec;
  --danger: #c73b46;
  --board-light: #f0d9b5;
  --board-dark: #b58863;
  --anim: 180ms;
  --font-display: "Lilita One", "Trebuchet MS", sans-serif;
  --font-ui: "Outfit", "Segoe UI", system-ui, -apple-system, sans-serif;
  --shadow-soft: 0 18px 50px rgba(41, 32, 20, 0.08);
  --shadow-card: 0 2px 0 rgba(255, 255, 255, 0.7) inset, 0 12px 30px rgba(41, 32, 20, 0.07);
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.45;
  background:
    radial-gradient(1200px 720px at 8% -12%, rgba(232, 135, 30, 0.17), transparent 62%),
    radial-gradient(900px 640px at 102% -4%, rgba(15, 118, 110, 0.14), transparent 58%),
    radial-gradient(900px 600px at 50% 110%, rgba(232, 135, 30, 0.07), transparent 60%),
    var(--paper);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    linear-gradient(rgba(22, 32, 46, 0.032) 1px, transparent 1px),
    linear-gradient(90deg, rgba(22, 32, 46, 0.032) 1px, transparent 1px);
  background-size: 36px 36px;
  mask-image: radial-gradient(ellipse 90% 70% at 50% 20%, #000 30%, transparent 75%);
}

main, .site-header { position: relative; z-index: 1; }

h1, h2, h3, p { margin: 0; }
button { font-family: inherit; color: inherit; }
ol, ul, dl, dd, dt { margin: 0; padding: 0; }
img, svg { display: block; }
[hidden] { display: none !important; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 18px; height: 18px; flex: none; }

:focus-visible {
  outline: 3px solid var(--teal);
  outline-offset: 2px;
}

/* ------------------------------------------------------------------ */
/* Header                                                              */
/* ------------------------------------------------------------------ */

.site-header {
  max-width: 1440px;
  margin: 0 auto;
  padding: 11px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  padding: 0;
  background: none;
  border: 0;
  cursor: pointer;
  text-align: left;
  border-radius: 14px;
}
.brand-mark {
  width: 44px;
  height: 44px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 13px;
  background: linear-gradient(150deg, #fff9ee 10%, #eddfc6 100%);
  border: 1px solid #e0d3bc;
  box-shadow: 0 4px 0 rgba(93, 63, 30, 0.08), 0 10px 22px rgba(93, 63, 30, 0.1);
}
.brand-mark svg { width: 36px; height: 36px; }
.brand-text { display: flex; flex-direction: column; line-height: 1; }
.brand-top {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.22em;
  color: var(--ink-soft);
  margin-bottom: 3px;
}
.brand-bottom {
  font-family: var(--font-display);
  font-size: 21px;
  letter-spacing: 0.015em;
  color: var(--ink);
}

.header-actions { display: flex; align-items: center; gap: 8px; }

.icon-btn, .ghost-btn, .small-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.72);
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  min-height: 40px;
  padding: 0 14px;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}
.icon-btn:hover, .ghost-btn:hover, .small-btn:hover {
  background: #fffdf8;
  border-color: var(--line-strong);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(41, 32, 20, 0.07);
}
.icon-btn:active, .ghost-btn:active, .small-btn:active { transform: translateY(0); }
.icon-btn[aria-pressed="false"] { color: var(--ink-faint); }
.small-btn { min-height: 34px; padding: 0 12px; font-size: 13px; }
.small-btn.ghost { background: transparent; border-color: transparent; color: var(--ink-soft); }
.small-btn.ghost:hover { background: rgba(255, 253, 248, 0.8); border-color: var(--line); }

.text-btn {
  border: 0;
  background: none;
  padding: 0;
  color: var(--accent-deep);
  font-weight: 700;
  font-size: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  cursor: pointer;
}

/* ------------------------------------------------------------------ */
/* Screens                                                             */
/* ------------------------------------------------------------------ */

.screen { display: none; }
.screen.is-active { display: block; }
@keyframes screen-in {
  from { opacity: 0.7; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.setup-inner, .credits-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 20px 28px 36px;
}
.game-inner {
  max-width: 1320px;
  margin: 0 auto;
  padding: 12px 26px 22px;
  display: grid;
  grid-template-columns: auto 338px;
  justify-content: center;
  gap: 26px;
  align-items: start;
}

.eyebrow {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--teal);
  margin-bottom: 8px;
}

/* ------------------------------------------------------------------ */
/* Setup hero                                                          */
/* ------------------------------------------------------------------ */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 480px);
  gap: 30px;
  align-items: center;
  padding: 10px 4px 26px;
}

.hero h1 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(40px, 5.4vw, 76px);
  line-height: 0.94;
  letter-spacing: 0.012em;
  color: var(--ink);
  text-wrap: balance;
}
.hero h1 span {
  color: var(--accent);
  text-shadow: 0 3px 0 rgba(180, 95, 11, 0.14);
}

.lede {
  font-size: clamp(16px, 1.3vw, 18.5px);
  line-height: 1.5;
  color: var(--ink-soft);
  max-width: 560px;
  margin-top: 14px;
}

.hero-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  border-radius: 999px;
  background: rgba(255, 253, 248, 0.8);
  border: 1px solid var(--line);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink-soft);
}
.tag .icon { width: 15px; height: 15px; color: var(--teal); }

.hero-art {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: clamp(6px, 1.2vw, 14px);
  min-height: 190px;
  padding: 8px;
}
.hero-art::before {
  content: "";
  position: absolute;
  inset: 18% 4% 6% 4%;
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(232, 135, 30, 0.2), rgba(15, 118, 110, 0.1) 55%, transparent 72%);
  filter: blur(12px);
  z-index: -1;
}
.hero-piece {
  position: relative;
  width: clamp(78px, 8.4vw, 112px);
  padding: 8px;
  border-radius: 22px;
  background: linear-gradient(155deg, rgba(255, 253, 248, 0.96), rgba(244, 233, 211, 0.9));
  border: 1px solid rgba(255, 255, 255, 0.8);
  box-shadow: 0 16px 34px rgba(65, 45, 22, 0.15), 0 2px 0 rgba(255, 255, 255, 0.7) inset;
  transform: rotate(var(--rot, 0deg)) translateY(var(--lift, 0px));
  transition: transform 0.25s ease;
}
.hero-piece:nth-child(1) { --rot: -5deg; --lift: 12px; }
.hero-piece:nth-child(2) { --rot: 2deg; --lift: 0px; }
.hero-piece:nth-child(3) { --rot: -2deg; --lift: 18px; }
.hero-piece:nth-child(4) { --rot: 5deg; --lift: 7px; }
.hero-piece:hover { transform: rotate(0deg) translateY(-4px); }
.hero-piece svg { width: 100%; height: auto; aspect-ratio: 1; }
.hero-piece span {
  display: block;
  margin-top: 5px;
  text-align: center;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ------------------------------------------------------------------ */
/* Setup panels                                                        */
/* ------------------------------------------------------------------ */

.setup-grid {
  display: grid;
  grid-template-columns: minmax(300px, 372px) minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

.panel {
  background: linear-gradient(180deg, rgba(255, 253, 248, 0.96), rgba(253, 249, 241, 0.94));
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow-card);
  padding: 20px;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}
.panel-head h2 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 24px;
  letter-spacing: 0.015em;
  line-height: 1.1;
}
.panel-head p { color: var(--ink-soft); font-size: 13.5px; margin-top: 3px; }
.step-num {
  width: 30px;
  height: 30px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--ink);
  color: #fff8ea;
  font-weight: 800;
  font-size: 14px;
  box-shadow: 0 4px 10px rgba(22, 32, 46, 0.2);
}

.mode-options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mode-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  text-align: left;
  padding: 13px 12px 12px;
  border-radius: 15px;
  border: 1.5px solid var(--line);
  background: #fffdf8;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease, background-color 0.15s ease;
}
.mode-card:hover { transform: translateY(-1px); border-color: var(--line-strong); box-shadow: 0 8px 18px rgba(41, 32, 20, 0.06); }
.mode-card strong { font-size: 15px; line-height: 1.2; }
.mode-card > span:last-child { font-size: 11.5px; color: var(--ink-soft); line-height: 1.25; }
.mode-card.is-selected {
  border-color: var(--accent);
  background: linear-gradient(180deg, #fffaf1, #fdf1dd);
  box-shadow: 0 0 0 3px rgba(232, 135, 30, 0.16), 0 10px 22px rgba(232, 135, 30, 0.1);
}
.mode-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--card-warm);
  color: var(--teal);
  margin-bottom: 6px;
}
.mode-card.is-selected .mode-icon { background: var(--accent-soft); color: var(--accent-deep); }
.mode-icon .icon { width: 20px; height: 20px; }

.side-picker {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--line-strong);
  animation: screen-in 0.25s ease both;
}
.small-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 7px;
}
.side-options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.side-choice {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 11px;
  border-radius: 12px;
  border: 1.5px solid var(--line);
  background: #fffdf8;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.side-choice:hover { border-color: var(--line-strong); }
.side-choice.is-selected {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
  background: #f4fbf9;
}
.side-art { width: 30px; height: 30px; flex: none; display: grid; place-items: center; }
.side-art svg { width: 100%; height: 100%; }
.fine-print { font-size: 11.5px; line-height: 1.4; color: var(--ink-faint); margin-top: 8px; }

.start-block { margin-top: 18px; }
.primary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 54px;
  padding: 0 22px;
  border-radius: 15px;
  border: 0;
  background: linear-gradient(180deg, #22334c, #111c2c);
  color: #fff7e8;
  font-weight: 800;
  font-size: 17px;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(17, 28, 44, 0.24), 0 1px 0 rgba(255, 255, 255, 0.18) inset;
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}
.primary-btn:hover { transform: translateY(-1px); filter: brightness(1.07); box-shadow: 0 14px 30px rgba(17, 28, 44, 0.28); }
.primary-btn:active { transform: translateY(0); }
.primary-btn .icon { width: 20px; height: 20px; color: var(--accent); }
.start-btn { width: 100%; }
.start-summary {
  text-align: center;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink-soft);
  margin-top: 9px;
}
.hint {
  margin-top: 12px;
  padding: 9px 12px;
  border-radius: 11px;
  background: rgba(15, 118, 110, 0.07);
  color: #255d57;
  font-size: 12.5px;
  line-height: 1.4;
  text-align: center;
}
.hint strong { color: #174641; }

.theme-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.theme-card {
  position: relative;
  display: grid;
  grid-template-columns: 126px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 16px;
  border: 1.5px solid var(--line);
  background: #fffdf8;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
  overflow: hidden;
}
.theme-card:hover { transform: translateY(-2px); border-color: var(--line-strong); box-shadow: 0 12px 26px rgba(41, 32, 20, 0.09); }
.theme-card.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(232, 135, 30, 0.16), 0 14px 30px rgba(232, 135, 30, 0.11);
}
.theme-art {
  height: 92px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.55);
  background: linear-gradient(150deg, #fbf3e3, #f3e3c8);
}
.theme-card[data-theme="aliens"] .theme-art { background: linear-gradient(150deg, #e6fffa, #c6f2ea 55%, #e2d1ff); }
.theme-card[data-theme="zombies"] .theme-art { background: linear-gradient(150deg, #f4f1da, #dfe0bd 55%, #c7cba4); }
.theme-card[data-theme="plants"] .theme-art { background: linear-gradient(150deg, #f0ffcd, #d2f09b 55%, #ffe0ec); }
.theme-art svg { width: 112px; height: auto; }
.theme-copy { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.theme-copy strong { font-size: 16px; line-height: 1.1; font-weight: 800; }
.theme-copy span { font-size: 11.5px; line-height: 1.35; color: var(--ink-soft); }
.theme-tick {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  box-shadow: 0 3px 8px rgba(180, 95, 11, 0.35);
  opacity: 0;
  transform: scale(0.5);
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.theme-tick .icon { width: 14px; height: 14px; }
.theme-card.is-selected .theme-tick { opacity: 1; transform: scale(1); }
.theme-footnote { margin-top: 12px; font-size: 11.5px; color: var(--ink-faint); line-height: 1.4; }

.setup-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 26px;
  color: var(--ink-faint);
  font-size: 12px;
}
.dot-sep { width: 3px; height: 3px; border-radius: 50%; background: var(--line-strong); }

/* ------------------------------------------------------------------ */
/* Game                                                               */
/* ------------------------------------------------------------------ */

.game-main {
  width: min(max(340px, calc(100vh - 300px)), calc(100vw - 420px), 700px);
  width: min(max(340px, calc(100dvh - 300px)), calc(100vw - 420px), 700px);
  max-width: 700px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.game-topline {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 8px;
}
.status-banner { flex: 1; min-width: 0; }
.turn-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: #fffdf8;
  border: 1px solid var(--line);
  box-shadow: 0 4px 12px rgba(41, 32, 20, 0.05);
  font-weight: 800;
  font-size: 13.5px;
  white-space: nowrap;
}
.turn-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fffaf0;
  border: 2px solid #8a7358;
  flex: none;
}
.turn-pill.is-black .turn-dot { background: #1b2532; border-color: #1b2532; }
.turn-pill.is-thinking .turn-dot { animation: pulse-dot 1s ease-in-out infinite; }
@keyframes pulse-dot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(0.68); opacity: 0.55; }
}
.turn-pill.is-over { background: #f4faf7; border-color: #bfe2d8; color: #155e52; }
.game-tools { display: flex; align-items: center; gap: 4px; }

.status-banner {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 54px;
  padding: 5px 12px;
  border-radius: 15px;
  background: #fffdf8;
  border: 1px solid var(--line);
  box-shadow: 0 4px 14px rgba(41, 32, 20, 0.05);
  transition: background-color 0.2s ease, border-color 0.2s ease;
}
.status-banner.is-check { background: #fff2ef; border-color: #f0c4bd; }
.status-banner.is-over { background: #f0f9f5; border-color: #b9e0d5; }
.status-emblem {
  width: 42px;
  height: 42px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--card-warm);
  border: 1px solid var(--line);
}
.status-emblem svg { width: 38px; height: 38px; }
.status-emblem.is-alert { background: #ffe5e1; border-color: #f2bcb4; }
.emblem-alert {
  font-family: var(--font-display);
  font-size: 27px;
  line-height: 1;
  color: var(--danger);
}
.status-banner.is-check .status-copy h2 { color: var(--danger); }
.status-banner.is-over .status-copy h2 { color: #155e52; }
.status-copy { min-width: 0; }
.status-copy h2 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 19px;
  letter-spacing: 0.02em;
  line-height: 1.1;
}
.status-copy p {
  font-size: 12.5px;
  color: var(--ink-soft);
  line-height: 1.25;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.game-tools {
  align-self: center;
  flex: none;
}

.board-area { display: flex; flex-direction: column; gap: 5px; }

.player-strip {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 44px;
  padding: 4px 10px;
  border-radius: 13px;
  background: rgba(255, 253, 248, 0.9);
  border: 1px solid var(--line);
  transition: box-shadow 0.2s ease, border-color 0.2s ease, background-color 0.2s ease;
}
.player-strip.is-active {
  border-color: var(--accent);
  background: #fffaf0;
  box-shadow: 0 0 0 2px rgba(232, 135, 30, 0.15);
}
.player-avatar {
  width: 34px;
  height: 34px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--card-warm);
  border: 1px solid var(--line);
}
.player-avatar svg { width: 30px; height: 30px; }
.player-avatar.is-dark { background: linear-gradient(155deg, #f3e5cd, #dcc4a1); border-color: #b39770; }
.player-meta { min-width: 0; flex: 1; }
.player-name-line { display: flex; align-items: center; gap: 7px; min-width: 0; }
.player-name { font-size: 14px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-side {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
  padding: 2px 6px;
  border-radius: 999px;
  border: 1px solid var(--line);
  flex: none;
}
.turn-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent-deep);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 2px 7px;
  flex: none;
}
.turn-chip.is-thinking::after {
  content: "";
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--accent-deep);
  animation: pulse-dot 0.9s ease-in-out infinite;
}
.captured { display: flex; flex-wrap: wrap; align-items: center; gap: 1px; min-height: 17px; }
.captured svg { width: 17px; height: 17px; opacity: 0.92; }
.captured .captured-label { font-size: 10.5px; color: var(--ink-faint); font-style: italic; }
.material {
  flex: none;
  font-size: 12.5px;
  font-weight: 800;
  color: var(--teal);
  background: var(--teal-soft);
  border-radius: 999px;
  padding: 3px 8px;
}

.board-shell {
  position: relative;
  width: 100%;
  padding: 10px;
  border-radius: 20px;
  background: linear-gradient(150deg, #4b3322 0%, #352215 52%, #241509 100%);
  box-shadow:
    0 2px 0 rgba(255, 255, 255, 0.16) inset,
    0 -2px 0 rgba(0, 0, 0, 0.5) inset,
    0 22px 44px rgba(41, 32, 20, 0.24);
}
.board {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 11px;
  overflow: hidden;
  background: var(--board-light);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.34);
}
.squares {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
}
.square {
  position: relative;
  appearance: none;
  border: 0;
  padding: 0;
  margin: 0;
  cursor: pointer;
  touch-action: manipulation;
  background-color: var(--board-light);
  transition: filter 0.12s ease;
}
.square.light { background-color: var(--board-light); }
.square.dark { background-color: var(--board-dark); }
.square:disabled, .board.is-locked .square { cursor: default; }
.square:hover { filter: brightness(1.035); }
.square:focus-visible { outline: 3px solid var(--teal); outline-offset: -3px; z-index: 6; }
.square .coord {
  position: absolute;
  font-size: clamp(8px, 1.15vw, 11px);
  font-weight: 800;
  line-height: 1;
  opacity: 0.48;
  pointer-events: none;
  letter-spacing: 0.02em;
}
.square.light .coord { color: #6b4a2b; }
.square.dark .coord { color: #fff6e2; }
.coord-file { right: 4px; bottom: 3px; }
.coord-rank { left: 4px; top: 3px; }
body.no-coords .coord { display: none; }

.square.last-move::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(232, 135, 30, 0.33);
  pointer-events: none;
}
.square.selected {
  box-shadow: inset 0 0 0 3px var(--teal), inset 0 0 0 999px rgba(15, 118, 110, 0.16);
}
.square.check {
  background-image: radial-gradient(circle at 50% 50%, rgba(199, 59, 70, 0.62), rgba(199, 59, 70, 0.1) 62%, transparent 72%);
}
.square.legal::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 25%;
  height: 25%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: rgba(15, 118, 110, 0.62);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.22);
  pointer-events: none;
}
.square.legal-capture::after {
  width: auto;
  height: auto;
  inset: 7%;
  left: 7%;
  top: 7%;
  transform: none;
  background: transparent;
  border: 3px solid rgba(199, 59, 70, 0.72);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.3), 0 0 12px rgba(199, 59, 70, 0.25);
}
.square.premove-target::after {
  content: "";
  position: absolute;
  inset: 35%;
  border-radius: 50%;
  background: rgba(22, 32, 46, 0.25);
}

.pieces {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}
.piece {
  position: absolute;
  left: 0;
  top: 0;
  width: 12.5%;
  height: 12.5%;
  transform: translate(calc(var(--x) * 100%), calc(var(--y) * 100%));
  transition: transform var(--anim) cubic-bezier(0.22, 0.8, 0.28, 1);
  will-change: transform;
  filter: drop-shadow(0 3px 2px rgba(32, 20, 9, 0.3));
}
.piece svg { width: 90%; height: 90%; margin: 5%; overflow: visible; }
.piece.no-anim { transition: none; }
.piece.is-moving { z-index: 9; }
.piece.is-captured {
  opacity: 0;
  transform: translate(calc(var(--x) * 100%), calc(var(--y) * 100%)) scale(0.48) rotate(7deg);
  transition: transform 0.22s ease, opacity 0.22s ease;
  z-index: 8;
}
.piece.is-promoted svg { animation: promote-pop 0.34s ease; }
@keyframes promote-pop {
  0% { transform: scale(0.7); }
  60% { transform: scale(1.12); }
  100% { transform: scale(1); }
}

.board-overlay {
  position: absolute;
  inset: 10px;
  z-index: 30;
  border-radius: 11px;
  background: rgba(12, 17, 25, 0.56);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  padding: 18px;
  animation: overlay-in 0.22s ease both;
}
@keyframes overlay-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
.promotion-card, .result-card {
  width: min(360px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 20px;
  box-shadow: 0 26px 60px rgba(0, 0, 0, 0.35);
  text-align: center;
  animation: card-in 0.28s cubic-bezier(0.22, 0.9, 0.28, 1.1) both;
}
@keyframes card-in {
  from { opacity: 0; transform: translateY(10px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.card-kicker {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 5px;
}
.promotion-card h2, .result-card h2 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 30px;
  letter-spacing: 0.02em;
  line-height: 1.05;
}
.result-kicker {
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent-deep);
  margin-bottom: 6px;
}
.result-card > p#result-sub { color: var(--ink-soft); font-size: 14px; margin-top: 6px; }
.result-actions { display: flex; gap: 8px; justify-content: center; margin-top: 18px; }
.result-actions .primary-btn { min-height: 46px; font-size: 15px; padding: 0 20px; }
.result-actions .ghost-btn { min-height: 46px; }
.result-card.is-win .result-kicker { color: var(--teal); }

.promotion-options {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 15px 0 12px;
}
.promo-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 2px 5px;
  border-radius: 12px;
  border: 1.5px solid var(--line);
  background: #fffdf8;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}
.promo-btn:hover, .promo-btn:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(232, 135, 30, 0.15);
  transform: translateY(-2px);
}
.promo-btn svg { width: 54px; height: 54px; }
.promo-btn span { font-size: 10px; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-soft); }

/* ------------------------------------------------------------------ */
/* Game sidebar                                                        */
/* ------------------------------------------------------------------ */

.game-side { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.side-card {
  background: rgba(255, 253, 248, 0.94);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 15px;
  box-shadow: 0 8px 24px rgba(41, 32, 20, 0.05);
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.card-head h3, .side-card h3 {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.match-badge {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--teal);
  background: var(--teal-soft);
  border-radius: 999px;
  padding: 3px 8px;
}
.match-facts { display: flex; flex-direction: column; gap: 7px; margin-bottom: 12px; }
.match-facts > div { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.match-facts dt { font-size: 12px; color: var(--ink-faint); font-weight: 600; }
.match-facts dd { font-size: 13.5px; font-weight: 700; text-align: right; }
.match-actions { display: flex; gap: 6px; }
.match-actions .small-btn { flex: 1; }

.move-count { font-size: 11px; font-weight: 700; color: var(--ink-faint); }
.move-scroll { max-height: min(280px, 30dvh); overflow-y: auto; scrollbar-width: thin; }
.move-list { list-style: none; }
.move-row {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) minmax(0, 1fr);
  gap: 4px;
  align-items: baseline;
  padding: 4px 6px;
  border-radius: 7px;
  font-variant-numeric: tabular-nums;
}
.move-row:nth-child(odd) { background: #faf5ea; }
.move-num { font-size: 11px; color: var(--ink-faint); font-weight: 600; }
.move-san { font-size: 13px; font-weight: 600; }
.move-san.is-last { color: var(--accent-deep); font-weight: 800; }
.move-san.is-empty { color: transparent; }
.empty-moves { color: var(--ink-faint); font-size: 12.5px; line-height: 1.4; padding: 2px 2px 4px; }
.moves-card .empty-moves[hidden] { display: none; }

.help-card p { font-size: 12.5px; line-height: 1.45; color: var(--ink-soft); }
.help-card .fine-print { margin-top: 8px; color: var(--ink-faint); font-size: 11.5px; }

/* ------------------------------------------------------------------ */
/* Credits                                                            */
/* ------------------------------------------------------------------ */

.credits-head { max-width: 760px; margin: 10px 0 24px; }
.credits-head h1 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(38px, 5vw, 62px);
  line-height: 0.96;
  letter-spacing: 0.01em;
}
.credits-head .lede { max-width: 680px; }
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.75);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
}
.back-btn:hover { background: #fffdf8; border-color: var(--line-strong); }
.credits-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.credit-card h2 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 22px;
  letter-spacing: 0.015em;
  margin-bottom: 7px;
}
.credit-card p { font-size: 13.5px; line-height: 1.55; color: var(--ink-soft); margin-bottom: 8px; }
.credit-card strong { color: var(--ink); }
.credit-note {
  display: inline-block;
  font-size: 11px !important;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--teal) !important;
  background: var(--teal-soft);
  border-radius: 999px;
  padding: 4px 9px;
  margin-top: 4px;
}
.credit-list { margin: 6px 0 8px 18px; color: var(--ink-soft); font-size: 13px; line-height: 1.6; }
.credit-card.wide { grid-column: 1 / -1; }
.build-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 12px;
}
.build-grid h3 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 17px;
  letter-spacing: 0.02em;
  color: var(--ink);
  margin-bottom: 4px;
}
.build-grid p { font-size: 12.5px; line-height: 1.5; color: var(--ink-soft); margin: 0; }
.build-grid code {
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 11.5px;
  background: #f7f1e4;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 4px;
}
.license-details { margin-top: 10px; }
.license-details summary {
  cursor: pointer;
  font-weight: 700;
  font-size: 13px;
  color: var(--accent-deep);
  padding: 4px 0;
}
.license-details pre {
  max-height: 280px;
  overflow: auto;
  background: #f8f2e6;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  font-size: 11px;
  line-height: 1.5;
  white-space: pre-wrap;
  color: var(--ink-soft);
  font-family: "Outfit", ui-monospace, monospace;
}
.credits-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 26px;
  color: var(--ink-faint);
  font-size: 12px;
}

/* ------------------------------------------------------------------ */
/* Toast                                                              */
/* ------------------------------------------------------------------ */

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 100;
  transform: translate(-50%, 16px);
  opacity: 0;
  pointer-events: none;
  background: #16202e;
  color: #fff8ea;
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 14px 34px rgba(22, 32, 46, 0.3);
  transition: opacity 0.2s ease, transform 0.2s ease;
  max-width: min(90vw, 420px);
  text-align: center;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* ------------------------------------------------------------------ */
/* Responsive                                                         */
/* ------------------------------------------------------------------ */

@media (max-width: 1120px) {
  .setup-grid { grid-template-columns: minmax(280px, 340px) minmax(0, 1fr); }
  .theme-card { grid-template-columns: 108px minmax(0, 1fr); }
  .theme-art svg { width: 98px; }
  .game-inner { grid-template-columns: minmax(0, 1fr) 310px; gap: 20px; }
}

@media (max-width: 980px) {
  .site-header { padding: 12px 18px; }
  .setup-inner, .credits-inner { padding: 14px 18px 30px; }
  .hero { grid-template-columns: 1fr; gap: 12px; padding-top: 4px; }
  .hero-art { min-height: 150px; justify-content: flex-start; padding-left: 4px; }
  .hero-piece { width: clamp(74px, 15vw, 100px); }
  .setup-grid { grid-template-columns: 1fr; }
  .theme-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .theme-card { grid-template-columns: 118px minmax(0, 1fr); }
  .theme-art { height: 86px; }
  .game-inner { grid-template-columns: 1fr; justify-content: stretch; gap: 16px; padding: 12px 16px 24px; }
  .game-main { width: 100%; max-width: 640px; }
  .game-side { max-width: 640px; margin: 0 auto; width: 100%; }
  .move-scroll { max-height: 220px; }
  .credits-grid { grid-template-columns: 1fr; }
  .credit-card.wide { grid-column: auto; }
  .build-grid { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  body { font-size: 15px; }
  .site-header { padding: 10px 12px; }
  .brand-mark { width: 38px; height: 38px; border-radius: 11px; }
  .brand-mark svg { width: 31px; height: 31px; }
  .brand-bottom { font-size: 18px; }
  .brand-top { font-size: 9px; }
  .icon-btn { padding: 0 10px; }
  .icon-btn span { display: none; }
  .ghost-btn { padding: 0 10px; }
  .ghost-btn span { display: inline; }
  #credits-btn span { display: none; }
  #credits-btn { width: 40px; padding: 0; }
  .header-actions { gap: 4px; }

  .setup-inner, .credits-inner { padding: 8px 12px 26px; }
  .hero h1 { font-size: clamp(38px, 11vw, 56px); }
  .hero-art { min-height: 118px; gap: 7px; }
  .hero-piece { width: 74px; padding: 6px; border-radius: 16px; }
  .hero-piece span { font-size: 8px; }
  .tag { font-size: 11.5px; padding: 5px 9px; }
  .panel { padding: 15px; border-radius: 18px; }
  .panel-head h2 { font-size: 21px; }
  .mode-options { gap: 8px; }
  .mode-card { padding: 11px 10px; }
  .mode-card strong { font-size: 13.5px; }
  .mode-card > span:last-child { font-size: 10.5px; }
  .mode-icon { width: 30px; height: 30px; }
  .theme-grid { grid-template-columns: 1fr; }
  .theme-card { grid-template-columns: 120px minmax(0, 1fr); }
  .theme-art { height: 84px; }
  .start-block { margin-top: 15px; }
  .primary-btn { min-height: 50px; font-size: 16px; }
  .setup-footer { font-size: 11px; }

  .game-inner { padding: 8px 10px 20px; }
  .game-topline { flex-wrap: wrap; gap: 5px; }
  .game-topline .status-banner { flex-basis: 100%; }
  .game-tools { margin-left: auto; }
  .turn-pill { font-size: 12.5px; padding: 5px 10px; }
  .small-btn { min-height: 32px; font-size: 12px; padding: 0 9px; }
  .small-btn .icon { width: 15px; height: 15px; }
  .game-tools .small-btn span { display: inline; }
  .status-banner { padding: 6px 10px; min-height: 54px; gap: 9px; }
  .status-emblem { width: 36px; height: 36px; border-radius: 10px; }
  .status-emblem svg { width: 33px; height: 33px; }
  .status-copy h2 { font-size: 17px; }
  .status-copy p { font-size: 11.5px; }
  .player-strip { min-height: 42px; padding: 4px 8px; border-radius: 11px; }
  .player-avatar { width: 30px; height: 30px; }
  .player-avatar svg { width: 26px; height: 26px; }
  .player-name { font-size: 13px; }
  .captured svg { width: 15px; height: 15px; }
  .material { font-size: 11.5px; padding: 2px 7px; }
  .board-shell { padding: 6px; border-radius: 14px; }
  .board { border-radius: 8px; }
  .board-overlay { inset: 6px; border-radius: 8px; padding: 12px; }
  .promotion-card, .result-card { padding: 16px; border-radius: 16px; }
  .promotion-options { gap: 5px; }
  .promo-btn svg { width: 44px; height: 44px; }
  .result-actions { flex-direction: column; }
  .result-actions .primary-btn, .result-actions .ghost-btn { width: 100%; }
  .side-card { border-radius: 15px; padding: 12px; }
  .side-card h3 { font-size: 12px; }
  .help-card p { font-size: 12px; }
  .credits-head h1 { font-size: clamp(34px, 10vw, 48px); }
  .credits-head .lede { font-size: 15px; }
}

@media (max-width: 390px) {
  .mode-options { grid-template-columns: 1fr; }
  .side-options { grid-template-columns: 1fr 1fr; }
  .theme-card { grid-template-columns: 104px minmax(0, 1fr); }
  .theme-art { height: 76px; }
  .hero-piece { width: 68px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .piece { transition: none !important; }
}
