/* schach.diedler.com — Design 1:1 von diedler.com
   Palette: Diedler-Blau #0c71c3, Diedler-Orange #ff9000,
   Text #1a1a2e, BG #fff, Alt #f0f6fd, Dark #083a6a. Outfit Variable. */

/* ───── Outfit Variable über Google Fonts ───── */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300..900&display=swap');

/* ───── Tokens ───── */
:root,
:root[data-theme="light"] {
  /* Diedler-Palette */
  --blue:        #0c71c3;
  --blue-2:      #0a5a9c;
  --blue-3:      #083a6a;
  --orange:      #ff9000;
  --orange-soft: rgba(255, 144, 0, 0.16);

  /* Light tokens */
  --bg:          #ffffff;
  --bg-alt:      #f0f6fd;
  --bg-card:     #ffffff;
  --bg-hover:    #e7eff8;
  --line:        #d9e4f2;
  --line-soft:   #ebf2fa;
  --ink:         #1a1a2e;
  --ink-soft:    #4f4f4f;
  --ink-mute:    #7a7e8a;
  --on-blue:     #ffffff;
  --on-orange:   #ffffff;

  /* Brett-Defaults (light, classic) */
  --sq-light:    #eef1f7;
  --sq-dark:     #234868;
  --sq-sel:      rgba(255, 144, 0, 0.55);
  --sq-legal:    rgba(12, 113, 195, 0.40);
  --sq-last:     rgba(255, 144, 0, 0.28);
  --sq-check:    rgba(231, 76, 60, 0.55);
  --pc-w:        #f6efd9;
  --pc-b:        #15151f;

  /* Effekte */
  --shadow:      0 4px 28px rgba(12, 113, 195, 0.10);
  --shadow-h:    0 10px 48px rgba(12, 113, 195, 0.20);
  --shadow-card: 0 2px 16px rgba(12, 113, 195, 0.08);
  --hero-grad:   linear-gradient(150deg, #0c71c3 0%, #0a5a9c 60%, #083a6a 100%);

  --radius-sm:   .5rem;
  --radius-md:   1rem;
  --radius-lg:   1.5rem;
  --radius-xl:   2.5rem;

  --font-sans:   "Outfit", ui-sans-serif, system-ui, -apple-system, "Segoe UI",
                 Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono:   ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
                 "Liberation Mono", "Courier New", monospace;

  --transition:  .3s cubic-bezier(.4, 0, .2, 1);
  color-scheme:  light;
}

:root[data-theme="dark"] {
  --bg:          #061a30;
  --bg-alt:      #0b2645;
  --bg-card:     #0b2848;
  --bg-hover:    #103254;
  --line:        #1b3e63;
  --line-soft:   #122e4d;
  --ink:         #eef4fb;
  --ink-soft:    #b3c4d6;
  --ink-mute:    #7d92a8;
  --on-blue:     #ffffff;
  --on-orange:   #1a1a2e;

  --sq-light:    #d6e2f0;
  --sq-dark:     #143358;
  --sq-sel:      rgba(255, 144, 0, 0.55);
  --sq-legal:    rgba(255, 144, 0, 0.38);
  --sq-last:     rgba(255, 144, 0, 0.32);
  --sq-check:    rgba(231, 76, 60, 0.60);
  --pc-w:        #f6efd9;
  --pc-b:        #15151f;

  --shadow:      0 4px 28px rgba(0, 0, 0, 0.50);
  --shadow-h:    0 12px 48px rgba(0, 0, 0, 0.55);
  --shadow-card: 0 2px 16px rgba(0, 0, 0, 0.45);
  --hero-grad:   linear-gradient(150deg, #0c71c3 0%, #083a6a 100%);
  color-scheme:  dark;
}

/* OS-Default: nur wenn kein explizites data-theme gesetzt */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg:          #061a30;
    --bg-alt:      #0b2645;
    --bg-card:     #0b2848;
    --bg-hover:    #103254;
    --line:        #1b3e63;
    --line-soft:   #122e4d;
    --ink:         #eef4fb;
    --ink-soft:    #b3c4d6;
    --ink-mute:    #7d92a8;
    --on-orange:   #1a1a2e;
    --sq-light:    #d6e2f0;
    --sq-dark:     #143358;
    --sq-legal:    rgba(255, 144, 0, 0.38);
    --sq-last:     rgba(255, 144, 0, 0.32);
    --pc-b:        #15151f;
    --shadow:      0 4px 28px rgba(0, 0, 0, 0.50);
    --shadow-card: 0 2px 16px rgba(0, 0, 0, 0.45);
    color-scheme:  dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background 0.2s ease, color 0.2s ease;
}
body { min-height: 100dvh; }

a { color: var(--blue); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--orange); }

