/* ==========================================================================
   Royal Games — lobby + Chess + Checkers (shared 2D look, AdSense-ready)
   ========================================================================== */

:root {
  /* Palette — warm royal wood & gold (richer depth) */
  --bg-deep: #0a0806;
  --bg: #15100c;
  --bg-elevated: #261c14;
  --bg-card: #2e231a;
  --bg-card-soft: #36291e;

  --ink: #f7efe0;
  --ink-muted: #c4b49a;
  --ink-faint: #8a7860;

  --gold: #d4af37;
  --gold-bright: #f5d76e;
  --gold-dim: #8a7020;
  --ember: #c45c3a;
  --velvet: #3d1f28;

  --board-light: #e0ccaa;
  --board-dark: #5c3d2e;
  --board-dark-alt: #4a3124;
  --board-frame: #2c1f14;
  --board-edge: #3d2a1c;

  --piece-red: #c23b2a;
  --piece-red-deep: #8b2418;
  --piece-red-shine: #e86a55;
  --piece-black: #2a2a2e;
  --piece-black-deep: #111114;
  --piece-black-shine: #4a4a52;

  --valid: rgba(212, 175, 55, 0.55);
  --valid-ring: rgba(240, 208, 96, 0.9);
  --selected: rgba(240, 208, 96, 0.35);
  --danger: #e85d4c;

  --ad-bg: #16120e;
  --ad-border: #3a3024;
  --ad-label: #6b5d48;

  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 22px;

  --shadow-soft: 0 10px 40px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(212, 175, 55, 0.06);
  --shadow-board: 0 24px 60px rgba(0, 0, 0, 0.6), 0 4px 12px rgba(0, 0, 0, 0.45), 0 0 40px rgba(212, 175, 55, 0.06);
  --ring-focus: 0 0 0 3px rgba(212, 175, 55, 0.45);

  --font-display: "Cormorant Garamond", Georgia, serif;
  --font-ui: "DM Sans", system-ui, sans-serif;

  --header-h: 72px;
  --ad-gap: 28px; /* AdSense: keep ads away from game click targets */
  --board-size: min(72vw, 520px);
  --square: calc(var(--board-size) / 8);

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --duration: 220ms;
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  position: relative;
  isolation: isolate;
  background-color: var(--bg-deep);
  /* Layered “palace hall” base */
  background-image:
    radial-gradient(ellipse 100% 70% at 50% -10%, rgba(245, 215, 110, 0.14), transparent 55%),
    radial-gradient(ellipse 50% 45% at 0% 30%, rgba(196, 92, 58, 0.12), transparent 55%),
    radial-gradient(ellipse 55% 50% at 100% 70%, rgba(90, 50, 90, 0.14), transparent 50%),
    radial-gradient(ellipse 80% 40% at 50% 100%, rgba(26, 80, 50, 0.1), transparent 50%),
    linear-gradient(180deg, #120e0a 0%, #0a0806 40%, #0d0a08 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Animated ambient glow orbs */
body::before {
  content: "";
  position: fixed;
  inset: -20%;
  z-index: -2;
  pointer-events: none;
  background:
    radial-gradient(circle 420px at 20% 30%, rgba(212, 175, 55, 0.16), transparent 60%),
    radial-gradient(circle 380px at 80% 20%, rgba(194, 59, 42, 0.1), transparent 55%),
    radial-gradient(circle 500px at 70% 85%, rgba(45, 90, 70, 0.12), transparent 55%),
    radial-gradient(circle 320px at 15% 80%, rgba(120, 70, 140, 0.08), transparent 50%);
  animation: ambient-drift 22s ease-in-out infinite alternate;
}

/* Film grain + vignette + soft lattice (alive texture) */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 1;
  background-image:
    /* vignette */
    radial-gradient(ellipse 75% 70% at 50% 45%, transparent 30%, rgba(5, 3, 2, 0.55) 100%),
    /* fine diamond lattice */
    repeating-linear-gradient(
      45deg,
      transparent,
      transparent 28px,
      rgba(212, 175, 55, 0.018) 28px,
      rgba(212, 175, 55, 0.018) 29px
    ),
    repeating-linear-gradient(
      -45deg,
      transparent,
      transparent 28px,
      rgba(212, 175, 55, 0.012) 28px,
      rgba(212, 175, 55, 0.012) 29px
    ),
    /* grain (SVG noise) */
    url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.55'/%3E%3C/svg%3E");
  background-size: 100% 100%, 56px 56px, 56px 56px, 180px 180px;
  mix-blend-mode: soft-light;
  opacity: 0.55;
  animation: grain-shift 0.5s steps(2) infinite;
}

@keyframes ambient-drift {
  0% {
    transform: translate(0, 0) scale(1);
    filter: hue-rotate(0deg);
  }
  50% {
    transform: translate(2%, -1.5%) scale(1.05);
  }
  100% {
    transform: translate(-2%, 2%) scale(1.03);
    filter: hue-rotate(8deg);
  }
}

@keyframes grain-shift {
  0% {
    background-position: 0 0, 0 0, 0 0, 0 0;
  }
  100% {
    background-position: 0 0, 0 0, 0 0, 3px 4px;
  }
}

@keyframes float-soft {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-6px);
  }
}

@keyframes shimmer-border {
  0%,
  100% {
    border-color: rgba(212, 175, 55, 0.12);
    box-shadow: var(--shadow-soft);
  }
  50% {
    border-color: rgba(212, 175, 55, 0.28);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4), 0 0 24px rgba(212, 175, 55, 0.08);
  }
}

@keyframes title-glow {
  0%,
  100% {
    filter: drop-shadow(0 0 12px rgba(212, 175, 55, 0.25));
  }
  50% {
    filter: drop-shadow(0 0 22px rgba(245, 215, 110, 0.45));
  }
}

@keyframes sparkle-twinkle {
  0%,
  100% {
    opacity: 0.15;
    transform: scale(0.8);
  }
  50% {
    opacity: 0.7;
    transform: scale(1.15);
  }
}

