:root {
  color-scheme: light dark;
  /* base surfaces + accent align to the gloam design language (light theme) */
  --fg: #1f2328;
  --bg: #ffffff;
  --panel: #f6f8fa;
  --panel-2: #eef1f5;
  --border: #d8dee4;
  --accent: #7c3aed;
  --accent-2: #6d28d9;
  --muted: #59636e;
  --sq-light: #eef0e4;
  --sq-dark: #7f9560;
  --sq-select: #f6f078;
  --sq-target: rgba(30, 30, 30, 0.25);
  --sq-last: rgba(246, 200, 90, 0.55);
}
@media (prefers-color-scheme: dark) {
  :root {
    /* gloam dark theme */
    --fg: #e6edf3; --bg: #0d1117; --panel: #161b22; --panel-2: #1c2230;
    --border: #2a3038; --muted: #9aa7b4;
    --accent: #a371f7; --accent-2: #bd93ff;
    --sq-light: #a8a495; --sq-dark: #5c7047;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, sans-serif;
  color: var(--fg);
  background: var(--bg);
  min-height: 100vh;
  display: grid;
  /* Bound the single column to the viewport (min 0 so content can shrink);
     without this, justify-items:center lets the column grow to max-content and
     wide views overflow horizontally on narrow screens. */
  grid-template-columns: minmax(0, 1fr);
  place-items: center;
}

.view { text-align: center; padding: 2rem; width: 100%; max-width: 60rem; }
.hidden { display: none !important; }

/* The table view anchors to the top of the page: the two game panes have
   different heights, and vertical centering would make the layout jump when
   switching tabs. */
#view-table { align-self: start; }

h1 { font-size: 3rem; margin: 0 0 0.5rem; letter-spacing: -0.02em; }
h2 { margin: 0 0 0.5rem; }
.tagline { color: var(--muted); max-width: 34rem; margin-inline: auto; }
.note { font-size: 0.85rem; color: var(--muted); }

button {
  font: inherit;
  padding: 0.7rem 1.4rem;
  border: 1px solid var(--accent);
  border-radius: 0.5rem;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}
button:disabled { opacity: 0.4; cursor: not-allowed; }
button.ghost { background: transparent; color: var(--accent); }

input[type="text"] {
  font: inherit;
  padding: 0.65rem 0.9rem;
  border: 1px solid var(--muted);
  border-radius: 0.5rem;
  background: var(--panel);
  color: var(--fg);
  min-width: 0;
}

/* ---- home + lobby: gloam-styled entry screens ---- */

/* A soft purple glow sits behind the entry views. It's a fixed layer, but
   hidden views are display:none, so it only shows on home/lobby. */
#view-home::before, #view-lobby::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(58rem 42rem at 80% 6%, color-mix(in srgb, var(--accent) 24%, transparent), transparent 60%),
    radial-gradient(46rem 34rem at 6% 96%, color-mix(in srgb, var(--accent-2) 15%, transparent), transparent 62%);
}

/* home */
#view-home { text-align: left; max-width: 66rem; }
.home-hero {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 3rem;
  align-items: center;
}
/* let both tracks shrink below their content so text wraps and the card
   never forces horizontal scroll on narrow screens */
.home-hero > * { min-width: 0; }

.brand-lockup { display: inline-flex; align-items: center; gap: 0.6rem; }
.brand-name { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.01em; }

.eyebrow {
  margin: 1.5rem 0 0;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--accent);
}
.home-lead h1 {
  font-size: clamp(2.4rem, 6vw, 3.4rem);
  line-height: 1.05;
  letter-spacing: -0.03em;
  margin: 0.5rem 0 0;
}
.home-lead .grad {
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.home-lead .tagline {
  margin: 1.1rem 0 0;
  max-width: 32rem;
  font-size: 1.02rem;
  line-height: 1.55;
}

.trust {
  list-style: none;
  padding: 0;
  margin: 1.5rem 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}
.trust li {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.84rem;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.4rem 0.85rem;
}
.trust-ico { font-size: 1rem; line-height: 1; }

/* action card */
.home-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.28);
}
.field { display: flex; flex-direction: column; gap: 0.35rem; text-align: left; }
.field-label { font-size: 0.85rem; font-weight: 600; }
.field-label .opt { color: var(--muted); font-weight: 400; }
.field input { width: 100%; }

