/* ==========================================================================
   GAPLE ARENA — DESIGN SYSTEM & REDESIGN VISUAL
   Identitas: Gaple Tradisional Nusantara Modern (Meja Felt Hijau, Kayu Jati/Mahoni,
   Batu Domino Gading dengan Titik 1 & 6 Merah).
   --------------------------------------------------------------------------
   SISTEM DESAIN (:root):
   - Palet Warna (WCAG AA): Obsidian Slate gelap utama + Tema Terang via
     prefers-color-scheme / [data-theme="light"].
   - Tipografi: Bricolage Grotesque (Display/Angka) + Plus Jakarta Sans (UI),
     dengan tabular-nums untuk timer, poin, dan angka ujung papan.
   - Skala Spacing: kelipatan 4px / 8px (--sp-1 .. --sp-8).
   - Radius: --r-sm (6px), --r-md (10px), --r-lg (16px), --r-xl (22px).
   - Elevasi: bayangan berlapis lembut untuk kedalaman meja & kartu.
   - Animasi: cepat 150ms–350ms, menghormati @media (prefers-reduced-motion).
   ========================================================================== */

:root {
  /* === Skala Spacing (4/8 px) === */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;

  /* === Radius === */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;
  --r-xl: 24px;
  --r-pill: 999px;

  /* === Durasi & Easing === */
  --dur-fast: 150ms;
  --dur-med: 250ms;
  --dur-slow: 350ms;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);

  /* === Tipografi === */
  --font-display: 'Bricolage Grotesque', system-ui, -apple-system, sans-serif;
  --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;

  /* === Palet Tema Gelap (Utama) === */
  --bg-canvas: #0b0f15;
  --bg-nav: rgba(13, 17, 24, 0.92);
  --bg-surface: #141923;
  --bg-card: #1b2230;
  --bg-elevated: #232c3d;
  --bg-input: #10151e;

  /* Bingkai Kayu Jati / Mahoni Hangat */
  --wood-outer: #1e1108;
  --wood-rim: #3e2312;
  --wood-inner: #57331c;
  --wood-brass: #b9933c;

  /* Karpet Meja Felt Hijau Nusantara */
  --felt-center: #1e5735;
  --felt-mid: #164428;
  --felt-edge: #0d2b18;

  /* Batu Domino Gading Realistis */
  --domino-top: #fdfbf6;
  --domino-mid: #f3ede0;
  --domino-bot: #e4dac6;
  --domino-border: #c5baa4;
  --domino-thick: #9e937d;
  --pip-black: #18181b;
  --pip-red: #c92a2a;
  --rivet-brass: #b9933c;

  /* Aksen Hangat & Kontras Tinggi (Bebas Neon) */
  --amber-gold: #dca842;
  --accent-gold: #dca842;
  --amber-soft: rgba(220, 168, 66, 0.16);
  --amber-border: rgba(220, 168, 66, 0.45);
  --jade-cta: #287d52;
  --jade-hover: #319462;
  --jade-soft: rgba(40, 125, 82, 0.18);
  --teal-accent: #4aa3ad;
  --teal-soft: rgba(74, 163, 173, 0.16);
  --blue-cta: #2f6db8;
  --blue-hover: #3b7ed0;
  --coral-red: #c94646;

  /* Teks & Garis */
  --text-main: #f3f5f8;
  --text-body: #cfd6e2;
  --text-muted: #98a2b3;
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-card: rgba(255, 255, 255, 0.14);
  --seat-bg: rgba(16, 21, 30, 0.88);
  --seat-active-bg: rgba(34, 28, 16, 0.94);
  --hud-pill-bg: rgba(16, 21, 30, 0.88);

  /* Elevasi / Bayangan */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 10px 28px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.72);
}

/* === Tema Terang Opsional === */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg-canvas: #ece8df;
    --bg-nav: rgba(250, 248, 243, 0.94);
    --bg-surface: #fbf9f4;
    --bg-card: #f1ede4;
    --bg-elevated: #e7e1d4;
    --bg-input: #ffffff;
    --text-main: #181c24;
    --text-body: #343b48;
    --text-muted: #5a6375;
    --border-subtle: rgba(24, 28, 36, 0.1);
    --border-card: rgba(24, 28, 36, 0.16);
    --seat-bg: rgba(251, 249, 244, 0.92);
    --seat-active-bg: rgba(253, 243, 220, 0.96);
    --hud-pill-bg: rgba(251, 249, 244, 0.92);
    --shadow-md: 0 10px 28px rgba(30, 25, 18, 0.14);
    --shadow-lg: 0 24px 60px rgba(30, 25, 18, 0.22);
  }
}

:root[data-theme="light"] {
  --bg-canvas: #ece8df;
  --bg-nav: rgba(250, 248, 243, 0.94);
  --bg-surface: #fbf9f4;
  --bg-card: #f1ede4;
  --bg-elevated: #e7e1d4;
  --bg-input: #ffffff;
  --text-main: #181c24;
  --text-body: #343b48;
  --text-muted: #5a6375;
  --border-subtle: rgba(24, 28, 36, 0.1);
  --border-card: rgba(24, 28, 36, 0.16);
  --seat-bg: rgba(251, 249, 244, 0.92);
  --seat-active-bg: rgba(253, 243, 220, 0.96);
  --hud-pill-bg: rgba(251, 249, 244, 0.92);
  --shadow-md: 0 10px 28px rgba(30, 25, 18, 0.14);
  --shadow-lg: 0 24px 60px rgba(30, 25, 18, 0.22);
}

/* ================= RESET & DASAR ================= */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-canvas);
  background-image: radial-gradient(ellipse at 50% 0%, rgba(220, 168, 66, 0.06) 0%, transparent 60%);
  color: var(--text-main);
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input, select {
  font-family: inherit;
}

.hidden {
  display: none !important;
}

.hidden-compat {
  display: none !important;
}

/* Fokus Keyboard Aksesibel */
:focus-visible {
  outline: 2px solid var(--amber-gold);
  outline-offset: 2px;
}

/* ================= 1. HEADER / NAVIGASI ATAS ================= */
.top-nav-bar {
  height: 56px;
  background: var(--bg-nav);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--sp-5);
  gap: var(--sp-3);
  z-index: 100;
  flex-shrink: 0;
}

.nav-left, .nav-center, .nav-right {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.app-logo {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--text-main);
  user-select: none;
}

.logo-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.35));
}