button,
a {
  font-family: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

a {
  color: var(--gold);
  text-decoration: none;
  transition: color var(--duration) var(--ease);
}

a:hover {
  color: var(--gold-bright);
}

img {
  max-width: 100%;
  display: block;
}

/* App shell --------------------------------------------------------------- */
.app {
  position: relative;
  z-index: 1;
  width: min(1280px, 100%);
  margin: 0 auto;
  padding: 12px 16px 40px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Ad regions — clear labels, isolation from game UI ----------------------- */
.ad-region {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  /* Physical separation from interactive game content */
  margin-block: 4px;
}

.ad-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ad-label);
  user-select: none;
}

.ad-slot {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ad-bg);
  border: 1px dashed var(--ad-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  /* Min heights help AdSense fill rate & prevent layout shift */
  min-height: 90px;
}

.ad-slot--leaderboard {
  max-width: 970px;
  min-height: 90px;
}

.ad-slot--skyscraper {
  width: 160px;
  min-height: 600px;
  max-height: 600px;
}

.ad-slot--rectangle {
  max-width: 336px;
  min-height: 280px;
}

.ad-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 16px;
  text-align: center;
  color: var(--ink-faint);
  font-size: 12px;
  font-weight: 500;
  min-height: inherit;
  width: 100%;
}

.ad-placeholder__icon {
  color: var(--gold-dim);
  font-size: 14px;
  opacity: 0.7;
}

.ad-placeholder__hint {
  font-size: 11px;
  opacity: 0.65;
}

.ad-placeholder--tall {
  min-height: 580px;
}

.ad-placeholder--box {
  min-height: 250px;
}

.ad-region--top {
  margin-bottom: 4px;
}

.ad-region--bottom {
  margin-top: var(--ad-gap);
}

.ad-region--in-content {
  margin-top: var(--ad-gap);
  /* Extra padding so ads aren't adjacent to New Game / Undo */
  padding-top: 8px;
}

.ad-region--side {
  display: none; /* shown on wide screens only */
}

.ad-region--panel .ad-slot {
  max-width: 100%;
}

/* Header ------------------------------------------------------------------ */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 4px 4px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand__mark {
  position: relative;
  width: 48px;
  height: 48px;
  flex-shrink: 0;
}

.brand__piece {
  position: absolute;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.4);
}

.brand__piece--dark {
  top: 2px;
  left: 2px;
  background: radial-gradient(circle at 35% 30%, var(--piece-black-shine), var(--piece-black) 55%, var(--piece-black-deep));
  border: 2px solid #1a1a1e;
}

.brand__piece--light {
  bottom: 2px;
  right: 2px;
  background: radial-gradient(circle at 35% 30%, var(--piece-red-shine), var(--piece-red) 55%, var(--piece-red-deep));
  border: 2px solid #6b1e14;
}

.brand__title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 3vw, 2.1rem);
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.1;
  background: linear-gradient(135deg, #fff4c4, var(--gold-bright) 25%, var(--gold) 55%, #b8942a 85%, #e8c84a);
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: title-shimmer 8s linear infinite, title-glow 5s ease-in-out infinite;
}

@keyframes title-shimmer {
  0% {
    background-position: 0% center;
  }
  100% {
    background-position: 200% center;
  }
}

.brand__tagline {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--ink-muted);
  letter-spacing: 0.04em;
}

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

/* Buttons ----------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  transition:
    background var(--duration) var(--ease),
    color var(--duration) var(--ease),
    box-shadow var(--duration) var(--ease),
    transform 120ms var(--ease);
}

.btn:focus-visible {
  outline: none;
  box-shadow: var(--ring-focus);
}

.btn:active {
  transform: scale(0.97);
}

.btn--ghost {
  color: var(--ink-muted);
  background: transparent;
  border: 1px solid transparent;
}

.btn--ghost:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.08);
}

.btn--secondary {
  color: var(--ink);
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.btn--secondary:hover {
  background: var(--bg-card-soft);
  border-color: rgba(212, 175, 55, 0.25);
}

.btn--primary {
  color: #1a1208;
  background: linear-gradient(160deg, var(--gold-bright), var(--gold) 45%, #b8942a);
  box-shadow: 0 4px 16px rgba(212, 175, 55, 0.25);
}

.btn--primary:hover {
  box-shadow: 0 6px 22px rgba(212, 175, 55, 0.4);
  filter: brightness(1.05);
}

.btn__icon {
  font-size: 15px;
  line-height: 1;
}

/* Layout ------------------------------------------------------------------ */
.layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  align-items: start;
}

.game-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  /* Isolate game chrome from neighboring ads */
  padding: 0 4px;
}

.game-shell {
  width: 100%;
  max-width: calc(var(--board-size) + 48px);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* Status bar -------------------------------------------------------------- */
.status-bar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  background:
    linear-gradient(135deg, rgba(212, 175, 55, 0.08), transparent 40%),
    linear-gradient(180deg, #2e241a, var(--bg-card));
  border: 1px solid rgba(212, 175, 55, 0.14);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft), inset 0 1px 0 rgba(255, 245, 220, 0.06);
  backdrop-filter: blur(8px);
}

.player-card {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  transition: background var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}

.player-card.is-active {
  background: rgba(212, 175, 55, 0.1);
  box-shadow: inset 0 0 0 1px rgba(212, 175, 55, 0.35);
}

.player-card__avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.4), inset 0 2px 4px rgba(255, 255, 255, 0.15);
}

.player-card__avatar--red {
  background: radial-gradient(circle at 32% 28%, var(--piece-red-shine), var(--piece-red) 50%, var(--piece-red-deep));
  border: 2px solid #6b1e14;
}

.player-card__avatar--black {
  background: radial-gradient(circle at 32% 28%, var(--piece-black-shine), var(--piece-black) 50%, var(--piece-black-deep));
  border: 2px solid #0a0a0c;
}

.player-card__info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.player-card__info--end {
  text-align: right;
  align-items: flex-end;
}

.player-card__name {
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.02em;
}

.player-card__meta {
  font-size: 11px;
  color: var(--ink-muted);
}

.player-card__turn {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: transparent;
  flex-shrink: 0;
  transition: background var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}

.player-card.is-active .player-card__turn {
  background: var(--gold);
  box-shadow: 0 0 10px var(--gold);
}

.status-center {
  text-align: center;
  padding: 0 6px;
}

.status-message {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--ink);
}

