/* ============================================================
   Whot — online-only. Classic warm parchment aesthetic with
   Splendour-style polish (Cinzel display, layered gradients,
   gold accents, 3D button treatments).
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;600;700;900&family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  /* Palette */
  --ink: #6b1f1f;
  --ink-deep: #4a1313;
  --ink-soft: #8a3232;
  --cream: #f4ece0;
  --paper: #fbf6ed;
  --paper-bright: #ffffff;
  --paper-dim: #ede4d3;
  --gold: #b8914e;
  --gold-deep: #8f6e34;
  --gold-soft: #d4b27b;
  --gold-glow: rgba(184, 145, 78, 0.35);
  --rule: rgba(107, 31, 31, 0.12);
  --text: #2a1919;
  --text-dim: #766558;
  --text-muted: #a89788;

  /* Card */
  --card-w: 150px;
  --card-h: 216px;
  --card-bg: #f4ece0;
  --card-border: #c9bfaa;

  /* Typography */
  --display: 'Cinzel', 'Playfair Display', 'Didot', serif;
  --body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  /* Radius system (Splendour) */
  --r: 10px;
  --r-sm: 6px;
  --r-lg: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  font-family: var(--body);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  background: linear-gradient(180deg, #ece5d5 0%, #e3d9c4 100%);
  background-image:
    radial-gradient(ellipse at 15% 20%, rgba(107,31,31,0.10) 0%, transparent 55%),
    radial-gradient(ellipse at 85% 15%, rgba(184,145,78,0.09) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 100%, rgba(107,31,31,0.06) 0%, transparent 45%),
    linear-gradient(180deg, #ece5d5 0%, #e3d9c4 100%);
  background-attachment: fixed;
}

/* Paper grain overlay */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.35;
  background-image:
    radial-gradient(rgba(0,0,0,0.045) 1px, transparent 1px),
    radial-gradient(rgba(0,0,0,0.03) 1px, transparent 1px);
  background-size: 3px 3px, 5px 5px;
  background-position: 0 0, 1px 2px;
  z-index: 0;
}

#app { position: relative; z-index: 1; }
.view { display: none; }
.view.active { display: block; }

/* ============================================================
   HERO / LANDING
   ============================================================ */

.hero {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 40px 20px;
  position: relative;
  overflow: hidden;
}

/* Floating decorative Whot cards behind the panel */
.hero-decor {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}
.hero-decor .card {
  position: absolute;
  opacity: 0.12;
  animation: float-slow 8s ease-in-out infinite;
}
.hero-decor .card.d1 { top: 8%;  left: 6%;  transform: rotate(-14deg); animation-delay: 0s; }
.hero-decor .card.d2 { top: 14%; right: 8%; transform: rotate(10deg) scale(1.1); animation-delay: 2s; }
.hero-decor .card.d3 { bottom: 14%; left: 10%; transform: rotate(8deg); animation-delay: 4s; }
.hero-decor .card.d4 { bottom: 10%;  right: 6%; transform: rotate(-6deg) scale(0.92); animation-delay: 6s; }

@keyframes float-slow {
  0%, 100% { transform: translateY(0) var(--t, rotate(0)); }
  50%      { transform: translateY(-10px) var(--t, rotate(0)); }
}
.hero-decor .card.d1 { --t: rotate(-14deg); }
.hero-decor .card.d2 { --t: rotate(10deg) scale(1.1); }
.hero-decor .card.d3 { --t: rotate(8deg); }
.hero-decor .card.d4 { --t: rotate(-6deg) scale(0.92); }

.hero-inner {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 480px;
  text-align: center;
  animation: appear 0.5s ease-out;
}

@keyframes appear {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.brand {
  margin: 0 0 8px;
  font-family: var(--display);
  font-style: italic;
  font-weight: 900;
  font-size: clamp(72px, 11vw, 116px);
  letter-spacing: -2px;
  line-height: 0.95;
  background: linear-gradient(90deg,
    var(--ink) 0%, var(--ink-soft) 25%, var(--ink) 50%,
    var(--ink-soft) 75%, var(--ink) 100%);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: shimmer 6s linear infinite;
  filter: drop-shadow(0 2px 2px rgba(74, 19, 19, 0.12));
}

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

.brand-sub {
  margin: 0 auto 36px;
  font-family: var(--body);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 5px;
  text-transform: uppercase;
  color: var(--text-dim);
  max-width: 360px;
}
.brand-sub::before, .brand-sub::after {
  content: "";
  display: inline-block;
  width: 28px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  vertical-align: middle;
  margin: 0 14px;
}

/* ============================================================
   PANELS
   ============================================================ */

.panel {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--r-lg);
  padding: 32px;
  box-shadow:
    0 1px 0 rgba(255,255,255,0.9) inset,
    0 8px 32px rgba(74, 19, 19, 0.10),
    0 2px 6px rgba(74, 19, 19, 0.05);
  text-align: left;
  position: relative;
}
.panel::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(255,255,255,0.3), transparent 20%);
}
.panel.center { text-align: center; }
.panel h2 {
  margin: 0 0 8px;
  font-family: var(--display);
  font-weight: 700;
  color: var(--ink);
  font-size: 24px;
  letter-spacing: 0.5px;
}
.panel .muted {
  margin: 0 0 24px;
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1.5;
}
.panel-footer {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--rule);
  text-align: right;
}