.logo-text strong {
  color: var(--amber-gold);
  font-weight: 800;
  margin-left: 2px;
}

.nav-divider {
  width: 1px;
  height: 20px;
  background: var(--border-subtle);
  margin: 0 var(--sp-1);
}

.nav-badge {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.nav-badge .badge-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.nav-badge strong {
  font-family: var(--font-display);
  color: var(--teal-accent);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.room-badge strong {
  color: var(--amber-gold);
  letter-spacing: 0.08em;
}

.turn-indicator-pill {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--r-pill);
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-body);
  transition: all var(--dur-med) var(--ease-out);
}

.turn-indicator-pill strong {
  color: var(--text-main);
  font-weight: 700;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.turn-indicator-pill.active-turn {
  background: var(--amber-soft);
  border-color: var(--amber-gold);
  box-shadow: 0 0 0 1px var(--amber-border);
}

.turn-indicator-pill.active-turn strong {
  color: var(--amber-gold);
}

.timer-pill {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--r-pill);
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 700;
  min-width: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: all var(--dur-fast) var(--ease-out);
}

.timer-pill strong {
  font-family: var(--font-display);
  font-variant-numeric: tabular-nums;
  font-size: 14px;
  color: var(--teal-accent);
}

.timer-unit {
  font-size: 11px;
  color: var(--text-muted);
}

.timer-pill.urgent {
  background: rgba(201, 70, 70, 0.16);
  border-color: var(--coral-red);
  animation: timerPulse 0.8s ease-in-out infinite;
}

.timer-pill.urgent strong {
  color: #f07171;
}

@keyframes timerPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); }
}

.badge-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  padding: 6px 11px;
  border-radius: var(--r-md);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  max-width: 210px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #e05252;
  flex-shrink: 0;
  transition: background var(--dur-med) ease;
}

.status-dot.connected {
  background: #3fb978;
  box-shadow: 0 0 0 3px rgba(63, 185, 120, 0.22);
}

.status-dot.connecting {
  background: var(--amber-gold);
  animation: pulseDot 1s ease-in-out infinite;
}

@keyframes pulseDot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.nav-btn {
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-card);
  border-radius: var(--r-md);
  padding: 7px 12px;
  min-height: 36px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background var(--dur-fast) ease, border-color var(--dur-fast) ease, transform var(--dur-fast) ease;
}

.nav-btn:hover {
  background: var(--bg-elevated);
  border-color: var(--amber-border);
  transform: translateY(-1px);
}

.nav-btn:active {
  transform: translateY(0);
}

.btn-theme {
  padding: 7px 10px;
}

.unread-pill {
  background: var(--coral-red);
  color: #fff;
  border-radius: var(--r-pill);
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

/* ================= 2. ARENA CONTAINER & MEJA KAYU-FELT ================= */
.arena-container {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-3) var(--sp-5) var(--sp-4);
  overflow: hidden;
  position: relative;
}

.game-table {
  width: 100%;
  height: 100%;
  max-width: 1440px;
  background: radial-gradient(ellipse at 50% 45%, var(--felt-center) 0%, var(--felt-mid) 58%, var(--felt-edge) 100%);
  border: 14px solid var(--wood-rim);
  outline: 3px solid var(--wood-outer);
  border-radius: 34px;
  box-shadow:
    0 24px 60px rgba(0, 0, 0, 0.65),
    inset 0 0 0 2px rgba(185, 147, 60, 0.28),
    inset 0 0 60px rgba(0, 0, 0, 0.62);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.table-felt-pattern {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    radial-gradient(rgba(0, 0, 0, 0.08) 1px, transparent 1px);
  background-size: 14px 14px, 7px 7px;
  background-position: 0 0, 3px 3px;
  z-index: 0;
}

.table-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at 50% 50%, transparent 45%, rgba(0, 0, 0, 0.35) 100%);
  z-index: 0;
}

.table-watermark {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--font-display);
  font-size: clamp(2.6rem, 6.5vw, 5.5rem);
  font-weight: 800;
  letter-spacing: 0.22em;
  color: rgba(255, 255, 255, 0.04);
  user-select: none;
  pointer-events: none;
  white-space: nowrap;
  z-index: 1;
}

/* ================= 3. LOBBY & RUANG TUNGGU ================= */
.lobby-overlay {
  position: absolute;
  inset: 0;
  background: rgba(9, 12, 18, 0.78);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow-y: auto;
  z-index: 50;
  padding: var(--sp-5);
  animation: fadeIn var(--dur-med) var(--ease-out);
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.lobby-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-card);
  border-radius: var(--r-xl);
  padding: var(--sp-6) var(--sp-8);
  margin: auto;
  width: 100%;
  max-width: 660px;
  box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
  text-align: center;
}

/* Komposisi Batu Domino Hero (CSS murni) */
.hero-domino-fan {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  height: 66px;
  margin-bottom: var(--sp-2);
  position: relative;
}

.hero-tile {
  width: 34px;
  height: 62px;
  background: linear-gradient(155deg, var(--domino-top), var(--domino-mid) 65%, var(--domino-bot));
  border: 1px solid var(--domino-border);
  border-radius: 6px;
  box-shadow: 0 4px 0 var(--domino-thick), 0 8px 18px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2px;
}

.hero-tile-left {
  transform: rotate(-14deg) translateX(6px) translateY(4px);
  opacity: 0.9;
}

.hero-tile-center {
  z-index: 2;
  transform: translateY(-2px);
  border-color: var(--amber-gold);
}

.hero-tile-right {
  transform: rotate(14deg) translateX(-6px) translateY(4px);
  opacity: 0.9;
}

.ht-div {
  width: 24px;
  height: 1.5px;
  background: #8c7e6a;
  margin: 1px 0;
  flex-shrink: 0;
}

.ht-half {
  flex: 1;
  width: 100%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  place-items: center;
  padding: 2px;
}

.ht-half i {
  display: block;
  width: 4.5px;
  height: 4.5px;
  border-radius: 50%;
  background: var(--pip-black);
}