.status-mode {
  margin: 2px 0 0;
  font-size: 11px;
  color: var(--ink-faint);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* Board ------------------------------------------------------------------- */
.board-frame {
  position: relative;
  width: var(--board-size);
  margin: 0 auto;
  padding: 14px;
  background:
    linear-gradient(145deg, #4a3424 0%, var(--board-frame) 40%, #1a120c 100%);
  border-radius: 18px;
  box-shadow:
    var(--shadow-board),
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    inset 0 -2px 8px rgba(0, 0, 0, 0.4);
}

.board-frame__glow {
  pointer-events: none;
  position: absolute;
  inset: -2px;
  border-radius: 20px;
  background: linear-gradient(135deg, rgba(212, 175, 55, 0.25), transparent 40%, transparent 60%, rgba(212, 175, 55, 0.12));
  opacity: 0.6;
  z-index: 0;
}

.board {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  width: 100%;
  aspect-ratio: 1;
  border-radius: 6px;
  overflow: hidden;
  box-shadow:
    inset 0 0 0 2px rgba(0, 0, 0, 0.35),
    0 2px 0 rgba(255, 255, 255, 0.05);
  user-select: none;
  touch-action: manipulation;
}

.board-coords {
  position: absolute;
  z-index: 2;
  display: flex;
  pointer-events: none;
  font-size: 10px;
  font-weight: 600;
  color: rgba(243, 233, 216, 0.45);
  letter-spacing: 0.04em;
}

.board-coords--files {
  left: 14px;
  right: 14px;
  bottom: 2px;
  justify-content: space-around;
  padding: 0 2px;
}

.board-coords--ranks {
  top: 14px;
  bottom: 14px;
  left: 2px;
  flex-direction: column;
  justify-content: space-around;
  align-items: center;
  width: 12px;
}

/* Squares ----------------------------------------------------------------- */
.square {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 120ms ease;
}

.square--light {
  background: linear-gradient(160deg, #e4d2b0, var(--board-light) 60%, #c9b48a);
}

.square--dark {
  background:
    radial-gradient(ellipse at 30% 25%, rgba(255, 255, 255, 0.06), transparent 50%),
    linear-gradient(160deg, #6b4836, var(--board-dark) 55%, var(--board-dark-alt));
}

.square.is-selected {
  box-shadow: inset 0 0 0 3px var(--gold-bright);
  background:
    radial-gradient(circle at center, var(--selected), transparent 70%),
    linear-gradient(160deg, #6b4836, var(--board-dark) 55%, var(--board-dark-alt));
}

.square.is-valid::after {
  content: "";
  position: absolute;
  width: 28%;
  height: 28%;
  border-radius: 50%;
  background: var(--valid);
  box-shadow: 0 0 12px var(--valid-ring);
  z-index: 1;
  animation: pulse-dot 1.4s var(--ease) infinite;
}

.square.is-valid.has-capture::after {
  width: 72%;
  height: 72%;
  background: transparent;
  border: 3px solid var(--gold);
  box-shadow: 0 0 14px rgba(212, 175, 55, 0.5);
  animation: pulse-ring 1.2s var(--ease) infinite;
}

.square.is-last-from::before,
.square.is-last-to::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(212, 175, 55, 0.12);
  pointer-events: none;
}

@keyframes pulse-dot {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.85;
  }
  50% {
    transform: scale(1.15);
    opacity: 1;
  }
}

@keyframes pulse-ring {
  0%,
  100% {
    transform: scale(0.96);
    opacity: 0.8;
  }
  50% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Pieces ------------------------------------------------------------------ */
.piece {
  position: relative;
  z-index: 2;
  width: 78%;
  height: 78%;
  border-radius: 50%;
  cursor: pointer;
  transition:
    transform 160ms var(--ease),
    filter 160ms var(--ease),
    box-shadow 160ms var(--ease);
  /* Layered 2D “coin” look */
  box-shadow:
    0 4px 6px rgba(0, 0, 0, 0.45),
    0 1px 0 rgba(255, 255, 255, 0.12) inset,
    0 -3px 6px rgba(0, 0, 0, 0.25) inset;
}

.piece:hover {
  transform: scale(1.06);
  filter: brightness(1.06);
}

.piece:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 3px var(--gold-bright),
    0 4px 6px rgba(0, 0, 0, 0.45);
}

.piece--red {
  background:
    radial-gradient(circle at 32% 28%, rgba(255, 255, 255, 0.35), transparent 28%),
    radial-gradient(circle at 50% 55%, var(--piece-red), var(--piece-red-deep) 75%);
  border: 2px solid #5c180f;
}

.piece--red::before {
  content: "";
  position: absolute;
  inset: 14%;
  border-radius: 50%;
  border: 2px solid rgba(255, 200, 180, 0.22);
  box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.2);
}

.piece--black {
  background:
    radial-gradient(circle at 32% 28%, rgba(255, 255, 255, 0.22), transparent 28%),
    radial-gradient(circle at 50% 55%, #3a3a42, var(--piece-black-deep) 75%);
  border: 2px solid #0c0c10;
}

.piece--black::before {
  content: "";
  position: absolute;
  inset: 14%;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.1);
  box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.35);
}

.piece--king::after {
  content: "♛";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(12px, 3.2vw, 18px);
  line-height: 1;
  color: var(--gold-bright);
  text-shadow:
    0 1px 2px rgba(0, 0, 0, 0.6),
    0 0 8px rgba(212, 175, 55, 0.45);
  pointer-events: none;
}

.piece.is-selected {
  transform: scale(1.08) translateY(-2px);
  box-shadow:
    0 0 0 3px var(--gold-bright),
    0 8px 16px rgba(0, 0, 0, 0.5),
    0 1px 0 rgba(255, 255, 255, 0.15) inset;
  z-index: 3;
}

.piece.is-movable {
  animation: piece-nudge 2s var(--ease) infinite;
}

.piece.is-capturing {
  animation: capture-flash 0.35s var(--ease);
}

@keyframes piece-nudge {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-2px);
  }
}

@keyframes capture-flash {
  0% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.15);
    filter: brightness(1.3);
  }
  100% {
    transform: scale(1);
  }
}

.piece.is-sliding {
  transition: transform 280ms var(--ease);
  z-index: 5;
  pointer-events: none;
}

/* Controls ---------------------------------------------------------------- */
.controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}

.mode-toggle {
  display: inline-flex;
  padding: 4px;
  background: var(--bg-elevated);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 999px;
  gap: 2px;
}

