/* ================================================================
   DRAUGHTS: EMBER & SLATE  v2.0
   Premium Board · 8 Themes + Custom · Lobby · Full Overlay Suite
   Custom Grid System · Reversi Architecture Port
================================================================ */
@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;600;700;900&family=Crimson+Pro:ital,wght@0,300;0,400;1,300&display=swap');

/* ══════════════════════════════════════════════════════════════
   CSS CUSTOM GRID SYSTEM
══════════════════════════════════════════════════════════════ */
.rs-grid          { display: grid; width: 100%; }
.rs-grid-2        { grid-template-columns: repeat(2, 1fr); }
.rs-grid-3        { grid-template-columns: repeat(3, 1fr); }
.rs-grid-4        { grid-template-columns: repeat(4, 1fr); }
.rs-grid-auto     { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
.rs-col-1         { grid-column: span 1; }
.rs-col-2         { grid-column: span 2; }
.rs-gap-xs        { gap: 4px; }
.rs-gap-sm        { gap: 6px; }
.rs-gap-md        { gap: 8px; }
.rs-gap-lg        { gap: 14px; }
.rs-align-center  { align-items: center; }
.rs-align-start   { align-items: start; }

/* ══════════════════════════════════════════════════════════════
   BASE THEME TOKENS  (Ember default)
══════════════════════════════════════════════════════════════ */
:root {
  --bg:             #1a1410;
  --surface:        #221c16;
  --panel:          #1e1812;
  --brass:          #d4a843;
  --brass-light:    #f0c85a;
  --brass-dark:     #8a6a20;
  --text-primary:   #f0e0c8;
  --text-muted:     #7a6a55;
  --border:         rgba(212,168,67,.2);
  --shadow-deep:    0 20px 60px rgba(0,0,0,.8);
  --radius:         4px;

  /* Board vars */
  --board-light:    #f5e8d0;
  --board-dark:     #7a3810;
  --board-frame:    #5c3010;
  --board-accent:   rgba(212,168,67,.5);

  /* Piece vars */
  --piece-c0: #f0a050;
  --piece-c1: #c87533;
  --piece-c2: #6a2e08;
  --piece-s0: #7090b0;
  --piece-s1: #3d5068;
  --piece-s2: #18222e;

  --score-active-glow: rgba(212,168,67,.2);

  --layout-ui-scale: 1;
  --layout-board-scale: 1;
  --layout-board-base: 480px;
  --layout-board-offset-x: 0px;
  --layout-board-offset-y: 0px;
}

/* ── Theme: Slate Night ─────────────────────────────────────── */
body[data-theme="slate"] {
  --bg:             #0d0f12;
  --surface:        #141820;
  --panel:          #0f1318;
  --brass:          #8090a8;
  --brass-light:    #a8bcd0;
  --brass-dark:     #405060;
  --text-primary:   #c8d8e8;
  --text-muted:     #4a5a6a;
  --border:         rgba(120,150,180,.2);

  --board-light:    #d0dce8;
  --board-dark:     #2a3848;
  --board-frame:    #1a2430;
  --board-accent:   rgba(120,150,180,.5);

  --piece-c0: #6080a0;
  --piece-c1: #405870;
  --piece-c2: #182030;
  --piece-s0: #d0e0f0;
  --piece-s1: #a8c0d8;
  --piece-s2: #708090;
  --score-active-glow: rgba(120,150,180,.2);
}

/* ── Theme: Forest ──────────────────────────────────────────── */
body[data-theme="forest"] {
  --bg:             #0a100a;
  --surface:        #121a12;
  --panel:          #0e160e;
  --brass:          #6ab050;
  --brass-light:    #90d070;
  --brass-dark:     #3a6030;
  --text-primary:   #d0e8c8;
  --text-muted:     #4a6040;
  --border:         rgba(100,170,80,.2);

  --board-light:    #c8ddb8;
  --board-dark:     #3a5a28;
  --board-frame:    #1e3412;
  --board-accent:   rgba(100,170,80,.5);

  --piece-c0: #d08840;
  --piece-c1: #a05a18;
  --piece-c2: #4a2808;
  --piece-s0: #b0e080;
  --piece-s1: #70a840;
  --piece-s2: #306020;
  --score-active-glow: rgba(100,170,80,.2);
}

/* ── Theme: Arctic ──────────────────────────────────────────── */
body[data-theme="arctic"] {
  --bg:             #080c12;
  --surface:        #0d1520;
  --panel:          #080e18;
  --brass:          #5ab4e8;
  --brass-light:    #88d0ff;
  --brass-dark:     #2a6090;
  --text-primary:   #c8ddf0;
  --text-muted:     #4a6080;
  --border:         rgba(80,160,220,.2);

  --board-light:    #d8eef8;
  --board-dark:     #1a3860;
  --board-frame:    #0a1e38;
  --board-accent:   rgba(80,160,220,.5);

  --piece-c0: #a0c8e8;
  --piece-c1: #5088b0;
  --piece-c2: #1a3858;
  --piece-s0: #e8f8ff;
  --piece-s1: #c0dff8;
  --piece-s2: #80b0d0;
  --score-active-glow: rgba(80,160,220,.2);
}

/* ── Theme: Midnight ────────────────────────────────────────── */
body[data-theme="midnight"] {
  --bg:             #060608;
  --surface:        #0c0c14;
  --panel:          #080810;
  --brass:          #a878e8;
  --brass-light:    #c8a0ff;
  --brass-dark:     #603890;
  --text-primary:   #d8c8f0;
  --text-muted:     #504868;
  --border:         rgba(160,110,220,.2);

  --board-light:    #c8b8e8;
  --board-dark:     #2a1848;
  --board-frame:    #160c28;
  --board-accent:   rgba(160,110,220,.5);

  --piece-c0: #9060d0;
  --piece-c1: #6030a0;
  --piece-c2: #280c48;
  --piece-s0: #f0e8ff;
  --piece-s1: #d8c0f0;
  --piece-s2: #a080c8;
  --score-active-glow: rgba(160,110,220,.2);
}

/* ── Theme: Crimson ─────────────────────────────────────────── */
body[data-theme="crimson"] {
  --bg:             #0e0a0a;
  --surface:        #1a1010;
  --panel:          #140a0a;
  --brass:          #e05a5a;
  --brass-light:    #ff8888;
  --brass-dark:     #8a2020;
  --text-primary:   #f0d8d8;
  --text-muted:     #806060;
  --border:         rgba(220,80,80,.2);

  --board-light:    #f0d0d0;
  --board-dark:     #6a1818;
  --board-frame:    #3a0c0c;
  --board-accent:   rgba(220,80,80,.5);

  --piece-c0: #e08080;
  --piece-c1: #a02828;
  --piece-c2: #480808;
  --piece-s0: #fff0f0;
  --piece-s1: #f0cece;
  --piece-s2: #c89898;
  --score-active-glow: rgba(220,80,80,.2);
}

/* ── Theme: Gold Marble ─────────────────────────────────────── */
body[data-theme="gold"] {
  --bg:             #f5f0e8;
  --surface:        #ede4d4;
  --panel:          #f0e8d8;
  --brass:          #8a6820;
  --brass-light:    #c09840;
  --brass-dark:     #5a4010;
  --text-primary:   #2a1e0a;
  --text-muted:     #8a7850;
  --border:         rgba(138,104,32,.22);

  --board-light:    #f8f0e0;
  --board-dark:     #8a5820;
  --board-frame:    #c09840;
  --board-accent:   rgba(138,104,32,.6);

  --piece-c0: #d4a020;
  --piece-c1: #9a6810;
  --piece-c2: #503008;
  --piece-s0: #2a1e0a;
  --piece-s1: #1a1208;
  --piece-s2: #080400;
  --score-active-glow: rgba(138,104,32,.2);
}

/* ── Theme: Neon Cyberpunk ──────────────────────────────────── */
body[data-theme="neon"] {
  --bg:             #060810;
  --surface:        #0a0d1a;
  --panel:          #060812;
  --brass:          #00ffe0;
  --brass-light:    #80fff0;
  --brass-dark:     #008870;
  --text-primary:   #c0f0e8;
  --text-muted:     #2a6060;
  --border:         rgba(0,255,200,.18);

  --board-light:    #102028;
  --board-dark:     #040810;
  --board-frame:    #020408;
  --board-accent:   rgba(0,255,200,.7);

  --piece-c0: #ff6040;
  --piece-c1: #c02808;
  --piece-c2: #500808;
  --piece-s0: #e0fffa;
  --piece-s1: #00ffe0;
  --piece-s2: #008878;
  --score-active-glow: rgba(0,255,200,.25);
}

/* ── Custom Theme ────────────────────────────────────────────── */
body[data-theme="custom"] {
  /* All tokens set dynamically by JS */
}

/* ══════════════════════════════════════════════════════════════
   RESET + BASE
══════════════════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text-primary);
  font-family: 'Crimson Pro', Georgia, serif;
  overflow-x: hidden;
  overflow-y: auto;
  transition: background .4s, color .4s;
}

body::before {
  content: '';
  position: fixed; inset: 0;
  background:
    radial-gradient(ellipse 70% 50% at 50% 0%, rgba(180,90,20,.15) 0%, transparent 70%),
    radial-gradient(ellipse 50% 40% at 20% 100%, rgba(200,117,51,.08) 0%, transparent 60%);
  pointer-events: none;
  transition: background .4s;
}

/* ══════════════════════════════════════════════════════════════
   BROWSER COMPATIBILITY SCREEN
══════════════════════════════════════════════════════════════ */
#compat-screen {
  position: fixed; inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  flex-direction: column;
  text-align: center;
  padding: 40px 24px;
}
#compat-screen.hidden { display: none; }
.compat-inner { max-width: 420px; width: 100%; }
.compat-icon {
  width: 64px; height: 64px;
  margin: 0 auto 20px;
  border: 2px solid var(--brass);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--brass);
  font-size: 1.6rem;
  box-shadow: 0 0 30px rgba(212,168,67,.2);
}
.compat-title {
  font-family: 'Cinzel', serif; font-size: 1.5rem; font-weight: 700;
  letter-spacing: .25em; color: var(--brass); margin-bottom: 8px;
  text-shadow: 0 0 30px rgba(212,168,67,.4);
}
.compat-subtitle {
  font-size: .85rem; font-style: italic;
  color: var(--text-muted); letter-spacing: .15em; margin-bottom: 24px;
}
.compat-message { font-size: .95rem; color: var(--text-primary); line-height: 1.7; margin-bottom: 24px; }
.compat-browsers { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; margin-bottom: 28px; }
.compat-browser-chip {
  padding: 8px 16px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--panel); color: var(--text-muted);
  font-family: 'Cinzel', serif; font-size: .6rem;
  letter-spacing: .15em; text-transform: uppercase;
}
.compat-divider { display: flex; align-items: center; gap: 12px; margin: 0 0 20px; }
.compat-divider-line { flex: 1; height: 1px; background: var(--border); }
.compat-divider-gem  { width: 5px; height: 5px; background: var(--brass-dark); transform: rotate(45deg); }
.compat-detail {
  font-size: .78rem; color: var(--text-muted); line-height: 1.6;
  text-align: left; background: var(--panel);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 16px;
}
.compat-detail-title {
  font-family: 'Cinzel', serif; font-size: .55rem;
  letter-spacing: .2em; text-transform: uppercase;
  color: var(--text-muted); margin-bottom: 6px;
}

