@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;600;700;800&family=Space+Grotesk:wght@500;700&display=swap');

/* Design tokens lifted from nonay.xyz so this sits alongside the main site. */
:root {
  --bg0: #0f111a;
  --bg1: #111629;
  --card: rgba(20, 22, 35, 0.92);
  --card2: rgba(18, 20, 32, 0.92);
  --text: #ffffff;
  --muted: #9aa4c8;
  --muted2: #7e88aa;
  --border: rgba(120, 128, 160, 0.25);
  --shadow: 0 18px 40px rgba(8, 10, 20, 0.55);
  --accent: #4f7cff;
  --accent2: #2ad6a5;
  --danger: #ff5f6d;
  --warn: #ffb74d;
  --radius: 6px;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--bg0); }

body {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  margin: 0;
  font-family: 'Manrope', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(900px 420px at 12% 8%, rgba(79, 124, 255, 0.25), transparent 65%),
    radial-gradient(700px 380px at 90% 0%, rgba(42, 214, 165, 0.2), transparent 60%),
    var(--bg0);
  overflow-x: hidden;
}

body > main { flex: 1; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; }

.container { max-width: 1150px; margin: 0 auto; padding: 0 20px; }

h1, h2, h3 { font-family: 'Space Grotesk', system-ui, sans-serif; }

/* ═══════════════════════ Header ═══════════════════════ */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(8px);
  background: rgba(12, 14, 22, 0.72);
  border-bottom: 1px solid var(--border);
}

.site-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
}

.brand { display: flex; align-items: center; gap: 12px; min-width: fit-content; }
.brand img { height: 40px; width: 40px; border-radius: 6px; }
.brand span { font-weight: 700; letter-spacing: -0.02em; }

.site-nav {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.nav-link {
  color: var(--muted);
  padding: 8px 10px;
  border-radius: 6px;
  transition: background 0.2s ease, color 0.2s ease;
}
.nav-link:hover, .nav-link:focus-visible { color: var(--text); background: rgba(255, 255, 255, 0.08); }
.nav-link.active { color: var(--text); background: rgba(255, 255, 255, 0.06); }

.nav-download {
  padding: 10px 14px;
  border-radius: 7px;
  font-weight: 600;
  background: linear-gradient(120deg, var(--accent), var(--accent2));
  color: #fff;
  transition: background 0.2s ease, transform 0.2s ease;
}
.nav-download:hover, .nav-download:focus-visible {
  background: linear-gradient(120deg, var(--accent2), var(--accent));
  transform: translateY(-1px);
}

.nav-dropdown { position: relative; }
.nav-dropdown > button { border: 0; background: transparent; font: inherit; cursor: pointer; }

/* Hover bridge so the menu does not collapse while moving the cursor */
.nav-dropdown::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  height: 14px;
}

.nav-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 12px);
  min-width: 260px;
  background: rgba(18, 20, 32, 0.92);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 8px;
  opacity: 0;
  transform: translateY(8px) scale(0.98);
  visibility: hidden;
  pointer-events: none;
  transition: opacity 180ms ease, transform 220ms cubic-bezier(0.22, 0.61, 0.36, 1), visibility 0ms linear 220ms;
  z-index: 60;
}

.nav-dropdown[data-open="true"] .nav-menu {
  opacity: 1;
  transform: translateY(0) scale(1);
  visibility: visible;
  pointer-events: auto;
  transition: opacity 180ms ease, transform 220ms cubic-bezier(0.22, 0.61, 0.36, 1);
}
.nav-dropdown[data-open="true"] > button svg { transform: rotate(180deg); }

.nav-menu a { display: block; padding: 10px 10px; border-radius: 6px; color: var(--text); }
.nav-menu a:hover, .nav-menu a:focus-visible { background: rgba(255, 255, 255, 0.06); }
.nav-menu .nav-muted { color: var(--muted); }

/* ═══════════════════════ Buttons ═══════════════════════ */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 6px;
  font-weight: 600;
  font-family: inherit;
  font-size: 0.95rem;
  border: none;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  transition: transform 0.2s ease, background 0.2s ease, opacity 0.2s ease;
}
.button:hover:not(:disabled), .button:focus-visible { transform: translateY(-1px); background: rgba(255, 255, 255, 0.09); }
.button:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.button-primary { background: linear-gradient(120deg, var(--accent), var(--accent2)); }
.button-primary:hover:not(:disabled) { background: linear-gradient(90deg, var(--accent2), var(--accent)); }