.ht-half i.r { background: var(--pip-red); }
.ht-half i.big { width: 7px; height: 7px; grid-column: 2; grid-row: 2; }
.ht-6 i:nth-child(1) { grid-column: 1; grid-row: 1; }
.ht-6 i:nth-child(2) { grid-column: 1; grid-row: 2; }
.ht-6 i:nth-child(3) { grid-column: 1; grid-row: 3; }
.ht-6 i:nth-child(4) { grid-column: 3; grid-row: 1; }
.ht-6 i:nth-child(5) { grid-column: 3; grid-row: 2; }
.ht-6 i:nth-child(6) { grid-column: 3; grid-row: 3; }
.ht-4 i:nth-child(1) { grid-column: 1; grid-row: 1; }
.ht-4 i:nth-child(2) { grid-column: 3; grid-row: 1; }
.ht-4 i:nth-child(3) { grid-column: 1; grid-row: 3; }
.ht-4 i:nth-child(4) { grid-column: 3; grid-row: 3; }

.hero-kicker {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: var(--amber-gold);
  margin-bottom: 4px;
}

.lobby-hero h2 {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.02em;
}

.lobby-hero .subtitle {
  font-size: 13.5px;
  color: var(--text-muted);
  margin-top: 6px;
  line-height: 1.5;
}

.conn-grid {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  text-align: left;
}

.input-row-single {
  display: grid;
  grid-template-columns: 1fr;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.input-group label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-body);
}

.input-group input {
  padding: 12px 14px;
  min-height: 44px;
  background: var(--bg-input);
  border: 1px solid var(--border-card);
  border-radius: var(--r-md);
  color: var(--text-main);
  font-size: 14px;
  transition: border-color var(--dur-fast) ease, box-shadow var(--dur-fast) ease;
}

.input-group input:focus {
  outline: none;
  border-color: var(--amber-gold);
  box-shadow: 0 0 0 3px var(--amber-soft);
}

.lobby-action-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-3);
}

.action-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-lg);
  padding: var(--sp-4);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: var(--sp-3);
  transition: border-color var(--dur-fast) ease, transform var(--dur-fast) ease, box-shadow var(--dur-fast) ease;
}

.action-card:hover {
  border-color: var(--border-card);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.card-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  margin-bottom: 6px;
}

.tag-host {
  background: var(--amber-soft);
  color: var(--amber-gold);
  border: 1px solid var(--amber-border);
}

.tag-join {
  background: var(--jade-soft);
  color: #52c488;
  border: 1px solid rgba(40, 125, 82, 0.4);
}

.action-card-info h4 {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 4px;
}

.action-card-info p {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.45;
}

.btn-cta {
  padding: 11px 16px;
  min-height: 44px;
  border-radius: var(--r-md);
  font-weight: 700;
  font-size: 13.5px;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background var(--dur-fast) ease, transform var(--dur-fast) ease, opacity var(--dur-fast) ease;
}

.btn-cta:disabled {
  opacity: 0.65;
  cursor: wait;
}

.btn-cta:active:not(:disabled) {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--blue-cta);
  color: #fff;
}
.btn-primary:hover:not(:disabled) {
  background: var(--blue-hover);
}

.btn-green {
  background: var(--jade-cta);
  color: #fff;
}
.btn-green:hover:not(:disabled) {
  background: var(--jade-hover);
}

.btn-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.join-input-wrap {
  display: flex;
  gap: var(--sp-2);
}

.join-input-wrap input {
  width: 96px;
  min-height: 44px;
  padding: 10px;
  background: var(--bg-input);
  border: 1px solid var(--border-card);
  border-radius: var(--r-md);
  color: var(--text-main);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 15px;
  text-align: center;
  letter-spacing: 0.14em;
}

.join-input-wrap .btn-cta {
  flex: 1;
}

.spectate-row {
  text-align: center;
}

.btn-spectator {
  background: transparent;
  color: var(--text-muted);
  border: 1px dashed var(--border-card);
  padding: 10px 18px;
  min-height: 44px;
  border-radius: var(--r-md);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--dur-fast) ease;
}

.btn-spectator:hover {
  color: var(--text-main);
  border-color: var(--amber-gold);
  background: var(--bg-card);
}

/* Ruang Tunggu */
.room-wait-box {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  text-align: left;
  animation: fadeIn var(--dur-med) var(--ease-out);
}

.room-code-banner {
  background: var(--bg-card);
  border: 1px solid var(--amber-border);
  border-radius: var(--r-lg);
  padding: var(--sp-3) var(--sp-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
}

.code-title {
  font-size: 11px;
  font-weight: 800;
  color: var(--amber-gold);
  letter-spacing: 0.08em;
}

.code-sub {
  font-size: 12px;
  color: var(--text-muted);
  display: block;
  margin-top: 2px;
}

.room-code-display {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.room-code-highlight {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 0.16em;
  color: var(--amber-gold);
  font-variant-numeric: tabular-nums;
}

.btn-copy {
  background: var(--bg-elevated);
  color: var(--text-main);
  border: 1px solid var(--border-card);
  padding: 8px 14px;
  min-height: 40px;
  border-radius: var(--r-md);
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--dur-fast) ease;
}

.btn-copy:hover {
  border-color: var(--amber-gold);
}

.btn-copy.copied {
  background: var(--jade-cta);
  color: #fff;
  border-color: var(--jade-cta);
}

.players-roster {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.roster-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.roster-header h4 {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-body);
}

.roster-tip {
  font-size: 11.5px;
  color: var(--text-muted);
}

.player-roster-list {
  list-style: none;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  padding: var(--sp-2) var(--sp-3);
  max-height: 170px;
  overflow-y: auto;
}

.player-roster-list li {
  padding: 9px 6px;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 13.5px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  animation: listSlideIn var(--dur-fast) var(--ease-out);
}

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

.player-roster-list li:last-child {
  border-bottom: none;
}

.lobby-controls {
  display: flex;
  gap: var(--sp-3);
  justify-content: center;
}

.btn-ready {
  background: var(--blue-cta);
  color: #fff;
  padding: 12px 28px;
}
.btn-ready:hover {
  background: var(--blue-hover);
}

.btn-start {
  padding: 12px 28px;
}

.lobby-footer-tips {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-2);
  text-align: left;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
  border-top: 1px solid var(--border-subtle);
  padding-top: var(--sp-3);
}

/* ================= 4. ARENA GRID & KURSI PEMAIN ================= */
.table-grid-layout {
  display: grid;
  grid-template-columns: 205px 1fr 205px;
  grid-template-rows: 92px 1fr 180px;
  width: 100%;
  height: 100%;
  position: relative;
  z-index: 2;
  padding: var(--sp-2) var(--sp-4);
}