/* ══════════════════════════════════════════════════════════════
   APP LAYOUT
══════════════════════════════════════════════════════════════ */
#app {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  width: 100%;
  max-width: 520px;
  padding: 12px 10px;
  position: relative;
  margin: 0 auto;
  transform: scale(var(--layout-ui-scale));
  transform-origin: top center;
}

/* ══════════════════════════════════════════════════════════════
   HEADER
══════════════════════════════════════════════════════════════ */
#header {
  width: 100%;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 4px 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
}
.game-title {
  font-family: 'Cinzel', serif; font-size: 1.1rem; font-weight: 700;
  letter-spacing: .25em; color: var(--brass);
  text-shadow: 0 0 20px rgba(212,168,67,.4);
}
.game-subtitle { font-size: .7rem; letter-spacing: .3em; color: var(--text-muted); text-transform: uppercase; }
.header-controls { display: flex; gap: 8px; align-items: center; }
.icon-btn {
  width: 34px; height: 34px;
  background: transparent;
  border: 1px solid var(--border); border-radius: var(--radius);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); transition: all .2s;
}
.icon-btn:hover { border-color: var(--brass); color: var(--brass); background: rgba(212,168,67,.06); }
.icon-btn svg { width: 16px; height: 16px; }

/* ══════════════════════════════════════════════════════════════
   SCORE PANEL
══════════════════════════════════════════════════════════════ */
#score-panel {
  width: 100%;
  display: grid; grid-template-columns: 1fr auto 1fr;
  gap: 8px; margin-bottom: 14px; align-items: center;
}
.score-card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 8px 12px;
  display: flex; align-items: center; gap: 10px;
  transition: border-color .3s, box-shadow .3s;
  position: relative; overflow: hidden;
}
.score-card.active {
  border-color: var(--brass);
  box-shadow: 0 0 16px var(--score-active-glow), inset 0 0 20px rgba(212,168,67,.04);
}
.score-disc {
  width: 22px; height: 22px; border-radius: 50%; flex-shrink: 0;
}
.score-disc.copper {
  background: radial-gradient(circle at 35% 30%, var(--piece-c0), var(--piece-c2));
  box-shadow: 0 3px 8px rgba(0,0,0,.6), inset 0 1px 3px rgba(255,200,100,.3);
}
.score-disc.slate {
  background: radial-gradient(circle at 35% 30%, var(--piece-s0), var(--piece-s2));
  box-shadow: 0 3px 8px rgba(0,0,0,.6), inset 0 1px 3px rgba(150,180,220,.25);
}
.score-info { flex: 1; min-width: 0; }
.score-name { font-family: 'Cinzel', serif; font-size: .6rem; letter-spacing: .15em; color: var(--text-muted); text-transform: uppercase; line-height: 1; }
.score-num  { font-family: 'Cinzel', serif; font-size: 1.4rem; font-weight: 700; color: var(--text-primary); line-height: 1.1; }
.score-label { font-size: .52rem; color: var(--text-muted); }
.score-sep  { font-family: 'Cinzel', serif; font-size: .7rem; color: var(--text-muted); text-align: center; }
.turn-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--brass); box-shadow: 0 0 6px var(--brass);
  flex-shrink: 0; opacity: 0; transition: opacity .3s;
}
.score-card.active .turn-dot { opacity: 1; }