.mode-btn {
  padding: 8px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-muted);
  transition:
    background var(--duration) var(--ease),
    color var(--duration) var(--ease),
    box-shadow var(--duration) var(--ease);
}

.mode-btn:hover {
  color: var(--ink);
}

.mode-btn.is-active {
  color: #1a1208;
  background: linear-gradient(160deg, var(--gold-bright), var(--gold));
  box-shadow: 0 2px 10px rgba(212, 175, 55, 0.3);
}

.mode-btn:focus-visible {
  outline: none;
  box-shadow: var(--ring-focus);
}

.control-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

/* Side panel -------------------------------------------------------------- */
.side-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  max-width: 320px;
  margin: 0 auto;
}

.panel-card {
  padding: 18px 18px 16px;
  background:
    linear-gradient(145deg, rgba(212, 175, 55, 0.06), transparent 50%),
    linear-gradient(165deg, #32261c, var(--bg-card));
  border: 1px solid rgba(212, 175, 55, 0.12);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft), inset 0 1px 0 rgba(255, 245, 220, 0.05);
  backdrop-filter: blur(10px);
  transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}

.panel-card:hover {
  border-color: rgba(212, 175, 55, 0.22);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.4), 0 0 20px rgba(212, 175, 55, 0.06);
}

.panel-card--soft {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent),
    var(--bg-card);
}

.panel-card__title {
  margin: 0 0 12px;
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--gold);
  letter-spacing: 0.02em;
}

.tips-list {
  margin: 0;
  padding: 0 0 0 18px;
  color: var(--ink-muted);
  font-size: 13px;
}

.tips-list li {
  margin-bottom: 8px;
}

.tips-list li:last-child {
  margin-bottom: 0;
}

.tips-list strong {
  color: var(--ink);
  font-weight: 600;
}

.stats {
  margin: 0;
}

.stats__row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 13px;
}

.stats__row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.stats__row dt {
  color: var(--ink-muted);
  margin: 0;
}

.stats__row dd {
  margin: 0;
  font-weight: 600;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

/* Footer ------------------------------------------------------------------ */
.site-footer {
  text-align: center;
  padding: 12px 8px 0;
  color: var(--ink-faint);
  font-size: 12px;
}

.site-footer p {
  margin: 4px 0;
}

.footer-links {
  display: flex;
  gap: 10px;
  justify-content: center;
  align-items: center;
}

.footer-links a {
  color: var(--ink-muted);
}

.footer-links a:hover {
  color: var(--gold);
}

/* Modal ------------------------------------------------------------------- */
.modal {
  border: none;
  padding: 0;
  background: transparent;
  max-width: min(480px, calc(100vw - 32px));
  color: var(--ink);
}

.modal::backdrop {
  background: rgba(8, 6, 4, 0.72);
  backdrop-filter: blur(4px);
}

.modal__inner {
  background: linear-gradient(165deg, #2e241a, var(--bg-card));
  border: 1px solid rgba(212, 175, 55, 0.2);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  overflow: hidden;
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 8px;
}

.modal__header h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.5rem;
  color: var(--gold-bright);
}

.modal__close {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 22px;
  line-height: 1;
  color: var(--ink-muted);
  transition: background var(--duration) var(--ease), color var(--duration) var(--ease);
}

.modal__close:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
}

.modal__body {
  padding: 8px 20px 12px;
  color: var(--ink-muted);
  font-size: 14px;
}

.modal__body h3 {
  margin: 14px 0 6px;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink);
}

.modal__body ul {
  margin: 0;
  padding-left: 18px;
}

.modal__body li {
  margin-bottom: 4px;
}

.modal__footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 20px 18px;
}

.modal--result .modal__inner--result {
  text-align: center;
  padding: 36px 28px 28px;
}

.result-trophy {
  font-size: 48px;
  line-height: 1;
  color: var(--gold-bright);
  text-shadow: 0 0 24px rgba(212, 175, 55, 0.45);
  margin-bottom: 8px;
  animation: float-trophy 2.5s var(--ease) infinite;
}

@keyframes float-trophy {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-6px);
  }
}

.modal--result h2 {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: 2rem;
  color: var(--gold-bright);
}

.modal--result p {
  margin: 0 0 20px;
  color: var(--ink-muted);
}

.modal--result .modal__footer {
  justify-content: center;
  padding: 0;
}

/* Responsive -------------------------------------------------------------- */
@media (min-width: 900px) {
  .layout {
    grid-template-columns: 1fr 300px;
    gap: 28px;
  }

  .side-panel {
    margin: 0;
    position: sticky;
    top: 16px;
  }

  .game-column {
    align-items: flex-end;
  }
}

@media (min-width: 1200px) {
  .layout {
    grid-template-columns: 160px 1fr 300px;
    gap: 24px;
  }

  .ad-region--side {
    display: flex;
    position: sticky;
    top: 16px;
  }

  .game-column {
    align-items: center;
  }
}

@media (max-width: 640px) {
  :root {
    --board-size: min(92vw, 420px);
    --ad-gap: 32px;
  }

  .app {
    padding: 8px 10px 32px;
  }

  .site-header {
    flex-wrap: wrap;
  }

  .status-bar {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
    gap: 8px;
  }

  .status-center {
    grid-column: 1 / -1;
    order: -1;
    padding-bottom: 4px;
  }

  .player-card__meta {
    font-size: 10px;
  }

  .board-coords {
    display: none;
  }

  .ad-slot--leaderboard {
    min-height: 60px;
  }

  .ad-slot--rectangle {
    min-height: 250px;
  }

  /* On mobile, keep ads below fold relative to board when possible */
  .ad-region--in-content {
    margin-top: 32px;
  }
}

/* Floating dust / embers (injected by atmosphere.js) ---------------------- */
.atmosphere {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.atmosphere__particle {
  position: absolute;
  bottom: -10%;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(245, 215, 110, 0.9), rgba(212, 175, 55, 0.1));
  box-shadow: 0 0 6px rgba(212, 175, 55, 0.45);
  animation: particle-rise linear infinite;
  opacity: 0;
}

.atmosphere__particle--ember {
  background: radial-gradient(circle, rgba(232, 140, 90, 0.85), transparent);
  box-shadow: 0 0 8px rgba(196, 92, 58, 0.4);
  width: 2px;
  height: 2px;
}