.button-danger { background: rgba(255, 95, 109, 0.16); color: #ff9aa3; }
.button-danger:hover:not(:disabled) { background: rgba(255, 95, 109, 0.28); }

.button-lg { padding: 16px 30px; font-size: 1.06rem; border-radius: 7px; }
.button-sm { padding: 8px 13px; font-size: 0.84rem; border-radius: 5px; }
.button-block { width: 100%; }

/* ═══════════════════════ Hero ═══════════════════════ */

.hero { padding: 74px 0 34px; position: relative; overflow: hidden; }
.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(to right, rgba(255, 255, 255, 0.06) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.06) 1px, transparent 1px);
  background-size: 54px 54px;
  opacity: 0.2;
  mask-image: radial-gradient(circle at center top, rgba(0, 0, 0, 1), rgba(0, 0, 0, 0) 75%);
  -webkit-mask-image: radial-gradient(circle at center top, rgba(0, 0, 0, 1), rgba(0, 0, 0, 0) 75%);
  pointer-events: none;
}
.hero-inner { position: relative; }
.hero h1 {
  font-size: clamp(2.4rem, 2vw + 1.9rem, 3.6rem);
  line-height: 1.05;
  letter-spacing: -0.04em;
  margin: 0 0 12px;
}
.hero p { margin: 0 0 22px; color: var(--muted); max-width: 640px; font-size: 1.08rem; line-height: 1.6; }

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--accent2);
  font-weight: 700;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.11em;
  margin-bottom: 14px;
}

/* ═══════════════════════ Game grid ═══════════════════════ */

.section { padding: 26px 0 58px; }
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.section-head h2 { margin: 0; font-size: 1.5rem; letter-spacing: -0.02em; }
.section-head .count { color: var(--muted2); font-size: 0.9rem; }

.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 18px;
}

.game-card {
  display: flex;
  flex-direction: column;
  background: linear-gradient(160deg, rgba(22, 26, 42, 0.95), rgba(15, 17, 26, 0.9));
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  position: relative;
}
.game-card:hover, .game-card:focus-visible {
  transform: translateY(-4px);
  box-shadow: 0 26px 52px rgba(8, 10, 20, 0.7);
}
.game-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.game-thumb {
  aspect-ratio: 1 / 1;
  position: relative;
  display: grid;
  place-items: center;
  background: radial-gradient(120% 100% at 50% 0%, rgba(79, 124, 255, 0.28), transparent 70%), #0c0e16;
  overflow: hidden;
}
.game-thumb svg { width: 100%; height: 100%; display: block; }

.game-card-body { padding: 13px 14px 15px; display: flex; flex-direction: column; gap: 5px; flex: 1; }
.game-card-body h3 { margin: 0; font-size: 1.02rem; letter-spacing: -0.01em; }
.game-card-tagline { margin: 0; color: var(--muted); font-size: 0.85rem; line-height: 1.45; }
.game-card-meta {
  margin-top: auto;
  padding-top: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted2);
  font-size: 0.79rem;
}
.game-card-meta svg { opacity: 0.7; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 5px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.badge-live { background: rgba(42, 214, 165, 0.15); color: var(--accent2); }
.badge-soon { background: rgba(255, 183, 77, 0.14); color: var(--warn); }
.badge-tag { background: rgba(255, 255, 255, 0.07); color: var(--muted); font-weight: 600; }

.thumb-badge { position: absolute; top: 10px; left: 10px; z-index: 2; backdrop-filter: blur(6px); }

/* Placeholder tiles that tease future games. They fill the whole card rather
   than mimicking the thumb/body split, so there is no dead space beneath. */
.game-card.placeholder {
  background: rgba(18, 20, 32, 0.4);
  box-shadow: none;
  border: 1px dashed rgba(120, 128, 160, 0.2);
  pointer-events: none;
  display: grid;
  place-items: center;
  min-height: 200px;
}
.game-card.placeholder .game-thumb-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  color: var(--muted2);
  font-size: 0.82rem;
  text-align: center;
  padding: 0 18px;
  line-height: 1.5;
  opacity: 0.75;
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
  background: rgba(18, 20, 32, 0.6);
  border-radius: 8px;
}