.player-seat {
  background: var(--seat-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border-card);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-md);
  transition: border-color var(--dur-med) ease, box-shadow var(--dur-med) ease, background var(--dur-med) ease;
  display: flex;
  z-index: 10;
}

.seat-turn-active {
  border: 1.5px solid var(--amber-gold) !important;
  background: var(--seat-active-bg) !important;
  box-shadow: 0 0 0 3px var(--amber-soft), var(--shadow-md) !important;
}

/* Ring Timer Melingkar di Sekitar Avatar Pemain Aktif */
.avatar-ring {
  padding: 3px;
  border-radius: 50%;
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background var(--dur-fast) linear;
}

.seat-turn-active .avatar-ring {
  background: conic-gradient(var(--amber-gold) var(--turn-progress, 100%), rgba(255, 255, 255, 0.12) 0);
}

.seat-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--bg-elevated), var(--bg-card));
  border: 1.5px solid var(--border-card);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 13px;
  color: var(--text-main);
}

.my-avatar {
  background: linear-gradient(145deg, var(--blue-cta), #1c4478);
  border-color: rgba(130, 180, 245, 0.6);
}

.seat-meta {
  min-width: 0;
}

.seat-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}

.seat-status {
  font-size: 11.5px;
  color: var(--text-muted);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.seat-top {
  grid-column: 2 / 3;
  grid-row: 1;
  align-self: start;
  justify-self: center;
  padding: 8px 16px;
  flex-direction: row;
  align-items: center;
  gap: 14px;
}

.seat-top .seat-profile {
  display: flex;
  align-items: center;
  gap: 10px;
}

.seat-left {
  grid-column: 1 / 2;
  grid-row: 2;
  align-self: center;
  justify-self: start;
  padding: 12px;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 190px;
}

.seat-right {
  grid-column: 3 / 4;
  grid-row: 2;
  align-self: center;
  justify-self: end;
  padding: 12px;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 190px;
}

.seat-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}

/* ================= 5. PUNGGUNG KARTU LAWAN ================= */
.seat-hand-cards {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
}

.cards-horizontal { flex-direction: row; }
.cards-vertical { flex-direction: column; }

.domino-back {
  box-sizing: border-box;
  flex-shrink: 0;
  border-radius: 4px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.45);
  background-size: 100% 100%;
  background-repeat: no-repeat;
  background-position: center;
  transition: transform var(--dur-fast) ease;
  user-select: none;
}

.cards-horizontal .domino-back,
.domino-back-horizontal {
  width: 34px;
  height: 60px;
  margin-left: -13px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='76' viewBox='0 0 40 76'%3E%3Cdefs%3E%3CradialGradient id='rg' cx='50%25' cy='50%25' r='65%25'%3E%3Cstop offset='0%25' stop-color='%239b1d22'/%3E%3Cstop offset='100%25' stop-color='%234a080b'/%3E%3C/radialGradient%3E%3C/defs%3E%3Crect x='0.5' y='0.5' width='39' height='75' rx='4' fill='%23f7f3ea' stroke='%23c5baa4'/%3E%3Crect x='2.5' y='2.5' width='35' height='71' rx='3' fill='url(%23rg)'/%3E%3Crect x='5' y='5' width='30' height='66' rx='2' fill='none' stroke='%23dca842' stroke-width='0.7' stroke-opacity='0.65'/%3E%3Cpolygon points='20,25 30,38 20,51 10,38' fill='%235c0a0e' stroke='%23dca842' stroke-width='0.9'/%3E%3Ccircle cx='20' cy='38' r='2.2' fill='%23dca842'/%3E%3C/svg%3E");
}
.cards-horizontal .domino-back:first-child,
.domino-back-horizontal:first-child { margin-left: 0; }

.cards-vertical .domino-back,
.domino-back-vertical {
  width: 60px;
  height: 32px;
  margin-top: -15px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='76' height='40' viewBox='0 0 76 40'%3E%3Cdefs%3E%3CradialGradient id='rgH' cx='50%25' cy='50%25' r='65%25'%3E%3Cstop offset='0%25' stop-color='%239b1d22'/%3E%3Cstop offset='100%25' stop-color='%234a080b'/%3E%3C/radialGradient%3E%3C/defs%3E%3Crect x='0.5' y='0.5' width='75' height='39' rx='4' fill='%23f7f3ea' stroke='%23c5baa4'/%3E%3Crect x='2.5' y='2.5' width='71' height='35' rx='3' fill='url(%23rgH)'/%3E%3Crect x='5' y='5' width='66' height='30' rx='2' fill='none' stroke='%23dca842' stroke-width='0.7' stroke-opacity='0.65'/%3E%3Cpolygon points='38,10 51,20 38,30 25,20' fill='%235c0a0e' stroke='%23dca842' stroke-width='0.9'/%3E%3Ccircle cx='38' cy='20' r='2.2' fill='%23dca842'/%3E%3C/svg%3E");
}
.cards-vertical .domino-back:first-child,
.domino-back-vertical:first-child { margin-top: 0; }

/* ================= 6. AREA TENGAH PAPAN & SNAKE BOARD ================= */
.board-center-area {
  grid-column: 2 / 3;
  grid-row: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 4px 10px;
  position: relative;
  overflow: hidden;
}

.board-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 680px;
  margin-bottom: 6px;
  z-index: 5;
}

.end-indicator-badge {
  background: var(--hud-pill-bg);
  border: 1px solid var(--border-card);
  border-radius: var(--r-md);
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-body);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 6px;
}

.end-indicator-badge strong {
  font-family: var(--font-display);
  font-variant-numeric: tabular-nums;
  font-size: 17px;
  color: var(--amber-gold);
}

.end-indicator-badge .end-arrow {
  font-size: 10px;
  color: var(--text-muted);
}

.board-table-tag {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: rgba(255, 255, 255, 0.55);
  display: flex;
  align-items: center;
  gap: 6px;
}

.board-table-tag strong {
  color: #fff;
}

/* WAJIB: flex: 1 1 0; min-height: 0 agar tinggi papan stabil untuk kalkulasi JS */
.board-track {
  width: 100%;
  max-width: 860px;
  flex: 1 1 0;
  min-height: 0;
  overflow: visible;
  padding: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
}

/* Drop Zones & Ghost Tiles */
.board-drop-zones {
  position: absolute;
  inset: -8px -14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
  z-index: 50;
}

