:root, :root[data-theme="hearth"] {
  color-scheme: dark;
  --bg: #090706;
  --panel: rgba(28, 20, 15, .84);
  --line: rgba(236, 183, 102, .22);
  --text: #f8ead4;
  --muted: #b9a68e;
  --gold: #e7b35d;
  --amber: #ffcc73;
  --ember: #ff7a3d;
  --red: #ff8b7c;
  --wood-hi: #6b4626;
  --wood-lo: #3c2413;
  --felt: #1d2b1f;
  --accent-rgb: 255, 204, 115;
  --glow-rgb: 255, 190, 100;
  --on-accent: #2b1608;
  --bg-a: #050403;
  --bg-b: #16100b;
  --bg-glow: rgba(183, 96, 46, .20);
  --shelf-a: rgba(38, 25, 15, .92);
  --shelf-b: rgba(24, 15, 9, .94);
}

:root[data-theme="tide"] {
  --bg: #05090d;
  --panel: rgba(13, 23, 31, .86);
  --line: rgba(122, 196, 219, .24);
  --text: #e6f2f7;
  --muted: #8fa9b8;
  --gold: #63b7d1;
  --amber: #8fd8ec;
  --ember: #3e8fb5;
  --red: #ff8b7c;
  --wood-hi: #33566b;
  --wood-lo: #182f3d;
  --accent-rgb: 143, 216, 236;
  --glow-rgb: 110, 190, 220;
  --on-accent: #06222e;
  --bg-a: #030608;
  --bg-b: #0b141c;
  --bg-glow: rgba(62, 143, 181, .18);
  --shelf-a: rgba(16, 30, 40, .92);
  --shelf-b: rgba(10, 20, 28, .94);
}

:root[data-theme="grove"] {
  --bg: #060804;
  --panel: rgba(20, 28, 16, .86);
  --line: rgba(163, 217, 119, .22);
  --text: #eef6e2;
  --muted: #a4b590;
  --gold: #9ac86e;
  --amber: #b5e88a;
  --ember: #5d9c4a;
  --red: #ff8b7c;
  --wood-hi: #4f6b33;
  --wood-lo: #2a3d1a;
  --accent-rgb: 181, 232, 138;
  --glow-rgb: 160, 210, 120;
  --on-accent: #152508;
  --bg-a: #040603;
  --bg-b: #101a0b;
  --bg-glow: rgba(93, 156, 74, .16);
  --shelf-a: rgba(24, 34, 16, .92);
  --shelf-b: rgba(15, 22, 10, .94);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font: 16px/1.5 Inter, ui-sans-serif, system-ui, sans-serif;
  background:
    radial-gradient(circle at 18% 8%, var(--bg-glow), transparent 32rem),
    linear-gradient(145deg, var(--bg-a), var(--bg-b));
}

.game-shell { width: min(1180px, calc(100vw - 32px)); margin: auto; padding: 28px 0; }

.game-header, .board-card, .rules-card, .chat-card, .shelf-unit {
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--panel);
  box-shadow: 0 24px 70px rgba(0, 0, 0, .38);
}