/* ══════════════════════════════════════════════════════════════
   BOARD
══════════════════════════════════════════════════════════════ */
#board-wrap {
  position: relative;
  width: min(100%, calc(var(--layout-board-base) * var(--layout-board-scale)));
  aspect-ratio: 1;
  transform: translate(var(--layout-board-offset-x), var(--layout-board-offset-y));
}
.board-corner {
  position: absolute; width: 18px; height: 18px;
  border-color: var(--brass-dark); border-style: solid;
  opacity: .7; z-index: 3;
}
.board-corner.tl { top: -2px; left: -2px;   border-width: 2px 0 0 2px; }
.board-corner.tr { top: -2px; right: -2px;   border-width: 2px 2px 0 0; }
.board-corner.bl { bottom: -2px; left: -2px; border-width: 0 0 2px 2px; }
.board-corner.br { bottom: -2px; right: -2px;border-width: 0 2px 2px 0; }

/* Wood frame */
#board-frame {
  position: absolute; inset: -10px;
  background: linear-gradient(135deg, var(--board-frame) 0%, color-mix(in srgb, var(--board-frame) 60%, #000) 40%, color-mix(in srgb, var(--board-frame) 80%, #fff 10%) 60%, color-mix(in srgb, var(--board-frame) 60%, #000) 100%);
  border-radius: 6px;
  box-shadow: var(--shadow-deep), inset 0 0 30px rgba(0,0,0,.4);
  z-index: 0;
  transition: background .4s;
}
#board-frame::before {
  content: '';
  position: absolute; inset: 0;
  background: repeating-linear-gradient(88deg, transparent 0px, transparent 3px, rgba(0,0,0,.04) 3px, rgba(0,0,0,.04) 4px);
  border-radius: 6px;
}