.drop-zone {
  display: none;
  pointer-events: auto;
  align-items: center;
  justify-content: center;
  padding: 8px;
  border-radius: var(--r-lg);
  cursor: pointer;
}

.drop-zone.active-target { display: flex; }
.drop-zone-left { position: absolute; left: 0; top: 50%; transform: translateY(-50%); }
.drop-zone-right { position: absolute; right: 0; top: 50%; transform: translateY(-50%); }
.drop-zone-center { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); }

.ghost-domino-tile {
  width: 52px;
  height: 96px;
  border-radius: var(--r-md);
  border: 2px dashed var(--amber-gold);
  background: rgba(220, 168, 66, 0.14);
  box-shadow: 0 0 18px rgba(220, 168, 66, 0.25);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--dur-fast) var(--ease-spring), border-color var(--dur-fast) ease, background var(--dur-fast) ease;
  animation: ghostPulse 1.6s ease-in-out infinite;
}

.ghost-tile-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  text-align: center;
}

.ghost-icon { font-size: 15px; }
.ghost-label {
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--amber-gold);
}
.ghost-target-num {
  font-family: var(--font-display);
  font-variant-numeric: tabular-nums;
  font-size: 17px;
  font-weight: 800;
  color: #fff;
  background: rgba(0, 0, 0, 0.45);
  padding: 1px 7px;
  border-radius: 5px;
  border: 1px solid var(--amber-border);
}

.drop-zone.drag-over .ghost-domino-tile,
.drop-zone:hover .ghost-domino-tile {
  transform: scale(1.1);
  border: 2px solid #52c488;
  background: rgba(40, 125, 82, 0.3);
  animation: none;
}

@keyframes ghostPulse {
  0%, 100% { transform: scale(1); opacity: 0.9; }
  50% { transform: scale(1.04); opacity: 1; }
}

.drag-floating-avatar {
  position: fixed;
  pointer-events: none;
  z-index: 1000;
  transform: translate(-50%, -50%) scale(1.08) rotate(3deg);
  filter: drop-shadow(0 16px 24px rgba(0, 0, 0, 0.65));
}

.card-flight-clone {
  position: fixed;
  pointer-events: none;
  z-index: 999;
  transition: all 320ms var(--ease-out);
  filter: drop-shadow(0 12px 20px rgba(0, 0, 0, 0.6));
}

.domino-tile.is-being-dragged {
  opacity: 0.35 !important;
  filter: grayscale(0.5) !important;
  transform: scale(0.95) !important;
}

.board {
  min-height: 100px;
  padding: 8px 16px;
  background: rgba(0, 0, 0, 0.24);
  border-radius: var(--r-lg);
  border: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: inset 0 2px 12px rgba(0, 0, 0, 0.42);
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

/* WAJIB: box-sizing: content-box; padding: 22px 20px 20px (sinkron dengan JS) */
.board.board-snake {
  display: block;
  box-sizing: content-box;
  padding: 22px 20px 20px;
  min-height: 80px;
  border-radius: var(--r-lg);
  background: rgba(0, 0, 0, 0.28);
  box-shadow: inset 0 2px 14px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.3);
}

/* WAJIB: ukuran .snake-domino-tile tetap 56x28 & 28x56 */
.snake-domino-tile {
  box-shadow: 0 3px 0 var(--domino-thick), 0 4px 10px rgba(0, 0, 0, 0.45) !important;
  border-radius: 5px !important;
}

.snake-domino-tile.domino-horizontal { width: 56px !important; height: 28px !important; }
.snake-domino-tile.domino-horizontal .domino-half { width: 27px !important; height: 26px !important; padding: 1px !important; }
.snake-domino-tile.domino-horizontal .domino-divider { width: 2px !important; height: 22px !important; }
.snake-domino-tile.domino-horizontal .domino-divider::after { width: 3px !important; height: 3px !important; }

.snake-domino-tile.domino-vertical { width: 28px !important; height: 56px !important; }
.snake-domino-tile.domino-vertical .domino-half { width: 26px !important; height: 27px !important; padding: 1px !important; }
.snake-domino-tile.domino-vertical .domino-divider { width: 22px !important; height: 2px !important; }
.snake-domino-tile.domino-vertical .domino-divider::after { width: 3px !important; height: 3px !important; }

.snake-domino-tile .pip { width: 5.5px !important; height: 5.5px !important; }
.snake-domino-tile .pip.pip-large { width: 7.5px !important; height: 7.5px !important; }

.tile-end-left { border: 2px solid var(--teal-accent) !important; z-index: 10; }
.tile-end-right { border: 2px solid var(--amber-gold) !important; z-index: 10; }
.tile-end-both { border: 2px solid #52c488 !important; z-index: 10; }

.snake-badge {
  position: absolute;
  top: -16px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 9px;
  font-weight: 800;
  padding: 1px 7px;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 15;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}
.snake-badge.badge-left { background: #214e54; color: #fff; border: 1px solid var(--teal-accent); }
.snake-badge.badge-right { background: #6e4e14; color: #fff; border: 1px solid var(--amber-gold); }
.snake-badge.badge-both { background: #1e5633; color: #fff; border: 1px solid #52c488; }

.board-empty-hint {
  font-size: 13.5px;
  color: rgba(255, 255, 255, 0.55);
  padding: 16px 26px;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ================= 7. BATU DOMINO GADING & PIPS ================= */
.domino-tile {
  background: linear-gradient(155deg, var(--domino-top) 0%, var(--domino-mid) 60%, var(--domino-bot) 100%);
  border-radius: 8px;
  border: 1px solid var(--domino-border);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.85),
    0 4px 0 var(--domino-thick),
    0 7px 14px rgba(0, 0, 0, 0.42);
  position: relative;
  box-sizing: border-box;
  user-select: none;
  flex-shrink: 0;
  transition: transform var(--dur-fast) var(--ease-spring), box-shadow var(--dur-fast) ease, filter var(--dur-fast) ease;
}

.domino-vertical { width: 48px; height: 96px; display: flex; flex-direction: column; }
.domino-vertical .domino-half { width: 46px; height: 46px; }
.domino-vertical .domino-divider {
  width: 38px; height: 2px; background: #7f7666; margin: 0 auto; border-radius: 1px;
  box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.5); flex-shrink: 0; position: relative;
}
.domino-vertical .domino-divider::after {
  content: ''; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 4.5px; height: 4.5px; border-radius: 50%; background: var(--rivet-brass);
}

.domino-horizontal { width: 96px; height: 48px; display: flex; flex-direction: row; }
.domino-horizontal .domino-half { width: 46px; height: 46px; }
.domino-horizontal .domino-divider {
  width: 2px; height: 38px; background: #7f7666; margin: auto 0; border-radius: 1px;
  box-shadow: inset 1px 0 1px rgba(0, 0, 0, 0.5); flex-shrink: 0; position: relative;
}
.domino-horizontal .domino-divider::after {
  content: ''; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 4.5px; height: 4.5px; border-radius: 50%; background: var(--rivet-brass);
}

.domino-half {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  place-items: center;
  padding: 3px;
}

.pip {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--pip-black);
  box-shadow: inset 0 1.5px 2px rgba(0, 0, 0, 0.65), 0 0.5px 0 rgba(255, 255, 255, 0.55);
}

.pip.pip-red { background: var(--pip-red) !important; }
.pip.pip-large { width: 11.5px; height: 11.5px; }

/* ================= 8. TANGAN PEMAIN (SEAT BOTTOM) ================= */
.seat-bottom {
  grid-column: 1 / 4;
  grid-row: 3;
  align-self: end;
  justify-self: center;
  width: 100%;
  max-width: 980px;
  padding: 10px 18px 12px;
  flex-direction: column;
  gap: 8px;
}

.bottom-control-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  width: 100%;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 8px;
}

.bottom-profile {
  display: flex;
  align-items: center;
  gap: 10px;
}

.turn-notice-box {
  background: var(--hud-pill-bg);
  border: 1px solid var(--border-card);
  border-radius: var(--r-pill);
  padding: 5px 14px;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-body);
}

