/* ═══════════════════════════════════════════════════════════
  SORTIS — The Deckbuilder  |  style.css
   ═══════════════════════════════════════════════════════════ */

/* ─── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* System accent colors */
  --poker:    #cc3333;
  --tarot:    #8b2be2;
  --baraja:   #c8961e;
  --mahjong:  #2da854;
  --chess:    #a0a0a0;
  --hanafuda: #d63384;

  /* System bg gradients (for cards) */
  --poker-bg:    linear-gradient(155deg, #1a0000 0%, #3d1010 60%, #1a0000 100%);
  --tarot-bg:    linear-gradient(155deg, #0d0022 0%, #2d1055 60%, #0d0022 100%);
  --baraja-bg:   linear-gradient(155deg, #1a1000 0%, #3d2800 60%, #1a1000 100%);
  --mahjong-bg:  linear-gradient(155deg, #001a08 0%, #0d3d18 60%, #001a08 100%);
  --chess-bg:    linear-gradient(155deg, #0a0a0a 0%, #252525 60%, #0a0a0a 100%);
  --hanafuda-bg: linear-gradient(155deg, #1a000e 0%, #4d1030 60%, #1a000e 100%);

  /* UI palette */
  --bg-deep:    #0d1117;
  --bg-board:   #161b22;
  --bg-zone:    #1c2128;
  --bg-hover:   #21262d;
  --border:     #30363d;
  --border-dim: #21262d;
  --text:       #e6edf3;
  --text-muted: #7d8590;
  --text-dim:   #484f58;

  /* Semantic */
  --damage:  #ff6b6b;
  --heal:    #56d364;
  --draw:    #58a6ff;
  --special: #bc8cff;
  --gold:    #d4a017;
  --gold-glow: 0 0 14px 3px rgba(212,160,23,0.65);
}

html, body {
  height: 100%;
  background: var(--bg-deep);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 13px;
  overflow: hidden;
}

/* ─── Scrollbar ─────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-board); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }


/* ═══════════════════════════════════════════════════════════
   SPLASH / NEW GAME SCREEN
   ═══════════════════════════════════════════════════════════ */
#new-game-screen {
  position: fixed; inset: 0;
  background: radial-gradient(ellipse at 50% 40%, #1a0d2e 0%, #0d1117 70%);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  overflow: hidden;
}
#menu-scaler {
  width: 1920px;
  height: 1080px;
  transform-origin: top left;
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.splash-content { text-align: center; max-width: 1220px; width: 100%; padding: 34px; }

.main-menu-topleft {
  position: absolute;
  top: 18px;
  left: 18px;
  z-index: 20;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.menu-fs-hint-bubble {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(212,160,23,.12);
  border: 1px solid var(--gold);
  border-radius: 8px;
  padding: 6px 12px;
  color: var(--gold);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  animation: fsHintPulse 2s ease-in-out infinite;
}
.fs-hint-arrow {
  font-size: 22px;
  line-height: 1;
}
@keyframes fsHintPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .5; }
}
.main-menu-topbar {
  position: absolute;
  top: 18px;
  right: 18px;
  z-index: 20;
}
.main-menu-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.main-menu-btn {
  font-size: 18px;
  padding: 12px 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-zone);
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  cursor: pointer;
}
.main-menu-btn-lg {
  font-size: 22px;
  padding: 14px 22px;
  border-radius: 12px;
}
.main-menu-btn:hover {
  border-color: var(--gold);
  color: var(--gold);
}
.account-menu-toggle {
  cursor: pointer;
}
.account-modal {
  position: fixed;
  inset: 0;
  background: rgba(10, 14, 20, .68);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2400;
}
.account-modal-box {
  width: min(960px, calc(100vw - 120px));
  background: var(--bg-board);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 24px 80px rgba(0,0,0,.65), inset 0 0 0 1px rgba(255,255,255,.03);
  position: relative;
  overflow: hidden;
  padding: 58px 20px 18px;
}
.account-modal-title {
  margin: 0 0 12px;
  text-align: center;
  font-size: 30px;
  color: var(--gold);
  letter-spacing: .5px;
}
.account-menu-header {
  font-size: 14px;
  color: var(--text-muted);
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-dim);
  background: rgba(255,255,255,.02);
}
.account-tabs {
  display: flex;
  gap: 10px;
  margin: 14px 0;
  flex-wrap: wrap;
}
.account-tab-btn {
  background: var(--bg-zone);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 9px;
  padding: 9px 14px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all .15s;
}
.account-tab-btn:hover {
  border-color: var(--gold);
  color: var(--gold);
}
.account-tab-btn.active {
  border-color: var(--gold);
  color: #000;
  background: var(--gold);
}
.account-tab-panel {
  background: rgba(255,255,255,.02);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}
.account-panel-title {
  font-size: 21px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 8px;
}
.account-panel-text {
  font-size: 15px;
  line-height: 1.5;
  color: var(--text-muted);
  margin-bottom: 14px;
}
.account-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 260px;
  background: var(--bg-zone);
  border: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
  font-size: 16px;
  font-weight: 700;
  border-radius: 9px;
  padding: 10px 14px;
  transition: all .15s;
}
.account-action-btn:hover {
  border-color: var(--gold);
  color: var(--gold);
}
.account-action-btn-danger {
  border-color: #6b1f1f;
  color: #ff8b8b;
}
.account-action-btn-danger:hover {
  border-color: #a93333;
  color: #ffb0b0;
  background: rgba(169,51,51,.08);
}

/* Account stats grid */
.account-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 6px;
}
.account-stat-card {
  background: var(--bg-zone);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 10px;
  text-align: center;
}
.account-stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.account-stat-value {
  font-size: 22px;
  font-weight: 800;
  color: var(--gold);
}

/* Account form */
.account-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 420px;
}
.account-form-label {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 600;
}
.account-form-input {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-zone);
  color: var(--text);
  font-size: 15px;
  outline: none;
}
.account-form-input:focus {
  border-color: var(--gold);
}
.account-form-msg {
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
}
.account-form-msg-ok {
  background: rgba(86,211,100,.1);
  border: 1px solid rgba(86,211,100,.3);
  color: var(--heal);
}
.account-form-msg-err {
  background: rgba(255,107,107,.1);
  border: 1px solid rgba(255,107,107,.3);
  color: var(--damage);
}

/* Account subscription info */
.account-sub-info {
  text-align: center;
}
.account-sub-tier {
  font-size: 36px;
  font-weight: 900;
  color: var(--gold);
  margin-bottom: 8px;
}