@keyframes particle-rise {
  0% {
    transform: translateY(0) translateX(0) scale(0.6);
    opacity: 0;
  }
  10% {
    opacity: 0.7;
  }
  70% {
    opacity: 0.35;
  }
  100% {
    transform: translateY(-110vh) translateX(var(--drift, 20px)) scale(1);
    opacity: 0;
  }
}

/* Site footer lift */
.site-footer {
  position: relative;
  z-index: 1;
  border-top: 1px solid rgba(212, 175, 55, 0.08);
  margin-top: 8px;
  padding-top: 20px !important;
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.2));
}

/* Reduced motion ---------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  body::before,
  body::after,
  .atmosphere {
    animation: none !important;
  }
}

/* Privacy page helpers ---------------------------------------------------- */
.legal-page {
  max-width: 720px;
  margin: 0 auto;
  padding: 32px 20px 60px;
}

.legal-page h1 {
  font-family: var(--font-display);
  font-size: 2.2rem;
  color: var(--gold-bright);
  margin: 0 0 8px;
}

.legal-page .lede {
  color: var(--ink-muted);
  margin-bottom: 28px;
}

.legal-page h2 {
  font-family: var(--font-display);
  font-size: 1.35rem;
  color: var(--gold);
  margin: 28px 0 10px;
}

.legal-page p,
.legal-page li {
  color: var(--ink-muted);
  line-height: 1.65;
}

.legal-page a.back {
  display: inline-flex;
  margin-bottom: 20px;
  font-size: 13px;
  font-weight: 600;
}

/* Brand link (game pages → lobby) ----------------------------------------- */
.brand--link {
  text-decoration: none;
  color: inherit;
}

.brand--link:hover .brand__title {
  filter: brightness(1.08);
}

.brand__mark--crown,
.brand__mark--chess {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  font-size: 26px;
  line-height: 1;
  background: linear-gradient(145deg, #4a3828, #1a120c 60%, #2a1810);
  border: 1px solid rgba(212, 175, 55, 0.45);
  box-shadow:
    0 4px 14px rgba(0, 0, 0, 0.35),
    0 0 20px rgba(212, 175, 55, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  color: var(--gold-bright);
  animation: float-soft 4.5s ease-in-out infinite;
}

.brand__mark {
  animation: float-soft 4.5s ease-in-out infinite;
}

/* Chess player avatars ---------------------------------------------------- */
.player-card__avatar--white,
.player-card__avatar--black-chess {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  line-height: 1;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.4);
}

.player-card__avatar--white {
  background: radial-gradient(circle at 32% 28%, #fff8e8, #e8d4b0 55%, #c4a878);
  border: 2px solid #8a7348;
  color: #2a2118;
}

.player-card__avatar--black-chess {
  background: radial-gradient(circle at 32% 28%, #4a4a52, #1a1a1e 60%, #0a0a0c);
  border: 2px solid #0a0a0c;
  color: #f0e6d4;
}

.player-card__meta {
  letter-spacing: 0.02em;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Check square (king in check) -------------------------------------------- */
.square.is-check {
  background:
    radial-gradient(circle at center, rgba(232, 93, 76, 0.55), rgba(232, 93, 76, 0.15) 70%),
    linear-gradient(160deg, #6b4836, var(--board-dark) 55%, var(--board-dark-alt)) !important;
  box-shadow: inset 0 0 0 2px rgba(232, 93, 76, 0.7);
}

.square.square--light.is-check {
  background:
    radial-gradient(circle at center, rgba(232, 93, 76, 0.45), rgba(232, 93, 76, 0.12) 70%),
    linear-gradient(160deg, #e4d2b0, var(--board-light) 60%, #c9b48a) !important;
}

/* Chess pieces ------------------------------------------------------------ */
.chess-piece {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(28px, 7vw, 44px);
  line-height: 1;
  cursor: pointer;
  border: none;
  background: transparent;
  padding: 0;
  transition: transform 160ms var(--ease), filter 160ms var(--ease);
  text-shadow:
    0 2px 3px rgba(0, 0, 0, 0.35),
    0 0 1px rgba(0, 0, 0, 0.5);
  -webkit-user-select: none;
  user-select: none;
}

.chess-piece--w {
  color: #fff8ec;
  -webkit-text-stroke: 0.5px rgba(40, 28, 16, 0.35);
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.55));
}

.chess-piece--b {
  color: #1c1410;
  -webkit-text-stroke: 0.6px rgba(255, 236, 200, 0.35);
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.55));
}

/* Extra contrast on opposing square tones */
.square--dark .chess-piece--w {
  color: #fffaf0;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.65));
}

.square--light .chess-piece--b {
  color: #120e0c;
  -webkit-text-stroke: 0.4px rgba(80, 50, 30, 0.25);
}

.square--dark .chess-piece--b {
  color: #0e0a08;
  -webkit-text-stroke: 1px rgba(232, 210, 170, 0.55);
  filter: drop-shadow(0 0 2px rgba(255, 240, 210, 0.25)) drop-shadow(0 2px 3px rgba(0, 0, 0, 0.5));
}

.chess-piece:hover {
  transform: scale(1.08);
}

.chess-piece:focus-visible {
  outline: none;
  border-radius: 8px;
  box-shadow: 0 0 0 3px var(--gold-bright);
}

.chess-piece.is-selected {
  transform: scale(1.1) translateY(-2px);
  filter: drop-shadow(0 0 6px rgba(240, 208, 96, 0.7));
}

.chess-piece.is-movable {
  animation: piece-nudge 2s var(--ease) infinite;
}

/* Promotion picker -------------------------------------------------------- */
.promote-choices {
  display: flex !important;
  gap: 12px;
  justify-content: center;
  padding: 16px 20px 24px !important;
}

.promote-btn {
  width: 64px;
  height: 64px;
  border-radius: 14px;
  font-size: 36px;
  line-height: 1;
  background: linear-gradient(160deg, #3a2c1e, #241c15);
  border: 1px solid rgba(212, 175, 55, 0.35);
  color: #f7f0e2;
  transition: transform 140ms var(--ease), border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}

.promote-btn:hover {
  transform: scale(1.06);
  border-color: var(--gold);
  box-shadow: 0 6px 20px rgba(212, 175, 55, 0.25);
}

.promote-btn--white {
  color: #fff8ec;
}

.promote-btn--black {
  color: #1a1512;
  background: linear-gradient(160deg, #e8d4b0, #c4a878);
}

/* Lobby ------------------------------------------------------------------- */
.lobby-hero {
  position: relative;
  text-align: center;
  padding: 28px 16px 20px;
  max-width: 680px;
  margin: 8px auto 12px;
  border-radius: var(--radius-lg);
  background:
    radial-gradient(ellipse 80% 100% at 50% 0%, rgba(212, 175, 55, 0.12), transparent 70%),
    linear-gradient(180deg, rgba(40, 30, 22, 0.55), rgba(20, 15, 12, 0.2));
  border: 1px solid rgba(212, 175, 55, 0.14);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 245, 220, 0.06);
  overflow: hidden;
}

.lobby-hero::before,
.lobby-hero::after {
  content: "✦";
  position: absolute;
  top: 18px;
  font-size: 12px;
  color: var(--gold);
  opacity: 0.45;
  animation: sparkle-twinkle 3.2s ease-in-out infinite;
}

.lobby-hero::before {
  left: 18%;
}

.lobby-hero::after {
  right: 18%;
  animation-delay: 1.1s;
  content: "✧";
}

.lobby-hero__eyebrow {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold-bright);
  text-shadow: 0 0 20px rgba(212, 175, 55, 0.35);
}

.lobby-hero__title {
  margin: 0 0 10px;
  font-family: var(--font-display);
  font-size: clamp(1.9rem, 4.5vw, 2.8rem);
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--ink);
  text-shadow: 0 2px 24px rgba(212, 175, 55, 0.15);
}

.lobby-hero__lede {
  margin: 0;
  color: var(--ink-muted);
  font-size: 15px;
  line-height: 1.6;
}

.lobby-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 28px;
  align-items: start;
}