#board-wrap::before {
  content: '';
  position: absolute; inset: -4px;
  border-radius: 4px;
  box-shadow: 0 0 40px rgba(0,0,0,.8), 0 0 0 1px rgba(212,168,67,.08), inset 0 0 60px rgba(0,0,0,.4);
  pointer-events: none; z-index: 2;
}

#board-canvas {
  position: relative; z-index: 1;
  display: block; width: 100%; height: 100%;
  cursor: pointer; border-radius: 2px;
  box-shadow: 0 8px 40px rgba(0,0,0,.7), 0 2px 8px rgba(0,0,0,.5), inset 0 0 0 1px rgba(255,255,255,.04);
}

#layout-drag-layer {
  position: absolute;
  inset: -12px;
  z-index: 4;
  display: none;
  cursor: grab;
  touch-action: none;
}

body.layout-editing #layout-drag-layer { display: block; }
body.layout-editing #board-wrap { outline: 1px dashed rgba(212,168,67,.45); outline-offset: 10px; }

#btn-layout { display: none; }

@media (max-width: 420px) {
  .header-controls { flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
  .icon-btn { width: 32px; height: 32px; }

  #score-panel { grid-template-columns: 1fr; gap: 6px; }
  .score-sep { display: none; }
}

/* ══════════════════════════════════════════════════════════════
   STATUS BAR
══════════════════════════════════════════════════════════════ */
#status-bar {
  width: 100%; display: flex; align-items: center; justify-content: center;
  gap: 8px; margin-top: 14px; min-height: 28px;
}
#status-text {
  font-family: 'Crimson Pro', serif;
  font-size: .95rem; font-style: italic;
  color: var(--text-muted); letter-spacing: .05em;
  text-align: center; transition: color .3s;
}
#status-text.highlight { color: var(--brass); }

/* ══════════════════════════════════════════════════════════════
   OVERLAYS — shared base
══════════════════════════════════════════════════════════════ */
.overlay {
  position: fixed; inset: 0;
  background: rgba(8,6,4,.88);
  display: flex; align-items: center; justify-content: center;
  z-index: 300;
  backdrop-filter: blur(6px);
  opacity: 0; pointer-events: none;
  transition: opacity .4s;
}
.overlay.show { opacity: 1; pointer-events: all; }

.dialog {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 36px 40px;
  text-align: center;
  max-width: 320px; width: 90%;
  position: relative;
  box-shadow: var(--shadow-deep);
  transform: translateY(10px);
  transition: transform .4s;
}
.overlay.show .dialog { transform: translateY(0); }

/* dialog corner ornaments */
.dialog::before, .dialog::after,
.dialog .d-corner-br, .dialog .d-corner-bl {
  content: ''; position: absolute;
  width: 14px; height: 14px;
  border-color: var(--brass-dark); border-style: solid;
}
.dialog::before  { top:8px; left:8px;   border-width:1px 0 0 1px; }
.dialog::after   { top:8px; right:8px;  border-width:1px 1px 0 0; }
.dialog .d-corner-br { bottom:8px; right:8px; border-width:0 1px 1px 0; }
.dialog .d-corner-bl { bottom:8px; left:8px;  border-width:0 0 1px 1px; }

.dialog-title {
  font-family: 'Cinzel', serif; font-size: 1.3rem; font-weight: 700;
  color: var(--brass); letter-spacing: .2em;
  margin-bottom: 6px;
  text-shadow: 0 0 20px rgba(212,168,67,.5);
}
.dialog-subtitle { font-size: .9rem; font-style: italic; color: var(--text-muted); margin-bottom: 24px; }