h1, h2, h3 { font-weight: 800; letter-spacing: -0.015em; margin: 0 0 .5em; }
h1 { font-size: clamp(2.2rem, 5vw, 3.6rem); line-height: 1.05; }
h2 { font-size: 1.4rem; }
h3 {
  font-size: .82rem;
  color: var(--ink-mute);
  text-transform: uppercase;
  letter-spacing: 0.10em;
  font-weight: 600;
}
p { margin: 0 0 .8em; color: var(--ink-soft); }
code, .code { font-family: var(--font-mono); font-size: 0.92em; }

/* ───── Topbar ───── */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line-soft);
}
.brand-link {
  display: inline-flex; align-items: center; gap: 12px;
  color: var(--ink); font-weight: 700; font-size: 1.05rem;
}
.brand-link:hover { color: var(--ink); }
.signet {
  width: 30px; height: 30px;
  background: var(--blue);
  border-radius: 50%;
  padding: 6px;
  -webkit-mask: url('/assets/signet-weiss.svg') center / 70% no-repeat;
          mask: url('/assets/signet-weiss.svg') center / 70% no-repeat;
}
.brand-dot   { color: var(--orange); }
.brand-accent { color: var(--ink-mute); font-weight: 500; margin-left: 1px; }

.topbar-right { display: inline-flex; align-items: center; gap: 14px; }
.topbar-link { color: var(--ink-soft); font-size: .94rem; }
.topbar-link:hover { color: var(--blue); }

.theme-toggle {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink-soft);
  width: 36px; height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.theme-toggle:hover { background: var(--bg-hover); color: var(--blue); border-color: var(--blue); }
.theme-toggle svg { width: 16px; height: 16px; }
.theme-toggle .icon-sun  { display: none; }
.theme-toggle .icon-moon { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-sun  { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .theme-toggle .icon-sun  { display: block; }
  :root:not([data-theme]) .theme-toggle .icon-moon { display: none; }
}

.conn-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--ink-mute);
  transition: background .2s ease, box-shadow .4s ease;
}
.conn-dot[data-state="connecting"] { background: var(--orange); animation: pulse 1.2s ease-in-out infinite; }
.conn-dot[data-state="on"]  { background: #2bb673; box-shadow: 0 0 0 4px rgba(43, 182, 115, 0.16); }
.conn-dot[data-state="off"] { background: #e74c3c; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .4; } }

/* ───── Lobby ───── */
.lobby-page { background: var(--bg); }
.lobby {
  max-width: 1080px;
  margin: 0 auto;
  padding: 60px 24px 96px;
  position: relative;
}
.lobby::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 420px;
  background: var(--hero-grad);
  z-index: -1;
  border-bottom-left-radius: 30% 8%;
  border-bottom-right-radius: 30% 8%;
  opacity: 0;
  transition: opacity var(--transition);
}
.lobby-page .lobby::before { opacity: 0.06; }
:root[data-theme="dark"] .lobby-page .lobby::before { opacity: 0.18; }

.hero { max-width: 760px; margin-bottom: 56px; }
.hero h1 .accent { color: var(--orange); }
.lead {
  font-size: 1.15rem;
  color: var(--ink-soft);
  max-width: 60ch;
  line-height: 1.55;
}

/* ───── Cards ───── */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 20px;
  margin-bottom: 56px;
}
.card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 32px;
  display: flex; flex-direction: column; gap: 14px;
  box-shadow: var(--shadow-card);
  transition: transform var(--transition), box-shadow var(--transition);
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-h); }
.card-primary {
  border-color: var(--blue);
  background:
    linear-gradient(150deg, color-mix(in srgb, var(--blue) 6%, var(--bg-card)) 0%, var(--bg-card) 60%);
}
.card h2 { margin: 0; }
.card p { margin: 0; color: var(--ink-soft); }

.field { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.field span {
  font-size: 0.78rem;
  color: var(--ink-mute);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}
.field input,
.share-row input {
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 1rem;
  font-family: inherit;
  outline: none;
  transition: border-color .15s ease, background .15s ease;
}
.field input:focus,
.share-row input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 20%, transparent);
}