.lobby-main {
  display: flex;
  flex-direction: column;
  gap: 28px;
  min-width: 0;
}

.game-cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

.game-card {
  position: relative;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  text-decoration: none;
  color: inherit;
  background:
    linear-gradient(165deg, rgba(255, 245, 220, 0.04), transparent 40%),
    linear-gradient(165deg, #32261c, var(--bg-card) 55%, #221910);
  border: 1px solid rgba(212, 175, 55, 0.14);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-soft);
  transition:
    transform 280ms var(--ease),
    border-color 280ms var(--ease),
    box-shadow 280ms var(--ease);
  animation: shimmer-border 7s ease-in-out infinite;
}

.game-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    120deg,
    transparent 30%,
    rgba(255, 240, 200, 0.07) 48%,
    transparent 62%
  );
  transform: translateX(-120%);
  transition: transform 0.7s var(--ease);
  pointer-events: none;
  z-index: 2;
}

.game-card:hover::before {
  transform: translateX(120%);
}

.game-card:hover {
  transform: translateY(-6px) scale(1.01);
  border-color: rgba(245, 215, 110, 0.5);
  box-shadow:
    0 20px 48px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(212, 175, 55, 0.2),
    0 0 36px rgba(212, 175, 55, 0.12);
  animation: none;
}

.game-card:focus-visible {
  outline: none;
  box-shadow: var(--ring-focus), var(--shadow-soft);
}

.game-card__preview {
  position: relative;
  z-index: 1;
  padding: 20px 20px 8px;
  display: flex;
  justify-content: center;
  background:
    radial-gradient(ellipse at 50% 20%, rgba(212, 175, 55, 0.16), transparent 55%),
    radial-gradient(ellipse at 80% 80%, rgba(194, 59, 42, 0.08), transparent 45%),
    linear-gradient(180deg, rgba(0, 0, 0, 0.2), transparent);
}

.mini-board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  width: min(100%, 200px);
  aspect-ratio: 1;
  border-radius: 10px;
  overflow: hidden;
  box-shadow:
    0 10px 28px rgba(0, 0, 0, 0.45),
    inset 0 0 0 2px rgba(0, 0, 0, 0.3);
}

.mini-sq {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  line-height: 1;
}