/* ═══════════════════════ Game detail ═══════════════════════ */

.detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 420px) minmax(0, 1fr);
  gap: 34px;
  align-items: start;
  padding: 34px 0 20px;
}
.detail-art {
  border-radius: 9px;
  overflow: hidden;
  box-shadow: var(--shadow);
  background: radial-gradient(120% 100% at 50% 0%, rgba(79, 124, 255, 0.3), transparent 70%), #0c0e16;
  aspect-ratio: 1 / 1;
  position: sticky;
  top: 92px;
}
.detail-art svg { width: 100%; height: 100%; display: block; }

.detail-title { font-size: clamp(2rem, 1.4vw + 1.6rem, 2.8rem); margin: 6px 0 8px; letter-spacing: -0.03em; }
.detail-tagline { color: var(--muted); font-size: 1.08rem; margin: 0 0 18px; }
.detail-tags { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 20px; }

.detail-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin: 20px 0 24px;
}
.stat {
  background: rgba(18, 20, 32, 0.85);
  border-radius: 7px;
  padding: 12px 14px;
}
.stat dt { color: var(--muted2); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.09em; font-weight: 700; margin-bottom: 4px; }
.stat dd { margin: 0; font-weight: 600; font-size: 0.95rem; }

.detail-actions { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-bottom: 26px; }

.prose { color: var(--muted); line-height: 1.72; font-size: 1rem; }
.prose p { margin: 0 0 14px; }

.rules-card {
  background: rgba(18, 20, 32, 0.85);
  border-radius: 8px;
  padding: 22px 24px;
  margin-top: 26px;
}
.rules-card h3 { margin: 0 0 4px; font-size: 1.12rem; }
.rules-card .credit { color: var(--muted2); font-size: 0.83rem; margin: 0 0 16px; }
.rules-list { margin: 0; padding-left: 0; list-style: none; counter-reset: rule; display: grid; gap: 11px; }
.rules-list li {
  counter-increment: rule;
  display: grid;
  grid-template-columns: 26px 1fr;
  gap: 12px;
  color: #d7ddf0;
  font-size: 0.93rem;
  line-height: 1.55;
}
.rules-list li::before {
  content: counter(rule);
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 5px;
  background: rgba(79, 124, 255, 0.16);
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 800;
}

/* ═══════════════════════ Loading screen ═══════════════════════ */

.loader {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  background: radial-gradient(700px 420px at 50% 30%, rgba(79, 124, 255, 0.22), transparent 70%), #090b12;
  transition: opacity 0.45s ease, visibility 0.45s ease;
}
.loader[hidden] { display: grid; opacity: 0; visibility: hidden; pointer-events: none; }
.loader-inner { text-align: center; width: min(420px, 86vw); }
/* The logo is already a coloured mark on transparency, so it sits on the
   backdrop directly rather than on a gradient tile. */