/* ───── Buttons ───── */
.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 12px 20px;
  font-size: 0.98rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  text-decoration: none;
  transition: transform .06s ease, background .15s ease,
              border-color .15s ease, color .15s ease, opacity .15s ease,
              box-shadow var(--transition);
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary {
  background: var(--blue);
  color: var(--on-blue);
  border-color: var(--blue);
  box-shadow: 0 4px 16px color-mix(in srgb, var(--blue) 35%, transparent);
}
.btn-primary:hover:not(:disabled) { background: var(--blue-2); border-color: var(--blue-2); }

.btn-accent {
  background: var(--orange);
  color: var(--on-orange);
  border-color: var(--orange);
  box-shadow: 0 4px 16px color-mix(in srgb, var(--orange) 35%, transparent);
}
.btn-accent:hover:not(:disabled) { background: #e07d00; border-color: #e07d00; }

.btn-ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--blue);
  color: var(--blue);
}

.btn-danger {
  background: transparent;
  color: #e74c3c;
  border-color: color-mix(in srgb, #e74c3c 45%, transparent);
}
.btn-danger:hover:not(:disabled) { background: rgba(231, 76, 60, 0.10); border-color: #e74c3c; }

.error { color: #e74c3c; font-size: 0.9rem; margin: 0; }
.error[hidden] { display: none; }

/* ───── Active games list ───── */
.active-games { margin-bottom: 56px; }
.active-games[hidden] { display: none; }
.active-games ul {
  list-style: none; padding: 0; margin: 12px 0 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
}
.active-games li {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  transition: border-color var(--transition), background var(--transition);
}
.active-games li:hover { border-color: var(--blue); background: var(--bg-hover); }
.active-games li a {
  display: flex; flex-direction: column; gap: 4px;
  padding: 16px 48px 16px 18px;
  color: var(--ink);
}
.active-games li a:hover { color: var(--ink); }
.g-id { font-family: var(--font-mono); color: var(--blue); font-size: .92rem; font-weight: 600; }
.g-meta { color: var(--ink-soft); font-size: .92rem; }
.g-delete {
  position: absolute;
  top: 50%; right: 10px;
  transform: translateY(-50%);
  background: transparent;
  color: var(--ink-mute);
  border: 0;
  width: 30px; height: 30px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 18px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: color .15s ease, background .15s ease;
}
.g-delete:hover { color: #e74c3c; background: rgba(231, 76, 60, 0.10); }

/* ───── How it works ───── */
.how ol { padding-left: 1.1em; color: var(--ink-soft); }
.how li { margin-bottom: 6px; }
.how strong { color: var(--ink); font-weight: 700; }

/* ───── Footer ───── */
.footer {
  border-top: 1px solid var(--line-soft);
  padding: 32px 24px 48px;
  text-align: center;
  color: var(--ink-mute);
  font-size: .88rem;
  background: var(--bg-alt);
}
.footer p { margin: 4px 0; color: var(--ink-mute); }
.footer .fineprint { max-width: 60ch; margin: 8px auto 0; opacity: .85; }
.footer a { color: var(--ink-soft); }
.footer a:hover { color: var(--blue); }

/* ───── Game shell ───── */
.game-shell {
  max-width: 1240px;
  margin: 0 auto;
  padding: 24px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 28px;
  align-items: start;
}
@media (max-width: 960px) {
  .game-shell { grid-template-columns: 1fr; padding: 16px; gap: 18px; }
}

.game-side { display: flex; flex-direction: column; gap: 14px; }
.player {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  box-shadow: var(--shadow-card);
}
.player.you {
  border-color: var(--blue);
  background:
    linear-gradient(150deg, color-mix(in srgb, var(--blue) 6%, var(--bg-card)) 0%, var(--bg-card) 60%);
}
.player-color {
  width: 22px; height: 22px; border-radius: 50%;
  border: 1px solid var(--line);
}
.player-color[data-color="w"] { background: #f3eedb; }
.player-color[data-color="b"] { background: #1a1a2e; }
.player-name { font-weight: 700; color: var(--ink); }
.player-status { font-size: .85rem; color: var(--ink-soft); }
.player-presence { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-mute); }
.player[data-live="1"] .player-presence {
  background: #2bb673;
  box-shadow: 0 0 0 3px rgba(43, 182, 115, 0.18);
}

/* ───── Board ───── */
.board-wrap {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow);
}
.board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  aspect-ratio: 1 / 1;
  width: 100%;
  border-radius: var(--radius-sm);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  box-shadow: inset 0 0 0 1px var(--line);
}
.sq {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background-color .1s ease;
}
.sq-light { background: var(--sq-light); }
.sq-dark  { background: var(--sq-dark); }
.sq.sel       { background: color-mix(in srgb, var(--orange) 60%, transparent); }
.sq.legal::after,
.sq.legal-capture::after { content: ""; position: absolute; pointer-events: none; }
.sq.legal::after {
  width: 28%; height: 28%; border-radius: 50%;
  background: var(--sq-legal);
}
.sq.legal-capture::after {
  inset: 6%;
  border-radius: 50%;
  border: 4px solid var(--sq-legal);
  box-sizing: border-box;
}
.sq.last-from { background: color-mix(in srgb, var(--orange) 24%, var(--sq-light)); }
.sq-dark.last-from { background: color-mix(in srgb, var(--orange) 24%, var(--sq-dark)); }
.sq.last-to   { background: color-mix(in srgb, var(--orange) 38%, var(--sq-light)); }
.sq-dark.last-to { background: color-mix(in srgb, var(--orange) 38%, var(--sq-dark)); }
.sq.in-check { background: var(--sq-check); }

.piece {
  font-size: clamp(28px, 7.2vw, 64px);
  line-height: 1;
  cursor: grab;
  font-weight: 700;
  transition: transform .08s ease;
}
.piece:active { cursor: grabbing; }

/* Crisp 1px outline in 8 directions — no blur, no glow. Guarantees
   pieces read clearly on every square colour. Theme overrides below
   may tune the outline colour. */
.piece-w {
  color: var(--pc-w);
  --pc-outline: #0a0a14;
  text-shadow:
    -1px -1px 0 var(--pc-outline),  1px -1px 0 var(--pc-outline),
    -1px  1px 0 var(--pc-outline),  1px  1px 0 var(--pc-outline),
     0   -1px 0 var(--pc-outline),  0    1px 0 var(--pc-outline),
    -1px  0   0 var(--pc-outline),  1px  0   0 var(--pc-outline);
}
.piece-b {
  color: var(--pc-b);
  --pc-outline: rgba(255, 255, 255, 0.92);
  text-shadow:
    -1px -1px 0 var(--pc-outline),  1px -1px 0 var(--pc-outline),
    -1px  1px 0 var(--pc-outline),  1px  1px 0 var(--pc-outline),
     0   -1px 0 var(--pc-outline),  0    1px 0 var(--pc-outline),
    -1px  0   0 var(--pc-outline),  1px  0   0 var(--pc-outline);
}

.coord {
  position: absolute;
  font-size: 10px;
  font-family: var(--font-mono);
  color: rgba(0, 0, 0, 0.45);
  pointer-events: none;
  user-select: none;
  font-weight: 600;
}
.sq-dark .coord { color: rgba(255, 255, 255, 0.65); }
.coord-rank { top: 3px; left: 4px; }
.coord-file { bottom: 3px; right: 5px; }

/* ───── Brett-Theme: WOOD ───── */
.board[data-theme="wood"] {
  box-shadow: inset 0 0 0 1px #3a2614;
}
.board[data-theme="wood"] .sq-light {
  background:
    repeating-linear-gradient(94deg, rgba(120, 76, 38, 0.08) 0 2px, transparent 2px 8px),
    repeating-linear-gradient(86deg, rgba(120, 76, 38, 0.06) 0 1px, transparent 1px 6px),
    linear-gradient(135deg, #f0d9a8 0%, #e6c587 100%);
}
.board[data-theme="wood"] .sq-dark {
  background:
    repeating-linear-gradient(98deg, rgba(255, 220, 160, 0.05) 0 2px, transparent 2px 9px),
    repeating-linear-gradient(82deg, rgba(40, 22, 8, 0.18) 0 1px, transparent 1px 7px),
    linear-gradient(135deg, #8a5a36 0%, #5d3a1f 100%);
}
.board[data-theme="wood"] .piece-w {
  color: #fbecc8;
  --pc-outline: #2b1a0a;
}
.board[data-theme="wood"] .piece-b {
  color: #1f140a;
  --pc-outline: #f8e6bf;
}
.board[data-theme="wood"] .coord { color: rgba(0,0,0,0.55); }
.board[data-theme="wood"] .sq-dark .coord { color: rgba(255,235,200,0.75); }

/* ───── Brett-Theme: GLASS 3D ───── */
.board[data-theme="glass"] {
  background:
    radial-gradient(ellipse at top, rgba(255,255,255,0.18), transparent 60%),
    linear-gradient(160deg, #0c71c3 0%, #062544 100%);
  padding: 0;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.18);
}
.board[data-theme="glass"] .sq {
  backdrop-filter: blur(2px);
}
.board[data-theme="glass"] .sq-light {
  background:
    linear-gradient(160deg, rgba(255,255,255,0.32), rgba(255,255,255,0.10) 60%, rgba(255,255,255,0.20));
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.40), inset 0 -1px 0 rgba(0,0,0,0.15);
}
.board[data-theme="glass"] .sq-dark {
  background:
    linear-gradient(160deg, rgba(8, 58, 106, 0.55), rgba(6, 25, 49, 0.85) 60%, rgba(8, 58, 106, 0.40));
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.10), inset 0 -1px 0 rgba(0,0,0,0.30);
}
.board[data-theme="glass"] .piece-w {
  color: #ffffff;
  --pc-outline: #0a1f3a;
}
.board[data-theme="glass"] .piece-b {
  color: #0a1428;
  --pc-outline: rgba(255, 255, 255, 0.95);
}
.board[data-theme="glass"] .coord { color: rgba(255,255,255,0.55); }

/* ───── Brett-Theme: FUTURISTIC NEO ───── */
.board[data-theme="neo"] {
  background: linear-gradient(180deg, #0a0e1f 0%, #050811 100%);
  box-shadow:
    inset 0 0 0 1px var(--orange),
    0 8px 24px rgba(0, 0, 0, 0.60);
}
.board[data-theme="neo"] .sq {
  border: 1px solid rgba(12, 113, 195, 0.35);
}
.board[data-theme="neo"] .sq-light {
  background: #1d3b5e;
}
.board[data-theme="neo"] .sq-dark {
  background: #050a18;
}
.board[data-theme="neo"] .sq.sel { box-shadow: inset 0 0 0 2px var(--orange); }
.board[data-theme="neo"] .piece-w {
  color: #f6efd9;
  --pc-outline: #050a18;
}
.board[data-theme="neo"] .piece-b {
  color: var(--orange);
  --pc-outline: #050a18;
}
.board[data-theme="neo"] .coord { color: rgba(180, 220, 255, 0.55); }
.board[data-theme="neo"] .sq-dark .coord { color: rgba(180, 220, 255, 0.55); }

/* ───── Board overlay ───── */
.board-overlay {
  position: absolute;
  inset: 18px;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  z-index: 5;
  animation: fadeIn 0.2s ease both;
}
.board-overlay[hidden] { display: none; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.overlay-inner { text-align: center; padding: 24px; max-width: 380px; }
.overlay-inner h2 { font-size: 1.6rem; margin-bottom: 8px; color: var(--ink); }
.overlay-inner p { margin-bottom: 20px; color: var(--ink-soft); }
.overlay-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* ───── Panel ───── */
.game-panel { display: flex; flex-direction: column; gap: 14px; }
.panel-card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  box-shadow: var(--shadow-card);
}
.panel-card[hidden] { display: none; }
.panel-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 5px 0;
  gap: 12px;
}
.panel-row + .panel-row { border-top: 1px solid var(--line-soft); }
.label {
  font-size: .76rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--ink-mute);
  font-weight: 600;
}
.value { color: var(--ink); font-weight: 500; }
.value.your-turn { color: var(--orange); font-weight: 700; }

.share-card { border-color: var(--orange); }
.share-card h3 { color: var(--orange); margin-bottom: 4px; }
.share-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-top: 10px; }
.share-row input { padding: 10px 12px; font-family: var(--font-mono); font-size: .9rem; }
.copy-feedback { color: #2bb673; font-size: .88rem; margin: 8px 0 0; }
.copy-feedback[hidden] { display: none; }

.move-list {
  list-style: decimal inside;
  margin: 8px 0 0; padding: 0;
  max-height: 240px;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: .92rem;
  color: var(--ink-soft);
}
.move-list li {
  display: grid;
  grid-template-columns: 32px 1fr 1fr;
  gap: 10px;
  padding: 3px 0;
}
.move-list li::marker { color: var(--ink-mute); }
.move-list .mv { color: var(--ink); }

.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.actions .btn { flex: 1; min-width: 0; }

.draw-offer { border-color: var(--orange); }
.draw-offer[hidden] { display: none; }
.draw-offer .row { display: flex; gap: 10px; margin-top: 10px; }
.draw-offer .row .btn { flex: 1; }

.hint { color: var(--ink-mute); font-size: .85rem; margin: 0; }

/* ───── Board theme picker ───── */
.themes {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 12px;
}
.theme-chip {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 8px 4px;
  cursor: pointer;
  font-family: inherit;
  font-size: .72rem;
  color: var(--ink-soft);
  font-weight: 600;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  transition: border-color var(--transition), background var(--transition), color var(--transition);
}
.theme-chip:hover { border-color: var(--blue); color: var(--blue); }
.theme-chip[aria-pressed="true"] {
  border-color: var(--orange);
  background: color-mix(in srgb, var(--orange) 8%, var(--bg-card));
  color: var(--orange);
}
.theme-swatch {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 4px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  overflow: hidden;
  border: 1px solid var(--line-soft);
}
.theme-swatch span { display: block; }
.theme-swatch.classic span:nth-child(1) { background: #eef1f7; }
.theme-swatch.classic span:nth-child(2) { background: #234868; }
.theme-swatch.classic span:nth-child(3) { background: #234868; }
.theme-swatch.classic span:nth-child(4) { background: #eef1f7; }
.theme-swatch.wood    span:nth-child(1) { background: #ecd29c; }
.theme-swatch.wood    span:nth-child(2) { background: #6f4524; }
.theme-swatch.wood    span:nth-child(3) { background: #6f4524; }
.theme-swatch.wood    span:nth-child(4) { background: #ecd29c; }
.theme-swatch.glass   span:nth-child(1) { background: rgba(255,255,255,0.55); }
.theme-swatch.glass   span:nth-child(2) { background: rgba(8, 58, 106, 0.85); }
.theme-swatch.glass   span:nth-child(3) { background: rgba(8, 58, 106, 0.85); }
.theme-swatch.glass   span:nth-child(4) { background: rgba(255,255,255,0.55); }
.theme-swatch.glass { background: linear-gradient(160deg, #0c71c3, #062544); }
.theme-swatch.neo     span:nth-child(1) { background: #1d3b5e; }
.theme-swatch.neo     span:nth-child(2) { background: #050a18; }
.theme-swatch.neo     span:nth-child(3) { background: #050a18; }
.theme-swatch.neo     span:nth-child(4) { background: #1d3b5e; }
.theme-swatch.neo { box-shadow: inset 0 0 0 1px var(--orange); }

.toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 12px;
  gap: 12px;
}
.toggle-row .label { margin-right: auto; }
.toggle {
  position: relative;
  width: 38px; height: 22px;
  background: var(--line);
  border-radius: 11px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--transition);
  border: 0;
  padding: 0;
}
.toggle::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 18px; height: 18px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--transition);
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}
.toggle[aria-pressed="true"] { background: var(--orange); }
.toggle[aria-pressed="true"]::after { transform: translateX(16px); }

/* ───── Promotion dialog ───── */
dialog#promotion-dialog,
dialog.modal {
  background: var(--bg-card);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-h);
  max-width: 360px;
  width: calc(100% - 32px);
}
dialog::backdrop { background: rgba(6, 26, 48, 0.65); backdrop-filter: blur(4px); }
dialog#promotion-dialog h3,
dialog.modal h3 {
  color: var(--ink);
  text-transform: none;
  letter-spacing: 0;
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 14px;
}
.promo-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.promo {
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: var(--radius-sm);
  padding: 14px 6px 10px;
  font-size: 2.2rem;
  cursor: pointer;
  font-family: inherit;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  transition: border-color .15s ease, background .15s ease;
}
.promo span { font-size: .7rem; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.promo:hover { border-color: var(--blue); background: var(--bg-hover); }

/* ───── Name-Modal ───── */
.name-modal .modal-actions { display: flex; gap: 10px; margin-top: 16px; }
.name-modal .modal-actions .btn { flex: 1; }
.name-modal label { display: block; }
.name-modal input { width: 100%; }

/* ───── Chat ───── */
.chat-card { display: flex; flex-direction: column; gap: 10px; }
.chat-log {
  display: flex; flex-direction: column; gap: 8px;
  max-height: 280px;
  min-height: 80px;
  overflow-y: auto;
  padding: 4px 2px;
  scroll-behavior: smooth;
}
.chat-empty {
  color: var(--ink-mute);
  font-size: .88rem;
  text-align: center;
  padding: 16px 0;
}
.chat-msg {
  display: flex; flex-direction: column; gap: 2px;
  max-width: 85%;
  word-wrap: break-word;
  overflow-wrap: break-word;
}
.chat-msg.me { align-self: flex-end; align-items: flex-end; }
.chat-msg.them { align-self: flex-start; align-items: flex-start; }
.chat-meta {
  font-size: .72rem;
  color: var(--ink-mute);
  padding: 0 4px;
}
.chat-bubble {
  padding: 8px 12px;
  border-radius: 14px;
  font-size: .94rem;
  line-height: 1.4;
  background: var(--bg-hover);
  color: var(--ink);
  border: 1px solid var(--line-soft);
}
.chat-msg.me .chat-bubble {
  background: var(--blue);
  color: var(--on-blue);
  border-color: transparent;
  border-bottom-right-radius: 4px;
}
.chat-msg.them .chat-bubble {
  background: var(--bg-hover);
  border-bottom-left-radius: 4px;
}
.chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
}
.chat-form input {
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: .94rem;
  font-family: inherit;
  outline: none;
  transition: border-color .15s ease;
  min-width: 0;
}
.chat-form input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 18%, transparent); }
.chat-form input:disabled { opacity: 0.6; }
.chat-form .btn { padding: 0 14px; }
.chat-hint { color: var(--ink-mute); font-size: .78rem; margin: 0; }
.chat-hint[hidden] { display: none; }

/* ───── Toast ───── */
.toast {
  position: fixed; left: 50%; bottom: 28px;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-card);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 12px 18px;
  font-size: .94rem;
  opacity: 0; pointer-events: none;
  transition: transform .2s ease, opacity .2s ease;
  z-index: 100;
  box-shadow: var(--shadow);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ───── PWA install popup ───── */
.pwa-install {
  position: fixed; left: 50%; bottom: 20px;
  transform: translateX(-50%) translateY(16px);
  width: min(420px, calc(100% - 24px));
  background: var(--bg-card);
  border: 1px solid var(--orange);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-h);
  padding: 16px 18px 18px;
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 14px;
  align-items: start;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .25s cubic-bezier(.2, .8, .2, 1);
}
.pwa-install[hidden] { display: none; }
.pwa-install.show { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
.pwa-close {
  position: absolute; top: 6px; right: 8px;
  background: transparent; border: 0;
  color: var(--ink-mute);
  font-size: 22px; line-height: 1;
  cursor: pointer; padding: 4px 8px; border-radius: 6px;
  font-family: inherit;
}
.pwa-close:hover { color: var(--ink); background: var(--bg-hover); }
.pwa-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  background: var(--blue);
  display: flex; align-items: center; justify-content: center;
}
.pwa-icon img { width: 26px; height: 26px; filter: brightness(0) invert(1); }
.pwa-title { display: block; font-weight: 700; font-size: 1rem; margin-bottom: 4px; color: var(--ink); }
.pwa-text { color: var(--ink-soft); font-size: .9rem; margin: 0 0 10px; }
.pwa-steps {
  list-style: decimal inside;
  padding: 0; margin: 4px 0 0;
  color: var(--ink-soft);
  font-size: .9rem;
  line-height: 1.55;
}
.pwa-steps em { color: var(--ink); font-style: normal; font-weight: 600; }
.pwa-share {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px;
  border-radius: 5px;
  border: 1px solid var(--orange);
  color: var(--orange);
  vertical-align: -6px;
  margin: 0 2px;
}
.pwa-action {
  background: var(--orange);
  color: var(--on-orange);
  border: 0;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: .94rem; font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}
.pwa-action:hover { background: #e07d00; }
.pwa-action:disabled { opacity: .6; cursor: progress; }

/* ───── Responsive ───── */
@media (max-width: 640px) {
  .topbar { padding: 14px 18px; }
  .lobby { padding: 36px 18px 56px; }
  .card { padding: 22px; }
  .game-shell { padding: 14px; gap: 14px; }
  .panel-card { padding: 16px; }
  .actions { flex-direction: column; }
  .actions .btn { width: 100%; }
}