.mini-sq.light {
  background: linear-gradient(160deg, #e4d2b0, var(--board-light));
  color: #1a1512;
}

.mini-sq.dark {
  background: linear-gradient(160deg, #6b4836, var(--board-dark));
  color: #f7f0e2;
}

.mini-piece {
  display: block;
  width: 58%;
  height: 58%;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}

.mini-piece--red {
  background: radial-gradient(circle at 32% 28%, var(--piece-red-shine), var(--piece-red) 55%, var(--piece-red-deep));
  border: 1.5px solid #6b1e14;
}

.mini-piece--black {
  background: radial-gradient(circle at 32% 28%, var(--piece-black-shine), var(--piece-black) 55%, var(--piece-black-deep));
  border: 1.5px solid #0a0a0c;
}

.game-card__body {
  padding: 16px 22px 22px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.game-card__badge {
  align-self: flex-start;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
  background: rgba(212, 175, 55, 0.12);
  border: 1px solid rgba(212, 175, 55, 0.25);
  padding: 4px 10px;
  border-radius: 999px;
}

.game-card__title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  background: linear-gradient(135deg, var(--gold-bright), var(--gold) 50%, #b8942a);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.game-card__desc {
  margin: 0;
  color: var(--ink-muted);
  font-size: 14px;
  line-height: 1.5;
}

.game-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  list-style: none;
  margin: 4px 0 0;
  padding: 0;
}

.game-card__meta li {
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-faint);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  padding: 4px 10px;
  border-radius: 999px;
}

.game-card__cta {
  margin-top: 8px;
  font-size: 14px;
  font-weight: 700;
  color: var(--gold-bright);
  letter-spacing: 0.02em;
}

.game-card:hover .game-card__cta {
  color: #fff0b0;
}

.lobby-features {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.feature-card {
  padding: 18px;
  background:
    linear-gradient(160deg, rgba(212, 175, 55, 0.06), transparent 50%),
    var(--bg-card);
  border: 1px solid rgba(212, 175, 55, 0.1);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  transition: transform var(--duration) var(--ease), border-color var(--duration) var(--ease);
}

.feature-card:hover {
  transform: translateY(-3px);
  border-color: rgba(212, 175, 55, 0.28);
}

.feature-card__icon {
  font-size: 22px;
  margin-bottom: 8px;
  color: var(--gold);
}

.feature-card h3 {
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-size: 1.15rem;
  color: var(--ink);
}

.feature-card p {
  margin: 0;
  font-size: 13px;
  color: var(--ink-muted);
  line-height: 1.5;
}

.tips-list--numbered {
  padding-left: 20px;
}

@media (min-width: 640px) {
  .game-cards {
    grid-template-columns: 1fr 1fr;
  }

  .lobby-features {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 900px) {
  .lobby-layout {
    grid-template-columns: 1fr 280px;
    gap: 28px;
  }

  .lobby-layout--solo {
    grid-template-columns: 1fr 280px;
  }

  .layout--game {
    grid-template-columns: 1fr 300px;
  }

  .lobby-side {
    margin: 0;
    position: sticky;
    top: 16px;
  }
}

@media (min-width: 1200px) {
  .lobby-layout:not(.lobby-layout--solo) {
    grid-template-columns: 160px 1fr 280px;
  }

  .layout--game {
    grid-template-columns: 1fr 300px;
    justify-content: center;
  }
}

.content-block__text {
  margin: 0 0 14px;
  color: var(--ink-muted);
  font-size: 14px;
}

.content-block__links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0;
}

@media (max-width: 639px) {
  .game-card__preview {
    padding-bottom: 4px;
  }
}

/* ==========================================================================
   Cards, Baccarat, Solitaire, Math
   ========================================================================== */

.game-shell--wide {
  max-width: min(960px, 100%);
}

.felt-frame {
  position: relative;
  width: 100%;
  max-width: calc(var(--board-size) + 80px);
  margin: 0 auto;
  padding: 20px 16px;
  background: linear-gradient(145deg, #1a4a32 0%, #0d2e1e 40%, #0a2418 100%);
  border-radius: 18px;
  box-shadow: var(--shadow-board), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.felt-frame__glow {
  pointer-events: none;
  position: absolute;
  inset: -2px;
  border-radius: 20px;
  background: linear-gradient(135deg, rgba(212, 175, 55, 0.2), transparent 40%, transparent 60%, rgba(212, 175, 55, 0.1));
  opacity: 0.55;
  z-index: 0;
}

.felt-frame--solitaire {
  max-width: min(920px, 100%);
  padding: 16px 12px 20px;
}

.felt-frame--math {
  max-width: calc(var(--board-size) + 48px);
  background: linear-gradient(145deg, #3a2c1e 0%, #241c15 45%, #1a120c 100%);
}

/* Playing cards ----------------------------------------------------------- */
.playing-card {
  position: relative;
  width: 64px;
  height: 90px;
  border-radius: 8px;
  background: linear-gradient(165deg, #fffef9, #f0e6d4);
  border: 1px solid rgba(0, 0, 0, 0.15);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35);
  color: #1a1510;
  font-family: var(--font-ui);
  font-weight: 700;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  padding: 6px 8px;
  flex-shrink: 0;
  cursor: default;
  transition: transform 140ms var(--ease), box-shadow 140ms var(--ease);
}

.playing-card--red {
  color: #b82a1a;
}

.playing-card__rank {
  font-size: 14px;
  line-height: 1.1;
}

.playing-card__suit {
  font-size: 18px;
  line-height: 1;
  margin-top: 2px;
}

.playing-card--back {
  background:
    repeating-linear-gradient(
      45deg,
      #2a1810,
      #2a1810 4px,
      #3d2418 4px,
      #3d2418 8px
    );
  border-color: rgba(212, 175, 55, 0.35);
}

.playing-card--back .playing-card__rank,
.playing-card--back .playing-card__suit {
  display: none;
}

.playing-card.is-selected,
.sol-card.is-selected {
  box-shadow: 0 0 0 3px var(--gold-bright), 0 6px 14px rgba(0, 0, 0, 0.4);
  transform: translateY(-4px);
  z-index: 5;
}

/* Baccarat ---------------------------------------------------------------- */
.baccarat-table {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-around;
  gap: 12px;
  flex-wrap: wrap;
  min-height: 160px;
}

.bac-hand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  min-width: 140px;
}

.bac-hand__label {
  font-family: var(--font-display);
  font-size: 1.15rem;
  color: var(--gold-bright);
  letter-spacing: 0.04em;
}

.bac-hand__score {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  margin-left: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.35);
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
}

.bac-hand__cards {
  display: flex;
  gap: 8px;
  min-height: 90px;
  align-items: center;
}

.bac-vs {
  font-family: var(--font-display);
  font-size: 1.4rem;
  color: rgba(243, 233, 216, 0.35);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.bet-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  width: 100%;
}

.bet-amounts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.chip-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  font-weight: 700;
  font-size: 13px;
  color: #1a1208;
  background: radial-gradient(circle at 35% 30%, #f0d060, var(--gold) 50%, #8a7020);
  border: 3px dashed rgba(26, 18, 8, 0.35);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.35);
  transition: transform 120ms var(--ease), box-shadow 120ms var(--ease);
}

.chip-btn:hover:not(:disabled) {
  transform: scale(1.06);
}

.chip-btn.is-active {
  box-shadow: 0 0 0 3px var(--gold-bright), 0 4px 12px rgba(212, 175, 55, 0.4);
}

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

.bet-targets {
  display: grid;
  grid-template-columns: 1fr 0.85fr 1fr;
  gap: 8px;
  width: 100%;
  max-width: 480px;
}

.bet-btn {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: var(--bg-card);
  transition: border-color var(--duration) var(--ease), background var(--duration) var(--ease);
}

.bet-btn__name {
  font-weight: 700;
  font-size: 14px;
}

.bet-btn__odds {
  font-size: 11px;
  color: var(--ink-muted);
}

.bet-btn--player.is-active,
.bet-btn--player:hover:not(:disabled) {
  border-color: rgba(232, 106, 85, 0.55);
  background: rgba(194, 59, 42, 0.15);
}

.bet-btn--banker.is-active,
.bet-btn--banker:hover:not(:disabled) {
  border-color: rgba(100, 140, 255, 0.45);
  background: rgba(60, 90, 180, 0.18);
}

.bet-btn--tie.is-active,
.bet-btn--tie:hover:not(:disabled) {
  border-color: rgba(212, 175, 55, 0.55);
  background: rgba(212, 175, 55, 0.12);
}

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

/* Solitaire --------------------------------------------------------------- */
.solitaire {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.sol-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}

.sol-stock-wrap {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.sol-pile {
  position: relative;
  width: 64px;
  height: 90px;
  border-radius: 8px;
  border: 1px dashed rgba(255, 255, 255, 0.2);
  background: rgba(0, 0, 0, 0.15);
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(243, 233, 216, 0.35);
  font-weight: 700;
}

.sol-pile .playing-card {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.sol-pile--empty {
  border-style: dashed;
}

.sol-stock {
  cursor: pointer;
}

.sol-stock:hover {
  border-color: rgba(212, 175, 55, 0.5);
}

.sol-waste {
  width: 100px;
  position: relative;
}

.sol-waste .sol-card--offset {
  position: absolute;
  top: 0;
}

.sol-foundations {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.sol-tableau {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
  min-height: 280px;
}

.sol-col {
  position: relative;
  min-height: 280px;
}

.sol-card--stacked {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: min(64px, 100%);
  height: 90px;
  cursor: pointer;
}

.sol-card--stacked.is-selected {
  transform: translateX(-50%) translateY(-4px);
}

.sol-col-empty {
  width: min(64px, 100%);
  margin: 0 auto;
  cursor: pointer;
}

.sol-card {
  cursor: pointer;
}

@media (max-width: 700px) {
  .playing-card,
  .sol-pile {
    width: 48px;
    height: 68px;
  }

  .sol-card--stacked {
    width: min(48px, 100%);
    height: 68px;
  }

  .sol-tableau {
    gap: 4px;
    min-height: 240px;
  }

  .playing-card__rank {
    font-size: 11px;
  }

  .playing-card__suit {
    font-size: 14px;
  }

  .sol-card--stacked {
    /* tighter stack */
  }

  .sol-col {
    min-height: 240px;
  }

  .sol-col .sol-card--stacked {
    top: calc(var(--i, 0) * 18px);
  }
}

/* Math -------------------------------------------------------------------- */
.math-stage {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 12px 8px 8px;
}

.math-progress {
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  margin-bottom: 16px;
  opacity: 0;
  transition: opacity 160ms ease;
}

.math-progress.is-active {
  opacity: 1;
}

.math-progress__bar {
  height: 100%;
  width: 100%;
  transform-origin: left center;
  transform: scaleX(1);
  background: linear-gradient(90deg, var(--gold-bright), var(--gold), #b8942a);
  border-radius: inherit;
}

.math-qnum {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.math-question {
  margin: 0 0 24px;
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 5vw, 2.6rem);
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 0.02em;
}

.math-choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  max-width: 360px;
  margin: 0 auto;
}

.math-choice {
  padding: 16px 12px;
  border-radius: var(--radius);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--ink);
  background: linear-gradient(165deg, var(--bg-elevated), var(--bg-card));
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: var(--shadow-soft);
  transition: transform 120ms var(--ease), border-color var(--duration) var(--ease), background var(--duration) var(--ease);
}

.math-choice:hover:not(:disabled) {
  transform: translateY(-2px);
  border-color: rgba(212, 175, 55, 0.45);
}

.math-choice.is-correct {
  border-color: #3d9a5f;
  background: rgba(61, 154, 95, 0.25);
  color: #b8f0c8;
}

.math-choice.is-wrong {
  border-color: var(--danger);
  background: rgba(232, 93, 76, 0.2);
  color: #ffb4aa;
}

.math-choice:disabled {
  cursor: default;
}

/* Lobby grid for many games ----------------------------------------------- */
.game-cards {
  grid-template-columns: 1fr;
}

@media (min-width: 640px) {
  .game-cards {
    grid-template-columns: 1fr 1fr;
  }
}

@media (min-width: 1000px) {
  .game-cards--many {
    grid-template-columns: repeat(3, 1fr);
  }
}

.mini-preview-emoji {
  display: flex;
  align-items: center;
  justify-content: center;
  width: min(100%, 200px);
  aspect-ratio: 1;
  border-radius: 10px;
  font-size: 64px;
  background:
    linear-gradient(160deg, #1a4a32, #0d2e1e);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
  margin: 0 auto;
}

.mini-preview-emoji--math {
  background: linear-gradient(160deg, #3a2c1e, #1a120c);
  font-family: var(--font-display);
  font-size: 56px;
  color: var(--gold-bright);
}

.mini-preview-emoji--solitaire {
  background: linear-gradient(160deg, #1a4a32, #0a2418);
  font-size: 52px;
  letter-spacing: -0.1em;
}

/* Royal Pool -------------------------------------------------------------- */
.pool-frame {
  position: relative;
  width: 100%;
  max-width: min(920px, 100%);
  margin: 0 auto;
  padding: 10px;
  background: linear-gradient(145deg, #4a3424 0%, #2c1f14 45%, #1a120c 100%);
  border-radius: 18px;
  box-shadow: var(--shadow-board), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.pool-frame__glow {
  pointer-events: none;
  position: absolute;
  inset: -2px;
  border-radius: 20px;
  background: linear-gradient(135deg, rgba(212, 175, 55, 0.22), transparent 45%, transparent 55%, rgba(26, 107, 69, 0.15));
  opacity: 0.7;
  z-index: 0;
}

#pool-canvas {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: auto;
  border-radius: 10px;
  touch-action: none;
  cursor: crosshair;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35);
}

.pool-hint {
  position: relative;
  z-index: 1;
  margin: 8px 4px 0;
  text-align: center;
  font-size: 12px;
  color: rgba(243, 233, 216, 0.55);
}

.player-card__avatar--solids {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 18px;
  color: #c23b2a;
  background: radial-gradient(circle at 32% 28%, #fff, #e8d4b0 55%, #c4a878);
  border: 2px solid #8a7348;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.4);
}

.player-card__avatar--stripes {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 18px;
  color: #1e5aa8;
  background: radial-gradient(circle at 32% 28%, #4a4a52, #1a1a1e 60%, #0a0a0c);
  border: 2px solid #0a0a0c;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.4);
}

.mini-preview-emoji--pool {
  background: linear-gradient(160deg, #1a6b45, #0d3d28);
  font-size: 48px;
  color: #f5f0e6;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}