.game-header { display: grid; grid-template-columns: auto 1fr auto; gap: 20px; align-items: center; padding: 18px; }
.back { color: var(--amber); text-decoration: none; font-weight: 800; white-space: nowrap; }
.eyebrow { margin: 0 0 4px; color: var(--gold); font-size: .72rem; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
h1, h2 { margin: 0; font-family: Georgia, serif; }
h1 { font-size: clamp(1.7rem, 4.5vw, 3rem); }
.subtitle, .turn-note, .rules-card p { color: var(--muted); margin: .3rem 0 0; }
.new-game {
  border: 1px solid rgba(var(--accent-rgb), .55);
  border-radius: 999px;
  color: var(--on-accent);
  background: linear-gradient(145deg, var(--amber), var(--ember));
  padding: 10px 16px;
  font-weight: 900;
  cursor: pointer;
}

/* ── The lamp in the room header ─────────────────────────────────────── */
.lamp { position: relative; width: 58px; height: 58px; justify-self: end; }
.lamp::before {
  content: "";
  position: absolute; inset: 0 auto auto 8px;
  width: 42px; height: 26px;
  background: linear-gradient(180deg, var(--amber), var(--ember));
  clip-path: polygon(18% 0, 82% 0, 100% 100%, 0 100%);
  border-radius: 4px;
}
.lamp::after {
  content: "";
  position: absolute; left: 26px; top: 26px;
  width: 6px; height: 24px;
  background: linear-gradient(180deg, #7a5a33, #4a3117);
  border-radius: 3px;
  box-shadow: 0 -8px 26px 10px rgba(var(--glow-rgb), .18);
}

/* ── Shelf page ──────────────────────────────────────────────────────── */
.shelf-unit {
  margin-top: 18px;
  padding: 34px 30px 26px;
  background:
    radial-gradient(circle at 50% 0%, rgba(var(--glow-rgb), .10), transparent 24rem),
    linear-gradient(180deg, var(--shelf-a), var(--shelf-b));
}
.shelf-row { display: flex; justify-content: center; align-items: flex-end; gap: clamp(12px, 3vw, 34px); padding: 0 8px; }
.shelf-board {
  height: 16px;
  margin: -2px 0 34px;
  border-radius: 6px;
  background: linear-gradient(180deg, var(--wood-hi), var(--wood-lo));
  box-shadow: 0 10px 18px rgba(0, 0, 0, .5), inset 0 1px 0 rgba(255, 220, 160, .25);
}

.game-box {
  display: flex; flex-direction: column;
  width: clamp(120px, 20vw, 190px);
  aspect-ratio: 3 / 4;
  border-radius: 12px;
  text-decoration: none;
  color: var(--text);
  border: 1px solid rgba(0, 0, 0, .5);
  box-shadow: inset 0 1px 0 rgba(255, 240, 210, .25), inset 0 -6px 12px rgba(0, 0, 0, .3), 0 8px 16px rgba(0, 0, 0, .45);
  padding: 14px;
  transition: transform .18s ease, box-shadow .18s ease;
}
.game-box:hover, .game-box:focus-visible {
  transform: translateY(-8px) rotate(0deg) scale(1.03);
  box-shadow: inset 0 1px 0 rgba(255, 240, 210, .25), 0 18px 30px rgba(0, 0, 0, .55), 0 0 40px rgba(var(--glow-rgb), .12);
  outline: none;
}
.game-box:nth-child(odd) { transform: rotate(-1.2deg); }
.game-box:nth-child(even) { transform: rotate(.9deg); }
.game-box:nth-child(odd):hover, .game-box:nth-child(even):hover { transform: translateY(-8px) scale(1.03); }

.box-art { flex: 1; display: grid; place-items: center; }
.box-art svg { width: 62%; height: auto; opacity: .92; }
.box-label {
  display: block; text-align: center;
  background: rgba(9, 6, 4, .55);
  border: 1px solid rgba(var(--glow-rgb), .18);
  border-radius: 8px;
  padding: 8px 6px;
}
.box-label strong { display: block; font-family: Georgia, serif; font-size: clamp(.9rem, 1.8vw, 1.15rem); }
.box-label em { display: block; font-style: normal; color: rgba(248, 234, 212, .75); font-size: .72rem; letter-spacing: .06em; }

.box-tictactoe { background: linear-gradient(160deg, #7c3f21, #4a2412); color: #ffd9a1; }
.box-connect4 { background: linear-gradient(160deg, #274168, #16233c); color: #a9c8f5; }
.box-checkers { background: linear-gradient(160deg, #6d1f1f, #3c1010); color: #ffb3a1; }
.box-backgammon { background: linear-gradient(160deg, #2e4a30, #16261a); color: #b9e0b3; }
.box-chess { background: linear-gradient(160deg, #4a3168, #241a3c); color: #cbb3f0; }
.box-battleship { background: linear-gradient(160deg, #1f4a55, #0e2229); color: #9fd6e0; }

/* Decor shelf */
.shelf-row--decor { min-height: 84px; gap: clamp(30px, 8vw, 90px); }
.decor { position: relative; display: inline-block; }
.decor-candle { width: 26px; height: 58px; border-radius: 6px 6px 4px 4px; background: linear-gradient(180deg, #f3e2c0, #cfb188); box-shadow: inset -4px 0 8px rgba(0,0,0,.25); }
.flame {
  position: absolute; top: -16px; left: 8px;
  width: 10px; height: 16px;
  background: radial-gradient(circle at 50% 80%, #ffdf8f, var(--ember));
  border-radius: 50% 50% 50% 50% / 62% 62% 38% 38%;
  box-shadow: 0 0 22px 8px rgba(var(--glow-rgb), .35);
  animation: flicker 2.4s infinite ease-in-out;
}
@keyframes flicker { 0%,100% { transform: scale(1) } 40% { transform: scale(.92) rotate(-3deg) } 70% { transform: scale(1.06) rotate(2deg) } }
.decor-dice .die { font-size: 44px; line-height: 1; color: #f3e2c0; display: inline-block; }
.decor-dice .die--tilt { transform: rotate(18deg) translateY(6px); color: var(--amber); }
.decor-plant { width: 34px; height: 30px; border-radius: 4px 4px 10px 10px; background: linear-gradient(180deg, #8a5a30, #5d3a1c); }
.leaf {
  position: absolute; bottom: 24px; left: 12px;
  width: 12px; height: 34px;
  background: linear-gradient(180deg, #5f8f56, #2e4a30);
  border-radius: 50% 50% 20% 20%;
  transform-origin: bottom center;
}
.leaf--b { transform: rotate(-28deg); height: 28px; }
.leaf--c { transform: rotate(26deg); height: 30px; }
.decor-trophy {
  width: 60px; height: 64px;
  border: 1px solid rgba(var(--glow-rgb), .3);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(58, 38, 20, .9), rgba(30, 19, 10, .95));
  box-shadow: inset 0 0 18px rgba(var(--glow-rgb), .18);
  display: grid; place-items: center;
}
.decor-trophy .trophy { font-size: 30px; filter: drop-shadow(0 0 8px rgba(var(--accent-rgb), .5)); }
.decor-cards .card {
  display: inline-block; width: 34px; height: 48px;
  background: #f3e2c0; border-radius: 4px; border: 1px solid #b99;
  box-shadow: 0 4px 8px rgba(0,0,0,.4);
}
.decor-cards .card--b { margin-left: -22px; transform: rotate(14deg); background: linear-gradient(160deg, #a33, #611); }
.room-note { color: var(--muted); text-align: center; margin: 20px auto 0; max-width: 640px; font-size: .9rem; }

/* ── Table page layout ───────────────────────────────────────────────── */
.table-layout { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(320px, .8fr); gap: 18px; margin-top: 18px; align-items: start; }
.board-card, .rules-card, .chat-card { padding: 22px; }
.side-stack { display: grid; gap: 18px; min-width: 0; }
.board-heading { display: flex; justify-content: space-between; gap: 12px; align-items: start; }
.state-badge { border: 1px solid var(--line); border-radius: 999px; padding: 6px 9px; color: var(--muted); font-size: .74rem; white-space: nowrap; }
.error { margin: 16px 0 0; border: 1px solid rgba(255, 107, 95, .44); border-radius: 12px; color: var(--red); padding: 10px; }
.rules-card h2 { font-size: 1.35rem; }
.rules-card dl { margin: 18px 0 0; }
.rules-card dl div { display: flex; justify-content: space-between; padding: 8px 0; border-top: 1px solid var(--line); }
.rules-card dt { color: var(--muted); }
.rules-card dd { margin: 0; font-weight: 800; }
.rules-card ol { color: var(--muted); margin: .6rem 0 0; padding-left: 1.2rem; }
.rules-card ol li { margin-top: .35rem; }

.board-actions { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.board-actions button {
  border: 1px solid rgba(var(--accent-rgb), .45);
  border-radius: 999px;
  background: rgba(var(--accent-rgb), .1);
  color: var(--amber);
  padding: 8px 14px;
  font-weight: 800;
  cursor: pointer;
}
.board-actions button:disabled { opacity: .4; cursor: default; }
.board-area { margin-top: 20px; }

/* ── Tic-tac-toe ─────────────────────────────────────────────────────── */
.ttt-board { width: min(100%, 480px); margin: 0 auto; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.square {
  aspect-ratio: 1;
  border: 1px solid rgba(var(--accent-rgb), .28);
  border-radius: 18px;
  color: var(--text);
  background: rgba(0, 0, 0, .24);
  font: 900 clamp(2rem, 8vw, 4rem) Georgia, serif;
  cursor: pointer;
  transition: background .15s, transform .15s, border-color .15s;
}
.square:not(:disabled):hover, .square:not(:disabled):focus-visible { background: rgba(var(--accent-rgb), .14); border-color: var(--amber); outline: none; transform: translateY(-2px); }
.square:disabled { cursor: default; }
.square:not(:disabled) { color: var(--amber); }
.square.winner { color: #251207; background: linear-gradient(145deg, var(--amber), var(--ember)); border-color: var(--amber); }

/* ── Connect Four ────────────────────────────────────────────────────── */
.c4-board {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px;
  width: min(100%, 520px); margin: 0 auto;
  background: linear-gradient(160deg, #274168, #16233c);
  border: 1px solid rgba(169, 200, 245, .3);
  border-radius: 16px;
  padding: 10px;
}
.c4-col { display: grid; gap: 6px; background: none; border: none; padding: 0; cursor: pointer; border-radius: 10px; }
.c4-col:disabled { cursor: default; }
.c4-col:not(:disabled):hover .c4-cell:not(.filled), .c4-col:not(:disabled):focus-visible .c4-cell:not(.filled) { background: rgba(var(--accent-rgb), .16); }
.c4-col:focus-visible { outline: 2px solid var(--amber); }
.c4-cell {
  aspect-ratio: 1;
  border-radius: 50%;
  background: rgba(5, 4, 3, .65);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, .6);
  transition: background .15s;
}
.c4-cell.p-human { background: radial-gradient(circle at 35% 30%, #ffb08a, var(--ember) 62%, #a33d12); }
.c4-cell.p-agent { background: radial-gradient(circle at 35% 30%, #fffbe8, #f0dcb2 62%, #a98d5e); }
.c4-cell.winner { box-shadow: 0 0 0 3px var(--amber), 0 0 18px rgba(var(--accent-rgb), .6); }

/* ── Checkers ────────────────────────────────────────────────────────── */
.ck-board {
  display: grid; grid-template-columns: repeat(8, 1fr);
  width: min(100%, 520px); margin: 0 auto;
  border: 6px solid var(--wood-lo);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .4);
}
.ck-square { aspect-ratio: 1; border: none; padding: 8%; background: #d8bd90; cursor: default; display: grid; place-items: center; }
.ck-square.dark { background: #5d3a1c; }
.ck-square.playable { cursor: pointer; }
.ck-square.playable:hover, .ck-square.playable:focus-visible { outline: none; box-shadow: inset 0 0 0 3px rgba(var(--accent-rgb), .75); }
.ck-square.selected { box-shadow: inset 0 0 0 3px var(--amber), inset 0 0 18px rgba(var(--accent-rgb), .5); }
.ck-piece {
  width: 100%; aspect-ratio: 1; border-radius: 50%;
  display: grid; place-items: center;
  font-size: clamp(.8rem, 2.6vw, 1.3rem);
  box-shadow: 0 3px 6px rgba(0, 0, 0, .5), inset 0 2px 3px rgba(255, 255, 255, .35), inset 0 -3px 5px rgba(0, 0, 0, .35);
}
.ck-piece.p-human { background: radial-gradient(circle at 35% 30%, #ff9a6b, #c4501d 68%, #8a3210); color: #ffe9d2; }
.ck-piece.p-agent { background: radial-gradient(circle at 35% 30%, #fffbe8, #ead1a0 68%, #b09062); color: #5d3a1c; }

/* ── Backgammon ──────────────────────────────────────────────────────── */
.bg-board {
  background: linear-gradient(160deg, #2e4a30, #16261a);
  border: 6px solid var(--wood-lo);
  border-radius: 12px;
  padding: 10px;
  display: grid;
  grid-template-columns: 6fr auto 6fr auto;
  grid-template-rows: 1fr auto 1fr;
  gap: 6px;
  width: 100%;
}
.bg-quad { display: grid; grid-template-columns: repeat(6, 1fr); gap: 3px; min-height: 120px; }
.bg-point { position: relative; border: none; background: none; padding: 4px 2px; cursor: default; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.bg-point::before {
  content: "";
  position: absolute; inset: 0;
  background: #7a5a33;
  opacity: .8;
}
.bg-point.alt::before { background: #d8bd90; opacity: .55; }
.bg-point.up::before { clip-path: polygon(0 100%, 100% 100%, 50% 0); }
.bg-point.down::before { clip-path: polygon(0 0, 100% 0, 50% 100%); }
.bg-point.down { justify-content: flex-start; }
.bg-point.up { justify-content: flex-end; }
.bg-point.playable { cursor: pointer; }
.bg-point.playable:hover::before, .bg-point.playable:focus-visible::before { background: var(--amber); opacity: .8; }
.bg-point.selected::before { background: var(--amber); opacity: .95; }
.bg-point:focus-visible { outline: none; }
.bg-label { position: absolute; font-size: .6rem; color: var(--muted); z-index: 1; }
.bg-point.down .bg-label { bottom: -2px; }
.bg-point.up .bg-label { top: -2px; }
.bg-checker {
  position: relative; z-index: 1;
  width: min(70%, 26px); aspect-ratio: 1; border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, .5), inset 0 1px 2px rgba(255, 255, 255, .4);
  font-size: .62rem; font-weight: 900; display: grid; place-items: center;
}
.bg-checker.p-human { background: radial-gradient(circle at 35% 30%, #ff9a6b, #c4501d 68%, #8a3210); color: #ffe9d2; }
.bg-checker.p-agent { background: radial-gradient(circle at 35% 30%, #fffbe8, #ead1a0 68%, #b09062); color: #5d3a1c; }
.bg-bar {
  grid-row: 1 / 4;
  width: 40px;
  background: linear-gradient(180deg, var(--wood-hi), var(--wood-lo));
  border-radius: 6px;
  border: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  cursor: default; color: var(--muted); font-size: .58rem; letter-spacing: .08em;
}
.bg-bar.playable { cursor: pointer; box-shadow: 0 0 0 2px rgba(var(--accent-rgb), .5); }
.bg-bar.selected { box-shadow: 0 0 0 3px var(--amber); }
.bg-off {
  grid-row: 1 / 4;
  width: 52px;
  border: 1px dashed rgba(236, 183, 102, .4);
  border-radius: 8px;
  background: rgba(0, 0, 0, .25);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  cursor: default; color: var(--muted); font-size: .58rem; letter-spacing: .08em; text-align: center;
}
.bg-off.playable { cursor: pointer; box-shadow: 0 0 0 2px rgba(var(--accent-rgb), .5); }
.bg-middle { grid-column: 1 / 4; display: flex; justify-content: center; align-items: center; gap: 14px; min-height: 40px; }
.bg-die {
  width: 34px; height: 34px; border-radius: 8px;
  background: #f3e2c0; color: var(--on-accent);
  display: grid; place-items: center;
  font-weight: 900; font-size: 1.15rem;
  box-shadow: 0 3px 6px rgba(0, 0, 0, .45);
}
.bg-die.used { opacity: .35; }
.bg-hint { color: var(--muted); font-size: .78rem; }

/* ── Chess ───────────────────────────────────────────────────────────── */
.ch-board {
  display: grid; grid-template-columns: repeat(8, 1fr);
  width: min(100%, 520px); margin: 0 auto;
  border: 6px solid var(--wood-lo);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .4);
}
.ch-square { aspect-ratio: 1; border: none; padding: 0; background: #d8bd90; cursor: default; display: grid; place-items: center; position: relative; }
.ch-square.dark { background: #8a5a30; }
.ch-square.playable { cursor: pointer; }
.ch-square.playable:hover, .ch-square.playable:focus-visible { outline: none; box-shadow: inset 0 0 0 3px rgba(var(--accent-rgb), .75); }
.ch-square.selected { box-shadow: inset 0 0 0 3px var(--amber), inset 0 0 18px rgba(var(--accent-rgb), .5); }
.ch-square.target::after {
  content: "";
  position: absolute;
  width: 26%; aspect-ratio: 1; border-radius: 50%;
  background: rgba(var(--accent-rgb), .55);
  box-shadow: 0 0 10px rgba(var(--accent-rgb), .6);
}
.ch-square.target:has(.ch-piece)::after { width: 82%; background: none; border: 3px solid rgba(var(--accent-rgb), .7); box-sizing: border-box; }
.ch-piece { font-size: clamp(1.4rem, 4.6vw, 2.4rem); line-height: 1; z-index: 1; }
.ch-piece.ember { color: #ff9a5b; text-shadow: 0 1px 0 #5c2405, 0 0 6px rgba(0, 0, 0, .45); }
.ch-piece.cream { color: #fff6e0; text-shadow: 0 1px 0 #4a3117, 0 0 6px rgba(0, 0, 0, .45); }

/* ── Battleship ──────────────────────────────────────────────────────── */
.bs-wrap { display: grid; gap: 22px; justify-items: center; }
.bs-title { margin: 0 0 8px; color: var(--muted); font-size: .85rem; letter-spacing: .04em; }
.bs-grid {
  display: grid; grid-template-columns: repeat(11, 1fr); gap: 2px;
  width: min(100%, 440px);
  background: linear-gradient(160deg, #1f4a55, #0e2229);
  border: 1px solid rgba(159, 214, 224, .35);
  border-radius: 10px;
  padding: 8px;
}
.bs-label { display: grid; place-items: center; color: rgba(159, 214, 224, .8); font-size: .62rem; font-weight: 800; aspect-ratio: 1; }
.bs-cell {
  aspect-ratio: 1; border: none; padding: 0;
  background: rgba(6, 20, 26, .8);
  border-radius: 4px;
  color: var(--text);
  font-size: .85rem; font-weight: 900;
  display: grid; place-items: center;
  cursor: default;
}
button.bs-cell:not(:disabled) { cursor: crosshair; }
button.bs-cell:not(:disabled):hover, button.bs-cell:not(:disabled):focus-visible { outline: none; background: rgba(var(--accent-rgb), .3); }
.bs-cell.miss, .bs-cell.splash { color: rgba(159, 214, 224, .7); }
.bs-cell.hit, .bs-cell.ship-hit { background: rgba(196, 80, 29, .5); color: #ffb08a; }
.bs-cell.sunk { background: rgba(120, 30, 20, .75); color: #ff8b7c; }
.bs-cell.own.ship { background: rgba(159, 214, 224, .35); box-shadow: inset 0 0 0 1px rgba(159, 214, 224, .5); }
.bs-cell.own.ship-hit { background: rgba(196, 80, 29, .6); }
.bs-sunk { color: var(--muted); font-size: .82rem; margin: 0; }
.bs-tally { color: var(--muted); font-size: .78rem; margin: 0; letter-spacing: .01em; }

/* ── House records (lobby ledger) ────────────────────────────────────── */
.records-card {
  margin-top: 18px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--panel);
  box-shadow: 0 24px 70px rgba(0, 0, 0, .38);
}
.records-stats { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 16px; }
.records-stats .stat {
  flex: 1 1 130px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  text-align: center;
  background: rgba(0, 0, 0, .22);
}
.records-stats .stat strong { display: block; font-family: Georgia, serif; font-size: 1.25rem; color: var(--amber); }
.records-stats .stat span { color: var(--muted); font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; }
.records-split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); gap: 22px; margin-top: 20px; }
.records-subhead { margin: 0 0 10px; font-family: Georgia, serif; font-size: 1.05rem; color: var(--gold); }
.records-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.records-table th { text-align: left; color: var(--muted); font-size: .7rem; letter-spacing: .1em; text-transform: uppercase; padding: 6px 8px; }
.records-table td { padding: 7px 8px; border-top: 1px solid var(--line); }
.records-table td:not(:first-child), .records-table th:not(:first-child) { text-align: center; }
.records-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.record-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: rgba(0, 0, 0, .22);
  display: grid; gap: 3px;
}
.record-item strong { font-family: Georgia, serif; }
.record-summary { color: var(--muted); font-size: .78rem; }
.record-note { color: var(--gold); font-size: .84rem; }
.record-when { color: var(--muted); font-size: .68rem; letter-spacing: .08em; }
.records-empty { color: var(--muted); font-size: .88rem; }

/* ── Chat panel ──────────────────────────────────────────────────────── */
.chat-card { display: flex; flex-direction: column; min-height: 320px; }
.chat-log {
  flex: 1;
  margin-top: 14px;
  overflow-y: auto;
  max-height: 380px;
  display: flex; flex-direction: column; gap: 10px;
  padding-right: 4px;
  scrollbar-width: thin;
}
.bubble {
  max-width: 88%;
  border-radius: 14px;
  padding: 9px 12px;
  font-size: .92rem;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}
.bubble.user { align-self: flex-end; color: var(--on-accent); background: linear-gradient(145deg, var(--amber), #e8a34e); border-bottom-right-radius: 4px; }
.bubble.jack { align-self: flex-start; background: rgba(0, 0, 0, .3); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.bubble.status { align-self: flex-start; color: var(--muted); font-style: italic; font-size: .8rem; background: none; padding: 0 4px; }
.bubble.chat-error { align-self: stretch; color: var(--red); border: 1px solid rgba(255, 107, 95, .44); background: none; }
.chat-empty { color: var(--muted); font-size: .88rem; margin: auto 0; text-align: center; }
.chat-composer { display: flex; gap: 8px; margin-top: 12px; align-items: flex-end; }
.chat-composer textarea {
  flex: 1; resize: none;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(0, 0, 0, .3);
  color: var(--text);
  font: inherit; font-size: .92rem;
  padding: 9px 12px;
}
.chat-composer textarea:focus { outline: none; border-color: var(--amber); }
.chat-composer button {
  border: 1px solid rgba(var(--accent-rgb), .55);
  border-radius: 999px;
  color: var(--on-accent);
  background: linear-gradient(145deg, var(--amber), var(--ember));
  padding: 9px 16px;
  font-weight: 900;
  cursor: pointer;
}
.chat-composer button:disabled { opacity: .5; cursor: default; }

@media (max-width: 900px) {
  .table-layout { grid-template-columns: 1fr; }
  .game-header { grid-template-columns: 1fr; }
  .new-game { justify-self: start; }
  .lamp { display: none; }
  .shelf-row { flex-wrap: wrap; }
  .records-split { grid-template-columns: 1fr; }
}

/* ── Theme picker ────────────────────────────────────────────────────── */
.theme-pick { justify-self: end; color: var(--muted); font-size: .78rem; display: flex; align-items: center; gap: 6px; }
.theme-pick select {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(0, 0, 0, .3);
  color: var(--text);
  font: inherit; font-size: .8rem;
  padding: 6px 10px;
}
.theme-pick select:focus { outline: none; border-color: var(--amber); }