/* ── Game Over result discs ── */
.result-discs { display: flex; justify-content: center; gap: 20px; margin-bottom: 24px; align-items: center; }
.result-item  { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.result-disc-large { width: 44px; height: 44px; border-radius: 50%; }
.result-disc-large.copper {
  background: radial-gradient(circle at 35% 30%, var(--piece-c0), var(--piece-c2));
  box-shadow: 0 6px 20px rgba(0,0,0,.7), inset 0 2px 4px rgba(255,200,100,.3);
}
.result-disc-large.slate {
  background: radial-gradient(circle at 35% 30%, var(--piece-s0), var(--piece-s2));
  box-shadow: 0 6px 20px rgba(0,0,0,.7), inset 0 2px 4px rgba(150,180,220,.3);
}
.result-score-num { font-family: 'Cinzel', serif; font-size: 1.6rem; font-weight: 700; color: var(--text-primary); }
.result-vs { font-family: 'Cinzel', serif; font-size: .7rem; color: var(--text-muted); letter-spacing: .2em; align-self: center; }
.winner-badge { font-size: .65rem; letter-spacing: .2em; color: var(--brass); text-transform: uppercase; font-family: 'Cinzel', serif; }

/* ── Buttons ── */
.primary-btn {
  width: 100%; padding: 11px;
  background: transparent; border: 1px solid var(--brass); border-radius: var(--radius);
  color: var(--brass); font-family: 'Cinzel', serif; font-size: .75rem;
  letter-spacing: .2em; text-transform: uppercase;
  cursor: pointer; margin-top: 6px;
  transition: all .2s; position: relative; overflow: hidden;
}
.primary-btn::before { content: ''; position: absolute; inset: 0; background: var(--brass); opacity: 0; transition: opacity .2s; }
.primary-btn:hover { color: var(--bg); }
.primary-btn:hover::before { opacity: 1; }
.primary-btn span { position: relative; z-index: 1; }

.go-lobby-btn { border-color: var(--border) !important; color: var(--text-muted) !important; }
.go-lobby-btn:hover { color: var(--text-primary) !important; border-color: var(--brass) !important; }

.pause-assign-btn { border-color: rgba(212,168,67,.35) !important; color: var(--text-muted) !important; }
.pause-assign-btn:hover { color: var(--bg) !important; border-color: var(--brass) !important; }

.quit-danger-btn  { border-color: rgba(180,60,60,.4) !important; color: rgba(180,80,80,.7) !important; }
.quit-danger-btn:hover { color: #c05050 !important; border-color: rgba(180,60,60,.7) !important; }

.quit-dialog-title { color: #b85050 !important; text-shadow: 0 0 20px rgba(180,60,60,.4) !important; }
.quit-confirm-btn  { border-color: rgba(180,60,60,.7) !important; color: #c05050 !important; }
.quit-confirm-btn:hover { color: #fff !important; }

/* ── Pause icon ── */
.pause-icon-wrap {
  margin: 16px auto 20px; width: 52px; height: 52px;
  display: flex; align-items: center; justify-content: center;
}
.pause-icon-wrap svg { width: 52px; height: 52px; }
.pause-icon-wrap svg rect { fill: var(--brass); opacity: .6; }

/* ── Assign overlay ── */
.assign-discs-preview { display: flex; justify-content: center; align-items: center; gap: 16px; margin: 16px 0 20px; }
.assign-disc-wrap { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.assign-disc { width: 38px; height: 38px; border-radius: 50%; }
.assign-disc.copper {
  background: radial-gradient(circle at 35% 30%, var(--piece-c0), var(--piece-c2));
  box-shadow: 0 4px 14px rgba(0,0,0,.6), inset 0 1px 3px rgba(255,200,100,.3);
}
.assign-disc.slate {
  background: radial-gradient(circle at 35% 30%, var(--piece-s0), var(--piece-s2));
  box-shadow: 0 4px 14px rgba(0,0,0,.6), inset 0 1px 4px rgba(150,180,220,.3);
}
.assign-disc-label { font-family: 'Cinzel', serif; font-size: .58rem; letter-spacing: .15em; color: var(--text-muted); text-transform: uppercase; }
.assign-role-badge { font-family: 'Crimson Pro', serif; font-size: .78rem; font-style: italic; color: var(--brass); }
.assign-vs-sep { font-family: 'Cinzel', serif; font-size: .65rem; color: var(--text-muted); letter-spacing: .2em; }

.assign-btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 4px; }
.assign-cancel-btn {
  padding: 10px; background: transparent;
  border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text-muted);
  font-family: 'Cinzel', serif; font-size: .65rem; letter-spacing: .15em; text-transform: uppercase;
  cursor: pointer; transition: all .2s;
}
.assign-cancel-btn:hover { border-color: rgba(200,60,60,.5); color: #c05050; }
.assign-confirm-btn {
  padding: 10px; background: transparent;
  border: 1px solid var(--brass); border-radius: var(--radius);
  color: var(--brass); font-family: 'Cinzel', serif; font-size: .65rem;
  letter-spacing: .15em; text-transform: uppercase;
  cursor: pointer; transition: all .2s; position: relative; overflow: hidden;
}
.assign-confirm-btn::before { content: ''; position: absolute; inset: 0; background: var(--brass); opacity: 0; transition: opacity .2s; }
.assign-confirm-btn:hover { color: var(--bg); }
.assign-confirm-btn:hover::before { opacity: 1; }
.assign-confirm-btn span { position: relative; z-index: 1; }

/* ── Dialog close icon ── */
.dialog-close-icon {
  position: absolute; top: 10px; right: 10px;
  width: 26px; height: 26px;
  background: rgba(255,255,255,.06);
  border: 1px solid var(--border); border-radius: 50%;
  color: var(--text-muted); font-size: .65rem;
  cursor: pointer; transition: all .2s;
  display: flex; align-items: center; justify-content: center;
}
.dialog-close-icon:hover { background: rgba(255,255,255,.12); color: var(--text-primary); border-color: var(--brass); }

.layout-dialog { max-width: 420px; width: 92%; }
.layout-controls {
  margin: 18px 0 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: left;
}
.layout-row { display: flex; align-items: center; gap: 12px; }
.layout-label {
  font-family: 'Cinzel', serif;
  font-size: .55rem;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--text-muted);
  width: 92px;
  flex: 0 0 auto;
}
.layout-field { flex: 1; display: flex; align-items: center; gap: 10px; min-width: 0; }
.layout-field input[type="range"] { width: 100%; flex: 1; accent-color: var(--brass); }
.layout-val {
  font-family: 'Cinzel', serif;
  font-size: .6rem;
  letter-spacing: .06em;
  color: var(--text-primary);
  width: 56px;
  text-align: right;
  flex: 0 0 auto;
}

@media (max-width: 420px) {
  .layout-label { width: 74px; }
  .layout-val { width: 48px; }
}

/* ══════════════════════════════════════════════════════════════
   ASSIGN CONFIRMED POPUP
══════════════════════════════════════════════════════════════ */
.assign-confirmed-dialog { position: relative; }
.assign-confirmed-icon {
  font-size: 2rem; color: var(--brass);
  margin-bottom: 4px; display: block;
  animation: spin-in .4s ease;
}
@keyframes spin-in {
  from { transform: rotate(-30deg) scale(.7); opacity: 0; }
  to   { transform: rotate(0) scale(1); opacity: 1; }
}
.assign-confirmed-roles {
  display: flex; align-items: center; justify-content: center;
  gap: 12px; margin: 12px 0;
  padding: 10px 16px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 4px;
}
.acr-item { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.acr-disc { width: 28px; height: 28px; border-radius: 50%; }
.acr-disc.copper { background: radial-gradient(circle at 35% 30%, var(--piece-c0), var(--piece-c1), var(--piece-c2)); box-shadow: 0 2px 8px rgba(0,0,0,.6); }
.acr-disc.slate  { background: radial-gradient(circle at 35% 30%, var(--piece-s0), var(--piece-s1), var(--piece-s2)); box-shadow: 0 2px 8px rgba(0,0,0,.4); }
.acr-name { font-family: 'Cinzel', serif; font-size: .5rem; letter-spacing: .12em; text-transform: uppercase; color: var(--text-muted); }
.acr-you { color: var(--brass); }
.acr-sep { color: var(--text-muted); font-size: .8rem; }
.assign-confirmed-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: 100%; margin: 4px 0; }
.acb-btn {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 12px 8px;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text-muted); cursor: pointer; transition: all .2s;
}
.acb-btn:hover {
  border-color: var(--brass); color: var(--brass);
  background: rgba(212,168,67,.07); transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0,0,0,.4);
}
.acb-icon  { font-size: 1.1rem; line-height: 1; }
.acb-label { font-family: 'Cinzel', serif; font-size: .6rem; letter-spacing: .12em; text-transform: uppercase; color: inherit; }
.acb-sub   { font-family: 'Crimson Pro', serif; font-size: .68rem; font-style: italic; color: var(--text-muted); text-transform: none; }

/* ══════════════════════════════════════════════════════════════
   LOBBY SCREEN
══════════════════════════════════════════════════════════════ */
#lobby-screen {
  position: fixed; inset: 0;
  background: var(--bg);
  display: flex; align-items: flex-start; justify-content: center;
  z-index: 200; opacity: 1; transition: opacity .5s;
  overflow-y: auto;
  overscroll-behavior: contain;
}
#lobby-screen.hidden { opacity: 0; pointer-events: none; }

.lobby-inner {
  width: 100%; max-width: 460px;
  padding: 24px 20px 28px;
  display: flex; flex-direction: column; align-items: center;
  position: relative; z-index: 1;
  margin: auto;
}

/* Brand */
.lobby-brand { text-align: center; margin-bottom: 8px; }
.lobby-title {
  font-family: 'Cinzel', serif; font-size: 2.6rem; font-weight: 900;
  letter-spacing: .35em; color: var(--brass); line-height: 1; margin-bottom: 6px;
  text-shadow: 0 0 40px rgba(212,168,67,.5), 0 0 80px rgba(212,168,67,.2);
}
.lobby-subtitle {
  font-family: 'Crimson Pro', serif; font-size: .85rem;
  letter-spacing: .4em; color: var(--text-muted);
  text-transform: uppercase; font-style: italic;
}

/* Ornament */
.lobby-ornament { display: flex; align-items: center; gap: 12px; margin: 16px 0 20px; width: 100%; }
.lobby-ornament-line { flex: 1; height: 1px; background: linear-gradient(to right, transparent, var(--border), transparent); }
.lobby-ornament-diamond { width: 6px; height: 6px; background: var(--brass-dark); transform: rotate(45deg); flex-shrink: 0; }

/* Section labels */
.lobby-section { width: 100%; margin-bottom: 14px; }
.lobby-section-label { font-family: 'Cinzel', serif; font-size: .55rem; letter-spacing: .25em; color: var(--text-muted); text-transform: uppercase; margin-bottom: 8px; padding-left: 2px; }

/* Mode grid */
.lobby-mode-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.lobby-mode-btn {
  padding: 14px 10px;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text-muted); font-family: 'Cinzel', serif; font-size: .65rem;
  letter-spacing: .12em; cursor: pointer; text-transform: uppercase; transition: all .2s;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  position: relative; overflow: hidden;
}
.lobby-mode-btn:hover  { border-color: var(--brass); color: var(--brass); }
.lobby-mode-btn.selected {
  border-color: var(--brass); color: var(--brass);
  background: rgba(212,168,67,.07);
  box-shadow: 0 0 12px rgba(212,168,67,.15);
}
.lobby-mode-icon  { font-size: 1.4rem; line-height: 1; }
.lobby-mode-label { position: relative; z-index: 1; }
.lobby-mode-desc  { font-family: 'Crimson Pro', serif; font-size: .72rem; font-style: italic; color: var(--text-muted); letter-spacing: .02em; text-transform: none; }
.lobby-mode-btn.selected .lobby-mode-desc { color: var(--brass-dark); }