.home-card #btn-create {
  width: 100%;
  padding: 0.85rem 1.4rem;
  font-size: 1.05rem;
  font-weight: 600;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  border-color: transparent;
}

.or-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--muted);
  font-size: 0.8rem;
}
.or-divider::before, .or-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.join-row { display: flex; gap: 0.5rem; }
.join-row #join-phrase { flex: 1; }

.home-card .note { text-align: left; margin: 0; min-height: 1.2em; }

/* invite banner (shown when arriving via a share link) */
.invite-banner {
  background: color-mix(in srgb, var(--accent) 10%, var(--panel));
  border: 1px solid var(--accent);
  border-radius: 0.75rem;
  padding: 0.9rem 1.1rem;
  text-align: left;
}
.invite-kicker {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.invite-phrase {
  font-family: ui-monospace, monospace;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--accent);
  margin-top: 0.25rem;
  word-break: break-word;
}

/* invited mode: a single focused card — lead with Join, hide the manual
   phrase box + marketing lead, demote "Start a table" to a quiet escape hatch. */
#view-home.invited .home-hero { grid-template-columns: 1fr; max-width: 26rem; margin-inline: auto; }
#view-home.invited .home-lead { display: none; }
#view-home.invited .or-divider, #view-home.invited #join-phrase { display: none; }
#view-home.invited .invite-banner { order: 0; }
#view-home.invited .field { order: 1; }
#view-home.invited .join-row { order: 2; }
#view-home.invited #btn-create { order: 3; }
#view-home.invited .home-card .note { order: 4; }
#view-home.invited #btn-join {
  width: 100%;
  padding: 0.85rem 1.4rem;
  font-size: 1.05rem;
  font-weight: 600;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  border-color: transparent;
  color: #fff;
}
#view-home.invited #btn-create {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
  font-size: 0.9rem;
  padding: 0.3rem;
}
#view-home.invited #btn-create:hover { color: var(--accent); }

@media (max-width: 820px) {
  .home-hero { grid-template-columns: 1fr; gap: 2rem; }
  .home-card { width: 100%; max-width: 30rem; }
  .home-lead .tagline { max-width: none; }
}
@media (max-width: 560px) {
  .view { padding: 1.5rem 1.15rem; }
}

/* lobby */
.lobby-card {
  max-width: 46rem;
  margin-inline: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 1.75rem;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.28);
  text-align: left;
}
.lobby-head h2 { margin: 0; }
.lobby-head .tagline { margin: 0.5rem 0 0; max-width: none; }
.lobby-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1.75rem;
  align-items: center;
  margin-top: 1.5rem;
}
.lobby-share { min-width: 0; }
.phrase {
  font-size: clamp(1.6rem, 5vw, 2.2rem);
  font-weight: 700;
  letter-spacing: 0.03em;
  font-family: ui-monospace, monospace;
  color: var(--accent);
  margin: 0 0 1rem;
  word-break: break-word;
}
.share-row { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
.share-row input { flex: 1; min-width: 0; }
.lobby-share .note { margin: 0; }
.lobby-qr-wrap { display: grid; place-items: center; }
#lobby-qr { border-radius: 0.75rem; background: #fff; padding: 0.5rem; width: 11rem; height: 11rem; }

@media (max-width: 640px) {
  .lobby-body { grid-template-columns: 1fr; }
  .lobby-qr-wrap { justify-self: start; }
}

/* table */
.table-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 18rem;
  gap: 1.25rem;
  text-align: left;
  align-items: start;
}
@media (max-width: 760px) {
  .table-grid { grid-template-columns: 1fr; }
}

.status { font-weight: 600; margin-bottom: 0.6rem; min-height: 1.4em; }