/* Language toggle */
.lang-toggle {
  display: flex;
  gap: 4px;
}
.lang-btn {
  background: var(--bg-zone);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all .15s;
}
.lang-btn:hover { border-color: var(--gold); color: var(--gold); }
.lang-btn.active { border-color: var(--gold); background: var(--gold); color: #000; }
.lang-toggle-sm { gap: 2px; }
.lang-btn-sm { padding: 4px 8px; font-size: 14px; border-radius: 5px; }

/* Play mode buttons */
.menu-play-row {
  display: flex;
  gap: 24px;
  justify-content: center;
  margin: 24px 0 8px;
}
.menu-play-btn {
  width: 340px;
  padding: 28px 24px;
  border-radius: 16px;
  border: 2px solid var(--border);
  background: var(--bg-zone);
  color: var(--text);
  font-size: 28px;
  font-weight: 800;
  cursor: pointer;
  transition: transform .2s, border-color .2s, box-shadow .2s;
}
.menu-play-btn:hover {
  transform: translateY(-4px);
  border-color: var(--gold);
  box-shadow: 0 8px 28px rgba(212,160,23,.25);
  color: var(--gold);
}
.menu-play-ai { border-color: #2a4a6a; }
.menu-play-online { border-color: #2a4a2a; }
.menu-remaining-games {
  text-align: center;
  font-size: 15px;
  color: var(--text-muted);
  margin-top: 6px;
}
.menu-back-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  margin-bottom: 8px;
  transition: color .15s;
}
.menu-back-btn:hover { color: var(--gold); }

.game-title {
  font-size: 88px;
  font-weight: 900;
  letter-spacing: 12px;
  background: linear-gradient(135deg, #d4a017, #e8c864, #d4a017);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: none;
}
.game-subtitle {
  font-size: 24px; letter-spacing: 7px; color: var(--text-muted);
  text-transform: uppercase; margin-top: -4px; margin-bottom: 6px;
}
.game-tagline { font-size: 18px; color: var(--text-dim); margin-bottom: 24px; }

.system-icons-row { font-size: 36px; display: flex; justify-content: center; gap: 20px; margin-bottom: 32px; }
.system-icons-row span { cursor: default; transition: transform .2s; }
.system-icons-row span:hover { transform: scale(1.3); }

.choose-label { font-size: 18px; text-transform: uppercase; letter-spacing: 4px; color: var(--text-muted); margin-bottom: 20px; }

.simple-mode-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 12px;
  margin-bottom: 14px;
  user-select: none;
}

.simple-mode-toggle input[type="checkbox"] {
  accent-color: var(--gold);
}

.deck-choices { display: flex; gap: 20px; justify-content: center; flex-wrap: wrap; }

.deck-btn {
  background: var(--bg-zone);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  cursor: pointer;
  padding: 24px 20px;
  width: 300px;
  text-align: center;
  transition: transform .2s, border-color .2s, box-shadow .2s;
  position: relative;
}
.deck-btn:hover {
  transform: translateY(-4px);
  border-color: var(--gold);
  box-shadow: 0 8px 24px rgba(212,160,23,.25);
}
.deck-btn.recommended { border-color: var(--gold); }
.deck-badge {
  position: absolute; top: -10px; left: 50%; transform: translateX(-50%);
  background: var(--gold); color: #000; font-size: 10px; font-weight: 700;
  padding: 2px 10px; border-radius: 10px; text-transform: uppercase; letter-spacing: 1px;
}
.deck-icon { font-size: 42px; margin-bottom: 12px; }
.deck-name { font-size: 24px; font-weight: 700; margin-bottom: 10px; }
.deck-desc { font-size: 15px; color: var(--text-muted); line-height: 1.5; margin-bottom: 14px; }
.deck-tags { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; }

.sys-tag {
  font-size: 11px; padding: 3px 9px; border-radius: 10px;
  font-weight: 600; letter-spacing: .5px;
}
.sys-tag.poker    { background: #3d1010; color: var(--poker); border: 1px solid var(--poker); }
.sys-tag.tarot    { background: #2d1055; color: var(--tarot); border: 1px solid var(--tarot); }
.sys-tag.baraja   { background: #3d2800; color: var(--baraja); border: 1px solid var(--baraja); }
.sys-tag.mahjong  { background: #0d3d18; color: var(--mahjong); border: 1px solid var(--mahjong); }
.sys-tag.chess    { background: #252525; color: var(--chess); border: 1px solid var(--chess); }
.sys-tag.hanafuda { background: #4d1030; color: var(--hanafuda); border: 1px solid var(--hanafuda); }


/* ═══════════════════════════════════════════════════════════
   GAME OVER SCREEN
   ═══════════════════════════════════════════════════════════ */
#game-over-screen {
  position: fixed; inset: 0;
  background: rgba(13,17,23,.92);
  display: flex; align-items: center; justify-content: center;
  z-index: 2000;
}
.gameover-content {
  text-align: center; padding: 40px 48px;
  background: var(--bg-zone); border: 1px solid var(--border);
  border-radius: 16px; min-width: 380px; max-width: 500px;
  box-shadow: 0 24px 80px rgba(0,0,0,.6);
}
.gameover-content.win  { border-color: var(--gold); box-shadow: 0 0 60px rgba(200,170,40,.2), 0 24px 80px rgba(0,0,0,.6); }
.gameover-content.loss { border-color: var(--damage); box-shadow: 0 0 60px rgba(200,40,40,.15), 0 24px 80px rgba(0,0,0,.6); }
#gameover-icon { font-size: 64px; margin-bottom: 8px; animation: go-pop .5s ease; }
@keyframes go-pop { 0% { transform: scale(0); } 60% { transform: scale(1.3); } 100% { transform: scale(1); } }
#gameover-title { font-size: 36px; font-weight: 900; margin-bottom: 4px; }
.win #gameover-title  { color: var(--gold); }
.loss #gameover-title { color: var(--damage); }
#gameover-sub { color: var(--text-muted); margin-bottom: 20px; font-size: 14px; }

/* HP bars */
.go-section { margin-bottom: 16px; }
.go-section-label { font-size: 10px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--text-dim); margin-bottom: 6px; }
.go-hp-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.go-hp-name { font-size: 12px; font-weight: 700; width: 80px; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.go-hp-track { flex: 1; height: 14px; background: rgba(255,255,255,.06); border-radius: 7px; overflow: hidden; }
.go-hp-fill { height: 100%; border-radius: 7px; transition: width .8s ease; }
.go-hp-you { background: linear-gradient(90deg, #2ea043, #56d364); }
.go-hp-opp { background: linear-gradient(90deg, #cc3333, #e06060); }
.go-hp-val { font-size: 13px; font-weight: 700; width: 56px; text-align: left; font-variant-numeric: tabular-nums; }

/* Stats grid */
.go-stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 16px; }
.go-stat {
  background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.06);
  border-radius: 8px; padding: 10px 12px; text-align: center;
}
.go-stat-val { font-size: 20px; font-weight: 800; line-height: 1.2; }
.go-stat-label { font-size: 10px; text-transform: uppercase; letter-spacing: 1px; color: var(--text-dim); margin-top: 2px; }

/* Mini board snapshot */
.go-board {
  display: inline-grid; grid-template-columns: repeat(4, 28px); grid-template-rows: repeat(4, 28px);
  gap: 2px; margin-top: 4px;
}
.go-board-cell {
  width: 28px; height: 28px; border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.06);
}
.go-board-cell.mine { background: rgba(46,160,67,.15); border-color: rgba(46,160,67,.3); }
.go-board-cell.theirs { background: rgba(204,51,51,.15); border-color: rgba(204,51,51,.3); }

/* Buttons */
.go-buttons { display: flex; gap: 12px; justify-content: center; margin-top: 20px; }
.go-btn-menu { border-color: var(--text-dim); color: var(--text-muted); font-size: 13px; }


/* ═══════════════════════════════════════════════════════════
   GAME LAYOUT — 1080p scale-to-fit
   ═══════════════════════════════════════════════════════════ */

/* The outer shell fills the viewport */
#game {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-deep);
  overflow: hidden;
}

/* The inner scaler always runs at 1920×1080 and is CSS-scaled to fit */
#game-scaler {
  width: 1920px;
  height: 1080px;
  display: flex; flex-direction: column;
  /* transform-origin top-left, actual transform set by JS */
  transform-origin: top left;
  overflow: hidden;
  position: absolute;
  top: 0; left: 0;
}

#game-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 14px;
  background: var(--bg-board);
  border-bottom: 1px solid var(--border);
  height: 42px; flex-shrink: 0;
}
.logo { font-weight: 900; letter-spacing: 4px; font-size: 14px; color: var(--gold); }
.turn-indicator { font-size: 12px; color: var(--text-muted); margin-left: 14px; }
#phase-indicator { font-size: 13px; color: var(--special); }

/* End Turn button in header */
.btn-endturn-header {
  background: linear-gradient(135deg, #1f6feb, #388bfd);
  color: #fff; border: none; border-radius: 5px;
  padding: 5px 14px; font-weight: 700; font-size: 12px;
  cursor: pointer; transition: opacity .15s, transform .1s;
  white-space: nowrap; flex-shrink: 0;
}
.btn-endturn-header:hover:not(:disabled) { opacity: .9; transform: translateY(-1px); }
.btn-endturn-header:active:not(:disabled) { transform: translateY(0); }
.btn-endturn-header:disabled { opacity: .35; cursor: not-allowed; }

.header-center {
  display: flex; align-items: center; gap: 10px;
}

#layout {
  display: grid;
  grid-template-columns: 1fr 230px;
  flex: 1;
  min-height: 0;
  overflow: visible;  /* must be visible so hovering cards can lift above the board */
}

#board {
  display: flex; flex-direction: column;
  gap: 4px; padding: 6px 8px;
  overflow: visible;    /* must be visible so hover cards can lift above */
  min-height: 0;
}

/* ─── Sidebar ────────────────────────────────────────────── */
#sidebar {
  background: var(--bg-board);
  border-left: 1px solid var(--border);
  padding: 8px 8px;
  overflow-y: auto;
  display: flex; flex-direction: column;
  gap: 4px;
  min-height: 0;
}
.sidebar-header {
  font-size: 10px; text-transform: uppercase; letter-spacing: 2px;
  color: var(--text-dim); padding: 2px 0 5px; border-bottom: 1px solid var(--border-dim);
  margin-bottom: 3px;
}
#action-log { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; min-height: 0; }
.log-entry {
  font-size: 11px; padding: 3px 5px; border-radius: 4px;
  border-left: 2px solid var(--border-dim); line-height: 1.4;
  word-break: break-word;
}
.log-damage  { border-color: var(--damage); color: #ffa0a0; }
.log-heal    { border-color: var(--heal); color: #a0ffc0; }
.log-draw    { border-color: var(--draw); color: #a0d0ff; }
.log-special { border-color: var(--special); color: #d0b0ff; }
.log-ai      { border-color: var(--border); color: var(--text-muted); font-style: italic; }
.log-gameover{ border-color: var(--gold); color: var(--gold); font-weight: 700; }
.log-normal  { color: var(--text); }


/* ═══════════════════════════════════════════════════════════
   COMBINED PLAYER INFO BAR
   ═══════════════════════════════════════════════════════════ */
#combined-info-bar {
  display: flex; align-items: center;
  background: var(--bg-zone); border: 1px solid var(--border);
  border-radius: 8px; padding: 5px 12px;
  flex-shrink: 0; gap: 8px;
}
.info-side {
  display: flex; align-items: center; gap: 10px;
  flex: 1;
}
.info-side-right {
  flex-direction: row-reverse;  /* mirror: name on far right */
}
.info-center {
  flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  min-width: 120px;
  font-size: 11px; color: var(--text-muted); text-align: center;
}
.player-name { font-weight: 700; font-size: 13px; min-width: 28px; white-space: nowrap; }

.hp-wrap { display: flex; align-items: center; gap: 6px; }
.hp-label { font-size: 10px; color: var(--text-muted); letter-spacing: 1px; }
.hp-bar-track {
  width: 140px; height: 9px;
  background: var(--bg-deep); border-radius: 4px; overflow: hidden;
  border: 1px solid var(--border);
}
.hp-bar-track-rev .hp-bar-fill { float: right; }  /* fills from right for opponent */
.hp-bar-fill {
  height: 100%; border-radius: 4px;
  background: linear-gradient(90deg, #2ea043, #6bc96b);
  transition: width .5s ease, background .5s ease;
}
.hp-bar-fill.medium { background: linear-gradient(90deg, #d4a017, #e8c864); }
.hp-bar-fill.low    { background: linear-gradient(90deg, #d32f2f, #ff6b6b); }
.hp-num { font-size: 12px; font-weight: 700; color: var(--text); min-width: 48px; }

.ap-dots { display: flex; gap: 4px; align-items: center; }
.ap-dot {
  width: 13px; height: 13px; border-radius: 50%;
  background: var(--gold); border: 1px solid #a07800;
  box-shadow: 0 0 4px rgba(212,160,23,.5);
}
.ap-dot.spent { background: var(--bg-deep); border-color: var(--border); box-shadow: none; }
.ap-dot.bonus {
  background: #50fa7b; border-color: #28a745;
  box-shadow: 0 0 6px rgba(80,250,123,.6);
  animation: bonus-pulse 0.8s ease-in-out infinite alternate;
}
@keyframes bonus-pulse {
  from { box-shadow: 0 0 4px rgba(80,250,123,.4); }
  to   { box-shadow: 0 0 10px rgba(80,250,123,.8); }
}

.shield-badge { font-size: 12px; color: #7dcfff; font-weight: 600; }

/* ─── Buffs ───────────────────────────────────────────────── */
.buffs-row { display: flex; gap: 3px; align-items: center; flex-wrap: wrap; }
.buff-pill {
  font-size: 11px; line-height: 1;
  padding: 2px 5px; border-radius: 8px;
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.15);
  cursor: default; white-space: nowrap;
  transition: background .15s;
}
.buff-pill:hover { background: rgba(255,255,255,.18); }

/* ─── Deck Stack Visual ───────────────────────────────────── */
.deck-stack-wrap {
  display: flex; align-items: center; gap: 8px;
}
.deck-stack {
  position: relative;
  width: 36px; height: 50px;
}
.deck-card-back {
  position: absolute;
  width: 32px; height: 46px;
  border-radius: 4px;
  background: repeating-linear-gradient(
    45deg,
    #1e2a3a 0%, #1e2a3a 3px,
    #15202e 3px, #15202e 6px
  );
  border: 1px solid #2d4060;
  box-shadow: 0 2px 6px rgba(0,0,0,.5);
}
.deck-card-back.s1 { transform: rotate(-4deg) translate(-2px,  2px); z-index: 1; }
.deck-card-back.s2 { transform: rotate(-1deg) translate( 1px,  1px); z-index: 2; }
.deck-card-back.s3 { transform: rotate( 2deg) translate( 3px,  0px); z-index: 3; }
.deck-count {
  font-size: 15px; font-weight: 800;
  color: var(--text); background: rgba(0,0,0,.5);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 2px 7px; min-width: 32px; text-align: center;
}


/* ═══════════════════════════════════════════════════════════
   CENTER AREA — Chess + Zones side by side
   ═══════════════════════════════════════════════════════════ */
#center-area {
  display: flex; flex-direction: row;
  flex: 1; min-height: 0;
  gap: 16px;          /* gap between chess panel and zones */
  align-items: stretch; /* zones fill full height; chess-panel uses align-self: center */
  overflow: visible;  /* must be visible for card z-index to work */
}

/* Left: chess panel — vertically centered within center-area */
#chess-panel {
  display: flex; flex-direction: column; align-items: center;
  flex-shrink: 0;
  justify-content: center;
  align-self: center;  /* center vertically even when zones-panel is taller */
  gap: 4px;
}
.zone-label-center {
  font-size: 10px; text-transform: uppercase; letter-spacing: 1.5px;
  color: var(--text-dim); align-self: center;
}
#chess-grid-wrap { display: flex; align-items: center; gap: 4px; }
#chess-row-labels { display: flex; flex-direction: column; gap: 0; font-size: 11px; color: var(--text-dim); }
#chess-row-labels span { display: flex; align-items: center; justify-content: center; width: 14px; }
#chess-col-labels { display: flex; gap: 0; margin-left: 18px; font-size: 11px; color: var(--text-dim); }
#chess-col-labels span { text-align: center; }
#chess-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
  /* Dynamic size set by JS scaler — CSS vars used */
  width:  calc(var(--chess-cell) * 4);
  height: calc(var(--chess-cell) * 4);
}
.chess-cell {
  display: flex; align-items: center; justify-content: center;
  position: relative; cursor: default;
  transition: background .15s;
  width: var(--chess-cell); height: var(--chess-cell);
}
#chess-row-labels span { height: var(--chess-cell); }
#chess-col-labels span { width: var(--chess-cell); }

.chess-cell.light { background: #2a2a2a; }
.chess-cell.dark  { background: #181818; }
.chess-cell.selected-piece { background: #3d3010 !important; outline: 2px solid var(--gold) inset; }
.chess-cell.valid-move { cursor: pointer; }
.chess-cell.valid-move::after {
  content: '';
  width: 30%; height: 30%; border-radius: 50%;
  background: rgba(46,160,67,.5); border: 2px solid #2ea043;
  position: absolute;
}
.chess-cell.valid-move:hover { background: rgba(46,160,67,.15) !important; }
.chess-cell.col-deploy { cursor: pointer; background: rgba(139,43,226,.15) !important; }
.chess-cell.col-deploy::after {
  content: '↓';
  font-size: 18px; color: var(--tarot); position: absolute; bottom: 2px;
}

/* Row/col control highlights */
.chess-cell.ctrl-mine     { box-shadow: inset 0 0 0 2px rgba(255,69,58,.55); }
.chess-cell.ctrl-opp      { box-shadow: inset 0 0 0 2px rgba(255,149,0,.55); }
.chess-cell.ctrl-mine-col { border-left: 2px solid rgba(80,250,123,.5); border-right: 2px solid rgba(80,250,123,.5); }
.chess-cell.ctrl-opp-col  { border-left: 2px solid rgba(255,149,0,.4); border-right: 2px solid rgba(255,149,0,.4); }
.chess-control-summary {
  font-size: 11px; color: var(--text-dim); text-align: center;
  margin-top: 4px; min-height: 16px; line-height: 1.4;
}

/* Right: zones panel split top/bottom — fills full height of center-area */
#zones-panel {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column;
  gap: 0; overflow: visible;
}
.zones-col {
  flex: 1; min-height: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 5px;
  overflow: visible;
  padding: 4px 0;
}
/* Opponent zones: reversed row-order so visually they mirror player zones
   (mahjong/garden in top rows, timeline/poker in bottom rows) */
.opponent-zones {
  grid-template-areas:
    "opp-mahjong  opp-garden"
    "opp-timeline opp-poker";
}
.opponent-zones .zone:nth-child(1) { grid-area: opp-timeline; }
.opponent-zones .zone:nth-child(2) { grid-area: opp-poker; }
.opponent-zones .zone:nth-child(3) { grid-area: opp-mahjong; }
.opponent-zones .zone:nth-child(4) { grid-area: opp-garden; }
.zones-divider {
  height: 1px; background: var(--border); flex-shrink: 0; margin: 6px 0;
  /* small visible separator between opponent and player zones */
}
.zone {
  background: var(--bg-zone); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 8px;
  overflow: hidden; min-height: 0;
  display: flex; flex-direction: column;
}
.zone-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: 1.2px;
  color: var(--text-dim); margin-bottom: 5px; flex-shrink: 0;
}

/* Targeting highlight on zones */
.zone.target-zone {
  border-color: var(--tarot);
  box-shadow: 0 0 12px rgba(139,43,226,.4);
  animation: pulse-zone .8s ease-in-out infinite alternate;
}
@keyframes pulse-zone {
  from { box-shadow: 0 0 8px rgba(139,43,226,.3); }
  to   { box-shadow: 0 0 20px rgba(139,43,226,.7); }
}

/* ─── Timeline Slots ─────────────────────────────────────── */
.timeline-slots {
  display: flex; gap: 0; align-items: stretch; flex: 1; min-height: 0; overflow: hidden;
  background: linear-gradient(90deg, rgba(139,43,226,.04) 0%, rgba(139,43,226,.08) 50%, rgba(139,43,226,.04) 100%);
  border-radius: 6px; padding: 4px 2px;
}
.timeline-slot {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  position: relative;
}
/* Flow arrows between slots */
.timeline-slot:not(:last-child)::after {
  content: '→';
  position: absolute; right: -3px; top: 50%;
  transform: translateY(-50%);
  font-size: 10px; color: var(--tarot); opacity: .5;
  z-index: 1;
}
.timeline-slot-label {
  font-size: 9px; color: var(--text-muted); text-transform: uppercase; flex-shrink: 0;
  letter-spacing: .5px; font-weight: 600;
}
.timeline-slot-inner {
  flex: 1; min-height: 0; width: calc(100% - 6px);
  border: 1.5px dashed var(--border);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  position: relative;
  transition: border-color .2s, box-shadow .2s, background .2s;
  background: rgba(0,0,0,.15);
}
.timeline-slot-inner:hover { background: rgba(139,43,226,.06); }
.timeline-slot-inner .card-mini {
  width: auto; height: calc(100% - 6px); max-height: 100%;
  aspect-ratio: 112 / 158; flex: unset; margin: 3px 0;
}
.timeline-slot-inner.has-card {
  border-style: solid; border-color: var(--tarot);
  background: rgba(139,43,226,.08);
  box-shadow: inset 0 0 8px rgba(139,43,226,.15);
}
.timeline-slot-inner.clickable {
  cursor: pointer; border-color: var(--tarot);
  animation: pulse-zone .8s ease-in-out infinite alternate;
}
.timeline-turns-badge {
  position: absolute; top: 2px; right: 2px;
  background: var(--tarot); color: #fff;
  font-size: 8px; font-weight: 700;
  width: 15px; height: 15px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 1px 4px rgba(139,43,226,.5);
}

/* ─── Poker Cards In Zone ────────────────────────────────── */
.poker-cards  { display: flex; flex-wrap: nowrap; gap: 5px; flex: 1; min-height: 0; overflow-x: auto; overflow-y: hidden; align-items: center; }
.poker-eval { font-size: 11px; color: var(--gold); margin-top: 4px; font-weight: 600; flex-shrink: 0; }

/* ─── Tableau ────────────────────────────────────────────── */
.tableau-tiles { display: flex; flex-wrap: nowrap; gap: 4px; flex: 1; min-height: 0; overflow-x: auto; overflow-y: hidden; align-items: center; }

/* ─── Garden ─────────────────────────────────────────────── */
.garden-cards { display: flex; flex-wrap: nowrap; gap: 5px; flex: 1; min-height: 0; overflow-x: auto; overflow-y: hidden; align-items: center; }
.yaku-list { margin-top: 4px; display: flex; flex-wrap: wrap; gap: 3px; flex-shrink: 0; }
.yaku-badge {
  font-size: 10px; background: #4d1030; color: var(--hanafuda);
  border: 1px solid var(--hanafuda); border-radius: 8px; padding: 1px 7px;
  font-weight: 600;
}

/* ─── Duel Arena (inside chess panel) ───────────────────── */
#duel-arena {
  background: var(--bg-zone); border: 1px solid var(--baraja);
  border-radius: 8px; padding: 8px; text-align: center;
  box-shadow: 0 0 16px rgba(200,150,30,.2);
  width: 100%; flex-shrink: 0;
}
#duel-cards { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 6px; }
.duel-vs { font-size: 18px; color: var(--baraja); font-weight: 700; }


/* ═══════════════════════════════════════════════════════════
   HAND SECTION — overflow visible so cards pop above container
   ═══════════════════════════════════════════════════════════ */
#hand-section {
  background: var(--bg-zone); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 10px;
  flex-shrink: 0;
  overflow: visible;      /* ← allows cards to lift above */
  position: relative;
  z-index: 10;
}
.hand-top-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 6px;
  position: relative; z-index: 20;
}
.hand-label { font-size: 10px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--text-dim); }
.hand-action-btns { display: flex; gap: 8px; align-items: center; }

#player-hand {
  display: flex; gap: 7px; flex-wrap: nowrap;
  /* Use padding + negative margin trick to avoid overflow-x:auto clipping hovered cards */
  overflow-x: auto; overflow-y: visible;
  padding-top: 80px; margin-top: -80px;   /* visual overflow above */
  padding-bottom: 6px;
  min-height: 168px; align-items: flex-end;
  flex: 1; min-width: 0;   /* take all available space, pushing deck to far right */
}
#player-hand::-webkit-scrollbar { height: 4px; }

/* Hand + deck-stack layout */
.hand-with-deck {
  display: flex; align-items: flex-end; gap: 10px;
}
#hand-deck-stack {
  flex-shrink: 0;
  width: 112px; height: 158px;
  position: relative;
  display: flex; align-items: flex-end; justify-content: center;
  cursor: default;
}
#hand-deck-stack .deck-card-back {
  position: absolute; left: 0; right: 0; margin: 0 auto;
  width: 108px; height: 154px;
  background: repeating-linear-gradient(45deg,#1e2a3a 0%,#1e2a3a 3px,#15202e 3px,#15202e 6px);
  border: 1.5px solid #2d4060; border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,.5);
}
#hand-deck-stack .deck-card-back.s1 { top: 0; }
#hand-deck-stack .deck-card-back.s2 { top: 3px; }
#hand-deck-stack .deck-card-back.s3 { top: 6px; }
#hand-deck-stack .deck-card-back.s4 { top: 9px; }
.hand-deck-count {
  position: absolute; bottom: 6px; left: 0; right: 0;
  text-align: center; font-size: 13px; font-weight: 700;
  color: #7ba8d4; z-index: 5;
}

/* Cash In inside Poker zone */
.btn-cashin-zone {
  margin-top: 6px;
  width: 100%;
  justify-content: center;
}

.hand-card {
  transition: margin .18s ease, transform .22s cubic-bezier(.25,.8,.25,1),
              box-shadow .22s ease;
  position: relative; z-index: 1;
}
.hand-card:hover { z-index: 200; }



/* Buttons */
.btn-primary {
  background: linear-gradient(135deg, #1f6feb, #388bfd);
  color: #fff; border: none; border-radius: 6px;
  padding: 7px 16px; font-weight: 700; font-size: 13px;
  cursor: pointer; transition: opacity .15s, transform .1s;
}
.btn-primary:hover:not(:disabled) { opacity: .9; transform: translateY(-1px); }
.btn-primary:active:not(:disabled) { transform: translateY(0); }
.btn-primary:disabled { opacity: .35; cursor: not-allowed; }
.btn-primary.btn-lg { padding: 9px 22px; font-size: 14px; }

.btn-action {
  background: var(--bg-hover); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 6px 12px; font-size: 12px; cursor: pointer;
  display: flex; align-items: center; gap: 5px;
  transition: border-color .15s, background .15s;
}
.btn-action:hover:not(:disabled) { border-color: var(--gold); background: var(--bg-zone); }
.btn-action:disabled { opacity: .4; cursor: not-allowed; }
.btn-action.ready { border-color: var(--gold); color: var(--gold); }
.btn-icon { font-size: 14px; }

/* Buttons */
.btn-primary {
  background: linear-gradient(135deg, #1f6feb, #388bfd);
  color: #fff; border: none; border-radius: 6px;
  padding: 7px 16px; font-weight: 700; font-size: 13px;
  cursor: pointer; transition: opacity .15s, transform .1s;
}
.btn-primary:hover:not(:disabled) { opacity: .9; transform: translateY(-1px); }
.btn-primary:active:not(:disabled) { transform: translateY(0); }
.btn-primary:disabled { opacity: .35; cursor: not-allowed; }
.btn-primary.btn-lg { padding: 9px 22px; font-size: 14px; }

.btn-action {
  background: var(--bg-hover); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 6px 12px; font-size: 12px; cursor: pointer;
  display: flex; align-items: center; gap: 5px;
  transition: border-color .15s, background .15s;
}
.btn-action:hover:not(:disabled) { border-color: var(--gold); background: var(--bg-zone); }
.btn-action:disabled { opacity: .4; cursor: not-allowed; }
.btn-action.ready { border-color: var(--gold); color: var(--gold); }
.btn-icon { font-size: 14px; }


.chess-piece {
  font-size: 26px; line-height: 1;
  cursor: pointer; transition: transform .15s;
  user-select: none;
}
.chess-piece.mine:hover { transform: scale(1.15); }
.chess-piece-power {
  position: absolute; bottom: 1px; right: 3px;
  font-size: 9px; font-weight: 700; color: var(--gold); line-height: 1;
}

#chess-hint {
  font-size: 11px; color: var(--text-muted); margin-top: 4px; text-align: center;
}


/* ═══════════════════════════════════════════════════════════
   CARDS — Redesigned
   ═══════════════════════════════════════════════════════════ */

/* ─── Full-size card (in hand) ──────────────────────────── */
.card {
  width: 112px; height: 158px;
  border-radius: 10px; border: 1.5px solid;
  position: relative; flex-shrink: 0;
  display: flex; flex-direction: column;
  padding: 0;
  cursor: pointer;
  user-select: none;
  transition: transform .22s cubic-bezier(.25,.8,.25,1),
              box-shadow .22s ease,
              opacity .18s,
              border-color .18s;
  overflow: hidden;
  will-change: transform;
}

/* Shimmer highlight sweep on hover */
.card::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(115deg,
    transparent 25%,
    rgba(255,255,255,.06) 45%,
    rgba(255,255,255,.13) 50%,
    rgba(255,255,255,.06) 55%,
    transparent 75%
  );
  background-size: 200% 100%;
  background-position: 200% 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
  transition: opacity .2s;
}
.card.playable:hover::after {
  opacity: 1;
  animation: card-shimmer .6s ease forwards;
}
@keyframes card-shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}

/* Watermark icon */
.card::before {
  font-size: 72px;
  opacity: .055;
  position: absolute;
  bottom: -4px; right: -4px;
  line-height: 1;
  pointer-events: none;
  transition: opacity .2s;
}
.card.playable:hover::before { opacity: .1; }

/* System themes */
.card[data-system="Poker"]    { background: var(--poker-bg);    border-color: #6b1515; }
.card[data-system="Poker"]::before    { content: "♠"; }
.card[data-system="Tarot"]    { background: var(--tarot-bg);    border-color: #5a1e8a; }
.card[data-system="Tarot"]::before    { content: "✦"; }
.card[data-system="Baraja"]   { background: var(--baraja-bg);   border-color: #8b6400; }
.card[data-system="Baraja"]::before   { content: "⚔"; }
.card[data-system="Mahjong"]  { background: var(--mahjong-bg);  border-color: #1a6b2e; }
.card[data-system="Mahjong"]::before  { content: "🀄"; font-size: 52px; }
.card[data-system="Chess"]    { background: var(--chess-bg);    border-color: #404040; }
.card[data-system="Chess"]::before    { content: "♛"; }
.card[data-system="Hanafuda"] { background: var(--hanafuda-bg); border-color: #8b0040; }
.card[data-system="Hanafuda"]::before { content: "✿"; }

/* Interactive states */
.card.playable:hover {
  transform: translateY(-14px) scale(1.06) rotate(-1deg);
  z-index: 50;
}
/* System hover glows */
.card.playable[data-system="Poker"]:hover    { box-shadow: 0 18px 32px rgba(204,51,51,.55),    0 0 0 1px rgba(204,51,51,.4); }
.card.playable[data-system="Tarot"]:hover    { box-shadow: 0 18px 32px rgba(139,43,226,.55),   0 0 0 1px rgba(139,43,226,.4); }
.card.playable[data-system="Baraja"]:hover   { box-shadow: 0 18px 32px rgba(200,150,30,.55),   0 0 0 1px rgba(200,150,30,.4); }
.card.playable[data-system="Mahjong"]:hover  { box-shadow: 0 18px 32px rgba(45,168,84,.55),    0 0 0 1px rgba(45,168,84,.4); }
.card.playable[data-system="Chess"]:hover    { box-shadow: 0 18px 32px rgba(160,160,160,.45),  0 0 0 1px rgba(160,160,160,.3); }
.card.playable[data-system="Hanafuda"]:hover { box-shadow: 0 18px 32px rgba(214,51,132,.55),   0 0 0 1px rgba(214,51,132,.4); }

.card.selected {
  transform: translateY(-18px) scale(1.08);
  box-shadow: var(--gold-glow);
  border-color: var(--gold) !important;
  z-index: 60;
}
.card.unplayable { opacity: .38; cursor: not-allowed; filter: saturate(.4); }
#player-hand.opponent-turn .card { opacity: 0.25; cursor: default; filter: saturate(0.2) brightness(0.6); }

/* Drag states */
.card.dragging {
  opacity: .3;
  transform: rotate(4deg) scale(.95);
  box-shadow: 0 8px 24px rgba(0,0,0,.6);
}

/* Gap drop zones between cards */
.drag-gap {
  width: 10px; height: 100%; min-height: 148px;
  flex-shrink: 0;
  border-radius: 4px;
  transition: width .15s ease, background .15s;
}
.drag-gap.drag-gap-active {
  width: 70px;
  background: rgba(212,160,23,.25);
  border: 1.5px dashed var(--gold);
}

/* ─── Play animation ─────────────────────────────────────── */
@keyframes card-play {
  0%   { transform: translateY(0) scale(1);    opacity: 1; }
  40%  { transform: translateY(-60px) scale(1.15); opacity: 1; }
  100% { transform: translateY(-120px) scale(.8);  opacity: 0; }
}
.card.playing {
  animation: card-play .38s cubic-bezier(.4,0,.6,1) forwards;
  pointer-events: none; z-index: 100;
}

/* ─── Draw card arrival glow ────────────────────────────── */
@keyframes card-arrive {
  0%   { transform: scale(1.08); box-shadow: 0 0 18px 4px rgba(88,166,255,.6), 0 0 6px rgba(88,166,255,.3); }
  50%  { transform: scale(1.02); box-shadow: 0 0 10px 2px rgba(88,166,255,.35), 0 0 4px rgba(88,166,255,.2); }
  100% { transform: scale(1);    box-shadow: none; }
}

/* ─── Card anatomy ──────────────────────────────────────── */

/* System header: thin colored banner at the very top */
.card-header-strip {
  display: flex; justify-content: space-between; align-items: center;
  padding: 5px 7px 4px;
  background: rgba(0,0,0,.35);
  border-bottom: 1px solid rgba(255,255,255,.06);
  flex-shrink: 0;
}
.card-sys-tag {
  font-size: 13px; line-height: 1; opacity: .95;
}
.card-cost {
  min-width: 20px; height: 20px; border-radius: 50%;
  background: rgba(0,0,0,.75);
  border: 1.5px solid rgba(255,255,255,.25);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 800; color: var(--gold);
  flex-shrink: 0;
  box-shadow: 0 1px 4px rgba(0,0,0,.5);
}

/* Art zone */
.card-art {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  position: relative;
  background: rgba(0,0,0,.25);
  overflow: hidden; min-height: 58px;
}
/* System-colored gradient wash inside art */
.card[data-system="Poker"]    .card-art { background: radial-gradient(ellipse at 50% 50%, rgba(204,51,51,.18) 0%, rgba(0,0,0,.25) 70%); }
.card[data-system="Tarot"]    .card-art { background: radial-gradient(ellipse at 50% 50%, rgba(139,43,226,.2) 0%, rgba(0,0,0,.25) 70%); }
.card[data-system="Baraja"]   .card-art { background: radial-gradient(ellipse at 50% 50%, rgba(200,150,30,.2) 0%, rgba(0,0,0,.25) 70%); }
.card[data-system="Mahjong"]  .card-art { background: radial-gradient(ellipse at 50% 50%, rgba(45,168,84,.18) 0%, rgba(0,0,0,.25) 70%); }
.card[data-system="Chess"]    .card-art { background: radial-gradient(ellipse at 50% 50%, rgba(160,160,160,.15) 0%, rgba(0,0,0,.25) 70%); }
.card[data-system="Hanafuda"] .card-art { background: radial-gradient(ellipse at 50% 50%, rgba(214,51,132,.2) 0%, rgba(0,0,0,.25) 70%); }

.card-art-symbol {
  font-size: 48px; opacity: .72; line-height: 1; user-select: none;
  transition: opacity .2s, transform .2s;
}
.card.playable:hover .card-art-symbol { opacity: .9; transform: scale(1.08); }

.card-art-badge {
  position: absolute; top: 3px; right: 5px;
  font-size: 9px; font-weight: 700; letter-spacing: .5px;
  color: rgba(255,255,255,.55);
}

/* Info strip */
.card-info {
  padding: 4px 6px 5px;
  background: rgba(0,0,0,.3);
  border-top: 1px solid rgba(255,255,255,.05);
  flex-shrink: 0;
}
.card-info .card-name {
  font-size: 10.5px; font-weight: 700; color: #f0f0f0;
  line-height: 1.2; margin-bottom: 3px;
  text-shadow: 0 1px 4px rgba(0,0,0,.9);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-stats {
  display: flex; gap: 3px; margin-bottom: 3px;
}
.card-stats span {
  font-size: 9.5px; font-weight: 700;
  padding: 1px 4px; border-radius: 3px;
  background: rgba(0,0,0,.4);
}
.stat-p { color: var(--damage); border: 1px solid rgba(255,107,107,.25); }
.stat-c { color: #4ecdc4;       border: 1px solid rgba(78,205,196,.25); }
.stat-f { color: var(--special); border: 1px solid rgba(188,140,255,.25); }

.card-footer {
  display: flex; flex-direction: column; gap: 1px;
}
.card-type-badge {
  font-size: 8px; text-transform: uppercase; letter-spacing: .8px;
  color: rgba(255,255,255,.35);
}
.card-kw {
  font-size: 8.5px; color: rgba(255,200,50,.75);
  font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ─── Mini card (zones, poker hand, etc.) ───────────────── */
.card-mini {
  width: 76px;
  aspect-ratio: 112 / 158;  /* same proportions as hand cards */
  height: auto; align-self: center;
  padding: 0; flex-shrink: 0;
}
.card-mini .card-mini-icon {
  flex: 1;  /* fills the extra zone height */
  font-size: 28px; line-height: 1; text-align: center;
  opacity: .85; padding: 6px 4px 4px;
  display: flex; align-items: center; justify-content: center;
}
.card-mini .card-name {
  font-size: 10px; font-weight: 700; color: #e0e0e0;
  padding: 0 4px 2px;
  text-shadow: 0 1px 3px rgba(0,0,0,.8);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  display: block; flex-shrink: 0;
}
.card-mini .card-stats {
  display: flex; gap: 2px; padding: 0 4px 4px; flex-shrink: 0;
}
.card-mini .card-stats span { font-size: 9px; padding: 1px 3px; }
.card-mini::before { font-size: 44px; }

/* ─── Face-down card ────────────────────────────────────── */
.card-facedown {
  background: repeating-linear-gradient(
    45deg,
    #1a1a2e 0%, #1a1a2e 4px,
    #12121f 4px, #12121f 8px
  );
  border-color: #30363d;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; color: rgba(255,255,255,.1);
  cursor: default;
}

/* ─── Card name (shared base) ───────────────────────────── */
.card-name {
  font-size: 11px; font-weight: 700; color: #fff;
  line-height: 1.2; flex: 1; padding: 0 2px;
  text-shadow: 0 1px 3px rgba(0,0,0,.8);
}




/* ═══════════════════════════════════════════════════════════
   HAND SECTION
   ═══════════════════════════════════════════════════════════ */
#hand-section {
  background: var(--bg-zone); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px;
}
.hand-label { font-size: 10px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--text-dim); margin-bottom: 8px; }
#player-hand {
  display: flex; gap: 8px; flex-wrap: nowrap;
  overflow-x: auto; padding-bottom: 10px;
  min-height: 172px; align-items: flex-end;
  perspective: 600px;
}
#player-hand::-webkit-scrollbar { height: 4px; }
/* Hand card: slight fan effect via sibling spacing */
.hand-card { transition: margin .18s ease, transform .22s cubic-bezier(.25,.8,.25,1), box-shadow .22s ease; }


/* ═══════════════════════════════════════════════════════════
   ACTION BAR
   ═══════════════════════════════════════════════════════════ */
#action-bar {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-zone); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 12px;
}
.action-btns { display: flex; gap: 8px; margin-left: auto; }

/* Buttons */
.btn-primary {
  background: linear-gradient(135deg, #1f6feb, #388bfd);
  color: #fff; border: none; border-radius: 6px;
  padding: 7px 16px; font-weight: 700; font-size: 13px;
  cursor: pointer; transition: opacity .15s, transform .1s;
}
.btn-primary:hover:not(:disabled) { opacity: .9; transform: translateY(-1px); }
.btn-primary:active:not(:disabled) { transform: translateY(0); }
.btn-primary:disabled { opacity: .35; cursor: not-allowed; }
.btn-primary.btn-lg { padding: 9px 22px; font-size: 14px; }

.btn-action {
  background: var(--bg-hover); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 6px 12px; font-size: 12px; cursor: pointer;
  display: flex; align-items: center; gap: 5px;
  transition: border-color .15s, background .15s;
}
.btn-action:hover:not(:disabled) { border-color: var(--gold); background: var(--bg-zone); }
.btn-action:disabled { opacity: .4; cursor: not-allowed; }
.btn-action.ready { border-color: var(--gold); color: var(--gold); }
.btn-icon { font-size: 14px; }

.btn-sm {
  background: var(--bg-hover); color: var(--text-muted);
  border: 1px solid var(--border); border-radius: 5px;
  padding: 4px 10px; font-size: 11px; cursor: pointer;
  transition: border-color .15s;
}
.btn-sm:hover { border-color: var(--text-muted); }
.cancel-btn { width: 100%; margin-top: 8px; }

/* Synergy & Mastery */
.synergy-item {
  font-size: 11px; padding: 3px 6px;
  background: var(--bg-hover); border-radius: 4px;
  color: var(--special); margin-bottom: 3px;
}
.mastery-item {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; padding: 2px 0;
}
.mastery-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}


/* ═══════════════════════════════════════════════════════════
   CARD TOOLTIP
   ═══════════════════════════════════════════════════════════ */
#card-tooltip {
  position: fixed; z-index: 9999;
  background: #0d1117;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0;
  width: 340px;
  box-shadow: 0 12px 40px rgba(0,0,0,.85);
  pointer-events: none;
  overflow: hidden;
}
.tt-art-wrap {
  width: 100%; aspect-ratio: 680/340; overflow: hidden;
  background: var(--bg-zone);
  border-bottom: 1px solid var(--border);
}
.tt-art {
  width: 100%; height: 100%; object-fit: cover;
}
.tt-content-pad {
  padding: 14px 16px;
}
#card-tooltip .tt-header,
#card-tooltip .tt-system,
#card-tooltip .tt-stats,
#card-tooltip .tt-type,
#card-tooltip .tt-keywords,
#card-tooltip .tt-divider,
#card-tooltip .tt-text,
#card-tooltip .tt-subtext { padding-left: 16px; padding-right: 16px; }
.tt-header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; padding-top: 14px; }
.tt-name { font-size: 18px; font-weight: 800; color: #fff; }
.tt-cost {
  font-size: 14px; font-weight: 700; color: var(--gold);
  background: rgba(212,160,23,.15); border: 1px solid rgba(212,160,23,.3);
  border-radius: 10px; padding: 2px 10px;
}
.tt-system { font-size: 14px; color: var(--text-muted); margin-bottom: 10px; }
.tt-stats { display: flex; gap: 14px; margin-bottom: 8px; font-size: 15px; font-weight: 700; }
.tt-power   { color: var(--damage); }
.tt-control { color: #4ecdc4; }
.tt-fate    { color: var(--special); }
.tt-type { font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--text-dim); margin-bottom: 6px; }
.tt-keywords { font-size: 13px; color: var(--gold); font-weight: 600; margin-bottom: 8px; }
.tt-divider { border: none; border-top: 1px solid var(--border); margin: 8px 16px; }
.tt-text { font-size: 15px; line-height: 1.55; color: var(--text); padding-bottom: 10px; }
.tt-subtext { font-size: 13px; color: var(--text-muted); margin-top: 0; line-height: 1.4; padding-bottom: 14px; }


/* ═══════════════════════════════════════════════════════════
   MODALS
   ═══════════════════════════════════════════════════════════ */
#modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 500;
}
.modal-box {
  background: var(--bg-board); border: 1px solid var(--border);
  border-radius: 12px; padding: 24px; min-width: 300px;
  text-align: center;
}
.modal-box h3 { font-size: 16px; font-weight: 700; margin-bottom: 8px; }
.modal-hint { font-size: 12px; color: var(--text-muted); margin-bottom: 16px; }
.modal-btns { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.slot-btn {
  background: var(--bg-zone); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text);
  padding: 12px 16px; cursor: pointer; min-width: 90px;
  transition: border-color .15s, transform .1s;
  font-size: 12px; line-height: 1.4;
}
.slot-btn small { display: block; font-size: 10px; color: var(--text-muted); margin-top: 3px; }
.slot-btn .slot-icon { font-size: 18px; display: block; margin-bottom: 4px; }
.slot-btn:hover { border-color: var(--tarot); transform: translateY(-2px); }
.past-btn:hover    { border-color: #7d8590; }
.present-btn:hover { border-color: #58a6ff; }
.future-btn:hover  { border-color: var(--tarot); }


/* ═══════════════════════════════════════════════════════════
   LOADING OVERLAY
   ═══════════════════════════════════════════════════════════ */
#loading {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 3000;
}
.loading-box { text-align: center; }
.loading-spinner {
  width: 40px; height: 40px; border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--gold);
  animation: spin .7s linear infinite;
  margin: 0 auto 10px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { color: var(--text-muted); font-size: 13px; }


/* ═══════════════════════════════════════════════════════════
   UTILITIES
   ═══════════════════════════════════════════════════════════ */
.hidden { display: none !important; }

/* ─── Toast notifications ────────────────────────────────── */
.game-toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: #1c2431; border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 20px;
  font-size: 13px; color: var(--text);
  box-shadow: 0 8px 24px rgba(0,0,0,.6);
  z-index: 9999; opacity: 0; pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
  white-space: nowrap;
}
.game-toast.toast-show { opacity: 1; transform: translateX(-50%) translateY(0); }
.game-toast-error { border-color: var(--damage); color: #ffa0a0; }
.game-toast-info  { border-color: var(--gold); }

.event-feedback {
  position: fixed;
  top: 58px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9100;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.event-chip {
  min-width: 280px;
  max-width: 720px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  box-shadow: 0 10px 24px rgba(0,0,0,.35);
  backdrop-filter: blur(4px);
  animation: chip-in .2s ease-out;
}

.event-chip.damage {
  color: #ffd5d5;
  border-color: var(--damage);
  background: rgba(114, 30, 30, 0.88);
}

.event-chip.heal {
  color: #dafbe1;
  border-color: var(--heal);
  background: rgba(24, 75, 40, 0.88);
}

.event-chip.ap {
  color: #dbeafe;
  border-color: var(--draw);
  background: rgba(25, 54, 88, 0.88);
}

.event-chip.info {
  color: var(--text);
  border-color: var(--gold);
  background: rgba(45, 38, 20, 0.9);
}

@keyframes chip-in {
  from { opacity: 0; transform: translateY(-6px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

#lang-select {
  min-width: 62px;
  text-align: center;
}

/* Damage float animation */
@keyframes float-up {
  0%   { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-40px); }
}
.damage-float {
  position: fixed; pointer-events: none;
  font-size: 22px; font-weight: 900;
  animation: float-up .9s ease-out forwards;
  z-index: 9000; text-shadow: 0 0 8px currentColor;
}

/* Pulse flash for taking damage / healing */
@keyframes flash-damage { 0%,100% { box-shadow: none; } 50% { box-shadow: 0 0 20px 4px var(--damage); } }
@keyframes flash-heal   { 0%,100% { box-shadow: none; } 50% { box-shadow: 0 0 20px 4px var(--heal); } }
.flash-damage { animation: flash-damage .4s ease; }
.flash-heal   { animation: flash-heal .4s ease; }


/* ═══════════════════════════════════════════════════════════
   CARD VISUAL REDESIGN (v2) — art-forward layout, no description in preview
   ═══════════════════════════════════════════════════════════ */

/* ─── New-game-screen extras ──────────────────────────────── */
/* Deck builder preview: parent wrap handles hover lift */
.db-card-preview { cursor: default !important; }
/* Hand card base */
.hand-card { }

.splash-extras {
  display: flex; gap: 14px; justify-content: center; margin-top: 30px;
}
.btn-outline {
  background: transparent; border: 1.5px solid var(--border);
  color: var(--text-muted); padding: 14px 28px;
  border-radius: 10px; font-size: 17px; font-weight: 700; cursor: pointer;
  transition: border-color .15s, color .15s;
}
.btn-outline:hover { border-color: var(--gold); color: var(--gold); }


/* ═══════════════════════════════════════════════════════════
   DECK BUILDER SCREEN
   ═══════════════════════════════════════════════════════════ */
#deck-builder-screen {
  position: fixed; inset: 0;
  background: var(--bg-deep);
  display: flex;
  z-index: 900;
  overflow: hidden;
}
#db-scaler,
#tut-scaler,
#lobby-scaler {
  width: 1920px;
  height: 1080px;
  transform-origin: top left;
  position: absolute;
  top: 0;
  left: 0;
}
#db-scaler {
  display: flex;
  flex-direction: column;
}
#tut-scaler,
#lobby-scaler {
  display: flex;
  align-items: center;
  justify-content: center;
}
.db-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 20px;
  background: var(--bg-board); border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.db-header-left  { display: flex; align-items: center; gap: 16px; }
.db-header-right { display: flex; align-items: center; gap: 10px; }
.db-count-label  { color: var(--text-muted); font-size: 13px; }

.db-body { display: flex; flex: 1; overflow: hidden; }

/* Left: card browser */
.db-browser {
  flex: 1; display: flex; flex-direction: column;
  padding: 12px 14px; gap: 10px; overflow: hidden;
}
.db-filters { display: flex; gap: 6px; flex-wrap: wrap; flex-shrink: 0; }
.db-filter-btn {
  padding: 4px 12px; border-radius: 14px;
  background: var(--bg-zone); border: 1px solid var(--border);
  color: var(--text-muted); font-size: 12px; cursor: pointer;
  transition: all .12s;
}
.db-filter-btn:hover,
.db-filter-btn.active { background: var(--border); color: var(--text); border-color: var(--gold); }

.db-card-grid {
  flex: 1; overflow-y: auto;
  display: flex; flex-wrap: wrap; gap: 14px;
  align-content: flex-start; padding-bottom: 12px;
}
.db-card-wrap {
  position: relative; display: flex;
  flex-direction: column; align-items: center; gap: 6px;
}
.db-card-wrap:hover .db-card-preview {
  transform: translateY(-6px);
  box-shadow: 0 8px 22px rgba(0,0,0,.5);
  transition: transform .15s, box-shadow .15s;
}
.db-card-wrap.in-deck .db-card-preview {
  border-color: var(--gold) !important;
  box-shadow: 0 0 8px rgba(212,160,23,.3);
}
.db-in-deck-badge {
  position: absolute; top: -7px; right: -7px;
  background: var(--gold); color: #000;
  font-size: 10px; font-weight: 800;
  border-radius: 10px; padding: 1px 6px;
  z-index: 5; pointer-events: none;
}
.db-card-controls { display: flex; gap: 6px; align-items: center; }
.db-btn {
  padding: 3px 10px; border-radius: 5px;
  background: var(--bg-zone); border: 1px solid var(--border);
  color: var(--text); font-size: 14px; cursor: pointer;
  transition: background .12s; font-weight: 700;
}
.db-btn:hover:not(:disabled) { background: var(--border); }
.db-btn:disabled { opacity: .35; cursor: not-allowed; }
.db-btn.db-plus  { color: var(--heal);   border-color: #1a4a28; }
.db-btn.db-plus:hover:not(:disabled)  { background: #1a4a28; }
.db-btn.db-minus { color: var(--damage); border-color: #4a1a1a; }
.db-btn.db-minus:hover:not(:disabled) { background: #4a1a1a; }

/* Right: deck panel */
.db-panel {
  width: 270px; flex-shrink: 0;
  background: var(--bg-board); border-left: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow-y: auto; padding: 12px; gap: 12px;
}
.db-panel-section { display: flex; flex-direction: column; gap: 6px; }
.db-panel-title {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 1px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-dim); padding-bottom: 4px;
}
.db-deck-list {
  max-height: 210px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 2px;
}
.db-list-header {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .8px; margin-top: 6px; padding: 2px 0;
}
.db-list-row {
  display: flex; align-items: center; gap: 4px;
  padding: 3px 6px; border-radius: 4px; background: var(--bg-zone);
}
.db-list-name  { flex: 1; font-size: 11px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.db-list-count { font-size: 11px; color: var(--gold); font-weight: 700; min-width: 20px; text-align: right; }
.db-list-remove {
  background: none; border: none; color: var(--text-dim); cursor: pointer;
  font-size: 10px; padding: 0 2px; line-height: 1;
}
.db-list-remove:hover { color: var(--damage); }
.db-empty { font-size: 11px; color: var(--text-dim); text-align: center; padding: 12px 0; }

.db-sys-bar {
  display: flex; height: 5px; border-radius: 3px;
  overflow: hidden; background: var(--border-dim); margin-bottom: 4px;
}
.db-sys-seg { height: 100%; min-width: 2px; transition: width .2s; }

.db-preset-row { display: flex; gap: 6px; flex-wrap: wrap; }

.db-name-input {
  width: 100%; padding: 6px 10px; border-radius: 5px;
  background: var(--bg-zone); border: 1px solid var(--border);
  color: var(--text); font-size: 12px; outline: none;
}
.db-name-input:focus { border-color: var(--gold); }

.db-saved-list { display: flex; flex-direction: column; gap: 4px; }
.db-saved-row {
  display: flex; align-items: center; gap: 4px;
  padding: 4px 6px; background: var(--bg-zone); border-radius: 4px;
}
.db-saved-name {
  flex: 1; font-size: 11px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; color: var(--text-muted);
}


/* ═══════════════════════════════════════════════════════════
   TUTORIAL SCREEN
   ═══════════════════════════════════════════════════════════ */
#tutorial-screen {
  position: fixed; inset: 0;
  background: radial-gradient(ellipse at 50% 30%, #1a0d2e 0%, #0d1117 75%);
  display: flex; align-items: center; justify-content: center;
  z-index: 950;
  overflow: hidden;
}
.tut-container,
.lobby-container {
  background: var(--bg-board); border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 24px 80px rgba(0,0,0,.65), inset 0 0 0 1px rgba(255,255,255,.03);
  max-width: 1120px; width: calc(100vw - 80px);
  height: 820px; max-height: 86vh;
  display: flex; flex-direction: column;
  padding: 34px 40px 28px; position: relative; overflow: hidden;
}
.tut-close {
  position: absolute; top: 14px; right: 16px;
  background: none; border: 1px solid var(--border);
  color: var(--text-muted); cursor: pointer;
  padding: 6px 12px; border-radius: 7px; font-size: 13px;
}
.tut-close:hover { color: var(--text); border-color: var(--text-muted); }

.tut-icon  { font-size: 46px; text-align: center; margin-bottom: 8px; flex-shrink: 0; }
.tut-title { font-size: 29px; font-weight: 700; text-align: center; color: var(--gold); margin-bottom: 16px; flex-shrink: 0; }

.tut-body {
  flex: 1; overflow-y: auto; font-size: 16px; line-height: 1.72; color: var(--text-muted);
}
.tut-body h3 {
  color: var(--text); font-size: 16px; font-weight: 700;
  margin: 12px 0 5px; letter-spacing: .5px; text-transform: uppercase;
}
.tut-body p     { margin-bottom: 8px; }
.tut-body ul,
.tut-body ol    { padding-left: 20px; margin-bottom: 8px; }
.tut-body li    { margin-bottom: 4px; }
.tut-body strong { color: var(--text); }
.tut-body kbd {
  display: inline-block; padding: 1px 6px; border-radius: 3px;
  background: var(--bg-zone); border: 1px solid var(--border);
  color: var(--text); font-size: 11px; font-family: monospace;
}

.tut-table {
  width: 100%; border-collapse: collapse; margin-bottom: 10px; font-size: 14px;
}
.tut-table th, .tut-table td { padding: 5px 8px; border: 1px solid var(--border-dim); text-align: left; }
.tut-table th { background: var(--bg-zone); color: var(--text-muted); font-weight: 600; }
.tut-table tr:hover td { background: var(--bg-hover); }

.tut-tip {
  background: rgba(212,160,23,.08); border-left: 3px solid var(--gold);
  padding: 6px 10px; border-radius: 0 4px 4px 0;
  color: var(--gold) !important; font-size: 12px !important; margin-top: 8px;
}

.tut-nav {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 18px; flex-shrink: 0;
}
.tut-nav-btn {
  padding: 11px 24px; border-radius: 8px;
  background: var(--bg-zone); border: 1px solid var(--border);
  color: var(--text); cursor: pointer; font-size: 16px; font-weight: 700; transition: background .12s;
}
.tut-nav-btn:hover:not(:disabled) { background: var(--border); }
.tut-nav-btn:disabled { opacity: .4; cursor: not-allowed; }
.tut-page-num { font-size: 14px; color: var(--text-muted); }

.tut-dots { display: flex; gap: 7px; justify-content: center; margin-top: 10px; flex-shrink: 0; }
.tut-dot  { width: 7px; height: 7px; border-radius: 50%; background: var(--border); transition: background .15s; }
.tut-dot.active { background: var(--gold); }


/* ══════════════════════════════════════════════════════════
   AUTH SCREENS  (login / register)
══════════════════════════════════════════════════════════ */
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}
.auth-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 36px 40px 32px;
  width: min(400px, 92vw);
  box-shadow: 0 8px 32px rgba(0,0,0,.45);
}
.auth-logo {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 3px;
  text-align: center;
  background: linear-gradient(135deg, var(--gold) 0%, #ff9f00 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 4px;
}
.auth-tagline {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  margin: 0 0 22px;
}
.auth-error {
  background: rgba(239,68,68,.15);
  border: 1px solid rgba(239,68,68,.4);
  color: #fca5a5;
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 16px;
}
.auth-form label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 5px;
}
.auth-form input {
  display: block;
  width: 100%;
  box-sizing: border-box;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 7px;
  padding: 9px 12px;
  font-size: 14px;
  margin-bottom: 14px;
  outline: none;
  transition: border-color .15s;
}
.auth-form input:focus { border-color: var(--gold); }
.auth-hint { font-size: 10px; color: var(--text-dim); }
.auth-submit {
  width: 100%;
  margin-top: 6px;
  padding: 11px;
  font-size: 15px;
}
.auth-switch {
  margin-top: 18px;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}
.auth-switch a { color: var(--gold); text-decoration: none; }
.auth-switch a:hover { text-decoration: underline; }


/* ══════════════════════════════════════════════════════════
   ONLINE LOBBY OVERLAY
══════════════════════════════════════════════════════════ */
#online-lobby {
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at 50% 30%, #1a0d2e 0%, #0d1117 75%);
  display: flex !important;
  align-items: center;
  justify-content: center;
  z-index: 2200;
  overflow: hidden;
}
#online-lobby.hidden { display: none !important; }

.lobby-container {
  position: relative;
  width: min(1120px, calc(100vw - 80px));
  max-height: 90vh;
  overflow-y: auto;
}
.lobby-title {
  text-align: center;
  font-size: 34px;
  font-weight: 700;
  margin: 0 0 8px;
  color: var(--text);
}
.lobby-subtitle {
  text-align: center;
  color: var(--text-dim);
  font-size: 17px;
  margin: 0 0 20px;
}
.lobby-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}
.lobby-tab {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 8px;
  padding: 12px 10px;
  font-size: 16px;
  cursor: pointer;
  transition: all .15s;
}
.lobby-tab.active {
  background: var(--gold);
  border-color: var(--gold);
  color: #000;
  font-weight: 600;
}
.lobby-panel { animation: fadeIn .15s ease; }

.lobby-deck-block {
  background: rgba(255,255,255,.02);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 14px;
}
.lobby-deck-label {
  display: block;
  font-size: 13px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1.4px;
  margin-bottom: 10px;
}
.lobby-deck-cards {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}
.deck-btn.deck-btn-mini {
  width: 220px;
  padding: 14px 12px;
}
.deck-btn.deck-btn-mini .deck-icon { font-size: 30px; margin-bottom: 8px; }
.deck-btn.deck-btn-mini .deck-name { font-size: 18px; margin-bottom: 0; }
.deck-btn.deck-btn-mini.active,
.deck-btn.deck-btn-mini[data-deck="custom-builder"].active {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(212,160,23,.25), 0 8px 20px rgba(212,160,23,.2);
}
.lobby-custom-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}
.lobby-custom-row label {
  font-size: 14px;
  color: var(--text-muted);
  white-space: nowrap;
}

.lobby-section { margin-bottom: 10px; }
.lobby-section h3 { margin: 0 0 8px; font-size: 19px; color: var(--text); }

.lobby-hint {
  font-size: 15px;
  color: var(--text-dim);
  margin: 0 0 14px;
}
.lobby-deck-pick {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0 14px;
}
.lobby-deck-pick label { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.lobby-select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  flex: 1;
  background: var(--bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23e0e0e0' d='M2 4l4 4 4-4z'/%3E%3C/svg%3E") no-repeat right 10px center;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 9px;
  padding: 11px 34px 11px 12px;
  font-size: 15px;
}
.lobby-select option {
  background: #151b23;
  color: #e6edf3;
}
.lobby-btns { display: flex; gap: 10px; align-items: center; }

.lobby-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 20px 0;
}
.lobby-code-input {
  display: block;
  width: 100%;
  box-sizing: border-box;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 7px;
  padding: 9px 12px;
  font-size: 18px;
  letter-spacing: 4px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 12px;
  outline: none;
}
.lobby-code-input:focus { border-color: var(--gold); }

.lobby-msg {
  margin-top: 14px;
  min-height: 22px;
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
}
.lobby-msg.lobby-ok   { color: #6ee7b7; }
.lobby-msg.lobby-warn { color: var(--gold); }
.lobby-msg.lobby-err  { color: #fca5a5; }

.lobby-status {
  background: rgba(234,179,8,.1);
  border: 1px solid rgba(234,179,8,.3);
  color: var(--gold);
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 15px;
  text-align: center;
  margin-bottom: 14px;
}

/* Room code display */
.room-code-display {
  background: var(--bg);
  border: 1px solid var(--gold);
  border-radius: 10px;
  padding: 18px;
  text-align: center;
  margin-top: 16px;
}
.room-code-label { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 2px; }
.room-code-big   { font-size: 46px; font-weight: 800; letter-spacing: 8px; color: var(--gold); margin: 8px 0; }
.room-code-hint  { font-size: 14px; color: var(--text-muted); }

@media (max-width: 900px) {
  .main-menu-topbar {
    flex-direction: column;
    align-items: flex-end;
  }
  .main-menu-actions {
    justify-content: center;
  }
  .deck-btn.deck-btn-mini {
    width: 140px;
  }
}

/* Header username badge */
.header-username {
  font-size: 13px;
  color: var(--text-muted);
  padding: 4px 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
}


/* ══════════════════════════════════════════════════════════
   LEADERBOARD / PROFILE  (server-rendered pages)
══════════════════════════════════════════════════════════ */
.lb-screen {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  padding: 0 0 60px;
}
.lb-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.lb-header h1 { margin: 0; font-size: 20px; }
.lb-back { color: var(--gold); text-decoration: none; font-size: 14px; }
.lb-back:hover { text-decoration: underline; }

.lb-my-rank {
  display: flex;
  align-items: center;
  gap: 16px;
  background: rgba(234,179,8,.08);
  border: 1px solid rgba(234,179,8,.25);
  border-radius: 10px;
  padding: 14px 22px;
  margin: 20px auto;
  max-width: 720px;
  font-size: 15px;
}
.lb-rank-badge {
  font-size: 22px;
  font-weight: 800;
  color: var(--gold);
  min-width: 44px;
}
.lb-own-name { font-weight: 600; flex: 1; }
.lb-wr { color: var(--gold); font-weight: 600; }

.lb-wrap { max-width: 720px; margin: 0 auto; padding: 0 16px; }

.lb-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  margin-top: 6px;
}
.lb-table th {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.lb-table td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255,255,255,.05);
}
.lb-table tr:hover td { background: rgba(255,255,255,.03); }
.lb-table tr.lb-me td { background: rgba(234,179,8,.07); }

.lb-rank   { font-weight: 700; font-size: 16px; min-width: 36px; }
.lb-player { font-weight: 500; }
.lb-wins   { color: var(--heal); }
.lb-losses { color: var(--damage); }

.lb-wr-bar-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 100px;
}
.lb-wr-bar {
  height: 6px;
  border-radius: 3px;
  background: var(--gold);
  min-width: 2px;
  max-width: 80px;
}

/* Profile stats cards */
.profile-stats {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  max-width: 720px;
  margin: 20px auto 24px;
  padding: 0 16px;
}
.profile-stat {
  flex: 1;
  min-width: 110px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 14px;
  text-align: center;
}
.ps-val { font-size: 26px; font-weight: 800; margin-bottom: 4px; }
.ps-lbl { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; }

/* ─── Turn Timer ────────────────────────────────────────────── */
#turn-timer-wrap {
  display: flex; align-items: center; gap: 6px; margin-top: 4px; justify-content: center;
}
#turn-timer-bar-track {
  width: 110px; height: 4px; background: var(--border); border-radius: 2px; overflow: hidden;
}
#turn-timer-bar-fill {
  height: 100%; background: var(--heal); border-radius: 2px;
  transition: width 0.9s linear, background 0.3s;
}
#turn-timer-label {
  font-size: 11px; color: var(--text-muted); min-width: 28px; font-variant-numeric: tabular-nums;
}
#turn-timer-wrap.timer-urgent #turn-timer-bar-fill { background: var(--damage); }
#turn-timer-wrap.timer-urgent #turn-timer-label { color: var(--damage); font-weight: 700; }