/* Difficulty */
.lobby-diff-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.lobby-diff-btn {
  padding: 8px 4px;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text-muted); font-family: 'Crimson Pro', serif; font-size: .82rem;
  letter-spacing: .08em; cursor: pointer; transition: all .2s; text-align: center;
}
.lobby-diff-btn.selected { border-color: rgba(100,180,100,.6); color: #90d890; background: rgba(100,180,100,.07); }
.lobby-diff-btn:hover:not(.selected) { border-color: rgba(100,180,100,.3); color: var(--text-primary); }
.lobby-diff-hard.selected { border-color: rgba(220,60,60,.7); color: #f07070; background: rgba(200,40,40,.09); }
.lobby-diff-hard:hover:not(.selected) { border-color: rgba(200,60,60,.35); color: var(--text-primary); }
.lobby-section.diff-section { transition: opacity .3s, max-height .3s; max-height: 80px; overflow: hidden; }
.lobby-section.diff-section.hidden { opacity: 0; pointer-events: none; max-height: 0; margin-bottom: 0; }

/* Theme Grid */
.lobby-theme-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.lobby-theme-btn {
  aspect-ratio: 1;
  border: 2px solid var(--border); border-radius: var(--radius);
  cursor: pointer; position: relative; overflow: hidden;
  transition: all .2s; background: transparent;
  display: flex; flex-direction: column;
  align-items: center; justify-content: flex-end;
  padding-bottom: 6px;
}
.lobby-theme-btn:hover { border-color: var(--brass); transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,.5); }
.lobby-theme-btn.selected { border-color: var(--brass); box-shadow: 0 0 16px rgba(212,168,67,.3), inset 0 0 20px rgba(212,168,67,.05); }
.lobby-theme-btn.selected::after { content: '✦'; position: absolute; top:4px; right:5px; font-size: .5rem; color: var(--brass); }

.theme-preview {
  position: absolute; inset: 0;
  display: grid; grid-template-columns: repeat(4,1fr); grid-template-rows: repeat(4,1fr);
  gap: 1px; padding: 4px;
}
.theme-cell { border-radius: 1px; }
.theme-name {
  position: relative; z-index: 2;
  font-family: 'Cinzel', serif; font-size: .45rem;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--text-primary);
  text-shadow: 0 1px 4px rgba(0,0,0,.8);
  text-align: center;
}