.turn-notice-box.my-turn {
  background: var(--amber-soft);
  border-color: var(--amber-gold);
  color: var(--amber-gold);
  font-weight: 700;
}

.hand-wrapper {
  display: flex;
  justify-content: center;
  width: 100%;
  overflow-x: auto;
  scrollbar-width: thin;
}

.hand-container {
  display: flex;
  gap: 10px;
  padding: 10px 6px 4px;
  align-items: flex-end;
  justify-content: center;
  min-height: 112px;
}

.domino-tile.playable {
  touch-action: none;
  transform: translateY(-8px);
  box-shadow: 0 0 0 2px var(--amber-gold), 0 5px 0 var(--domino-thick), 0 10px 18px rgba(0, 0, 0, 0.45);
  border-color: var(--amber-gold);
  cursor: grab;
}

.domino-tile.playable:hover {
  transform: translateY(-16px) scale(1.05);
  box-shadow: 0 0 0 2px #fff, 0 0 18px rgba(220, 168, 66, 0.45), 0 6px 0 var(--domino-thick);
  z-index: 20;
}

.domino-tile.dimmed {
  opacity: 0.5;
  filter: brightness(0.82);
  cursor: not-allowed;
}

/* ================= 9. MODAL & KLASEMEN & PODIUM ================= */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 11, 16, 0.78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: var(--sp-4);
  animation: fadeIn var(--dur-fast) var(--ease-out);
}

.choice-modal-card, .result-modal-card, .help-modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-card);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  animation: modalPop var(--dur-med) var(--ease-spring);
}

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

.choice-modal-card {
  padding: 26px 30px;
  width: 100%;
  max-width: 460px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.choice-header-badge {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--amber-gold);
}

.choice-header h3 {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 800;
}

.choice-header p {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
  line-height: 1.5;
}

.choice-tile-preview { display: flex; justify-content: center; }

.choice-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-3);
}

.btn-choice-side {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--r-lg);
  padding: 16px 14px;
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--text-main);
  cursor: pointer;
  transition: all var(--dur-fast) ease;
}

.btn-choice-side:hover {
  background: var(--bg-elevated);
  border-color: var(--amber-gold);
  transform: translateY(-2px);
}

.choice-icon { font-size: 18px; color: var(--amber-gold); }
.choice-title { font-size: 14px; font-weight: 800; }
.choice-val { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.btn-choice-cancel {
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  padding: 8px;
  min-height: 40px;
}

.result-modal-card, .help-modal-card {
  padding: 22px 26px;
  width: 100%;
  max-width: 820px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
}

.modal-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 14px;
  margin-bottom: 14px;
}

.modal-card-title { display: flex; align-items: center; gap: 12px; }
.modal-card-title h3 { font-family: var(--font-display); font-size: 18px; font-weight: 800; }
.modal-sub { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }
.trophy-icon { font-size: 26px; }

.btn-modal-close {
  background: var(--bg-card);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--dur-fast) ease;
}
.btn-modal-close:hover { background: var(--bg-elevated); color: var(--text-main); }

.modal-tab-bar { display: flex; gap: 8px; margin-bottom: 14px; }

.modal-tab-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  padding: 8px 16px;
  min-height: 40px;
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.modal-tab-btn.active {
  background: var(--blue-cta);
  color: #fff;
  border-color: var(--blue-cta);
}

.bracket-view-area { flex: 1; overflow-y: auto; padding-right: 4px; }

/* Podium 3 Besar */
.podium-row {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 12px;
  margin-top: 14px;
}

.podium-step {
  flex: 1;
  max-width: 160px;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--r-md);
  padding: 10px 8px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.podium-1 { border-color: var(--amber-gold); background: var(--amber-soft); }
.podium-medal { font-size: 22px; }
.podium-name { font-weight: 800; font-size: 13px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.podium-pts { font-family: var(--font-display); font-variant-numeric: tabular-nums; font-size: 12px; color: var(--amber-gold); font-weight: 700; }
.podium-bar {
  width: 100%;
  margin-top: 6px;
  padding: 4px 0;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 12px;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 4px 4px 0 0;
}
.podium-1 .podium-bar { padding: 10px 0; background: var(--amber-gold); color: #161410; }
.podium-2 .podium-bar { padding: 6px 0; }

/* Tabel Klasemen */
.standings-table, .result-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-bottom: 14px;
}
.standings-table th, .result-table th {
  background: rgba(0, 0, 0, 0.22);
  padding: 10px 14px;
  text-align: left;
  color: var(--text-muted);
  font-weight: 700;
  border-bottom: 1px solid var(--border-subtle);
}
.standings-table td, .result-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}