.loader-art {
  width: 96px;
  height: 96px;
  margin: 0 auto 22px;
  display: grid;
  place-items: center;
  animation: loader-pulse 1.7s ease-in-out infinite;
}
.loader-art img { width: 96px; height: 96px; display: block; }
@keyframes loader-pulse {
  0%, 100% { transform: scale(1); opacity: 0.9; }
  50% { transform: scale(1.06); opacity: 1; }
}
.loader h2 { margin: 0 0 6px; font-size: 1.5rem; letter-spacing: -0.02em; }
.loader-status { color: var(--muted); font-size: 0.92rem; margin: 0 0 20px; min-height: 1.3em; }
.loader-bar { height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.loader-fill {
  height: 100%;
  width: 0%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  transition: width 0.35s cubic-bezier(0.22, 0.61, 0.36, 1);
}
@media (prefers-reduced-motion: reduce) {
  .loader-art { animation: none; }
  .loader, .loader-fill { transition: none; }
}

/* ═══════════════════════ Lobby ═══════════════════════ */

.lobby { padding: 40px 0 60px; display: grid; place-items: center; min-height: calc(100vh - 190px); }
.lobby-panel {
  width: min(520px, 100%);
  background: linear-gradient(160deg, rgba(22, 26, 42, 0.96), rgba(15, 17, 26, 0.94));
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 30px 30px 26px;
}
.lobby-panel h1 { margin: 0 0 6px; font-size: 1.6rem; letter-spacing: -0.02em; }
.lobby-panel > p.sub { color: var(--muted); margin: 0 0 22px; font-size: 0.95rem; line-height: 1.6; }

.field { margin-bottom: 16px; }
.field label {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.input {
  width: 100%;
  padding: 13px 15px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: rgba(12, 14, 22, 0.9);
  color: #fff;
  font-size: 1rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79, 124, 255, 0.18); }
.input::placeholder { color: var(--muted2); opacity: 0.7; }

.input-code {
  text-transform: uppercase;
  letter-spacing: 0.42em;
  font-weight: 800;
  font-size: 1.35rem;
  text-align: center;
  font-family: 'Space Grotesk', monospace;
  padding-left: 0.42em;
}

.divider { display: flex; align-items: center; gap: 14px; color: var(--muted2); font-size: 0.78rem; margin: 22px 0; text-transform: uppercase; letter-spacing: 0.12em; font-weight: 700; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.notice { padding: 11px 14px; border-radius: 6px; font-size: 0.89rem; margin-bottom: 14px; line-height: 1.5; }
.notice-error { background: rgba(255, 95, 109, 0.14); color: #ff9aa3; }
.notice-info { background: rgba(79, 124, 255, 0.14); color: #b6c8ff; }

/* Waiting-for-opponent state */
.code-display {
  text-align: center;
  background: rgba(12, 14, 22, 0.8);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 18px;
}
.code-display .label { color: var(--muted2); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.14em; font-weight: 700; }
.code-value {
  font-family: 'Space Grotesk', monospace;
  font-size: 2.6rem;
  font-weight: 700;
  letter-spacing: 0.24em;
  margin: 8px 0 4px;
  padding-left: 0.24em;
  background: linear-gradient(120deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.waiting-dots::after {
  content: "";
  animation: dots 1.4s steps(4, end) infinite;
}
@keyframes dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }

/* ═══════════════════════ Match view ═══════════════════════ */

.match {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 24px;
  padding: 22px 0 40px;
  align-items: start;
}

.board-column { display: flex; flex-direction: column; gap: 12px; min-width: 0; }

.player-strip {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 15px;
  border-radius: 7px;
  background: rgba(18, 20, 32, 0.85);
  transition: box-shadow 0.25s ease, background 0.25s ease;
}
.player-strip.is-turn {
  background: rgba(79, 124, 255, 0.12);
  box-shadow: inset 0 0 0 1px rgba(79, 124, 255, 0.4);
}
.player-strip.is-turn .turn-flag { opacity: 1; }

.pip {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: inset 0 -2px 4px rgba(0, 0, 0, 0.35);
}
.pip-0 { background: linear-gradient(150deg, #f6f2e6, #cdc3ad); }
.pip-1 { background: linear-gradient(150deg, #4a5570, #232838); }

.player-strip .who { display: flex; flex-direction: column; min-width: 0; }
.player-strip .who b { font-size: 0.97rem; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-strip .who span { font-size: 0.76rem; color: var(--muted2); }
.player-strip .pieces { margin-left: auto; text-align: right; }
.player-strip .pieces b { font-size: 1.15rem; font-family: 'Space Grotesk', sans-serif; }
.player-strip .pieces span { display: block; font-size: 0.68rem; color: var(--muted2); text-transform: uppercase; letter-spacing: 0.09em; }
.turn-flag {
  opacity: 0;
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  background: rgba(79, 124, 255, 0.16);
  padding: 3px 8px;
  border-radius: 5px;
  transition: opacity 0.2s ease;
}
.dot-offline { width: 7px; height: 7px; border-radius: 50%; background: var(--muted2); flex-shrink: 0; }
.dot-online { background: var(--accent2); box-shadow: 0 0 8px rgba(42, 214, 165, 0.7); }

/* The board itself */
.board-wrap {
  position: relative;
  width: 100%;
  max-width: min(74vh, 100%);
  margin: 0 auto;
  aspect-ratio: 1 / 1;
}
.board {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  border-radius: 7px;
  overflow: hidden;
  box-shadow: 0 22px 60px rgba(8, 10, 20, 0.65), inset 0 0 0 1px rgba(255, 255, 255, 0.07);
  background: #1a1d2b;
  touch-action: manipulation;
}

.sq {
  position: relative;
  border: 0;
  padding: 0;
  margin: 0;
  cursor: default;
  background: #1c2030;
  transition: background 0.15s ease;
  display: grid;
  place-items: center;
}
.sq.light { background: #232838; }
.sq.selectable { cursor: pointer; }
.sq.selectable:hover { background: rgba(79, 124, 255, 0.2); }
/* The piece covers most of its square, so the selection also gets a ring
   drawn over the top of it, otherwise only a thin rim would show. */
.sq.selected { background: rgba(79, 124, 255, 0.35) !important; }
/* Drawn on ::before, not ::after: the last-move and capture highlights own
   ::after, and a selected square can never also be a move target. */
.sq.selected::before {
  content: "";
  position: absolute;
  inset: 6%;
  border-radius: 3px;
  box-shadow: inset 0 0 0 2px var(--accent), 0 0 14px rgba(79, 124, 255, 0.55);
  pointer-events: none;
  z-index: 2;
}
.sq.lastfrom::after, .sq.lastto::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(255, 183, 77, 0.16);
  pointer-events: none;
}

/* Move-target hint dot */
.sq.target { cursor: pointer; }
.sq.target::before {
  content: "";
  position: absolute;
  width: 26%;
  height: 26%;
  border-radius: 50%;
  background: rgba(42, 214, 165, 0.55);
  box-shadow: 0 0 14px rgba(42, 214, 165, 0.5);
  pointer-events: none;
  transition: transform 0.15s ease;
}
.sq.target:hover::before { transform: scale(1.5); }
/* A target that will win pieces gets a warmer marker. */
.sq.target.capturing::before { background: rgba(255, 95, 109, 0.75); box-shadow: 0 0 16px rgba(255, 95, 109, 0.6); }

.piece {
  width: 76%;
  height: 76%;
  border-radius: 50%;
  pointer-events: none;
  position: relative;
  animation: place 0.18s ease;
}
.piece-0 {
  background: linear-gradient(155deg, #fbf7ec 0%, #e6ddc8 45%, #b8ad93 100%);
  box-shadow: inset 0 -3px 6px rgba(0, 0, 0, 0.28), inset 0 2px 3px rgba(255, 255, 255, 0.85), 0 4px 10px rgba(0, 0, 0, 0.45);
}
.piece-1 {
  background: linear-gradient(155deg, #59637f 0%, #333a51 45%, #171b28 100%);
  box-shadow: inset 0 -3px 6px rgba(0, 0, 0, 0.5), inset 0 2px 3px rgba(255, 255, 255, 0.22), 0 4px 10px rgba(0, 0, 0, 0.5);
}
.piece::after {
  content: "";
  position: absolute;
  inset: 22%;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.12);
}
.piece-1::after { border-color: rgba(255, 255, 255, 0.09); }
@keyframes place { from { transform: scale(0.72); opacity: 0.4; } to { transform: scale(1); opacity: 1; } }

.sq.captured-flash::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(255, 95, 109, 0.5);
  animation: capture-fade 0.6s ease forwards;
  pointer-events: none;
}
@keyframes capture-fade { to { opacity: 0; } }

.board-status {
  text-align: center;
  padding: 11px 16px;
  border-radius: 7px;
  background: rgba(18, 20, 32, 0.85);
  font-size: 0.95rem;
  font-weight: 600;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.board-status.your-turn { background: rgba(42, 214, 165, 0.13); color: #7cf0cf; }
.board-status.over { background: rgba(79, 124, 255, 0.14); color: #b6c8ff; }

.match-actions { display: flex; gap: 9px; flex-wrap: wrap; justify-content: center; }

/* Side panel */
.side-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: sticky;
  top: 88px;
}
.panel {
  background: rgba(18, 20, 32, 0.88);
  border-radius: 8px;
  padding: 15px 16px;
}
.panel h3 {
  margin: 0 0 11px;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted2);
  font-weight: 800;
  font-family: 'Manrope', sans-serif;
}
.room-code-row { display: flex; align-items: center; gap: 8px; }

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  padding: 0;
  border: 0;
  border-radius: 5px;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  transition: background 0.2s ease, color 0.2s ease;
}
.icon-button:hover, .icon-button:focus-visible { background: rgba(255, 255, 255, 0.1); color: var(--text); }
.icon-button.is-off { color: var(--muted2); opacity: 0.65; }
.room-code-row .code {
  font-family: 'Space Grotesk', monospace;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  padding-left: 0.2em;
}

.chat-log {
  height: 230px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 0.86rem;
  line-height: 1.45;
  padding-right: 4px;
  overscroll-behavior: contain;
  /* Firefox: without this the default light scrollbar is very loud on a dark panel. */
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
}
.chat-log::-webkit-scrollbar { width: 6px; }
.chat-log::-webkit-scrollbar-track { background: transparent; }
.chat-log::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.14); border-radius: 3px; }
.chat-msg b { color: #cfd8f5; }
.chat-msg.system { color: var(--muted2); font-style: italic; font-size: 0.81rem; }
.chat-form { display: flex; gap: 7px; margin-top: 11px; }
.chat-form .input { padding: 9px 12px; font-size: 0.88rem; }

.draw-offer {
  background: rgba(255, 183, 77, 0.13);
  color: #ffd08a;
  border-radius: 6px;
  padding: 12px 14px;
  font-size: 0.88rem;
  line-height: 1.5;
}
.draw-offer .row { display: flex; gap: 8px; margin-top: 10px; }

/* Result overlay */
.result-overlay {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: grid;
  place-items: center;
  background: rgba(9, 11, 18, 0.78);
  backdrop-filter: blur(6px);
  padding: 20px;
  animation: fade-in 0.3s ease;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.result-card {
  width: min(440px, 100%);
  background: linear-gradient(160deg, rgba(24, 28, 46, 0.98), rgba(15, 17, 26, 0.98));
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 30px 28px 24px;
  text-align: center;
}
.result-crest {
  width: 68px;
  height: 68px;
  margin: 0 auto 16px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: linear-gradient(140deg, var(--accent), var(--accent2));
}
.result-card.lose .result-crest { background: linear-gradient(140deg, #4a5370, #262c40); }
.result-card.draw .result-crest { background: linear-gradient(140deg, var(--warn), #b4762a); }
.result-card h2 { margin: 0 0 8px; font-size: 1.7rem; letter-spacing: -0.02em; }
.result-card p { color: var(--muted); margin: 0 0 20px; line-height: 1.6; font-size: 0.95rem; }
.result-card .row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* Toasts */
.toast-stack { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 300; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  background: rgba(24, 28, 44, 0.97);
  color: #fff;
  padding: 11px 18px;
  border-radius: 6px;
  font-size: 0.89rem;
  box-shadow: var(--shadow);
  animation: toast-in 0.25s ease;
  max-width: 90vw;
}
.toast.error { background: rgba(88, 26, 34, 0.97); color: #ffc2c8; }
@keyframes toast-in { from { transform: translateY(14px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* Connection banner */
.conn-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 400;
  text-align: center;
  padding: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  background: rgba(255, 183, 77, 0.95);
  color: #2a1c00;
}

/* ═══════════════════════ Footer ═══════════════════════ */

.site-footer { padding: 22px 0; color: var(--muted2); font-size: 0.86rem; margin-top: auto; }
.footer-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.footer-inner a:hover { color: var(--text); }

/* ═══════════════════════ Responsive ═══════════════════════ */

@media (max-width: 1000px) {
  .match { grid-template-columns: minmax(0, 1fr); }
  .side-panel { position: static; }
  .chat-log { height: 170px; }
  .detail-layout { grid-template-columns: minmax(0, 1fr); gap: 24px; }
  .detail-art { position: static; max-width: 420px; }
}

@media (max-width: 640px) {
  /* Same stacking nonay.xyz uses on small screens. */
  .site-header-inner { flex-direction: column; align-items: flex-start; padding: 11px 0; }
  .site-nav { justify-content: flex-start; gap: 8px; }
  .nav-link { padding: 7px 8px; font-size: 0.88rem; }
  .hero { padding: 44px 0 22px; }
  .game-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 13px; }
  .board-wrap { max-width: 100%; }
  .code-value { font-size: 2rem; }
  .lobby-panel { padding: 24px 20px 20px; }
}

.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;
}