/* Lobby Actions */
.lobby-actions { width: 100%; margin-top: 4px; }
.lobby-custom-btn { margin-top: 10px; }
.lobby-play-btn {
  width: 100%; padding: 14px;
  background: transparent; border: 1px solid var(--brass); border-radius: var(--radius);
  color: var(--brass); font-family: 'Cinzel', serif; font-size: .8rem; font-weight: 700;
  letter-spacing: .3em; text-transform: uppercase;
  cursor: pointer; position: relative; overflow: hidden; transition: color .2s;
  box-shadow: 0 0 20px rgba(212,168,67,.15);
}
.lobby-play-btn::before {
  content: ''; position: absolute; inset: 0;
  background: var(--brass);
  transform: scaleX(0); transform-origin: left; transition: transform .3s ease;
}
.lobby-play-btn:hover { color: var(--bg); }
.lobby-play-btn:hover::before { transform: scaleX(1); }
.lobby-play-btn span { position: relative; z-index: 1; }

/* Custom theme float button */
.lobby-custom-float {
  position: absolute; z-index: 5;
  width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--panel);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: border-color .2s, box-shadow .2s, transform .2s, color .2s;
  color: var(--text-muted);
}
.lobby-custom-float svg { width: 16px; height: 16px; transition: transform .2s; }
.lobby-custom-float:hover {
  border-color: var(--brass); color: var(--brass);
  transform: translateY(-2px); box-shadow: 0 4px 16px rgba(212,168,67,.25);
}
.lobby-custom-float:hover svg { transform: rotate(-8deg) scale(1.1); }
.lobby-custom-float.selected { border-color: var(--brass); color: var(--brass); box-shadow: 0 0 14px rgba(212,168,67,.35); }

/* ══════════════════════════════════════════════════════════════
   CUSTOM THEME MODAL
══════════════════════════════════════════════════════════════ */
.ctm-dialog { max-width: 380px; width: 90%; padding: 36px 28px 24px; position: relative; text-align: center; }
.ctm-dialog .dialog-subtitle { margin-bottom: 16px; }