.board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  aspect-ratio: 1;
  width: min(100%, 34rem);
  border-radius: 0.5rem;
  overflow: hidden;
  border: 2px solid var(--sq-dark);
  user-select: none;
}
.sq {
  all: unset;
  display: grid;
  place-items: center;
  font-size: clamp(1.4rem, 5.5vmin, 2.6rem);
  cursor: pointer;
  aspect-ratio: 1;
  line-height: 1;
}
.sq.light { background: var(--sq-light); }
.sq.dark { background: var(--sq-dark); }
.sq.last-move { background-color: var(--sq-last); }
.sq.selected { outline: 3px solid var(--sq-select); outline-offset: -3px; }
.sq.target::after {
  content: "";
  width: 26%;
  height: 26%;
  border-radius: 50%;
  background: var(--sq-target);
}
.sq.white-piece { color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,0.55); }
.sq.black-piece { color: #111; text-shadow: 0 1px 2px rgba(255,255,255,0.25); }

.game-actions { display: flex; gap: 0.6rem; margin-top: 0.8rem; align-items: center; }

/* game picker */
.game-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
  gap: 0.8rem;
}
.game-card {
  background: var(--panel);
  border-radius: 0.75rem;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: flex-start;
  border: 1px solid transparent;
}
.game-card.clickable { cursor: pointer; }
.game-card.clickable:hover { border-color: var(--accent); }
.game-title { font-weight: 700; font-size: 1.1rem; display: flex; align-items: center; gap: 0.5rem; }
.game-icon { font-size: 1.9rem; line-height: 1; }
.game-badge { font-size: 0.8rem; color: var(--muted); }
.game-badge.live { color: var(--accent); font-weight: 600; }
.game-matchup { font-size: 0.78rem; color: var(--muted); }
.start-btn {
  font-size: 0.85rem;
  padding: 0.35rem 0.8rem;
}
button.back { margin-bottom: 0.7rem; }

/* backgammon board */
.bg-board {
  width: min(100%, 40rem);
  border: 2px solid var(--sq-dark);
  border-radius: 0.5rem;
  background: var(--sq-light);
  padding: 0.4rem;
  user-select: none;
}
.bg-row { display: grid; grid-template-columns: repeat(6, 1fr) 0.7fr repeat(6, 1fr); gap: 2px; }
.bg-point, .bg-bar {
  all: unset;
  position: relative;
  display: flex;
  align-items: flex-start;
  flex-direction: column;
  gap: 1px;
  min-height: 7.5rem;
  cursor: pointer;
  padding: 2px;
  box-sizing: border-box;
}
.bg-row.bottom .bg-point, .bg-row.bottom .bg-bar {
  flex-direction: column-reverse;
  align-items: flex-start;
}
/* The point triangle is a pseudo-element behind the checkers — clipping the
   cell itself would clip the round checkers into triangles too. */