/* ============================================================
   FORMS
   ============================================================ */

.field { display: block; margin-bottom: 18px; }
.field > span {
  display: block;
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 8px;
  font-weight: 700;
}
.field input, .field select, .join-row input {
  width: 100%;
  padding: 13px 15px;
  border: 1.5px solid #dccfb6;
  border-radius: var(--r);
  font-size: 15px;
  font-family: var(--body);
  background: #fff;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.03);
}
.field input:focus, .field select:focus, .join-row input:focus {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(107, 31, 31, 0.12), inset 0 1px 3px rgba(0,0,0,0.03);
}
.field input::placeholder { color: #b3a08c; }

/* ============================================================
   BUTTONS
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: #fff;
  border: 1.5px solid #dccfb6;
  color: var(--text);
  padding: 11px 20px;
  border-radius: var(--r);
  font-size: 13px;
  font-weight: 600;
  font-family: var(--body);
  letter-spacing: 0.3px;
  cursor: pointer;
  transition: all 0.15s ease;
  min-height: 42px;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); border-color: var(--ink); color: var(--ink); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none !important; }

.btn.primary {
  background: linear-gradient(180deg, var(--ink-soft) 0%, var(--ink) 70%, var(--ink-deep) 100%);
  border-color: var(--ink-deep);
  color: var(--paper);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.25),
    0 4px 14px rgba(74, 19, 19, 0.30),
    0 1px 2px rgba(74, 19, 19, 0.20);
  letter-spacing: 0.5px;
}
.btn.primary:hover {
  color: #fff;
  border-color: #000;
  filter: brightness(1.08);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.3),
    0 6px 18px rgba(74, 19, 19, 0.40),
    0 1px 2px rgba(74, 19, 19, 0.25);
}

.btn.gold {
  background: linear-gradient(180deg, var(--gold-soft), var(--gold) 60%, var(--gold-deep));
  border-color: var(--gold-deep);
  color: #3a2a10;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.4),
    0 4px 14px var(--gold-glow);
}
.btn.gold:hover { filter: brightness(1.1); color: #2a1d08; }

.btn.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-dim);
  font-size: 12px;
  padding: 6px 12px;
  min-height: 0;
  letter-spacing: 0.5px;
}
.btn.ghost:hover { color: var(--ink); background: rgba(255,255,255,0.5); border-color: var(--rule); }

.btn.danger {
  background: rgba(168, 30, 30, 0.08);
  border-color: rgba(168, 30, 30, 0.3);
  color: var(--ink);
}
.btn.danger:hover { background: rgba(168, 30, 30, 0.15); border-color: var(--ink); color: var(--ink); }

.btn.copied {
  background: linear-gradient(180deg, #8fb976, #5a8a3e) !important;
  border-color: #4a7530 !important;
  color: #fff !important;
}

/* Actions column */
.online-actions {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 8px;
}
.online-actions > .btn { width: 100%; padding: 15px 20px; font-size: 14px; text-transform: uppercase; letter-spacing: 1.5px; }
.or-sep {
  position: relative;
  text-align: center;
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 4px;
  margin: 2px 0;
  font-weight: 700;
}
.or-sep::before, .or-sep::after {
  content: "";
  position: absolute;
  top: 50%;
  width: calc(50% - 28px);
  height: 1px;
  background: var(--rule);
}
.or-sep::before { left: 0; }
.or-sep::after { right: 0; }

.join-row { display: flex; gap: 10px; }
.join-row input {
  letter-spacing: 8px;
  font-weight: 700;
  text-align: center;
  font-family: var(--display);
  font-size: 20px;
  color: var(--ink);
}
.join-row .btn { min-width: 96px; padding: 13px 22px; }

/* ============================================================
   LOBBY
   ============================================================ */

.lobby-wrap {
  min-height: 100vh;
  padding: 36px 20px;
  display: grid;
  place-items: start center;
}
.lobby { width: 100%; max-width: 640px; padding: 36px; }
.lobby-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
}
.lobby-header h2 { font-size: 30px; margin: 0 0 4px; }
.lobby-header .muted { margin: 0; font-size: 13px; }