.ctm-live-preview { margin-bottom: 14px; display: flex; justify-content: center; }
.ctm-preview-board {
  width: 120px; height: 120px;
  border-radius: 4px; overflow: hidden;
  border: 2px solid var(--border);
  box-shadow: 0 4px 20px rgba(0,0,0,.5);
  position: relative; transition: border-color .3s;
}
.ctm-preview-grid { width: 100%; height: 100%; display: grid; grid-template-columns: repeat(8,1fr); grid-template-rows: repeat(8,1fr); }
.ctm-cell { transition: background .25s; }
.ctm-cell.piece-c, .ctm-cell.piece-s { position: relative; }
.ctm-cell.piece-c::after, .ctm-cell.piece-s::after {
  content: ''; position: absolute; inset: 15%; border-radius: 50%;
  transition: background .25s, box-shadow .25s;
}
.ctm-cell.piece-c::after {
  background: radial-gradient(circle at 35% 30%, var(--ctm-pc-light,#f0a050), var(--ctm-pc-mid,#c87533), var(--ctm-pc-dark,#6a2e08));
  box-shadow: 0 1px 4px rgba(0,0,0,.5);
}
.ctm-cell.piece-s::after {
  background: radial-gradient(circle at 35% 30%, var(--ctm-ps-light,#7090b0), var(--ctm-ps-mid,#3d5068), var(--ctm-ps-dark,#18222e));
  box-shadow: 0 1px 4px rgba(0,0,0,.3);
}

.ctm-controls {
  display: flex; gap: 0; align-items: stretch;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 6px; overflow: hidden; margin-bottom: 10px;
}
.ctm-group { flex: 1; padding: 10px 12px; }
.ctm-group-label { font-family: 'Cinzel', serif; font-size: .48rem; letter-spacing: .2em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 8px; }
.ctm-divider { width: 1px; background: var(--border); flex-shrink: 0; }

.ctm-swatches { display: flex; gap: 6px; align-items: flex-end; }
.ctm-swatch-item { display: flex; flex-direction: column; align-items: center; gap: 4px; flex: 1; }
.ctm-swatch-item span { font-family: 'Crimson Pro', serif; font-size: .62rem; color: var(--text-muted); text-align: center; white-space: nowrap; }
.ctm-swatch-wrap {
  position: relative; width: 100%; height: 30px;
  border-radius: 3px; border: 1px solid var(--border);
  overflow: hidden; cursor: pointer; transition: border-color .2s, box-shadow .2s;
}
.ctm-swatch-wrap:hover { border-color: var(--brass); box-shadow: 0 0 8px rgba(212,168,67,.3); }
.ctm-swatch-wrap input[type="color"] { position: absolute; inset: -5px; width: calc(100% + 10px); height: calc(100% + 10px); border: none; padding: 0; cursor: pointer; }
.ctm-swatch-shine { position: absolute; top: 0; left: 0; right: 0; height: 45%; background: linear-gradient(180deg, rgba(255,255,255,.14) 0%, transparent 100%); pointer-events: none; }
.ctm-swatch-accent { border-color: var(--brass) !important; }

.ctm-pieces { display: flex; gap: 10px; align-items: flex-end; justify-content: center; }
.ctm-piece-item { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.ctm-piece-item span { font-family: 'Crimson Pro', serif; font-size: .62rem; color: var(--text-muted); text-align: center; }
.ctm-piece-orb {
  width: 40px; height: 40px; border-radius: 50%;
  position: relative; overflow: hidden;
  border: 2px solid var(--border); cursor: pointer;
  transition: border-color .2s, box-shadow .2s, transform .2s;
}
.ctm-piece-orb:hover { border-color: var(--brass); box-shadow: 0 0 14px rgba(212,168,67,.4); transform: scale(1.08); }
.ctm-orb-copper { background: radial-gradient(circle at 35% 30%, #f0a050, #c87533, #6a2e08); }
.ctm-orb-slate  { background: radial-gradient(circle at 35% 30%, #7090b0, #3d5068, #18222e); }
.ctm-piece-orb input[type="color"] { position: absolute; inset: -10px; width: calc(100% + 20px); height: calc(100% + 20px); border: none; opacity: 0; cursor: pointer; }

.ctm-presets-row { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.ctm-presets-label { font-family: 'Cinzel', serif; font-size: .48rem; letter-spacing: .18em; text-transform: uppercase; color: var(--text-muted); flex-shrink: 0; }
.ctm-presets { display: flex; gap: 5px; }
.ctm-preset {
  width: 28px; height: 28px; border-radius: 3px;
  border: 1px solid var(--border); cursor: pointer;
  display: flex; overflow: hidden;
  transition: border-color .2s, transform .2s, box-shadow .2s;
  padding: 0;
}
.ctm-preset span { flex: 1; display: block; }
.ctm-preset:hover { border-color: var(--brass); transform: scale(1.15); box-shadow: 0 2px 10px rgba(0,0,0,.4); }

.ctm-footer { display: flex; gap: 8px; }
.ctm-btn-apply {
  flex: 1; padding: 11px 8px;
  background: transparent; border: 1px solid var(--brass); border-radius: var(--radius);
  color: var(--brass); font-family: 'Cinzel', serif; font-size: .62rem;
  letter-spacing: .2em; text-transform: uppercase;
  cursor: pointer; transition: all .25s;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  position: relative; overflow: hidden;
}
.ctm-btn-apply::before {
  content: ''; position: absolute; inset: 0; background: var(--brass);
  transform: scaleX(0); transform-origin: left; transition: transform .3s ease;
}
.ctm-btn-apply:hover { color: var(--bg); }
.ctm-btn-apply:hover::before { transform: scaleX(1); }
.ctm-btn-apply span { position: relative; z-index: 1; }

/* ══════════════════════════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════════════════════════ */
@media (max-width: 480px) {
  #app { padding: 8px; }
  .game-title  { font-size: .9rem; }
  .score-num   { font-size: 1.2rem; }
  #status-text { font-size: .85rem; }
  .lobby-title { font-size: 2rem; letter-spacing: .2em; }
  .lobby-theme-grid { grid-template-columns: repeat(4,1fr); }
  .ctm-dialog { padding: 16px; }
}
@media (max-height: 680px) {
  .lobby-inner  { padding: 16px 18px 24px; }
  .lobby-title  { font-size: 2rem; }
}
@media (max-height: 700px) {
  #app { padding: 6px 10px; }
  #header { padding-bottom: 8px; margin-bottom: 10px; }
  #score-panel { margin-bottom: 10px; }
  #status-bar  { margin-top: 8px; min-height: 22px; }
}