.bg-point::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background: var(--sq-dark);
  clip-path: polygon(0 0, 100% 0, 50% 92%);
}
.bg-row.bottom .bg-point::before { clip-path: polygon(50% 8%, 100% 100%, 0 100%); }
.bg-point.even::before { background: var(--accent); opacity: 0.92; }
.bg-bar { background: rgba(0,0,0,0.25); border-radius: 3px; align-items: center; }
.bg-point.source, .bg-bar.source { outline: 3px solid var(--sq-select); outline-offset: -3px; }
.bg-point.target, .bg-bar.target { outline: 3px dashed #fff; outline-offset: -3px; }
.checker {
  width: 1.5rem; height: 1.5rem;
  border-radius: 50%;
  align-self: center;
  flex-shrink: 0;
  border: 2px solid rgba(0,0,0,0.4);
  position: relative; /* sit above the triangle pseudo-element */
  z-index: 1;
}
.checker.w { background: #f2f0e8; }
.checker.b { background: #2a2a33; border-color: rgba(255,255,255,0.3); }
.count {
  align-self: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
  background: rgba(0,0,0,0.55);
  border-radius: 0.5rem;
  padding: 0 0.3rem;
  position: relative;
  z-index: 1;
}
.pt-label {
  position: absolute;
  bottom: 0; left: 50%;
  transform: translateX(-50%);
  font-size: 0.6rem;
  color: rgba(255,255,255,0.6);
  z-index: 1;
}
.bg-row.bottom .pt-label { bottom: auto; top: 0; }
.bg-trays { display: flex; gap: 0.5rem; justify-content: flex-end; margin-top: 0.4rem; }
.bg-tray {
  all: unset;
  cursor: pointer;
  padding: 0.3rem 0.7rem;
  border-radius: 0.4rem;
  background: rgba(0,0,0,0.25);
  color: #fff;
  font-size: 0.85rem;
}
.bg-tray.target { outline: 3px dashed #fff; outline-offset: -3px; }
.dice { font-size: 2rem; line-height: 1; min-width: 4.5rem; }

/* connect four */
.c4-board {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  width: min(100%, 26rem);
  background: var(--accent);
  padding: 8px;
  border-radius: 0.75rem;
}
.c4-cell {
  all: unset;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--bg);
  cursor: pointer;
  box-sizing: border-box;
}
.c4-cell.red { background: #e04343; }
.c4-cell.yellow { background: #f0c93c; }
.c4-cell.win { outline: 3px solid #fff; outline-offset: -3px; }

/* checkers */
.ck-board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  width: min(100%, 30rem);
  aspect-ratio: 1;
  border: 2px solid var(--sq-dark);
  border-radius: 0.5rem;
  overflow: hidden;
}
.ck-cell { all: unset; display: grid; place-items: center; aspect-ratio: 1; }
.ck-cell.light { background: var(--sq-light); }
.ck-cell.dark { background: var(--sq-dark); cursor: pointer; }
.ck-cell.selected { outline: 3px solid var(--sq-select); outline-offset: -3px; }
.ck-cell.source { outline: 3px solid rgba(255,255,255,0.55); outline-offset: -3px; }
.ck-cell.target::after {
  content: "";
  width: 26%; height: 26%;
  border-radius: 50%;
  background: var(--sq-target);
  position: absolute;
}
.ck-cell { position: relative; }
.ck-piece {
  width: 70%; height: 70%;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 1.1rem;
  border: 2px solid rgba(0,0,0,0.4);
}
.ck-piece.p1 { background: #a03030; color: #f8d8d8; }
.ck-piece.p2 { background: #f2ead8; color: #6b5b2a; border-color: rgba(0,0,0,0.25); }

/* reversi */
.rv-board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  width: min(100%, 30rem);
  aspect-ratio: 1;
  background: #1d6b3c;
  padding: 4px;
  border-radius: 0.5rem;
}
.rv-cell {
  all: unset;
  position: relative;
  display: grid;
  place-items: center;
  background: #2a8a4f;
  aspect-ratio: 1;
}
.rv-cell.legal { cursor: pointer; }
.rv-cell.legal::after {
  content: "";
  width: 24%; height: 24%;
  border-radius: 50%;
  background: rgba(0,0,0,0.35);
}
.rv-cell.last { outline: 2px solid #f6f078; outline-offset: -2px; }
.rv-disc {
  width: 78%; height: 78%;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.35);
}
.rv-disc.black { background: #17171f; }
.rv-disc.white { background: #f4f2ea; }

/* battleship — stack the two grids so each keeps full width (side-by-side
   flex items with a percentage width collapse to nothing). Default stretch
   sizes each row item to the pane width; the gridwrap caps itself at 25rem. */
.bs-boards { display: flex; flex-direction: column; gap: 1.2rem; }
.bs-label { font-size: 0.85rem; color: var(--muted); margin-bottom: 0.3rem; }
.bs-grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 1px;
  width: min(100%, 19rem);
  aspect-ratio: 1;
  background: rgba(20, 60, 110, 0.5);
  padding: 2px;
  border-radius: 0.4rem;
}
.bs-cell { all: unset; background: #2b5f8f; aspect-ratio: 1; position: relative; }
.bs-cell.shootable, .bs-cell.placeable { cursor: pointer; }
.bs-cell.shootable:hover, .bs-cell.placeable:hover { filter: brightness(1.3); }
.bs-cell.miss::after {
  content: "";
  position: absolute; inset: 35%;
  border-radius: 50%;
  background: rgba(255,255,255,0.55);
}
.bs-cell.ship { background: #6f7c86; }
.bs-cell.hit { background: #c04030; }
.bs-cell.hit::after {
  content: "✕";
  position: absolute; inset: 0;
  display: grid; place-items: center;
  color: #fff; font-size: 0.75rem;
}
.bs-cell.sunk { background: #7a1f14; }
.bs-cell.origin { outline: 2px solid var(--sq-select); outline-offset: -2px; }
.bs-ships { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-bottom: 0.6rem; }
.bs-ships .active { outline: 2px solid var(--sq-select); }

/* side pane */
.side-pane {
  background: var(--panel);
  border-radius: 0.75rem;
  padding: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  min-height: 24rem;
  max-height: 38rem;
}
.members { font-size: 0.95rem; color: var(--muted); display: flex; flex-direction: column; gap: 0.3rem; }
.member { display: flex; align-items: center; gap: 0.4rem; }
.role-icon { font-size: 1.25rem; line-height: 1; color: var(--fg); opacity: 0.8; width: 1.4rem; text-align: center; }
.chat-log {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.95rem;
  overflow-wrap: anywhere;
}
.chat-msg .who { color: var(--accent); font-weight: 600; }
.chat-msg.own .who { color: var(--muted); }
#chat-form { display: flex; }
#chat-input { flex: 1; }

/* ============================ polish layer ============================ */

/* board-pane header + mute toggle */
.board-pane-head { display: flex; justify-content: flex-end; margin-bottom: 0.4rem; }
.icon-btn {
  all: unset;
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 1;
  padding: 0.2rem 0.4rem;
  border-radius: 0.4rem;
  opacity: 0.85;
}
.icon-btn:hover { opacity: 1; background: rgba(127, 127, 127, 0.15); }

/* turn glow — the board the local player must act on breathes softly */
.my-turn { animation: turn-glow 2.4s ease-in-out infinite; }
@keyframes turn-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(124, 92, 255, 0.0); }
  50%      { box-shadow: 0 0 0 4px rgba(124, 92, 255, 0.45); }
}

/* enhanced chess pieces: a subtle disc + crisper glyph */
.sq { position: relative; }
.sq.white-piece, .sq.black-piece { font-weight: 400; }
.sq.white-piece { color: #f7f7fa; text-shadow: 0 1px 1px rgba(0,0,0,0.7), 0 0 2px rgba(0,0,0,0.5); }
.sq.black-piece { color: #14141a; text-shadow: 0 1px 1px rgba(255,255,255,0.35); }

/* chess coordinate labels (orientation-aware, set by the module) */
.coord {
  position: absolute;
  font-size: 0.5rem;
  font-weight: 700;
  line-height: 1;
  opacity: 0.7;
  pointer-events: none;
}
.coord.file { right: 2px; bottom: 1px; }
.coord.rank { left: 2px; top: 1px; }
.sq.light .coord { color: rgba(0, 0, 0, 0.55); }
.sq.dark .coord { color: rgba(255, 255, 255, 0.75); }

/* piece slide (FLIP) — the module sets the transform; this is the fallback */
.sq .slide-piece { display: inline-block; }

/* connect four: clip drops, column hover ghost, drop animation */
.c4-board { overflow: hidden; position: relative; }
.c4-cell.dropping { animation: c4-drop 0.34s cubic-bezier(0.5, 0, 0.6, 1); }
@keyframes c4-drop { from { transform: translateY(-340px); } to { transform: translateY(0); } }
.c4-cell.ghost-red { background: #e04343; opacity: 0.35; }
.c4-cell.ghost-yellow { background: #f0c93c; opacity: 0.35; }

/* reversi: flip animation + place pop */
.rv-disc.flip { animation: rv-flip 0.4s ease-in-out; }
@keyframes rv-flip { 0% { transform: scaleX(1); } 50% { transform: scaleX(0.05); } 100% { transform: scaleX(1); } }
.rv-cell.place-pop .rv-disc { animation: pop 0.3s ease-out; }

/* backgammon checker pop + dice tumble */
.checker.pop { animation: pop 0.28s ease-out; }
@keyframes pop { 0% { transform: scale(0.3); opacity: 0.2; } 70% { transform: scale(1.12); } 100% { transform: scale(1); opacity: 1; } }
.dice.rolled { animation: dice-tumble 0.5s ease-out; }
@keyframes dice-tumble { 0% { transform: rotate(-18deg) scale(0.6); opacity: 0.3; } 60% { transform: rotate(8deg) scale(1.15); } 100% { transform: rotate(0) scale(1); opacity: 1; } }

/* checkers: crown pop */
.ck-piece.crowned { animation: pop 0.3s ease-out; }
.ck-cell.captured::after {
  content: "";
  position: absolute; inset: 15%;
  border-radius: 50%;
  background: rgba(200, 60, 60, 0.5);
  animation: fade-out 0.4s ease-out forwards;
}
@keyframes fade-out { to { opacity: 0; transform: scale(0.4); } }

/* battleship: coordinate gutters, placement preview, shot fx */
.bs-gridwrap {
  display: grid;
  grid-template-columns: 1.15rem 1fr;
  grid-template-rows: 1.15rem 1fr;
  gap: 2px;
  width: min(100%, 25rem);
}
.bs-coltop { grid-column: 2; grid-row: 1; display: grid; grid-template-columns: repeat(10, 1fr); }
.bs-rowside { grid-column: 1; grid-row: 2; display: grid; grid-template-rows: repeat(10, 1fr); }
.bs-coltop span, .bs-rowside span { display: grid; place-items: center; font-size: 0.6rem; color: var(--muted); }
.bs-gridwrap .bs-grid { grid-column: 2; grid-row: 2; width: 100%; }
.bs-cell.preview { background: #4f7fae; outline: 2px solid rgba(255,255,255,0.6); outline-offset: -2px; }
.bs-cell.preview-bad { background: #9a4040; outline: 2px solid rgba(255,120,120,0.8); outline-offset: -2px; }
.bs-cell.miss.just::after { animation: bs-splash 0.45s ease-out; }
@keyframes bs-splash { 0% { transform: scale(2.4); opacity: 0; } 60% { opacity: 1; } 100% { transform: scale(1); opacity: 1; } }
.bs-cell.hit.just { animation: bs-boom 0.4s ease-out; }
@keyframes bs-boom { 0% { transform: scale(1); filter: brightness(2.5); } 50% { transform: scale(1.25); } 100% { transform: scale(1); filter: brightness(1); } }
.bs-cell.sunk.just { animation: pulse-sunk 0.7s ease-out; }
@keyframes pulse-sunk { 0%, 100% { filter: brightness(1); } 40% { filter: brightness(1.9); } }

/* win banner */
#game-pane { position: relative; }
.win-banner {
  position: absolute;
  top: 2.5rem; left: 50%;
  transform: translate(-50%, -8px);
  z-index: 20;
  padding: 0.6rem 1.4rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: 1.05rem;
  color: #fff;
  box-shadow: 0 6px 24px rgba(0,0,0,0.3);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease, transform 0.35s ease;
}
.win-banner.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; cursor: pointer; }
.win-banner.win { background: linear-gradient(135deg, #7c5cff, #4aa3ff); }
.win-banner.lose { background: #55556a; }
.win-banner.neutral { background: #6b6b7b; }

/* confetti (rains over the viewport; skipped under reduced motion) */
.confetti-layer { position: fixed; inset: 0; pointer-events: none; z-index: 100; overflow: hidden; }
.confetti-bit {
  position: absolute; top: -12px;
  width: 8px; height: 12px;
  border-radius: 1px;
  animation-name: confetti-fall;
  animation-timing-function: cubic-bezier(0.3, 0.6, 0.5, 1);
  animation-fill-mode: forwards;
}
@keyframes confetti-fall {
  to { transform: translate(var(--drift, 0), 105vh) rotate(var(--rot, 180deg)); opacity: 0.15; }
}

@media (prefers-reduced-motion: reduce) {
  .my-turn { animation: none; box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.5); }
  .c4-cell.dropping, .rv-disc.flip, .rv-cell.place-pop .rv-disc, .checker.pop,
  .dice.rolled, .ck-piece.crowned, .ck-cell.captured::after,
  .bs-cell.miss.just::after, .bs-cell.hit.just, .bs-cell.sunk.just { animation: none; }
  .win-banner { transition: opacity 0.2s; }
}

/* version badge — faint, fixed, on every screen; brightens on hover */
.version-badge {
  position: fixed;
  bottom: 0.35rem;
  right: 0.55rem;
  z-index: 40;
  font-size: 0.68rem;
  font-family: ui-monospace, monospace;
  color: var(--muted);
  opacity: 0.45;
  text-decoration: none;
  pointer-events: auto;
}
.version-badge:hover { opacity: 0.9; }

/* toast */
.toast {
  position: fixed;
  bottom: 1.2rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--fg);
  color: var(--bg);
  padding: 0.6rem 1.1rem;
  border-radius: 0.6rem;
  font-size: 0.9rem;
  max-width: 90vw;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.25);
}