.rank-pill, .rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  font-size: 12px;
  padding: 3px 10px;
  border-radius: var(--r-sm);
  min-width: 46px;
}
.rank-1 { background: var(--amber-soft); color: var(--amber-gold); border: 1px solid var(--amber-border); }
.rank-2 { background: rgba(160, 170, 185, 0.14); color: #cbd5e1; border: 1px solid rgba(160, 170, 185, 0.3); }
.rank-3 { background: rgba(190, 130, 65, 0.14); color: #d49b62; border: 1px solid rgba(190, 130, 65, 0.3); }
.rank-other { background: var(--bg-card); color: var(--text-muted); border: 1px solid var(--border-subtle); }

.status-pill {
  display: inline-flex;
  align-items: center;
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: var(--r-sm);
}
.status-pill.champ { background: var(--amber-soft); color: var(--amber-gold); border: 1px solid var(--amber-border); }
.status-pill.active { background: var(--jade-soft); color: #52c488; border: 1px solid rgba(40, 125, 82, 0.35); }
.status-pill.elim { background: rgba(201, 70, 70, 0.16); color: #f07171; border: 1px solid rgba(201, 70, 70, 0.32); }
.status-pill.waiting { background: var(--bg-card); color: var(--text-muted); }

.points-val {
  font-family: var(--font-display);
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  font-size: 14px;
  color: var(--amber-gold);
}

.result-banner-box {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-lg);
  padding: 14px 18px;
  text-align: center;
  margin-bottom: 16px;
}
.result-banner-box.champ {
  background: linear-gradient(135deg, rgba(220, 168, 66, 0.14), var(--bg-card));
  border-color: var(--amber-gold);
}
.result-banner-box.champ h2 { font-family: var(--font-display); color: var(--amber-gold); font-size: 20px; }

.tech-log-details { margin-top: 12px; border-top: 1px solid var(--border-subtle); padding-top: 10px; font-size: 12px; color: var(--text-muted); }
.tech-log-details summary { cursor: pointer; margin-bottom: 8px; }
.result-box { background: var(--bg-input); border-radius: var(--r-md); padding: 10px; font-family: monospace; font-size: 11px; max-height: 120px; overflow-y: auto; color: var(--teal-accent); }

/* Panduan */
.help-content { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; overflow-y: auto; }
.help-item { display: flex; gap: 12px; background: var(--bg-card); border: 1px solid var(--border-subtle); border-radius: var(--r-md); padding: 12px 14px; }
.help-num {
  width: 28px; height: 28px; border-radius: 50%; background: var(--amber-soft); color: var(--amber-gold);
  border: 1px solid var(--amber-border); display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 800; font-size: 13px; flex-shrink: 0;
}
.help-text strong { font-size: 13.5px; display: block; margin-bottom: 3px; }
.help-text p { font-size: 12.5px; color: var(--text-muted); line-height: 1.5; }
.help-footer { text-align: right; border-top: 1px solid var(--border-subtle); padding-top: 12px; }

/* ================= 10. DRAWER LOG, TOAST, WATCH BAR, & FROZEN SUMMARY ================= */
.log-drawer-overlay {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.45);
  z-index: 150; display: flex; justify-content: flex-end;
}
.log-drawer-backdrop { position: absolute; inset: 0; z-index: 0; }
.log-drawer-panel {
  position: relative; z-index: 1; width: 100%; max-width: 350px; height: 100%;
  background: var(--bg-surface); border-left: 1px solid var(--border-card);
  display: flex; flex-direction: column; padding: 16px; box-shadow: -12px 0 36px rgba(0, 0, 0, 0.5);
  animation: slideInRight var(--dur-med) var(--ease-out);
}
@keyframes slideInRight { from { transform: translateX(100%); } to { transform: translateX(0); } }

.drawer-header { display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border-subtle); padding-bottom: 12px; margin-bottom: 12px; }
.log-items-container { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.log-item { font-size: 12px; line-height: 1.5; padding: 8px 10px; border-radius: var(--r-sm); background: var(--bg-card); border-left: 3px solid var(--border-subtle); color: var(--text-body); }
.log-item.play { border-left-color: var(--jade-cta); }
.log-item.pass { border-left-color: var(--coral-red); }
.log-item.turn { border-left-color: var(--amber-gold); }
.log-item.info { border-left-color: var(--teal-accent); }
.log-time { font-size: 10px; color: var(--text-muted); margin-right: 4px; font-variant-numeric: tabular-nums; }

.game-toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(32px);
  background: var(--bg-elevated); border: 1px solid var(--amber-border);
  box-shadow: var(--shadow-md); color: var(--text-main);
  padding: 10px 20px; border-radius: var(--r-pill); font-size: 13px; font-weight: 600;
  z-index: 300; opacity: 0; pointer-events: none; max-width: 90vw; text-align: center;
  transition: all var(--dur-med) var(--ease-spring);
}
.game-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.watch-table-bar {
  background: var(--bg-surface); border: 1px solid var(--teal-accent);
  border-radius: var(--r-md); padding: 6px 12px;
  display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 6px; z-index: 30;
}
.table-nav-title { font-size: 12px; font-weight: 700; color: var(--teal-accent); white-space: nowrap; }
.table-nav-buttons { display: flex; gap: 6px; flex-wrap: wrap; }
.btn-watch-table {
  background: var(--bg-card); border: 1px solid var(--border-subtle); color: var(--text-body);
  padding: 5px 12px; min-height: 32px; border-radius: var(--r-sm); font-size: 12px; font-weight: 700; cursor: pointer;
}
.btn-watch-table.active { background: var(--teal-accent); border-color: var(--teal-accent); color: #fff; }
.badge-watching-table {
  background: var(--teal-soft); border: 1px solid var(--teal-accent); color: var(--teal-accent);
  font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: var(--r-pill); white-space: nowrap;
}

.frozen-summary-overlay {
  position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%);
  width: 95%; max-width: 920px; z-index: 90;
  animation: slideUpFade var(--dur-slow) var(--ease-spring);
}
@keyframes slideUpFade {
  from { opacity: 0; transform: translateX(-50%) translateY(18px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.frozen-summary-card {
  background: var(--bg-surface); border: 1.5px solid var(--amber-gold);
  border-radius: var(--r-lg); padding: 16px 20px; box-shadow: var(--shadow-lg);
}
.frozen-header { display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border-subtle); padding-bottom: 10px; margin-bottom: 10px; gap: 10px; }
.frozen-reason { font-size: 14px; font-weight: 800; color: var(--amber-gold); }
.frozen-players-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; margin-bottom: 12px; max-height: 200px; overflow-y: auto; }
.frozen-player-card { background: var(--bg-card); border: 1px solid var(--border-subtle); border-radius: var(--r-md); padding: 8px 12px; display: flex; flex-direction: column; gap: 6px; }
.frozen-player-card.winner { border-color: var(--amber-gold); background: var(--amber-soft); }
.frozen-player-info { display: flex; align-items: center; justify-content: space-between; font-size: 13px; font-weight: 700; }
.frozen-cards-section { display: flex; flex-direction: column; gap: 4px; font-size: 11px; color: var(--text-muted); }
.frozen-tiles-row, .mini-tiles-row { display: inline-flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.frozen-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; border-top: 1px solid var(--border-subtle); padding-top: 10px; }

.btn-frozen-close {
  background: var(--bg-card); color: var(--text-main); border: 1px solid var(--border-card);
  padding: 9px 16px; min-height: 40px; border-radius: var(--r-md); font-size: 12.5px; font-weight: 700; cursor: pointer;
}
.btn-play-again {
  background: var(--jade-cta); color: #fff; border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--r-md); padding: 10px 20px; min-height: 44px; font-size: 13.5px; font-weight: 800; cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px;
}

/* Konfeti Juara Turnamen */
.confetti-burst { position: fixed; inset: 0; pointer-events: none; z-index: 400; overflow: hidden; }
.confetti-piece {
  position: absolute; top: -12px; width: 9px; height: 14px; border-radius: 2px;
  animation: confettiFall 2.4s var(--ease-out) forwards;
}
@keyframes confettiFall {
  0% { transform: translateY(0) translateX(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(100vh) translateX(var(--drift, 40px)) rotate(540deg); opacity: 0; }
}

/* ================= 11. RESPONSIVITAS PENUH (1100x700, TABLET, PONSEL 360-430px) ================= */
/* Laptop 1100x700 (tinggi terbatas, harus muat tanpa scroll) */
@media (max-height: 740px) {
  .top-nav-bar { height: 48px; }
  .arena-container { padding: 8px 14px 10px; }
  .game-table { border-width: 10px; border-radius: 26px; }
  .table-grid-layout { grid-template-rows: 78px 1fr 154px; padding: 6px 12px; }
  .hand-container { min-height: 92px; padding: 6px 4px 2px; }
  .domino-vertical { width: 42px; height: 84px; }
  .domino-vertical .domino-half { width: 40px; height: 40px; }
  .lobby-card { padding: 20px 26px; gap: 14px; }
}

@media (max-width: 1180px) {
  .top-nav-bar { padding: 0 12px; gap: 8px; }
  .badge-status #status-text { display: none; }
  .badge-status { padding: 7px; }
  .nav-btn { padding: 6px 10px; font-size: 12px; }
}

@media (max-width: 1024px) {
  .table-grid-layout {
    grid-template-columns: 164px 1fr 164px;
    grid-template-rows: 82px 1fr 164px;
    padding: 6px 10px;
  }
  .seat-left, .seat-right { width: 154px; padding: 10px; }
}

/* Ponsel Portrait (360-430px) & Layar Sempit: susun ulang lawan di atas dalam baris ringkas */
@media (max-width: 680px) {
  .top-nav-bar { padding: 0 8px; height: 48px; gap: 4px; }
  .nav-left, .nav-center, .nav-right { gap: 4px; }
  .nav-divider, .nav-badge, .badge-status #status-text { display: none; }
  .app-logo { font-size: 13.5px; gap: 5px; }
  .logo-mark svg { width: 20px; height: 20px; }
  .turn-indicator-pill { display: none; }
  .timer-pill { padding: 4px 8px; min-width: 48px; font-size: 11.5px; }
  .nav-btn { padding: 5px 7px; min-height: 34px; font-size: 12px; }
  .nav-btn .btn-label { display: none; }
  .badge-status { padding: 5px; }

  .arena-container { padding: 6px; }
  .game-table { border-width: 7px; border-radius: 20px; }

  /* Susun ulang: 3 lawan berjejer ringkas di atas, papan penuh di tengah, tangan di bawah */
  .table-grid-layout {
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: auto 1fr auto;
    gap: 6px;
    padding: 6px;
  }

  .seat-left { grid-column: 1 / 2; grid-row: 1; width: 100%; justify-self: stretch; padding: 6px 8px; gap: 4px; }
  .seat-top { grid-column: 2 / 3; grid-row: 1; width: 100%; justify-self: stretch; flex-direction: column; padding: 6px 8px; gap: 4px; }
  .seat-right { grid-column: 3 / 4; grid-row: 1; width: 100%; justify-self: stretch; padding: 6px 8px; gap: 4px; }
  .seat-hand-cards { display: none; }

  .seat-avatar { width: 28px; height: 28px; font-size: 10px; }
  .seat-name { font-size: 11px; max-width: 64px; }
  .seat-status { font-size: 10px; }

  .board-center-area { grid-column: 1 / 4; grid-row: 2; padding: 2px 4px; }
  .board-header-bar { margin-bottom: 4px; }
  .end-indicator-badge { padding: 4px 8px; font-size: 11px; }
  .end-indicator-badge strong { font-size: 14px; }

  .seat-bottom { grid-column: 1 / 4; grid-row: 3; padding: 6px 10px 8px; gap: 6px; }
  .bottom-control-bar { flex-wrap: wrap; padding-bottom: 6px; }
  .turn-notice-box { font-size: 11.5px; padding: 4px 10px; flex: 1 1 auto; justify-content: center; }

  .hand-wrapper { justify-content: flex-start; }
  .hand-container { justify-content: flex-start; gap: 7px; min-height: 88px; padding: 8px 4px 2px; }
  .domino-vertical { width: 40px; height: 80px; }
  .domino-vertical .domino-half { width: 38px; height: 38px; }
  .pip { width: 6px; height: 6px; }
  .pip.pip-large { width: 9px; height: 9px; }

  .lobby-overlay { padding: 10px; }
  .lobby-card { padding: 18px 16px; border-radius: 18px; gap: 14px; }
  .lobby-hero h2 { font-size: 20px; }
  .lobby-action-cards { grid-template-columns: 1fr; }
  .room-code-banner { flex-direction: column; text-align: center; }
  .room-code-highlight { font-size: 22px; }
  .podium-row { gap: 6px; }
}

/* Hormati prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