.share-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 14px;
  margin: 0 0 28px;
}
.share-item {
  background: linear-gradient(180deg, #fffdf7 0%, #f5ead4 100%);
  border: 1px solid var(--gold);
  border-radius: var(--r-lg);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  overflow: hidden;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.8),
    0 4px 16px rgba(184, 145, 78, 0.18);
}
.share-item::before {
  content: "";
  position: absolute; inset: 0;
  background: radial-gradient(circle at top right, rgba(184,145,78,0.10), transparent 60%);
  pointer-events: none;
}
.share-label {
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--gold-deep);
  font-weight: 700;
}
.share-value {
  font-family: 'SF Mono', ui-monospace, monospace;
  color: var(--ink);
  word-break: break-all;
  min-height: 44px;
  display: flex;
  align-items: center;
}
.share-value.code-value {
  font-family: var(--display);
  font-size: 44px;
  font-weight: 700;
  letter-spacing: 10px;
  line-height: 1;
  color: var(--ink);
  text-shadow: 0 0 20px var(--gold-glow), 0 1px 0 rgba(255,255,255,0.6);
}
.share-value.link-value {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.5;
}

/* Player list */
.player-list {
  list-style: none;
  padding: 0;
  margin: 8px 0 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.player-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: var(--r);
  font-size: 14px;
  box-shadow: 0 1px 2px rgba(74,19,19,0.04);
}
.player-list li.disconnected { opacity: 0.5; }
.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--ink-soft), var(--ink));
  color: var(--paper);
  display: inline-grid;
  place-items: center;
  font-family: var(--display);
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  flex-shrink: 0;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.3),
    0 2px 4px rgba(74,19,19,0.2);
}
.avatar.offline { background: linear-gradient(135deg, #c9bfaa, #a89685); }

.tag {
  display: inline-block;
  font-size: 9px;
  letter-spacing: 1px;
  padding: 3px 8px;
  border-radius: 10px;
  text-transform: uppercase;
  font-weight: 700;
  border: 1px solid transparent;
}
.tag.host { background: linear-gradient(180deg, var(--gold-soft), var(--gold)); color: #3a2a10; border-color: var(--gold-deep); }
.tag.you { background: var(--ink); color: var(--paper); }
.tag.muted { background: #efe9de; color: var(--text-muted); }

.btn-kick {
  margin-left: auto;
  background: transparent;
  border: 1px solid rgba(168, 30, 30, 0.4);
  color: var(--ink);
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-family: var(--body);
  font-weight: 600;
  transition: all 0.15s;
}
.btn-kick:hover { background: rgba(168, 30, 30, 0.1); border-color: var(--ink); }

/* Rule toggles */
.toggles { display: flex; flex-direction: column; gap: 8px; }
.toggle {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 13px 15px;
  border: 1.5px solid #dccfb6;
  border-radius: var(--r);
  background: #fffdf7;
  cursor: pointer;
  transition: all 0.15s;
}
.toggle:hover { border-color: var(--ink); }
.toggle input[type="checkbox"] {
  margin-top: 3px;
  width: 16px; height: 16px;
  accent-color: var(--ink);
  flex-shrink: 0;
}
.toggle:has(input:checked) {
  background: linear-gradient(180deg, #fffdf7, #f5ead4);
  border-color: var(--gold);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.6), 0 2px 8px rgba(184,145,78,0.12);
}
.toggle.readonly { opacity: 0.65; cursor: default; }
.toggle.readonly:hover { border-color: #dccfb6; }
.toggle-text strong { display: block; font-size: 14px; color: var(--ink); margin-bottom: 3px; font-weight: 700; }
.toggle-text small { display: block; font-size: 12px; color: var(--text-dim); line-height: 1.5; }

.lobby-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 24px;
}
.lobby-actions .btn { padding: 15px; font-size: 14px; text-transform: uppercase; letter-spacing: 1.5px; }

/* ============================================================
   GAME TABLE
   ============================================================ */

.game-wrap {
  min-height: 100vh;
  padding: 24px;
  background:
    radial-gradient(ellipse at center, #2d453a, #17231d 80%);
  background-attachment: fixed;
  color: #e8e2d0;
}
.game {
  max-width: 1320px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 260px 1fr;
  grid-template-rows: auto 1fr;
  grid-template-areas:
    "players table"
    "players hand";
  gap: 18px;
}

.players {
  grid-area: players;
  background: rgba(0,0,0,0.28);
  border: 1px solid rgba(184,145,78,0.15);
  border-radius: var(--r-lg);
  padding: 18px;
  backdrop-filter: blur(8px);
}
.players h3 {
  margin: 0 0 12px;
  font-family: var(--display);
  font-size: 12px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--gold-soft);
  font-weight: 700;
}
.player-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-radius: var(--r);
  margin-bottom: 6px;
  font-size: 14px;
  color: #d4cbb7;
  background: rgba(255,255,255,0.02);
  border: 1px solid transparent;
  transition: background 0.2s;
}
.player-row.active {
  background: linear-gradient(90deg, rgba(184,145,78,0.28), rgba(184,145,78,0.06));
  border-color: rgba(184,145,78,0.35);
  box-shadow: inset 0 0 20px rgba(184,145,78,0.06);
  animation: glow-pulse 2.4s ease-in-out infinite;
}
@keyframes glow-pulse {
  0%, 100% { box-shadow: inset 0 0 20px rgba(184,145,78,0.06); }
  50%      { box-shadow: inset 0 0 30px rgba(184,145,78,0.14); }
}
.player-row.you { font-weight: 700; color: #f5ead4; }
.player-row .avatar { width: 28px; height: 28px; font-size: 11px; }
.player-row .card-count {
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  font-family: var(--display);
}
.player-row.active .card-count { color: var(--gold-soft); }
.last-card-badge {
  display: inline-block;
  background: var(--ink);
  color: var(--paper);
  font-size: 9px;
  padding: 2px 6px;
  border-radius: 3px;
  letter-spacing: 1px;
  margin-left: 4px;
}

/* --- Turn time-limit selector (lobby) --- */
.time-options {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.time-btn {
  background: #fff;
  border: 1.5px solid #dccfb6;
  color: var(--text);
  padding: 8px 14px;
  border-radius: var(--r-sm);
  font-family: var(--body);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.time-btn:hover { border-color: var(--ink); color: var(--ink); }
.time-btn.active {
  background: linear-gradient(180deg, var(--gold-soft), var(--gold));
  border-color: var(--gold-deep);
  color: #3a2a10;
}
.time-btn:disabled { cursor: default; opacity: 0.65; }
.time-btn:disabled:hover { border-color: #dccfb6; color: var(--text); }

/* --- Live turn timer (game view) --- */
.turn-timer {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  padding: 3px 9px;
  margin-left: 6px;
  border-radius: 12px;
  background: rgba(184,145,78,0.2);
  color: var(--gold-soft);
  border: 1px solid rgba(184,145,78,0.35);
  font-family: var(--display);
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  transition: all 0.2s;
}
.turn-timer.critical {
  background: rgba(240,71,90,0.28);
  color: #ffb3b8;
  border-color: rgba(240,71,90,0.6);
  animation: timer-pulse 0.85s ease-in-out infinite;
}
@keyframes timer-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(240,71,90,0); }
  50%      { box-shadow: 0 0 10px 2px rgba(240,71,90,0.35); }
}
.players hr { border: 0; border-top: 1px solid rgba(255,255,255,0.08); margin: 14px 0; }
.ruleset-info { font-size: 12px; color: var(--text-muted); }
.ruleset-info strong { display: block; color: var(--gold-soft); font-size: 10px; letter-spacing: 2px; text-transform: uppercase; margin-bottom: 4px; }
.ruleset-info small {
  display: block;
  font-family: var(--display);
  font-size: 18px;
  color: #e8e2d0;
  letter-spacing: 4px;
  font-weight: 700;
}
.side-actions { display: flex; flex-direction: column; gap: 6px; margin-top: 16px; }

/* --- Game log (collapsible sidebar section) --- */
.game-log {
  margin-top: 14px;
  border-top: 1px solid rgba(255,255,255,0.08);
  padding-top: 10px;
}
.game-log-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  color: #c9bfaa;
  padding: 8px 12px;
  border-radius: var(--r-sm);
  font-family: var(--body);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.15s;
}
.game-log-toggle:hover { background: rgba(255,255,255,0.08); color: var(--gold-soft); }
.game-log-toggle .log-count {
  margin-left: auto;
  background: rgba(184,145,78,0.25);
  color: var(--gold-soft);
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 11px;
}
.game-log-toggle .chev { color: var(--gold-soft); font-size: 12px; }
.game-log-entries {
  margin-top: 8px;
  background: rgba(0,0,0,0.32);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--r-sm);
  max-height: 260px;
  overflow-y: auto;
  padding: 6px 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.log-entry {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 8px;
  padding: 6px 10px;
  font-size: 12px;
  color: #d4cbb7;
  line-height: 1.4;
  border-radius: 4px;
}
.log-entry strong { color: #f5ead4; font-weight: 700; }
.log-entry .log-icon {
  color: var(--gold-soft);
  text-align: center;
  font-weight: 700;
}
.log-entry.log-win { background: rgba(184,145,78,0.18); color: #f5ead4; }
.log-entry.log-win .log-icon { color: var(--gold); }
.log-entry.log-last-card-penalty,
.log-entry.log-timeout { background: rgba(168,30,30,0.16); color: #f6d4d4; }
.log-entry.log-last-card-penalty .log-icon,
.log-entry.log-timeout .log-icon { color: #ff9e9e; }
.log-entry.log-start .log-icon { color: #c9bfaa; }
.log-empty {
  padding: 12px;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
}

/* Scrollbar polish (webkit only; falls back to default elsewhere) */
.game-log-entries::-webkit-scrollbar { width: 6px; }
.game-log-entries::-webkit-scrollbar-thumb { background: rgba(184,145,78,0.3); border-radius: 3px; }
.game-log-entries::-webkit-scrollbar-track { background: transparent; }
.side-actions .btn {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.15);
  color: #e8e2d0;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-size: 11px;
}
.side-actions .btn:hover { background: rgba(255,255,255,0.14); border-color: rgba(184,145,78,0.5); color: var(--gold-soft); }
.side-actions .btn.danger {
  background: rgba(168,30,30,0.18);
  border-color: rgba(168,30,30,0.4);
  color: #f6d4d4;
}
.side-actions .btn.danger:hover { background: rgba(168,30,30,0.30); color: #fff; }

.table {
  grid-area: table;
  background:
    radial-gradient(ellipse at center, rgba(255,255,255,0.03), transparent 60%),
    linear-gradient(180deg, #2f4b3f, #1e2f27);
  border: 1px solid rgba(184,145,78,0.25);
  border-radius: var(--r-lg);
  padding: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 48px;
  min-height: 300px;
  flex-wrap: wrap;
  box-shadow:
    inset 0 0 60px rgba(0,0,0,0.45),
    inset 0 1px 0 rgba(255,255,255,0.05);
}
.table .label {
  font-family: var(--display);
  font-size: 10px;
  letter-spacing: 3px;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 12px;
  text-align: center;
  font-weight: 700;
}
.top-card-wrap, .market { display: flex; flex-direction: column; align-items: center; }
.market .card-back {
  width: var(--card-w);
  height: var(--card-h);
  background:
    repeating-linear-gradient(135deg, rgba(255,255,255,0.04) 0 4px, transparent 4px 10px),
    linear-gradient(180deg, #6b1f1f, #4a1414);
  border-radius: var(--r);
  border: 1px solid #3a0f0f;
  cursor: pointer;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.08),
    0 6px 20px rgba(0,0,0,0.5);
  transition: transform 0.15s, box-shadow 0.15s;
  position: relative;
}
.market .card-back::after {
  content: "Whot";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--display);
  font-style: italic;
  font-weight: 700;
  font-size: 32px;
  color: rgba(252, 241, 207, 0.85);
  text-shadow: 0 2px 8px rgba(0,0,0,0.5);
}
.market .card-back:hover { transform: translateY(-4px); box-shadow: inset 0 1px 0 rgba(255,255,255,0.08), 0 10px 28px rgba(0,0,0,0.6); }
.market .card-back.disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.active-shape-pill {
  margin-top: 14px;
  background: linear-gradient(180deg, rgba(184,145,78,0.22), rgba(184,145,78,0.08));
  color: var(--gold-soft);
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 12px;
  text-transform: capitalize;
  letter-spacing: 0.5px;
  border: 1px solid rgba(184,145,78,0.3);
}
.active-shape-pill strong { color: #fff; font-weight: 700; }
.pending {
  flex-basis: 100%;
  text-align: center;
  padding: 12px 16px;
  background: rgba(168,30,30,0.22);
  color: #f6d4d4;
  border: 1px solid rgba(168,30,30,0.4);
  border-radius: var(--r);
  font-size: 14px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.05);
}

.hand-area {
  grid-area: hand;
  background: rgba(0,0,0,0.22);
  border: 1px solid rgba(184,145,78,0.15);
  border-radius: var(--r-lg);
  padding: 18px;
  backdrop-filter: blur(8px);
}
.hand-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}
.hand-header h3 {
  margin: 0;
  font-family: var(--display);
  font-weight: 700;
  font-style: italic;
  color: var(--gold-soft);
  font-size: 22px;
  letter-spacing: 0.5px;
}
.hand { display: flex; flex-wrap: wrap; gap: 10px; }
.hand-slot .card-wrap { cursor: pointer; transition: transform 0.15s, filter 0.15s; animation: card-in 0.25s ease backwards; }
.hand-slot:nth-child(1) .card-wrap { animation-delay: 0.03s; }
.hand-slot:nth-child(2) .card-wrap { animation-delay: 0.06s; }
.hand-slot:nth-child(3) .card-wrap { animation-delay: 0.09s; }
.hand-slot:nth-child(4) .card-wrap { animation-delay: 0.12s; }
.hand-slot:nth-child(5) .card-wrap { animation-delay: 0.15s; }
.hand-slot:nth-child(6) .card-wrap { animation-delay: 0.18s; }
@keyframes card-in {
  from { opacity: 0; transform: translateY(10px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.hand-slot .card-wrap.playable:hover { transform: translateY(-10px); }
.hand-slot .card-wrap.unplayable { opacity: 0.38; cursor: not-allowed; filter: grayscale(0.45); }
.hand-controls { margin-top: 14px; }

.whot-picker {
  margin-top: 18px;
  padding: 16px;
  background: linear-gradient(180deg, rgba(184,145,78,0.15), rgba(184,145,78,0.05));
  border: 1px solid rgba(184,145,78,0.3);
  border-radius: var(--r);
  animation: appear 0.3s ease-out;
}
.whot-picker .label { color: var(--gold-soft); margin-bottom: 10px; }
.shape-choices { display: flex; gap: 8px; flex-wrap: wrap; }
.shape-btn {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.2);
  color: #e8e2d0;
  padding: 12px 16px;
  border-radius: var(--r-sm);
  font-size: 12px;
  text-transform: capitalize;
  cursor: pointer;
  font-family: var(--body);
  font-weight: 600;
  transition: all 0.15s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 78px;
}
.shape-btn:hover {
  background: linear-gradient(180deg, var(--gold-soft), var(--gold));
  border-color: var(--gold-deep);
  color: #3a2a10;
  transform: translateY(-1px);
}
.shape-btn-icon {
  width: 32px;
  height: 32px;
  display: block;
}
.shape-btn-icon .shape-svg {
  width: 100%;
  height: 100%;
  fill: currentColor;
  display: block;
}
.shape-btn-label { display: block; }

/* --- Last Card prompt (visible whenever hand is down to 1) --- */
.last-card-prompt {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
  margin-bottom: 14px;
  background: linear-gradient(135deg, rgba(184,145,78,0.22), rgba(107,31,31,0.12));
  border: 1px solid var(--gold);
  border-radius: var(--r);
  color: #fdf0d7;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08), 0 4px 18px rgba(184,145,78,0.15);
  animation: glow-pulse 2.4s ease-in-out infinite;
}
.last-card-prompt strong {
  display: block;
  font-family: var(--display);
  font-size: 16px;
  color: var(--gold-soft);
  font-weight: 700;
}
.last-card-prompt small {
  display: block;
  font-size: 12px;
  color: #e8dcbf;
  margin-top: 2px;
  line-height: 1.4;
}
.last-card-prompt.called {
  justify-content: center;
  animation: none;
  font-family: var(--display);
  font-style: italic;
  font-size: 14px;
  color: var(--gold-soft);
}
.last-card-prompt.warning {
  background: linear-gradient(135deg, rgba(168,30,30,0.22), rgba(74,19,19,0.14));
  border-color: rgba(168,30,30,0.55);
  color: #f6d4d4;
  animation: none;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}
.last-card-prompt.warning strong {
  color: #f6d4d4;
  font-family: var(--display);
  font-size: 15px;
}

.final-hands { list-style: none; padding: 0; text-align: left; max-width: 300px; margin: 16px auto 24px; }
.final-hands li { padding: 8px 0; border-bottom: 1px solid var(--rule); }

/* Winner banner */
.winner-banner {
  text-align: center;
  padding: 36px 28px 28px;
  background: linear-gradient(135deg, rgba(184,145,78,0.15), rgba(107,31,31,0.05));
  border: 1px solid var(--gold);
  border-radius: var(--r-lg);
  margin-bottom: 14px;
  box-shadow: 0 8px 40px var(--gold-glow), inset 0 1px 0 rgba(255,255,255,0.3);
}
.winner-text {
  font-family: var(--display);
  font-style: italic;
  font-size: 44px;
  font-weight: 800;
  margin: 0 0 10px;
  background: linear-gradient(90deg,
    var(--ink) 0%, var(--gold) 25%, var(--ink) 50%,
    var(--gold) 75%, var(--ink) 100%);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: shimmer 3s linear infinite;
}

/* ============================================================
   RESILIENCE UI
   ============================================================ */

.mute-toggle {
  position: fixed;
  top: 16px;
  right: 72px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--rule);
  background: #fff;
  cursor: pointer;
  font-size: 16px;
  z-index: 51;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  display: grid;
  place-items: center;
  padding: 0;
  transition: transform 0.15s;
}
.mute-toggle:hover { transform: scale(1.08); }
.mute-toggle.muted { opacity: 0.6; }

.conn-badge {
  position: fixed;
  top: 16px;
  right: 16px;
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  z-index: 50;
  background: #fff;
  border: 1px solid var(--rule);
  color: var(--ink);
  box-shadow: 0 4px 14px rgba(0,0,0,0.10);
  font-family: var(--body);
}
.conn-badge.reconnecting {
  background: linear-gradient(180deg, #fef6dd, #fce9b6);
  border-color: #d9b653;
  color: #7a5a15;
  animation: glow-pulse 1.6s ease-in-out infinite;
}
.conn-badge.disconnected {
  background: linear-gradient(180deg, #fcecec, #f6c9c9);
  border-color: #c27272;
  color: var(--ink);
}

.toast-container {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  pointer-events: none;
  width: 400px;
  max-width: 90vw;
}
.toast {
  position: absolute;
  left: 0; right: 0;
  padding: 13px 20px;
  background: linear-gradient(180deg, var(--ink-soft), var(--ink));
  color: var(--paper);
  border-radius: var(--r);
  font-size: 14px;
  text-align: center;
  box-shadow: 0 12px 36px rgba(74, 19, 19, 0.4), inset 0 1px 0 rgba(255,255,255,0.2);
  animation: toast-in 0.25s ease-out;
  font-weight: 500;
}
@keyframes toast-in {
  from { transform: translateY(-14px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

/* ============================================================
   RULES OVERLAY
   ============================================================ */

.rules-overlay {
  position: fixed;
  inset: 0;
  background: rgba(34, 20, 14, 0.55);
  backdrop-filter: blur(3px);
  z-index: 200;
  display: grid;
  place-items: start center;
  padding: 32px 20px;
  overflow-y: auto;
  animation: appear 0.2s ease-out;
}
.rules-sheet {
  width: 100%;
  max-width: 620px;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--r-lg);
  padding: 28px 32px 36px;
  box-shadow:
    0 1px 0 rgba(255,255,255,0.9) inset,
    0 20px 60px rgba(74,19,19,0.3);
  position: relative;
  animation: appear 0.25s ease-out;
}
.rules-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 12px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--rule);
}
.rules-header h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 28px;
  color: var(--ink);
  font-weight: 700;
}
.rules-header em {
  font-family: var(--display);
  font-style: italic;
  font-weight: 800;
}
.rules-section {
  margin: 20px 0 0;
}
.rules-section h3 {
  font-family: var(--display);
  font-weight: 700;
  color: var(--ink);
  font-size: 18px;
  margin: 0 0 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.rules-section p {
  margin: 0 0 10px;
  line-height: 1.6;
  color: var(--text);
}
.rules-section p.muted { color: var(--text-dim); font-size: 13px; }
.rules-section p.example {
  background: linear-gradient(180deg, #fffdf7, #f5ead4);
  border-left: 3px solid var(--gold);
  padding: 10px 14px;
  border-radius: var(--r-sm);
  font-size: 14px;
  color: var(--text);
}
.rules-section ol { margin: 8px 0 10px; padding-left: 22px; line-height: 1.7; }
.rules-section ol li { margin-bottom: 2px; }

.shape-list {
  list-style: none;
  padding: 0;
  margin: 6px 0 0;
  display: grid;
  gap: 6px;
}
.shape-list li {
  display: flex;
  justify-content: space-between;
  padding: 8px 12px;
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: var(--r-sm);
  font-size: 13px;
}
.shape-list li span:first-child { font-weight: 700; color: var(--ink); }
.shape-list li span:last-child  { color: var(--text-dim); font-family: 'SF Mono', ui-monospace, monospace; font-size: 12px; }

.command-list {
  list-style: none;
  padding: 0;
  margin: 6px 0 0;
  display: grid;
  gap: 6px;
}
.command-list li {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 12px;
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: var(--r-sm);
  font-size: 14px;
  line-height: 1.5;
}
.command-list .cmd-num {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(180deg, var(--ink-soft), var(--ink));
  color: var(--paper);
  font-family: var(--display);
  font-weight: 800;
  font-size: 16px;
  flex-shrink: 0;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.3), 0 2px 4px rgba(74,19,19,0.25);
}

.penalty-modes {
  list-style: none;
  padding: 0;
  margin: 8px 0 0;
  display: grid;
  gap: 8px;
}
.penalty-modes li {
  padding: 10px 14px;
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: var(--r-sm);
  font-size: 14px;
  opacity: 0.6;
}
.penalty-modes li.active {
  opacity: 1;
  border-color: var(--gold);
  background: linear-gradient(180deg, #fffdf7, #f5ead4);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.6);
}
.penalty-modes li strong { color: var(--ink); }
.penalty-modes .example {
  margin-top: 6px;
  padding: 6px 10px;
  background: rgba(184,145,78,0.12);
  border-left: 2px solid var(--gold);
  border-radius: 4px;
  font-size: 13px;
  color: var(--text-dim);
}

.rule-flag {
  font-family: var(--body);
  font-style: normal;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 10px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.rule-flag.on  { background: rgba(184,145,78,0.18); color: var(--gold-deep); border-color: rgba(184,145,78,0.4); }
.rule-flag.off { background: #efe9de; color: var(--text-muted); }

@media (max-width: 640px) {
  .rules-sheet { padding: 22px 20px 28px; }
  .rules-header h2 { font-size: 22px; }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 820px) {
  .game { grid-template-columns: 1fr; grid-template-areas: "players" "table" "hand"; }
  .hero-decor { display: none; }
}
@media (max-width: 640px) {
  :root { --card-w: 112px; --card-h: 162px; }
  .share-grid { grid-template-columns: 1fr; }
  .brand { font-size: 72px; }
  .panel { padding: 24px; }
  .lobby { padding: 24px; }
  .share-value.code-value { font-size: 34px; letter-spacing: 6px; }
}

/* ============================================================
   CARD (shared visual language)
   ============================================================ */

.card {
  width: var(--card-w);
  height: var(--card-h);
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--r);
  position: relative;
  overflow: hidden;
  color: var(--ink);
  background-image:
    radial-gradient(rgba(0,0,0,0.025) 1px, transparent 1px),
    radial-gradient(rgba(0,0,0,0.02) 1px, transparent 1px);
  background-size: 3px 3px, 5px 5px;
  background-position: 0 0, 1px 2px;
  box-shadow:
    0 1px 2px rgba(0,0,0,0.06),
    0 6px 14px rgba(0,0,0,0.12),
    inset 0 1px 0 rgba(255,255,255,0.5);
}
.corner {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  line-height: 1;
  z-index: 2;
  color: var(--ink);
}
.corner-tl { top: 10px; left: 12px; }
.corner-br { bottom: 10px; right: 12px; transform: rotate(180deg); }
.corner-num {
  font-size: 28px;
  font-family: 'Helvetica Neue', Arial, sans-serif;
  font-weight: 900;
  letter-spacing: -1px;
}
.corner-shape { display: inline-block; width: 14px; height: 14px; margin-left: 2px; }
.corner-shape .shape-svg { width: 100%; height: 100%; fill: var(--ink); stroke: none; display: block; }
.corner-w {
  font-family: var(--display);
  font-style: italic;
  font-weight: 700;
  font-size: 15px;
  margin-left: 4px;
}
.corner-star-wrap { position: relative; width: 20px; height: 20px; margin-left: 2px; }
.corner-star-wrap .shape-svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.corner-star-num {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 8px; font-weight: 800; color: var(--card-bg); line-height: 1;
}

.card-center { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.card-center .shape-svg { width: 128px; height: 128px; fill: var(--ink); stroke: none; }

.whot-wordmark-stack { display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 0.82; gap: 0; }
.whot-wordmark { font-family: var(--display); font-style: italic; font-weight: 700; font-size: 42px; color: var(--ink); line-height: 1; }
.whot-wordmark.whot-flipped { transform: rotate(180deg); }
