/* ===== SELF-HOSTED FONTS (no Google Fonts round-trip) ===== */
@font-face { font-family: 'Cinzel'; font-style: normal; font-weight: 600; font-display: swap;
  src: url('/fonts/cinzel-latin-600-normal.woff2') format('woff2'),
       url('/fonts/cinzel-latin-600-normal.woff')  format('woff'); }
@font-face { font-family: 'Cinzel'; font-style: normal; font-weight: 700; font-display: swap;
  src: url('/fonts/cinzel-latin-700-normal.woff2') format('woff2'),
       url('/fonts/cinzel-latin-700-normal.woff')  format('woff'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('/fonts/inter-latin-400-normal.woff2') format('woff2'),
       url('/fonts/inter-latin-400-normal.woff')  format('woff'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 500; font-display: swap;
  src: url('/fonts/inter-latin-500-normal.woff2') format('woff2'),
       url('/fonts/inter-latin-500-normal.woff')  format('woff'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 600; font-display: swap;
  src: url('/fonts/inter-latin-600-normal.woff2') format('woff2'),
       url('/fonts/inter-latin-600-normal.woff')  format('woff'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 700; font-display: swap;
  src: url('/fonts/inter-latin-700-normal.woff2') format('woff2'),
       url('/fonts/inter-latin-700-normal.woff')  format('woff'); }

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

:root {
  --felt:        #1f6b2e;
  --felt-dark:   #0f3d1a;
  --felt-light:  #2a7d39;
  --card-bg:     #fffef5;
  --card-border: rgba(0,0,0,0.12);
  --card-shadow: 0 2px 4px rgba(0,0,0,0.45), 0 6px 14px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.8);
  --card-shadow-hover: 0 8px 22px rgba(0,0,0,0.55), 0 16px 32px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.8);
  --red:         #cc1f1f;
  --black:       #111;
  --gold:        #f5c518;
  --gold-dark:   #c9a012;
  --gold-glow:   rgba(245,197,24,0.4);
  --radius:      10px;
  --card-radius: 8px;
  --font:        'Cinzel', 'Georgia', serif;
  --font-ui:     'Inter', 'Segoe UI', Arial, sans-serif;
  --card-w:      60px;
  --card-h:      84px;
  --card-sm-w:   38px;
  --card-sm-h:   54px;

  /* ── D3 Theme ── */
  --teal:    #14a89c;
  --coral:   #e8502a;
  --coral-d: #c23a18;
  --ink:     #0c3b3a;
  --ink-d:   #062322;
  --ink2:    #14322f;
  --d3-gold:   #ffb648;
  --d3-gold-d: #c98a1e;
  --batik: repeating-linear-gradient(45deg,rgba(255,255,255,.10) 0 6px,transparent 6px 12px),
           repeating-linear-gradient(-45deg,rgba(255,255,255,.06) 0 6px,transparent 6px 12px);
}

body {
  font-family: var(--font-ui);
  background: var(--felt-dark);
  color: #fff;
  min-height: 100svh;
  overscroll-behavior: none;
  overflow-x: hidden;
}

/* ===== SCREENS ===== */
.screen { display: none; min-height: 100svh; }
.screen.active { display: flex; flex-direction: column; }

/* ===== LOBBY ===== */
#screen-lobby {
  align-items: stretch;
  justify-content: stretch;
  background:
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 28px,
      rgba(0,0,0,0.06) 28px,
      rgba(0,0,0,0.06) 29px
    ),
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent 28px,
      rgba(0,0,0,0.06) 28px,
      rgba(0,0,0,0.06) 29px
    ),
    linear-gradient(155deg, #1a6128 0%, #0d3d18 55%, #061a09 100%);
  position: relative;
  overflow: hidden;
}

/* ── Two-panel wrap ── */
.lobby-wrap {
  display: flex;
  width: 100%;
  min-height: 100vh;
  align-items: stretch;
}

/* ── Footer copyright ── */
.lobby-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  padding: 0 12px calc(12px + env(safe-area-inset-bottom, 0px));
  text-align: center;
  font-size: 0.68rem;
  color: rgba(255,255,255,0.22);
  letter-spacing: 0.5px;
  pointer-events: none;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px 6px;
  box-sizing: border-box;
}
.lf-game    { font-weight: 700; color: rgba(255,255,255,0.3); }
.lf-sep     { color: rgba(255,255,255,0.15); }
.lf-version { font-family: 'Courier New', monospace; }
.lf-copy    { white-space: nowrap; }

/* ── Left: Branding ── */
.lobby-brand {
  flex: 1.1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 36px;
  padding: 56px 40px;
  position: relative;
  overflow: hidden;
}

/* Giant watermark suit — controlled via JS for smooth cycling */
.lobby-brand::before { display: none; }

.lobby-bg-suit {
  position: absolute;
  bottom: -120px;
  right: -60px;
  font-size: 560px;
  line-height: 1;
  pointer-events: none;
  user-select: none;
  /* Transition diset JS per fase (exit vs enter beda easing) */
  will-change: opacity, transform;
}

/* Thin gold divider on right edge */
.lobby-brand::after {
  content: '';
  position: absolute;
  top: 15%;
  right: 0;
  width: 1px;
  height: 70%;
  background: linear-gradient(
    to bottom,
    transparent 0%,
    rgba(245,197,24,0.22) 25%,
    rgba(245,197,24,0.22) 75%,
    transparent 100%
  );
}

/* Card stack decoration */
.brand-deco { position: relative; width: 210px; height: 190px; }
.brand-card-stack { position: relative; width: 100%; height: 100%; }

.bcs-back, .bcs-front {
  position: absolute;
  width: 108px; height: 152px;
  border-radius: 12px;
  box-shadow: 0 14px 40px rgba(0,0,0,0.6), 0 4px 10px rgba(0,0,0,0.35);
}

/* Card back shared style — dark felt with diagonal stripe */
.bcs-back {
  background:
    repeating-linear-gradient(
      135deg,
      rgba(232,80,42,0.18) 0px,
      rgba(232,80,42,0.18) 2px,
      transparent 2px,
      transparent 10px
    ),
    linear-gradient(160deg, #0d3d1c, #07240f);
  border: 2px solid rgba(232,80,42,0.55);
}

/* Far back card — leftmost, most rotated */
.bcs-back-far {
  top: 22px; left: 4px;
  transform: rotate(-20deg);
  z-index: 1;
  box-shadow: 0 16px 44px rgba(0,0,0,0.7), 0 4px 10px rgba(0,0,0,0.4);
}

/* Near back card — middle */
.bcs-back-near {
  top: 10px; left: 44px;
  transform: rotate(-8deg);
  z-index: 2;
}

.bcs-front {
  background: #fffef5;
  background-image:
    radial-gradient(ellipse at 50% 0%, rgba(255,255,255,0.7) 0%, transparent 65%),
    radial-gradient(ellipse at 50% 100%, rgba(0,0,0,0.04) 0%, transparent 60%);
  border: 1px solid rgba(0,0,0,0.12);
  top: 0; left: 80px;
  transform: rotate(6deg);
  z-index: 3;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  will-change: transform, filter;
  backface-visibility: hidden;
  box-shadow: 0 18px 48px rgba(0,0,0,0.55), 0 6px 16px rgba(0,0,0,0.3);
}

.bcs-corner {
  position: absolute;
  display: flex; flex-direction: column; align-items: center;
  line-height: 1; gap: 1px;
}
.bcs-tl { top: 7px; left: 8px; }
.bcs-br { bottom: 7px; right: 8px; transform: rotate(180deg); }

.bcs-rank {
  font-family: var(--font); font-size: 1.1rem;
  font-weight: 700; line-height: 1; color: #111;
}
.bcs-suit { font-size: 0.85rem; line-height: 1; color: #111; }

.bcs-suit-center {
  font-size: 3rem; line-height: 1; color: #111;
}

.bcs-front.red .bcs-rank,
.bcs-front.red .bcs-suit,
.bcs-front.red .bcs-suit-center { color: var(--red); }
.bcs-front.black .bcs-rank,
.bcs-front.black .bcs-suit,
.bcs-front.black .bcs-suit-center { color: #111; }

.bcs-joker-hint {
  margin-top: 6px; font-size: 0.65rem;
  color: rgba(245,197,24,0.45); letter-spacing: 0.5px;
  text-align: center; width: 160px;
}

/* Brand text */
.brand-text { text-align: center; }
.brand-tagline {
  font-size: 0.6rem;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: rgba(255,255,255,0.3);
  margin-bottom: 10px;
}
.brand-title {
  font-family: var(--font);
  font-size: 3.4rem;
  font-weight: 700;
  letter-spacing: 3px;
  background: linear-gradient(175deg, #fff 0%, #f7e08a 35%, #d4a017 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.08;
  filter: drop-shadow(0 3px 20px rgba(0,0,0,0.55));
}
.brand-aka {
  display: flex; align-items: center; gap: 14px;
  margin-top: 12px; justify-content: center;
}
.brand-line {
  flex: 1; max-width: 44px; height: 1px;
  background: linear-gradient(to right, transparent, rgba(245,197,24,0.45));
}
.brand-aka .brand-line:last-child {
  background: linear-gradient(to left, transparent, rgba(245,197,24,0.45));
}
.brand-aka-text {
  font-family: var(--font);
  font-size: 1.05rem;
  color: rgba(245,197,24,0.72);
  letter-spacing: 2px;
}

/* Stats strip — number + label, no emoji badges */
.brand-stats {
  display: flex;
  align-items: center;
}
.brand-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 26px;
}
.bs-num {
  font-family: var(--font);
  font-size: 1.65rem;
  font-weight: 700;
  line-height: 1;
  color: var(--gold);
  text-shadow: 0 0 24px rgba(245,197,24,0.35);
}
.bs-lbl {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 1.8px;
  color: rgba(255,255,255,0.3);
  margin-top: 5px;
  white-space: nowrap;
}
.bs-sep {
  width: 1px;
  height: 36px;
  background: linear-gradient(
    to bottom,
    transparent,
    rgba(245,197,24,0.25) 30%,
    rgba(245,197,24,0.25) 70%,
    transparent
  );
}

/* Suits — properly colored */
.brand-suits {
  display: flex;
  gap: 24px;
  font-size: 2rem;
}
.suit-black {
  color: rgba(210,235,220,0.7);
  text-shadow: 0 0 14px rgba(210,235,220,0.25);
}
.suit-red {
  color: rgba(220,55,55,0.75);
  text-shadow: 0 0 14px rgba(220,55,55,0.3);
}

/* ── Right: Form panel ── */
.lobby-panel {
  flex: 0 0 410px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 52px 38px;
  background: rgba(4,18,9,0.88);
  backdrop-filter: blur(24px);
  position: relative;
  overflow-y: auto;
  box-shadow: -1px 0 0 rgba(245,197,24,0.1), -8px 0 32px rgba(0,0,0,0.35);
}

.lp-header {
  margin-bottom: 30px;
  padding-bottom: 24px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  position: relative;
}
.lp-eyebrow {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 3px;
  color: rgba(245,197,24,0.45);
  margin-bottom: 8px;
  font-weight: 500;
}
.lp-header h2 {
  font-family: var(--font);
  font-size: 1.55rem;
  color: #fff;
  letter-spacing: 1.5px;
  font-weight: 700;
  line-height: 1.15;
}
/* Accent bar below header */
.lp-header::after {
  content: '';
  position: absolute;
  bottom: -1px; left: 0;
  width: 40px; height: 2px;
  background: var(--gold);
  border-radius: 1px;
}

/* ── Fields ── */
.lp-field { margin-bottom: 0px; }
.lp-label {
  display: block;
  font-size: 0.62rem;
  color: rgba(255,255,255,0.32);
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 9px;
  font-weight: 600;
}

/* Inputs */
.lobby-panel input[type="text"],
.lobby-panel input[type="number"] {
  width: 100%;
  padding: 13px 16px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.04);
  color: #fff; font-size: 0.92rem;
  outline: none; font-family: var(--font-ui);
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}
.lobby-panel input:focus {
  border-color: rgba(245,197,24,0.45);
  background: rgba(245,197,24,0.03);
  box-shadow: 0 0 0 3px rgba(245,197,24,0.09);
}
.lobby-panel input::placeholder { color: rgba(255,255,255,0.18); }

/* Room code input — centered monospace */
.lobby-panel input.input-code {
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.4em;
  font-weight: 700;
  font-size: 1.1rem;
  padding: 14px 16px;
}

/* ── Tabs — underline style ── */
.lp-tabs {
  display: flex;
  position: relative;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  margin-bottom: 22px;
  gap: 0;
  background: none;
  border-radius: 0;
  padding: 0;
}
.lp-tab {
  flex: 1;
  padding: 11px 8px;
  background: none; border: none;
  color: rgba(255,255,255,0.28);
  font-size: 0.72rem; font-weight: 600;
  cursor: pointer; font-family: var(--font-ui);
  text-transform: uppercase; letter-spacing: 1.5px;
  position: relative;
  transition: color 0.2s;
}
.lp-tab:hover:not(.active) { color: rgba(255,255,255,0.55); }
.lp-tab.active { color: var(--gold); }
.lp-tab.active::after {
  content: '';
  position: absolute;
  bottom: -1px; left: 15%; right: 15%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold) 30%, var(--gold) 70%, transparent);
  border-radius: 2px;
}

.lp-section { display: flex; flex-direction: column; gap: 14px; }

/* ── Settings ── */
.settings-card {
  background: rgba(255,255,255,0.025);
  border-radius: 12px;
  padding: 4px 18px 14px;
  border: 1px solid rgba(255,255,255,0.06);
  display: flex;
  flex-direction: column;
  gap: 0;
}
.settings-card-title {
  font-size: 0.58rem;
  color: rgba(255,255,255,0.2);
  text-transform: uppercase;
  letter-spacing: 2.5px;
  padding: 13px 0 10px;
  font-weight: 600;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  margin-bottom: 2px;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 0;
  font-size: 0.84rem;
  gap: 12px;
  color: rgba(255,255,255,0.58);
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.setting-row:last-child { border-bottom: none; padding-bottom: 4px; }
.setting-row > label { display: flex; align-items: center; flex-shrink: 0; }
.setting-icon { display: none; }

/* Control wrapper — uniform width, right-aligned */
.setting-ctrl {
  width: 120px;
  flex-shrink: 0;
  display: block;
}

/* ── Button ── */
.btn-full {
  flex: none !important;
  width: 100%;
  margin-top: 2px;
  padding: 15px;
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  border-radius: 10px;
}

/* Legacy compat */
.lobby-buttons, .join-form { display: flex; gap: 10px; }
.join-form .input-wrap { flex: 1; }
.lobby-form { display: flex; flex-direction: column; gap: 12px; }
.lobby-form input[type="text"],
.lobby-form input[type="number"] {
  padding: 13px 16px;
  border-radius: var(--radius);
  border: 1px solid rgba(255,255,255,0.16);
  background: rgba(255,255,255,0.06);
  color: #fff; font-size: 1rem; outline: none;
  width: 100%; font-family: var(--font-ui);
  transition: border 0.2s, background 0.2s, box-shadow 0.2s;
}
.lobby-form input:focus {
  border-color: rgba(245,197,24,0.65);
  background: rgba(255,255,255,0.08);
  box-shadow: 0 0 0 3px rgba(245,197,24,0.16);
}
.lobby-form input::placeholder { color: rgba(255,255,255,0.28); }
.input-wrap { position: relative; }
.input-wrap .input-icon {
  position: absolute; left: 13px; top: 50%;
  transform: translateY(-50%);
  color: rgba(255,255,255,0.35); font-size: 0.95rem; pointer-events: none;
}

/* ── Settings legacy ── */
.room-settings {
  background: rgba(0,0,0,0.22);
  border-radius: var(--radius);
  padding: 16px;
  border: 1px solid rgba(245,197,24,0.14);
}
.settings-title {
  font-size: 0.72rem;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 14px;
  font-weight: 600;
}

.setting-ctrl select,
.setting-ctrl input[type="number"] {
  width: 100%;
  padding: 7px 10px;
  border-radius: 7px;
  border: 1px solid rgba(255,255,255,0.09);
  background: rgba(255,255,255,0.05);
  color: rgba(255,255,255,0.75);
  font-size: 0.82rem;
  font-family: var(--font-ui);
  text-align: center;
  transition: border-color 0.18s, box-shadow 0.18s;
}
.setting-ctrl select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 28px;
  text-align: left;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5' viewBox='0 0 8 5'%3E%3Cpath d='M0 0l4 5 4-5z' fill='%23f5c518' fill-opacity='0.55'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  cursor: pointer;
}
.setting-ctrl select:focus,
.setting-ctrl input[type="number"]:not(:disabled):focus {
  outline: none;
  border-color: rgba(245,197,24,0.4);
  box-shadow: 0 0 0 3px rgba(245,197,24,0.08);
}
.setting-ctrl select option { background: #0a2010; color: #fff; }
.setting-ctrl input[type="number"]:disabled { opacity: 0.28; cursor: not-allowed; }

/* Checkbox + number inline — must come after generic .setting-ctrl rule */
.setting-ctrl-check {
  display: flex;
  align-items: center;
  gap: 8px;
}
.setting-ctrl-check input[type="number"] {
  flex: 1;
  min-width: 0;
  width: auto;
}
.setting-row input[type="checkbox"] {
  width: 16px; height: 16px;
  flex-shrink: 0;
  accent-color: var(--gold);
  cursor: pointer;
}

/* ===== BUTTONS ===== */
.btn {
  padding: 12px 22px;
  border-radius: var(--radius);
  border: none;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s;
  flex: 1;
  letter-spacing: 0.3px;
  font-family: var(--font-ui);
}
/* Squash & Stretch on press (css-animation-creator: micro-interaction 100-200ms) */
.btn:active  { transform: scaleX(0.97) scaleY(0.94) !important; transition-duration: 0.08s !important; }
.btn:disabled { opacity: 0.38; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(155deg, #ffe259 0%, #f5c518 48%, #c9920a 100%);
  color: #1a1a1a;
  box-shadow:
    0 4px 18px rgba(245,197,24,0.4),
    inset 0 1px 0 rgba(255,255,255,0.55),
    inset 0 -1px 0 rgba(0,0,0,0.25);
  text-shadow: 0 1px 2px rgba(255,255,255,0.35);
  letter-spacing: 0.5px;
}
.btn-primary:hover:not(:disabled) {
  background: linear-gradient(155deg, #ffec74 0%, #ffd028 48%, #e0a800 100%);
  box-shadow:
    0 6px 24px rgba(245,197,24,0.58),
    inset 0 1px 0 rgba(255,255,255,0.55),
    inset 0 -1px 0 rgba(0,0,0,0.25);
  transform: translateY(-1px);
}

.btn-secondary {
  background: rgba(255,255,255,0.1);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.14);
}
.btn-secondary:hover:not(:disabled) { background: rgba(255,255,255,0.18); }

.btn-danger { background: linear-gradient(135deg, #e53935, #c62828); color: #fff; }
.btn-danger:hover:not(:disabled) { background: linear-gradient(135deg, #ef5350, #e53935); }
.btn-danger-outline { background: transparent; color: #ef9a9a; border: 1px solid rgba(239,154,154,0.5); }
.btn-danger-outline:hover:not(:disabled) { background: rgba(239,154,154,0.08); }

.btn-success {
  background: linear-gradient(135deg, #43a047, #2e7d32);
  color: #fff;
  box-shadow: 0 4px 12px rgba(46,125,50,0.3);
}
.btn-success:hover:not(:disabled) {
  background: linear-gradient(135deg, #66bb6a, #43a047);
  transform: translateY(-1px);
}

.btn-gold {
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  color: #1a1a1a;
  box-shadow: 0 4px 16px rgba(245,197,24,0.4);
}
.btn-gold:hover:not(:disabled) {
  box-shadow: 0 6px 22px rgba(245,197,24,0.55);
  transform: translateY(-1px);
}

.btn-outline {
  background: transparent;
  color: rgba(255,255,255,0.7);
  border: 1px solid rgba(255,255,255,0.24);
}
.btn-outline:hover:not(:disabled) {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.4);
}

.btn-sm    { padding: 7px 13px; font-size: 0.82rem; flex: none; }
.btn-small {
  padding: 4px 10px; font-size: 0.8rem; border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.22); background: transparent;
  color: rgba(255,255,255,0.7); cursor: pointer; transition: all 0.15s;
}
.btn-small:hover { background: rgba(255,255,255,0.1); }

.hidden { display: none !important; }

.error-msg {
  background: rgba(198,40,40,0.14);
  border: 1px solid rgba(198,40,40,0.4);
  color: #ef9a9a;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 0.88rem;
}

/* ===== WAITING ROOM ===== */
/* base centering wrapper — transparent pass-through on desktop */
.waiting-center-wrap {
  width: 100%;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

#screen-waiting {
  align-items: stretch;
  justify-content: flex-start;
  background:
    radial-gradient(ellipse at 20% 90%, rgba(245,197,24,0.09) 0%, transparent 45%),
    radial-gradient(ellipse at 80% 10%, rgba(245,197,24,0.06) 0%, transparent 40%),
    radial-gradient(ellipse at center, #1d7a2e 0%, #07240d 100%);
}

.waiting-container {
  background: linear-gradient(165deg, rgba(6,44,16,0.95) 0%, rgba(2,14,6,0.97) 100%);
  border: 1px solid rgba(245,197,24,0.28);
  border-radius: 24px;
  padding: 40px;
  width: 100%;
  max-width: 520px;
  text-align: center;
  backdrop-filter: blur(16px);
  box-shadow:
    0 0 0 1px rgba(245,197,24,0.06),
    0 32px 80px rgba(0,0,0,0.65),
    inset 0 1px 0 rgba(245,197,24,0.18),
    inset 0 -1px 0 rgba(0,0,0,0.4);
}
.waiting-container h2 {
  margin-bottom: 22px;
  font-family: var(--font);
  font-size: 1.55rem;
  color: var(--gold);
}

.room-code-display {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  padding: 6px 12px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(245,197,24,0.2);
  border-radius: 8px;
}
.rcd-label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: rgba(255,255,255,0.35);
  text-transform: uppercase;
}
.room-code-display strong {
  color: var(--gold);
  font-size: 1.2rem;
  letter-spacing: 6px;
  font-family: 'Courier New', monospace;
  text-shadow: 0 0 10px var(--gold-glow);
}
.rcd-share {
  background: none;
  border: none;
  color: rgba(245,197,24,0.6);
  font-size: 1rem;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
  line-height: 1;
}
.rcd-share:hover { color: var(--gold); background: rgba(245,197,24,0.1); }

.player-slots { display: flex; flex-direction: column; gap: 8px; margin-bottom: 24px; }

.player-slot {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255,255,255,0.04);
  border-radius: var(--radius);
  padding: 12px 16px;
  border: 1px solid rgba(255,255,255,0.08);
  transition: border-color 0.3s, background 0.3s, box-shadow 0.3s;
}
.player-slot.empty  { opacity: 0.28; font-style: italic; }
.player-slot.bot    { border-color: rgba(245,197,24,0.22); }
.player-slot.me     {
  border-color: rgba(245,197,24,0.55);
  background: rgba(245,197,24,0.06);
  box-shadow: 0 0 18px rgba(245,197,24,0.1), inset 0 0 12px rgba(245,197,24,0.04);
}

.slot-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(255,255,255,0.14), rgba(255,255,255,0.04));
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem; flex-shrink: 0;
  border: 1px solid rgba(255,255,255,0.1);
  line-height: 1;
}
.player-slot.bot .slot-avatar { background: linear-gradient(135deg, rgba(100,100,255,0.2), rgba(100,100,255,0.05)); }

.slot-info { flex: 1; text-align: left; }
.slot-name { font-weight: 600; font-size: 0.95rem; }
.slot-sub  { font-size: 0.73rem; color: rgba(255,255,255,0.38); margin-top: 1px; }

/* Legacy slot-number / slot-name compatibility */
.slot-number {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: rgba(255,255,255,0.12);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.85rem; flex-shrink: 0;
}

.slot-badge {
  font-size: 0.72rem;
  padding: 3px 10px;
  border-radius: 20px;
  font-weight: 600;
  letter-spacing: 0.5px;
}
.slot-badge.host      { background: var(--gold); color: #1a1a1a; }
.slot-badge.bot-badge { background: rgba(100,100,255,0.22); border: 1px solid rgba(100,100,255,0.3); color: #ccd; }
.slot-badge.bot-level-easy   { background: rgba(40,160,60,0.25);  border-color: rgba(40,160,60,0.4);  color: #8ef0a0; }
.slot-badge.bot-level-medium { background: rgba(200,160,30,0.25); border-color: rgba(200,160,30,0.4); color: #f5d060; }
.slot-badge.bot-level-hard   { background: rgba(200,40,40,0.25);  border-color: rgba(200,40,40,0.4);  color: #f08080; }

.room-info-bar {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.room-info-chip {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 0.76rem;
  color: rgba(255,255,255,0.6);
  display: flex;
  align-items: center;
  gap: 5px;
}
.room-info-chip span { color: var(--gold); font-weight: 600; }

/* Host editable settings dalam waiting room */
.ws-settings {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  margin-bottom: 10px;
}
.ws-panel-title {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: rgba(255,255,255,0.35);
  text-transform: uppercase;
  text-align: center;
}
.ws-settings-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}
.ws-setting-row {
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 20px;
  padding: 4px 10px 4px 12px;
}
.ws-lbl {
  font-size: 0.74rem;
  color: rgba(255,255,255,0.5);
  white-space: nowrap;
}
.ws-select, .ws-settings input[type="number"] {
  background: transparent;
  border: none;
  color: var(--gold);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  padding: 0 2px;
  appearance: auto;
}
.ws-target-ctrl,
.ws-bot-ctrl {
  display: flex;
  align-items: center;
  gap: 4px;
}
.ws-bot-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding-top: 6px;
  border-top: 1px solid rgba(255,255,255,0.07);
  width: 100%;
}
.ws-bot-row #btn-add-bot {
  border-radius: 0 8px 8px 0 !important;
}
.ws-settings input[type="checkbox"] {
  accent-color: var(--gold);
  cursor: pointer;
  width: 14px;
  height: 14px;
}

.bot-controls {
  display: flex;
  gap: 8px;
  justify-content: center;
  align-items: center;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.bot-level-select {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.2);
  color: #fff;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 0.84rem;
  cursor: pointer;
  outline: none;
}
.bot-level-select:focus { border-color: var(--gold); }
.bot-level-select option { background: #1a3a22; color: #fff; }
.waiting-actions { margin-bottom: 20px; }
.hint { color: rgba(255,255,255,0.42); font-size: 0.84rem; margin-top: 12px; }

/* ===== GAME TABLE ===== */
#screen-game {
  background:
    radial-gradient(ellipse at 50% -10%, rgba(50,140,65,0.45) 0%, transparent 55%),
    radial-gradient(ellipse at 50% 110%, rgba(0,0,0,0.6) 0%, transparent 55%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='0.045'/%3E%3C/svg%3E"),
    linear-gradient(160deg, #1f6b2e 0%, #164f22 50%, #0f3d1a 100%);
  background-size: auto, auto, 200px 200px, auto;
  /* display: grid set only when active — prevents bleed-through when screen is hidden */
  grid-template-rows: auto 1fr auto auto auto;
  min-height: 100svh;
  position: relative;
}
#screen-game.active { display: grid; }
/* Table border shadow */
#screen-game::before {
  content: '';
  position: fixed; inset: 0;
  box-shadow: inset 0 0 40px rgba(0,0,0,0.4);
  pointer-events: none;
  z-index: 50;
}

/* ===== HEADER ===== */
.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 14px;
  background: linear-gradient(180deg, rgba(0,0,0,0.62) 0%, rgba(0,0,0,0.44) 100%);
  border-bottom: 1px solid rgba(245,197,24,0.1);
  font-size: 0.82rem;
  flex-wrap: nowrap;
  gap: 6px;
  backdrop-filter: blur(8px);
  position: relative;
  z-index: 10;
  box-shadow: 0 2px 16px rgba(0,0,0,0.35);
  min-height: 42px;
}

.joker-info {
  display: flex; align-items: center; gap: 6px;
  color: var(--gold); font-weight: 600; font-size: 0.78rem;
  flex-shrink: 0;
}
#joker-rank-display {
  font-size: 0.88rem;
  background: rgba(245,197,24,0.14);
  padding: 1px 8px; border-radius: 4px;
  border: 1px solid rgba(245,197,24,0.38);
}
.joker-ref-card { font-size: 0.68rem; }

.header-center {
  display: flex; flex-direction: row; align-items: center; gap: 6px;
  flex: 1; justify-content: center; min-width: 0;
}
.round-info {
  font-weight: 700; color: rgba(255,255,255,0.75); font-size: 0.78rem;
  letter-spacing: 0.3px; white-space: nowrap; flex-shrink: 0;
}

.turn-info {
  background: rgba(255,255,255,0.08);
  padding: 3px 10px; border-radius: 20px; font-size: 0.78rem;
  transition: all 0.35s; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; max-width: 260px;
}
.turn-info.my-turn {
  background: linear-gradient(135deg, #ffe259, var(--gold-dark));
  color: #1a1a1a;
  font-weight: 700;
  box-shadow: 0 0 18px rgba(245,197,24,0.5), 0 2px 6px rgba(0,0,0,0.3);
  text-shadow: 0 1px 2px rgba(255,255,255,0.3);
}

/* ── TIMER ── */
.timer-wrapper {
  display: flex; flex-direction: row; align-items: center; gap: 6px;
  flex-shrink: 0;
}
.timer-seconds {
  font-size: 1.1rem; font-weight: 700;
  font-family: 'Courier New', monospace;
  color: rgba(255,255,255,0.85);
  line-height: 1; transition: color 0.4s;
  min-width: 28px; text-align: right;
}
.timer-seconds.urgent      { color: #ff5252; animation: timerPulse 0.45s ease infinite alternate; }
.timer-seconds.very-urgent { color: #ff2020; animation: timerShake 0.28s ease infinite; text-shadow: 0 0 12px rgba(255,32,32,0.8); }
.timer-seconds.no-timer { display: none; }

@keyframes timerPulse {
  from { opacity: 1; transform: scale(1); }
  to   { opacity: 0.5; transform: scale(0.95); }
}
@keyframes timerShake {
  0%, 100% { transform: scale(1.0)  translateX(0);   }
  18%       { transform: scale(1.18) translateX(-4px); }
  36%       { transform: scale(1.12) translateX(4px);  }
  54%       { transform: scale(1.18) translateX(-3px); }
  72%       { transform: scale(1.1)  translateX(3px);  }
}

.btn-mute {
  background: none;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  opacity: 0.55;
  transition: opacity 0.2s, transform 0.15s;
  padding: 2px 4px;
  line-height: 1;
  border-radius: 6px;
  flex-shrink: 0;
}
.btn-mute:hover { opacity: 1; transform: scale(1.15); }
.btn-mute.muted { opacity: 0.3; }
.btn-show-scores {
  background: rgba(245,197,24,0.15);
  border: 1px solid rgba(245,197,24,0.4);
  color: var(--gold);
  font-size: 0.72rem;
  cursor: pointer;
  padding: 3px 9px;
  border-radius: 8px;
  font-family: var(--font-ui); font-weight: 700;
  transition: background 0.18s, border-color 0.18s;
  flex-shrink: 0;
}
.btn-show-scores:hover { background: rgba(245,197,24,0.28); border-color: var(--gold); }

.timer-bar-track {
  width: 60px; height: 4px;
  background: rgba(255,255,255,0.1);
  border-radius: 3px; overflow: hidden;
}
.timer-bar-fill {
  height: 100%; background: var(--gold);
  border-radius: 3px;
  transition: width 1s linear, background 0.5s;
}
.timer-bar-fill.urgent      { background: #ff5252; }
.timer-bar-fill.very-urgent { background: #ff2020; animation: barFlash 0.28s ease infinite alternate; }
@keyframes barFlash {
  from { opacity: 1; }
  to   { opacity: 0.35; }
}

/* ===== OPPONENTS ===== */
.opponents-area {
  display: flex; flex-direction: column; align-items: center;
  padding: 10px 10px 4px; gap: 8px; flex: 1;
  position: relative; z-index: 1;
}
.side-opponents {
  display: flex; width: 100%; gap: 8px; align-items: flex-start; flex: 1;
  overflow: visible;
}

/* UNO-style opponent pod — position:relative so meld floats anchor here */
.opponent-slot {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  background: rgba(0,0,0,0.32);
  border-radius: 16px;
  padding: 10px 8px;
  border: 1.5px solid rgba(255,255,255,0.055);
  box-shadow: 0 4px 16px rgba(0,0,0,0.25), inset 0 1px 0 rgba(255,255,255,0.04);
  transition: all 0.3s cubic-bezier(0.4,0,0.2,1);
  position: relative;
  min-width: 90px;
  backdrop-filter: blur(4px);
  /* overflow:visible so floating meld panels can escape the pod bounds */
  overflow: visible;
}

/* Top opponent: compact horizontal pod — elevated so meld strip clears the center piles */
#opp-top {
  width: auto;
  align-self: center;
  flex-direction: row;
  flex-wrap: nowrap;
  gap: 12px;
  padding: 8px 18px;
  align-items: center;
  min-width: 0;
  max-width: 600px;
  overflow: visible;
  z-index: 10;
}
#opp-top .opp-body {
  display: flex; flex-direction: column; gap: 1px;
  min-width: 0;
}
#opp-top .opp-name {
  font-size: 0.82rem; font-weight: 700; max-width: 160px;
}
#opp-top .opp-score { font-size: 0.68rem; }

/* Top opponent melds: floating box below the pod */
.opp-top-meld-strip {
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;

  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  justify-content: center;
  align-items: center;
  gap: 0;
  padding: 5px 8px;
  max-width: 80vw;
  overflow: hidden;

  background: rgba(0,0,0,0.58);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.45);
  pointer-events: none;
}
.opp-top-meld-strip:empty { display: none; }
/* Hand reveal inline in top strip — boleh wrap agar kartu banyak tidak terpotong */
.opp-top-meld-strip .opp-hand-reveal {
  display: flex;
  flex-basis: auto;
  flex-wrap: wrap;
  max-width: 100%;
  margin-top: 0;
  margin-left: 6px;
  /* padding: 4px 6px; */
  background: none;
}

/* Cards in top meld: no extra bg/border — flat cards in a row */
.opp-top-meld-strip .meld-group {
  display: flex;
  flex-wrap: nowrap;
  gap: 2px;
  background: none;
  border: none;
  border-radius: 0;
  padding: 3px 8px;
  animation: none;
}
/* No divider between top meld groups */
.opp-top-meld-strip .meld-group + .meld-group {
  border-left: none;
  margin-left: 4px;
}
/* Top strip cards */
.opp-top-meld-strip .card-sm { width: 30px; height: 42px; font-size: 11px; }
.opp-top-meld-strip .card-sm .card-rank { font-size: 1em; line-height: 1; }
.opp-top-meld-strip .card-sm .card-suit { font-size: 1.1em; line-height: 1; }

/* Side panel cards */
#opp-left-melds .card-sm, #opp-right-melds .card-sm { width: 30px; height: 42px; font-size: 11px; }
#opp-left-melds .card-sm .card-rank, #opp-right-melds .card-sm .card-rank { font-size: 1em; line-height: 1; }
#opp-left-melds .card-sm .card-suit, #opp-right-melds .card-sm .card-suit { font-size: 1.1em; line-height: 1; }

/* Side opponent pods — horizontal layout matching top pod */
#opp-left, #opp-right {
  flex: 0 0 auto;
  width: auto;
  align-self: flex-start;
  height: fit-content;
  flex-direction: row;
  flex-wrap: nowrap;
  gap: 10px;
  padding: 8px 14px;
  align-items: center;
  min-width: 0;
  max-width: 190px;
}
#opp-left .opp-body, #opp-right .opp-body {
  display: flex; flex-direction: column; gap: 1px;
  min-width: 0;
}
#opp-left .opp-name, #opp-right .opp-name {
  font-size: 0.8rem; font-weight: 700;
  text-align: center; max-width: 110px;
}
#opp-left .opp-score, #opp-right .opp-score {
  font-size: 0.68rem; text-align: center;
}

/* Avatar circle */
.opp-avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(255,255,255,0.16) 0%, rgba(255,255,255,0.04) 100%);
  border: 2px solid rgba(255,255,255,0.12);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.15rem; font-weight: 700;
  color: rgba(255,255,255,0.85);
  position: relative; flex-shrink: 0;
  text-transform: uppercase;
  letter-spacing: 0;
  transition: border-color 0.3s, box-shadow 0.3s;
}
.opp-avatar::before {
  content: attr(data-initial);
  font-size: 1.15rem; font-weight: 700;
  line-height: 1;
}

/* Card count badge on avatar */
.opp-card-badge {
  position: absolute; top: -5px; right: -5px;
  background: linear-gradient(135deg, #1565c0, #0d47a1);
  color: #fff; border-radius: 10px;
  min-width: 20px; height: 20px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.7rem; font-weight: 800;
  border: 2px solid rgba(0,0,0,0.55);
  padding: 0 3px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
  font-family: var(--font-ui);
}

.opp-name {
  font-size: 0.73rem; font-weight: 600; color: rgba(255,255,255,0.78);
  text-align: center; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; max-width: 100%;
}
/* opp-cards: hidden — count shown via badge on avatar */
.opp-cards { display: none; }
/* Generic meld container (used by top strip) */
.opp-melds { display: flex; flex-wrap: nowrap; gap: 0; }
.opp-melds .meld-group { border: none; background: none; }
/* Side meld bar: zero-height wrapper — panels float via absolute children */
.opp-side-melds-bar {
  /* Keep it in the DOM but give it no height so it doesn't push siblings */
  display: contents;
}

/* Left side meld: floating panel, TOP-aligned to pod (not vertically centered) */
.side-meld-panel {
  position: absolute;
  top: calc(100% + 6px);        /* below the pod */
  left: 0;
  z-index: 5;

  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 3px;
  align-items: flex-start;
  max-width: 200px;

  background: rgba(0,0,0,0.58);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  padding: 5px 6px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.45);
  pointer-events: none;
}
.side-meld-panel:empty { display: none; }

/* Right side meld: anchor to right edge of pod, grow leftward */
.side-meld-right {
  left: auto;
  right: 0;
  align-items: flex-end;
}

/* Meld groups in side panel: flat cards + horizontal row + row divider */
.side-meld-panel .meld-group {
  display: flex;
  flex-wrap: nowrap;
  gap: 2px;
  background: none;
  border: none;
  border-radius: 0;
  padding: 3px 0;
  border-left: none;
  margin-left: 0;
  padding-left: 0;
  animation: none;
}
/* No margin on siblings — gap handled by parent */
.side-meld-panel .meld-group + .meld-group {
  border-top: none;
  border-left: none;
  margin-top: 0;
  padding-top: 0;
  padding-left: 0;
  margin-left: 0;
}
.opp-score {
  font-size: 0.68rem; color: rgba(245,197,24,0.75); font-weight: 700;
  text-align: center;
}
.opp-timer { font-size: 0.68rem; color: rgba(255,255,255,0.38); font-family: monospace; }

/* Kartu belakang mini */
.card-back-mini {
  width: 16px; height: 24px;
  background: linear-gradient(155deg, #1d3d90 0%, #0c1e5e 100%);
  border-radius: 2px; border: 1px solid rgba(255,255,255,0.18);
  display: inline-block; box-shadow: 0 1px 3px rgba(0,0,0,0.45);
}

/* ===== CENTER AREA ===== */
.center-area {
  display: flex; flex-direction: row; align-items: center;
  justify-content: center; gap: 18px; flex: 1;
}
.card-piles { display: flex; gap: 28px; align-items: center; }

.pile-wrapper { display: flex; flex-direction: column; align-items: center; gap: 6px; }

.card-pile {
  width: 74px; height: 104px;
  border-radius: 10px;
  border: 2px dashed rgba(255,255,255,0.2);
  display: flex; align-items: center; justify-content: center;
  position: relative; cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.4,0,0.2,1), box-shadow 0.2s;
}
.card-pile:hover {
  border-color: rgba(255,255,255,0.5);
  transform: translateY(-4px) scale(1.02);
  box-shadow: 0 14px 32px rgba(0,0,0,0.5);
}

/* Stock depth illusion */
.stock-pile {
  background: rgba(0,0,0,0.3);
}
.stock-pile .card-back {
  width: 100%; height: 100%;
  border-radius: 8px;
}
.stock-pile::before, .stock-pile::after {
  content: '';
  position: absolute; width: 100%; height: 100%;
  border-radius: var(--card-radius);
  background: linear-gradient(155deg, #1d3d90, #0c1e5e);
  border: 1px solid rgba(255,255,255,0.09); z-index: -1;
}
.stock-pile::before { transform: translate(-2px,-2px); opacity: 0.65; }
.stock-pile::after  { transform: translate(-4px,-4px); opacity: 0.3; }

.discard-pile {
  background: rgba(0,0,0,0.2);
  width: var(--card-w);
  height: var(--card-h);
}
.discard-dropzone-wrap {
  padding: 20px 24px;
  border-radius: 14px;
  border: 2px dashed transparent;
  transition: border-color 0.18s, background 0.18s, box-shadow 0.18s;
  cursor: pointer;
}
.discard-dropzone-wrap.discard-drag-over {
  border-color: var(--red) !important;
  background: rgba(204,31,31,0.08);
  box-shadow: 0 0 22px rgba(204,31,31,0.35);
}
.discard-dropzone-wrap.discard-drag-over .discard-pile {
  border-color: transparent;
  box-shadow: none;
}
.discard-pile.discard-drag-over {
  border-color: var(--red) !important;
  border-style: solid !important;
  box-shadow: 0 0 22px rgba(204,31,31,0.55);
  background: rgba(204,31,31,0.08);
}

.pile-count {
  position: absolute; bottom: -20px;
  font-size: 0.65rem; color: rgba(255,255,255,0.5);
  background: rgba(0,0,0,0.55); padding: 1px 7px; border-radius: 10px;
}
.pile-count-label { font-size: 0.65rem; color: rgba(255,255,255,0.35); margin-top: 1px; }
.pile-label {
  margin-top: 22px; font-size: 0.66rem; color: rgba(255,255,255,0.35);
  text-align: center; text-transform: uppercase; letter-spacing: 0.8px; font-weight: 600;
}

/* Joker ref: same footprint as card-pile — sits in pile row */
.joker-ref-pile {
  width: 74px; height: 104px;
  cursor: default;
  border: 1px solid rgba(245,197,24,0.35);
  box-shadow: 0 0 14px rgba(245,197,24,0.18), var(--card-shadow);
}
/* Legacy — kept for CSS compat, no longer in DOM */
.joker-ref-chip { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.joker-chip-label { font-size: 0.6rem; color: rgba(245,197,24,0.65); text-transform: uppercase; letter-spacing: 1.2px; font-weight: 700; }
/* Legacy: keep old ref wrapper for compat */
.joker-ref-wrapper { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.joker-ref-label { font-size: 0.66rem; color: rgba(255,255,255,0.38); text-transform: uppercase; letter-spacing: 0.5px; }

/* ===== KARTU ===== */
.card {
  width: var(--card-w); height: var(--card-h);
  border-radius: var(--card-radius);
  background: var(--card-bg);
  background-image: radial-gradient(ellipse at 50% 0%, rgba(255,255,255,0.55) 0%, transparent 70%);
  border: 1px solid var(--card-border);
  box-shadow: var(--card-shadow);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  cursor: pointer; user-select: none; position: relative;
  font-weight: 700; font-family: var(--font);
  font-size: 10px;

  /* Fan layout via CSS custom props (set inline per card) */
  --card-rot: 0deg;
  --card-y:   0px;
  transform: rotate(var(--card-rot)) translateY(var(--card-y));
  transform-origin: bottom center;
  transition: box-shadow 0.2s;
}
/* Subtle inner border */
.card::before {
  content: ''; position: absolute; inset: 3px;
  border-radius: calc(var(--card-radius) - 2px);
  border: 1px solid rgba(0,0,0,0.055);
  pointer-events: none;
}

/*
 * ── FAN HAND: wrapper-based hover (fixes flicker) ──
 *
 * Architecture: each card is wrapped in .card-hit-zone
 * The WRAPPER handles fan rotation and has an extended bottom hit-area
 * (padding-bottom: 34px) so it never leaves the cursor when the CARD lifts.
 * The card inside lifts via CSS wrapper:hover — no element-moves-away-from-cursor loop.
 */

/* Wrapper: fan rotation + extended hit area */
.card-hit-zone {
  position: relative;
  flex-shrink: 0;
  margin-left: -18px;
  /* Extended bottom hit area prevents hover flicker when card lifts */
  padding-bottom: 34px;
  margin-bottom: -34px;
  transform: rotate(var(--card-rot, 0deg)) translateY(var(--card-y, 0px));
  transform-origin: bottom center;
  cursor: pointer;
}
.card-hit-zone:first-child { margin-left: 0; }

/* Card inside wrapper: no fan rotation (wrapper handles it) */
.my-hand .card {
  flex-shrink: 0;
  margin-left: 0;
  will-change: transform;
  /* Override fan props — rotation is on wrapper now */
  --card-rot: 0deg;
  --card-y:   0px;
  transform: none;
  transition: transform 0.22s cubic-bezier(0.25, 0.1, 0.25, 1),
              box-shadow 0.22s ease-out;
}

/* Lift card when WRAPPER is hovered (wrapper stays put → no cursor-escape loop) */
.card-hit-zone:hover .card:not(.selected):not(.dragging) {
  transform: translateY(-28px) scale(1.06);
  box-shadow: var(--card-shadow-hover);
  transition: transform 0.2s cubic-bezier(0.25, 0.1, 0.25, 1),
              box-shadow 0.2s ease-out;
}
/* Hovered zone sits above all siblings */
.card-hit-zone:hover {
  z-index: 200 !important;
}

/* Selected card — hitZone gets z-index boost so card sits above siblings */
.card-hit-zone:has(.card.selected) {
  z-index: 150 !important;
}
.my-hand .card.selected {
  transform: translateY(-20px) scale(1.05) !important;
  box-shadow: 0 14px 32px rgba(245,197,24,0.6), var(--card-shadow);
  outline: 2.5px solid var(--gold);
}

/* Original card while ghost is active — invisible but holds space */
.my-hand .card.dragging {
  opacity: 0;
  pointer-events: none;
}

/* Placeholder shown at insertion point during drag preview */
.my-hand .card.drag-placeholder {
  opacity: 1 !important;
  background-color: rgba(255,255,255,0.05) !important;
  background-image: none !important;
  border: 2px dashed rgba(255,255,255,0.28) !important;
  box-shadow: none !important;
  outline: none !important;
  animation: slotPulse 1.2s ease-in-out infinite !important;
}
.my-hand .card.drag-placeholder > * { visibility: hidden; }
/* Dashed slot where dragged card came from — suppressed when placeholder is shown */
.card-hit-zone:has(.card.drag-placeholder)::after { display: none !important; }
.card-hit-zone:has(.card.dragging)::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: var(--card-w, 68px);
  height: var(--card-h, 96px);
  border: 2px dashed rgba(255,255,255,0.28);
  border-radius: var(--card-radius);
  pointer-events: none;
  background: rgba(255,255,255,0.04);
  animation: slotPulse 1.2s ease-in-out infinite;
}
@keyframes slotPulse {
  0%, 100% { border-color: rgba(255,255,255,0.2); background: rgba(255,255,255,0.03); }
  50%       { border-color: rgba(255,255,255,0.42); background: rgba(255,255,255,0.06); }
}

/* Drop insertion indicator — glowing left-border line + target card tint */
.card-hit-zone.drag-over-card {
  z-index: 500 !important;
}
/* Gold insertion bar to the left of target card */
.card-hit-zone.drag-over-card::before {
  content: '';
  position: absolute;
  left: -4px;
  top: 0;
  bottom: 38px; /* above extended hit area */
  width: 4px;
  background: linear-gradient(180deg, transparent 0%, var(--gold) 15%, var(--gold) 85%, transparent 100%);
  border-radius: 4px;
  box-shadow: 0 0 14px rgba(245,197,24,0.9), 0 0 28px rgba(245,197,24,0.5);
  z-index: 10;
  pointer-events: none;
  animation: insertPulse 0.5s ease-in-out infinite alternate;
}
@keyframes insertPulse {
  from { opacity: 0.75; transform: scaleX(1); }
  to   { opacity: 1;    transform: scaleX(1.5); }
}
/* Target card dims slightly to show it's the drop zone */
.card-hit-zone.drag-over-card .card {
  opacity: 0.72;
  transition: opacity 0.12s ease !important;
}

/* Small card */
.card-sm {
  width: var(--card-sm-w); height: var(--card-sm-h);
  border-radius: 5px;
  background: var(--card-bg);
  background-image: radial-gradient(ellipse at 50% 0%, rgba(255,255,255,0.5) 0%, transparent 70%);
  border: 1px solid rgba(0,0,0,0.11);
  box-shadow: 0 2px 6px rgba(0,0,0,0.35);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 700; font-family: var(--font); position: relative;
}

.card.red   .card-rank, .card.red   .card-suit,
.card-sm.red   .card-rank, .card-sm.red   .card-suit { color: var(--red); }
.card.black .card-rank, .card.black .card-suit,
.card-sm.black .card-rank, .card-sm.black .card-suit { color: var(--black); }

.card.joker-card, .card-sm.joker-card {
  /* Fix: use separate background-color + background-image
     background: gradient shorthand resets background-color to transparent,
     then background-image: none removes the gradient → invisible card. */
  background-color: #fff8e1;
  background-image: linear-gradient(135deg, rgba(255,255,255,0.55) 0%, rgba(255,210,80,0.12) 100%);
  outline: 2px solid rgba(245,197,24,0.55);
  box-shadow: 0 0 14px rgba(245,197,24,0.28), var(--card-shadow);
}
.card.joker-card .card-rank,
.card-sm.joker-card .card-rank { color: #7b1fa2; }

.card-rank { font-size: 1em; line-height: 1.1; }
.card-suit { font-size: 1.1em; line-height: 1; }

.card-corner-tl, .card-corner-br {
  position: absolute; font-size: 0.9em; line-height: 1; font-weight: 700;
}
.card-corner-tl { top: 3px; left: 4px; text-align: left; }
.card-corner-br { bottom: 3px; right: 4px; text-align: right; transform: rotate(180deg); }

.card-back {
  background:
    repeating-linear-gradient(45deg, #1a3a8a 0px, #1a3a8a 4px, #1565c0 4px, #1565c0 8px);
  color: rgba(255,255,255,0.4); font-size: 1.5rem;
  cursor: default; border: 3px solid rgba(255,255,255,0.14);
  background-image: none;
}
.card-back::after {
  content: '♠'; position: absolute; font-size: 1.8rem; color: rgba(255,255,255,0.12);
}

/* ===== MELD AREA + DROPZONE (unified) ===== */
.my-melds-area {
  padding: 0 14px;
  background: linear-gradient(180deg, rgba(0,0,0,0.2) 0%, rgba(0,0,0,0.32) 100%);
  border-top: 1px solid rgba(255,255,255,0.055);
  /* Unified container: label + melds + hint in one flex row */
  display: flex; align-items: center; gap: 10px;
  min-height: 56px; overflow-x: auto;
  position: relative; z-index: 1;
  /* Meld dropzone states will be applied to this same element */
  border: 1.5px solid transparent;
  border-radius: 0;
  cursor: default;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}
/* When active as drop target */
.my-melds-area.drag-over {
  border-color: var(--gold);
  background: linear-gradient(180deg, rgba(245,197,24,0.08) 0%, rgba(245,197,24,0.12) 100%);
  box-shadow: 0 0 24px rgba(245,197,24,0.2) inset;
}
.melds-label {
  font-size: 0.64rem; color: rgba(255,255,255,0.32);
  white-space: nowrap; flex-shrink: 0;
  text-transform: uppercase; letter-spacing: 1px; font-weight: 700;
  padding: 6px 0;
}
.melds-container { display: flex; gap: 10px; overflow-x: auto; flex: 1; }

/* Meld group: player's own melds (keeps full styling + animation) */
.meld-group {
  display: flex; gap: 2px;
  background: rgba(255,255,255,0.035);
  border-radius: 6px; padding: 5px 8px;
  border: 1px solid rgba(255,255,255,0.075);
  animation: meldSlideIn 0.3s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes meldSlideIn {
  0%   { opacity: 0; transform: scale(0.6) translateY(14px); }
  55%  { opacity: 1; transform: scale(1.06) translateY(-4px); }
  75%  { transform: scale(0.97) translateY(2px); }
  100% { transform: scale(1) translateY(0); }
}
/* Drag hint: shows in the empty space to the right of melds */
.meld-dropzone-hint {
  font-size: 0.75rem; font-weight: 600;
  color: rgba(255,255,255,0.18);
  letter-spacing: 0.3px;
  white-space: nowrap;
  flex-shrink: 0;
  pointer-events: none;
  transition: color 0.2s;
}
.my-melds-area.drag-over .meld-dropzone-hint {
  color: var(--gold);
}

/* Legacy .meld-dropzone standalone class — keep for state toggling */
.meld-dropzone {
  /* No standalone styles needed — unified above */
}
.meld-dropzone.drag-over {
  border-color: var(--gold);
  background: linear-gradient(180deg, rgba(245,197,24,0.08) 0%, rgba(245,197,24,0.12) 100%);
  box-shadow: 0 0 24px rgba(245,197,24,0.2) inset;
}

/* ===== MY HAND AREA ===== */
.my-area {
  background: linear-gradient(0deg, rgba(0,0,0,0.52) 0%, rgba(0,0,0,0.36) 100%);
  border-top: 2px solid rgba(255,255,255,0.07);
  padding: 8px 16px 16px;
  position: relative; z-index: 2;
  transition: border-top-color 0.3s, box-shadow 0.3s;
}
.my-info {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 2px; font-size: 0.84rem;
  position: relative;
}
.my-name  { font-weight: 700; color: var(--gold); font-size: 0.9rem; }
.my-score { color: rgba(255,255,255,0.45); font-size: 0.78rem; margin-right: auto; }

/* Fan hand container */
.my-hand {
  touch-action: none;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  padding: 32px 10px 10px;
  min-height: 132px;
  position: relative;
  overflow: visible;
}

.selected-info {
  position: fixed;
  left: 18px;
  bottom: 170px;
  z-index: 200;
  display: flex; align-items: center; gap: 6px;
  font-size: 0.82rem;
  color: rgba(255,255,255,0.9);
  background: rgba(0,0,0,0.55);
  padding: 5px 12px;
  border-radius: 20px;
  backdrop-filter: blur(6px);
  pointer-events: none;
  transition: opacity 0.18s;
}
.selected-info.hidden { opacity: 0; pointer-events: none; }
#selected-count { font-weight: 700; color: var(--gold); font-size: 0.88rem; }
#selection-hint { color: rgba(255,255,255,0.42); font-size: 0.79rem; transition: color 0.2s; }
#selection-hint.hint-valid   { color: #66bb6a; }
#selection-hint.hint-invalid { color: #ff7043; }

/* ── Pointer drag ghost ── */
/* Ghost inherits .card base styles; just ensure cursor & lift shadow */
.my-hand .card { cursor: grab; }
.my-hand .card:active { cursor: grabbing; }

.action-hint {
  display: inline-flex;
  align-items: center;
  font-size: 0.8rem;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  color: #fff;
  padding: 5px 14px 5px 11px;
  border-radius: 14px;
  border-left: 3px solid rgba(255,255,255,0.25);
  background: rgba(0,0,0,0.38);
  pointer-events: none;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0;
  max-width: 0;
  padding-left: 0;
  padding-right: 0;
  border-width: 0;
  transition: opacity 0.2s ease, max-width 0.25s ease, padding 0.2s ease, border-width 0.2s ease;
}
.action-hint:not(:empty) {
  opacity: 1;
  max-width: 380px;
  padding: 5px 14px 5px 11px;
  border-width: 3px;
}
/* Tipe hint */
.action-hint[data-type="draw"]     { border-color: #64b5f6; color: #c8e6ff; background: rgba(20,40,80,0.5); }
.action-hint[data-type="required"] { border-color: #f59220; color: #ffd080; background: rgba(50,22,0,0.6); }
.action-hint[data-type="close"]    { border-color: #66e070; color: #ccffcc; background: rgba(0,50,15,0.6); }
.action-hint[data-type="nomeld"]   { border-color: #e6e060; color: #f5f0a0; background: rgba(30,30,0,0.5); }
.action-hint[data-type="action"]   { border-color: rgba(255,255,255,0.3); color: rgba(255,255,255,0.8); }
.action-hint[data-type="waiting"]  { border-color: rgba(255,255,255,0.2); color: rgba(255,255,255,0.6); font-weight: 500; }

.declare-bar { margin-left: auto; }
.return-discard-bar { margin-left: 8px; }
.return-discard-bar .btn { font-size: 0.72rem; padding: 1px 10px; line-height: 1; opacity: 0.88; }
.declare-bar .btn-gold {
  padding: 6px 16px; font-size: 0.84rem; letter-spacing: 0.6px;
  border: 2px solid var(--gold); white-space: nowrap;
  animation: declareGlow 1.4s ease-in-out infinite;
}
@keyframes declareGlow {
  0%, 100% { box-shadow: 0 0 10px rgba(245,197,24,0.38), 0 4px 14px rgba(0,0,0,0.3); }
  50%       { box-shadow: 0 0 28px rgba(245,197,24,0.72), 0 8px 22px rgba(0,0,0,0.3); }
}

/* ===== POPUP ===== */
.popup {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.78);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; backdrop-filter: blur(6px);
}
.popup-content {
  background: linear-gradient(155deg, #1e3d2a, #132216);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 18px; padding: 30px;
  max-width: 420px; width: 90%; text-align: center;
  box-shadow: 0 24px 64px rgba(0,0,0,0.65);
  animation: popupIn 0.22s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes popupIn {
  from { transform: scale(0.88) translateY(12px); opacity: 0; }
  to   { transform: scale(1)    translateY(0);    opacity: 1; }
}
.popup-content h3 { margin-bottom: 10px; color: var(--gold); font-family: var(--font); }
.popup-content p  { color: rgba(255,255,255,0.62); font-size: 0.9rem; margin-bottom: 18px; }
.discard-preview  { display: flex; justify-content: center; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.popup-actions    { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.popup-actions .btn { flex: 1; min-width: 80px; }

/* ===== TOAST ===== */
.toast {
  position: fixed; top: 62%; left: 50%;
  transform: translateX(-50%) translateY(0);
  background: #0d3533; color: #fff;
  padding: 10px 22px; border-radius: 14px;
  font-size: 0.87rem; font-weight: 700;
  font-family: 'Nunito', sans-serif;
  z-index: 9999;
  border: 2px solid rgba(20,168,156,0.4);
  box-shadow: 0 6px 0 #062322, 0 10px 30px rgba(0,0,0,0.5);
  max-width: 90vw; text-align: center;
  pointer-events: none;
  animation: toastIn 0.28s cubic-bezier(.175,.885,.32,1.275) both;
  transition: opacity 0.35s ease, transform 0.35s ease;
}
@keyframes toastIn {
  from { transform: translateX(-50%) translateY(16px) scale(0.92); opacity: 0; }
  to   { transform: translateX(-50%) translateY(0)    scale(1);    opacity: 1; }
}
.toast.toast-hiding {
  opacity: 0;
  transform: translateX(-50%) translateY(10px) scale(0.95);
}

/* Toast di luar permainan (lobby / waiting room) — top center */
.toast.toast--lobby {
  top: 24px;
  animation: toastInTop 0.3s cubic-bezier(.175,.885,.32,1.275) both;
}
.toast.toast--lobby.toast-hiding {
  opacity: 0;
  transform: translateX(-50%) translateY(-10px) scale(0.95);
}
@keyframes toastInTop {
  from { transform: translateX(-50%) translateY(-16px) scale(0.92); opacity: 0; }
  to   { transform: translateX(-50%) translateY(0)     scale(1);    opacity: 1; }
}
.toast.success {
  background: #0d3533;
  border-color: #14a89c;
  color: #7fffd4;
  box-shadow: 0 6px 0 #062322, 0 0 20px rgba(20,168,156,0.3);
}
.toast.error {
  background: #2d0f08;
  border-color: #e8502a;
  color: #fff;
  box-shadow: 0 6px 0 #1a0800, 0 0 20px rgba(232,80,42,0.35);
}
.toast.warning {
  background: #2a1a00;
  border-color: #ffb648;
  color: #ffdc8a;
  box-shadow: 0 6px 0 #1a1000, 0 0 20px rgba(255,182,72,0.3);
}
.toast.gold {
  background: #1a1200;
  border-color: #ffb648;
  color: #ffb648;
  box-shadow: 0 6px 0 #0d0a00, 0 0 24px rgba(255,182,72,0.4);
}

/* ===== SCOREBOARD POPUP OVERLAY ===== */
#screen-scores {
  display: none;
  position: fixed !important;
  inset: 0;
  z-index: 10000;
  min-height: unset !important;
  background: rgba(0,0,0,0.96);
  backdrop-filter: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}
#screen-scores.active { display: flex !important; }
.scores-container {
  background: linear-gradient(165deg, rgba(6,44,16,0.97) 0%, rgba(2,14,6,0.99) 100%);
  border: none;
  border-radius: 24px;
  padding: 32px 36px 0;
  max-height: 88vh; overflow-y: hidden;
  width: 100%; max-width: 560px; text-align: center;
  backdrop-filter: blur(16px);
  box-shadow:
    0 32px 80px rgba(0,0,0,0.65),
    inset 0 -1px 0 rgba(0,0,0,0.4);
  contain: style;
  display: flex; flex-direction: column;
}
.scores-container h2 {
  margin-bottom: 28px; color: var(--gold);
  font-size: 1.8rem; font-family: var(--font);
  text-shadow: 0 0 22px var(--gold-glow);
  flex-shrink: 0;
}
.scores-round-stats { flex-shrink: 0; margin-bottom: 12px; }
.scores-meta {
  display: flex;
  gap: 0;
  justify-content: stretch;
  align-items: stretch;
  background: rgba(0,0,0,1);
  border: none;
  border-radius: 0;
  overflow: hidden;
}
.scores-meta-item {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex: 1;
  padding: 6px 2px;
  font-size: 0.60rem;
  color: rgba(255,255,255,0.5);
  border-right: 1px solid rgba(255,255,255,0.07);
}
.scores-meta-item:last-child { border-right: none; }
.scores-meta-icon { font-size: 0.8rem; line-height: 1; }
.scores-meta-label { color: rgba(255,255,255,0.38); }
.scores-meta-val { color: rgba(255,255,255,0.92); font-weight: 700; }
.scores-table { width: 100%; margin-bottom: 0; flex: 1; overflow-y: auto; min-height: 0; }
.score-row {
  display: flex; flex-direction: column; align-items: stretch;
  padding: 0 0 10px; border-radius: var(--radius);
  margin-bottom: 8px; background: rgba(255,255,255,0.038);
  font-size: 0.95rem; border: 1px solid rgba(255,255,255,0.045);
  gap: 6px; position: relative; overflow: hidden;
}
.score-row.winner-row {
  background: rgba(245,197,24,0.1);
  border-color: rgba(245,197,24,0.32);
  /* box-shadow: inset 3px 0 0 rgba(245,197,24,0.6); */
}
/* Game-over: winner row gets a spotlight entrance + persistent glow */
.game-over-winner {
  animation: winnerSpotlight 0.85s cubic-bezier(0.34,1.56,0.64,1) forwards 0.25s,
             winnerGlow 2s ease-in-out infinite 1.1s !important;
  opacity: 0;
}
@keyframes winnerSpotlight {
  0%   { opacity: 0; transform: scale(0.82) translateY(24px); }
  65%  { transform: scale(1.04) translateY(-4px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes winnerGlow {
  0%, 100% { box-shadow: inset 3px 0 0 rgba(245,197,24,0.6), 0 0 8px rgba(245,197,24,0.22); }
  50%       { box-shadow: inset 3px 0 0 rgba(245,197,24,0.9), 0 0 28px rgba(245,197,24,0.55); }
}
.sc-tag-row {
  display: flex; align-items: stretch; gap: 0;
  flex-shrink: 0; width: 100%;
  border-radius: var(--radius) var(--radius) 0 0;
}
.sc-tag {
  font-size: 0.67rem; font-weight: 600; line-height: 1;
  padding: 4px 8px; white-space: nowrap;
  display: flex; align-items: center;
  border-right: 1px solid rgba(0,0,0,0.25);
  border-radius: 0 0 8px 0;
  margin-left: -5px;
  padding-left: 12px;
  position: relative;
}
.sc-tag:first-child { margin-left: 0; z-index: 4; }
.sc-tag:nth-child(2) { z-index: 3; }
.sc-tag:nth-child(3) { z-index: 2; }
.sc-tag:nth-child(4) { z-index: 1; }
.sc-tag:last-child   { z-index: 0; }
.sc-tag:last-child { border-right: none; border-radius: 0; }
.sc-tag-name   { font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; color: #e2e8f0; background: #1e2d3a; }
.sc-tag-stats  { background: #1c2530; color: rgba(255,255,255,0.45); font-size: 0.62rem; }
.sc-tag-round  { background: #202d3a; color: rgba(255,255,255,0.68); }
.sc-tag-round.round-pos { color: #4ade80; }
.sc-tag-round.round-neg { color: #f87171; }
.sc-tag-total  { background: #1e2a12; color: var(--gold); font-weight: 800; font-size: 0.78rem; border-right: none; }
.declare-badge { color: rgba(245,197,24,0.75); font-size: 0.7rem; font-weight: 400; margin-left: 4px; }
.sc-close-card { font-weight: 700; }
.score-total-pair { display: flex; gap: 8px; align-items: baseline; flex-shrink: 0; }
.score-row .round-pts { color: rgba(255,255,255,0.38); font-size: 0.75rem; }
.score-row .total-pts { color: var(--gold); font-weight: 800; min-width: 40px; text-align: right; font-size: 1.05rem; }
/* Breakdown baris: chips */
.score-breakdown { display: flex; gap: 4px; flex-wrap: nowrap; align-items: center; overflow-x: auto; scrollbar-width: none; padding: 0 14px; }
.score-breakdown::-webkit-scrollbar { display: none; }
.sc-part { font-size: 0.67rem; padding: 2px 7px; border-radius: 20px; font-weight: 500; flex-shrink: 0; white-space: nowrap; }
.sc-part.pos { background: rgba(100,210,100,0.13); color: #7ed87e; }
.sc-part.neg { background: rgba(220,80,80,0.13);  color: #f08080; }
.sc-part.pen { background: rgba(200,100,50,0.13);  color: #e8a870; }
.sc-part.sc-declare { background: rgba(245,197,24,0.14); color: rgba(245,197,24,0.9); }
.sc-stats { font-size: 0.64rem; color: rgba(255,255,255,0.28); white-space: nowrap; flex-shrink: 0; }
/* Mini cards — melds grouped */
.score-cards-row { margin: 0 14px 4px; }
.score-hand-cards {
  display: flex; flex-wrap: wrap; gap: 3px; padding: 4px 0 2px;
}
.score-hand-group {
  display: flex; flex-wrap: wrap; gap: 4px;
  padding: 4px 8px; border-radius: 8px; margin-top: 4px;
}
.score-hand-plus  { border: 1.5px solid rgba(100,210,100,0.55); background: rgba(100,210,100,0.06); }
.score-hand-minus { border: 1.5px solid rgba(220,80,80,0.55);  background: rgba(220,80,80,0.06); }
.score-meld-inner { display: flex; flex-wrap: wrap; gap: 2px; }
.score-meld-inner + .score-meld-inner { margin-left: 0; padding-left: 0; border-left: none; }

/* Kartu tersisa lawan terungkap di arena saat ronde selesai */
.opp-hand-reveal {
  display: flex; flex-wrap: wrap; gap: 3px;
  flex-basis: 100%;           /* force to new row inside side-meld-panel */
  margin-top: 4px;
  padding: 2px 2px;
  border-radius: 6px;
  border: 1px dashed rgba(255,255,255,0.28);
  background: rgba(0,0,0,0.22);
}
.opp-hand-reveal .card-sm {
  opacity: 0.92;
  animation: revealCard 0.3s ease both;
}
@keyframes revealCard {
  from { transform: rotateY(90deg) scale(0.85); opacity: 0; }
  to   { transform: rotateY(0deg)  scale(1);    opacity: 0.92; }
}

/* Kartu tersisa di tangan saat ronde berakhir */
.score-hand-section { margin-top: 6px; }
.score-hand-label {
  font-size: 0.64rem; color: rgba(255,255,255,0.38);
  text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 4px;
}
.score-hand-cards-row { display: flex; flex-wrap: wrap; gap: 4px; }
.score-hand-cards-row .hand-card-valid {
  box-shadow: 0 0 0 2px rgba(100,210,100,0.7), var(--card-shadow);
}
.score-hand-cards-row .hand-card-invalid {
  box-shadow: 0 0 0 2px rgba(220,70,70,0.7), var(--card-shadow);
  opacity: 0.85;
}
.scores-actions {
  display: flex; gap: 0; justify-content: stretch; flex-wrap: nowrap;
  flex-shrink: 0;
  padding: 0;
  margin: 16px -36px 0;
  border-top: 1px solid rgba(255,255,255,0.1);
  background: rgba(0,0,0,0.18);
  border-radius: 0 0 24px 24px;
  overflow: hidden;
}
.scores-actions .btn {
  flex: 1;
  border-radius: 0;
  margin: 0;
  border: none;
  border-right: 1px solid rgba(255,255,255,0.08);
  padding: 14px 8px;
}
.scores-actions .btn:last-child { border-right: none; }
.btn-ghost {
  background: transparent;
  border: 1.5px solid rgba(255,255,255,0.22);
  color: rgba(255,255,255,0.6);
  font-size: 0.85rem;
  padding: 8px 16px; border-radius: 10px; cursor: pointer;
  transition: border-color 0.18s, color 0.18s, background 0.18s;
  font-family: var(--font-ui); font-weight: 600;
}
.btn-ghost:hover { border-color: rgba(255,255,255,0.5); color: #fff; background: rgba(255,255,255,0.06); }

/* ===== ACTIVE PLAYER HIGHLIGHT ===== */
.opponent-slot.active-turn {
  border-color: rgba(245,197,24,0.65);
  background: rgba(245,197,24,0.07);
  box-shadow: 0 0 28px rgba(245,197,24,0.22), inset 0 0 16px rgba(245,197,24,0.05);
}
.opponent-slot.active-turn .opp-avatar {
  border-color: var(--gold);
  box-shadow: 0 0 14px rgba(245,197,24,0.55);
}
/* Glow ring */
.opponent-slot.active-turn::after {
  content: ''; position: absolute; inset: -2px;
  border-radius: 18px;
  border: 1.5px solid rgba(245,197,24,0.6);
  animation: glowRing 1.6s ease-in-out infinite;
  pointer-events: none;
}
@keyframes glowRing {
  0%, 100% { opacity: 0.9; box-shadow: 0 0 10px var(--gold-glow); }
  50%       { opacity: 0.25; box-shadow: 0 0 26px var(--gold-glow); }
}

.my-area.my-turn-active {
  border-top-color: var(--gold);
  box-shadow: inset 0 2px 32px rgba(245,197,24,0.09);
}

/* ===== ANIMATIONS ===== */
/* Deal flip (face-down → face-up) */
@keyframes cardFlip {
  0%   { transform: rotateY(90deg) scale(0.88); opacity: 0; }
  65%  { transform: rotateY(-6deg) scale(1.02); opacity: 1; }
  100% { transform: rotateY(0deg)  scale(1);    opacity: 1; }
}
.card.deal-flip {
  animation: cardFlip 0.38s cubic-bezier(0.34,1.56,0.64,1) both;
}

/* Simple slide-in for non-flip contexts */
@keyframes dealIn {
  from { opacity: 0; transform: translateY(-28px) scale(0.86); }
  to   { opacity: 1; transform: translateY(0)     scale(1);    }
}
.card.deal-anim { animation: dealIn 0.28s cubic-bezier(0.34,1.56,0.64,1) forwards; }

/* Error shake for invalid actions — uses standalone `translate` to compose with .selected's transform */
@keyframes cardShake {
  0%   { translate: 0px 0;  box-shadow: var(--card-shadow); }
  12%  { translate: -8px 0; box-shadow: 0 0 14px 4px rgba(220,38,38,0.65); }
  25%  { translate: 7px 0;  box-shadow: 0 0 10px 3px rgba(220,38,38,0.5); }
  38%  { translate: -6px 0; box-shadow: 0 0 8px 2px rgba(220,38,38,0.4); }
  50%  { translate: 5px 0;  box-shadow: 0 0 6px 2px rgba(220,38,38,0.3); }
  63%  { translate: -3px 0; }
  75%  { translate: 2px 0; }
  100% { translate: 0px 0;  box-shadow: var(--card-shadow); }
}
.card.shake-error {
  animation: cardShake 0.5s cubic-bezier(0.36,0.07,0.19,0.97) !important;
}

/* Tada: celebrate on declare (css-animation-creator: tada) */
@keyframes cardTada {
  0%         { transform: scale(1) rotate(0); }
  10%, 20%   { transform: scale(0.9) rotate(-3deg); }
  30%, 50%, 70%, 90% { transform: scale(1.1) rotate(3deg); }
  40%, 60%, 80%      { transform: scale(1.1) rotate(-3deg); }
  100%       { transform: scale(1) rotate(0); }
}
.card.tada {
  animation: cardTada 0.6s ease !important;
  z-index: 60 !important;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}
.score-row { animation: slideUp 0.28s ease forwards; }

/* ── DRAW REVEAL (animasi kartu yang baru diambil) ── */
.draw-reveal-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.draw-reveal-card {
  filter: drop-shadow(0 8px 24px rgba(0,0,0,0.55));
  animation: drawRevealIn 1.7s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes drawRevealIn {
  0%   { opacity: 0; transform: translateY(-80px) scale(0.45) rotateY(90deg); }
  22%  { opacity: 1; transform: translateY(0)     scale(1.18) rotateY(0deg); }
  55%  { opacity: 1; transform: translateY(0)     scale(1.05) rotateY(0deg); }
  80%  { opacity: 1; transform: translateY(0)     scale(1.0)  rotateY(0deg); }
  100% { opacity: 0; transform: translateY(50px)  scale(0.75) rotateY(0deg); }
}

/* Kartu baru di tangan — kilatan emas singkat */
@keyframes newCardGlow {
  0%   { box-shadow: 0 0 0   0px rgba(245,197,24,0.0), var(--card-shadow); }
  20%  { box-shadow: 0 0 28px 10px rgba(245,197,24,0.75), var(--card-shadow-hover); }
  70%  { box-shadow: 0 0 14px 4px  rgba(245,197,24,0.4),  var(--card-shadow); }
  100% { box-shadow: var(--card-shadow); }
}
.card.new-card {
  animation: newCardGlow 1.6s ease-out forwards !important;
  z-index: 55 !important;
}

/* Kartu wajib dipakai dalam kombinasi — glow emas berulang */
@keyframes requiredCardPulse {
  0%, 100% { box-shadow: 0 0 10px 3px rgba(245,197,24,0.55), var(--card-shadow); outline-color: rgba(245,197,24,0.7); }
  50%       { box-shadow: 0 0 28px 10px rgba(245,197,24,0.9), var(--card-shadow-hover); outline-color: var(--gold); }
}
.card.required-card {
  outline: 2.5px solid var(--gold);
  animation: requiredCardPulse 1.1s ease-in-out infinite !important;
  z-index: 56 !important;
}

/* ===== DEAL ANIMATION — flying cards (arc + rotation via Web Animations API) ===== */
.deal-anim-card {
  position: fixed;
  pointer-events: none;
  z-index: 9999;
  width: var(--card-w);
  height: var(--card-h);
  border-radius: var(--card-radius);
  background-color: var(--ink);
  background-image: repeating-linear-gradient(45deg, rgba(232,80,42,.45) 0 4px, transparent 4px 8px);
  border: 2px solid var(--coral);
  will-change: transform, opacity;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 600px) {
  /* Lock body scroll — prevent background showing when page overscrolls */
  html, body {
    overflow: hidden !important;
    height: 100svh !important;
    overscroll-behavior: none !important;
  }

  /* ── Tokens ── */
  :root {
    --card-w:    50px; --card-h:    72px;
    --card-sm-w: 34px; --card-sm-h: 48px;
  }

  /* ── Typography ── */
  .card     { font-size: 8.5px; }
  .card-sm  { font-size: 7.5px; }

  /* ── Header ── */
  .game-header  { font-size: 0.7rem; padding: 4px 8px; gap: 4px; }
  .joker-info   { font-size: 0.68rem; gap: 3px; }
  .joker-ref-card { display: none; }
  .header-center { gap: 4px; }
  .round-info   { font-size: 0.68rem; }
  .turn-info    { font-size: 0.7rem; padding: 2px 8px; max-width: 180px; }
  .timer-seconds { font-size: 0.9rem; }
  .timer-wrapper { min-width: 54px; gap: 2px; }
  .timer-bar-track { width: 50px; height: 4px; }
  .btn-mute     { font-size: 0.92rem; padding: 4px; }

  /* ── Opponents ── */
  .opp-avatar { width: 34px; height: 34px; }
  .opp-avatar::before { font-size: 0.85rem; }
  .opp-card-badge { width: 16px; height: 16px; font-size: 0.6rem; top: -4px; right: -4px; }
  .opponents-area { padding: 5px 5px 3px; gap: 3px; }
  .side-opponents { gap: 4px; align-items: flex-start; }

  /* Side pods: ubah margin-top untuk atur jarak dari atas */
  #opp-left, #opp-right {
    flex: 0 0 auto;
    min-width: 0;
    max-width: 140px;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 6px;
    padding: 5px 8px;
    align-self: flex-start;
    margin-top: 15vh; /* ← ubah nilai ini */
  }
  #opp-left .opp-name, #opp-right .opp-name {
    font-size: 0.6rem; text-align: center; max-width: 80px;
  }
  #opp-left .opp-score, #opp-right .opp-score {
    font-size: 0.54rem; text-align: center;
  }
  #opp-left .opp-cards, #opp-right .opp-cards { display: none; }

  /* Side melds: tighter sizing on mobile */
  #opp-left-melds, #opp-right-melds {
    top: calc(100% + 4px);
    max-width: 160px;
    padding: 0px 2px;
    z-index: 15;
  }
  #opp-left-melds .meld-group, #opp-right-melds .meld-group {
    padding: 2px 3px;
  }
  #opp-left-melds .card-sm, #opp-right-melds .card-sm { width: 24px; height: 34px; font-size: 5.5px; }

  .opp-top-meld-strip .card-sm { width: 28px; height: 40px; }

  /* ── Center area ── */
  .center-area  { gap: 8px; align-items: center; padding-top: 150px; }
  .card-piles   {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    justify-items: center;
  }
  /* Discard (3rd item) spans both columns, centered */
  .card-piles .pile-wrapper:nth-child(3) {
    grid-column: 1 / -1;
    justify-self: center;
  }
  .joker-ref-pile { width: 60px; height: 85px; }
  .joker-ref-chip { gap: 4px; }
  .joker-chip-label { font-size: 0.54rem; }
  .card-pile    { width: 60px; height: 85px; }
  .discard-pile { width: var(--card-w); height: var(--card-h); }
  .pile-label   { font-size: 0.6rem; }
  .pile-count   { font-size: 0.6rem; }

  /* ── My area ── */
  .my-area      { padding: 6px 10px 10px; }
  .my-info      { font-size: 0.72rem; }
  .my-hand      { padding: 20px 6px 6px; min-height: 105px; }
  .card-hit-zone { margin-left: -16px; }
  .selected-info { font-size: 0.78rem; gap: 4px; flex-wrap: wrap; }
  .btn-sm       { font-size: 0.74rem; padding: 5px 8px; }
  #action-hint  { font-size: 0.7rem; }

  /* ── Meld area ── */
  .my-melds-area { padding: 0 8px; }
  .melds-label   { font-size: 0.68rem; }
  .meld-group    { gap: 2px; }
  .meld-dropzone-hint { font-size: 0.7rem; }
  .lobby-brand   { flex: none; padding: 32px 24px 20px; gap: 16px; }
  .lobby-brand::before { display: none; }
  .lobby-brand::after  { display: none; }
  .brand-title   { font-size: 2.1rem; }
  .brand-deco    { display: none; }

  /* ── Lobby ── */
  .lobby-wrap    { flex-direction: column; }
  .lobby-panel   { flex: none; padding: 24px 18px 32px; box-shadow: 0 -1px 0 rgba(245,197,24,0.1); }
  .settings-card { padding: 14px 14px; }
  .lp-header h2  { font-size: 1.1rem; }
  .brand-stats   { gap: 0; }
  .brand-stat    { padding: 0 16px; }
  .bs-num        { font-size: 1.3rem; }

  /* ── Waiting / Scores ── */
  .waiting-container { padding: 24px 16px; }
  .scores-container  { padding: 24px 16px 0; }
  .player-slots { gap: 8px; }
  .player-slot  { padding: 8px 10px; }
  .slot-avatar  { width: 34px; height: 34px; font-size: 1.1rem; }

  /* ── Scores ── */
  .score-row { padding: 0 0 10px; font-size: 0.86rem; }
  .score-breakdown { padding: 0 12px; }
  .score-cards-row { padding: 0 12px; }
  .score-row .total-pts { font-size: 0.92rem; width: 60px; }
  .score-row .round-pts { width: 60px; }

  /* ── Dropzone ── */
  .meld-dropzone { font-size: 0.8rem; padding: 8px 14px; }
}

/* ── Extra small (≤380px) ── */
@media (max-width: 380px) {
  :root { --card-w: 44px; --card-h: 63px; --card-sm-w: 30px; --card-sm-h: 42px; }
  #opp-left, #opp-right { grid-template-columns: 30px 1fr; }
  #opp-left .opp-avatar, #opp-right .opp-avatar { width: 30px; height: 30px; }
  #opp-left .opp-avatar::before, #opp-right .opp-avatar::before { font-size: 0.75rem; }
  #opp-left-melds .card-sm, #opp-right-melds .card-sm { width: 20px; height: 28px; font-size: 4.5px; }
  .card-hit-zone { margin-left: -18px; }
  .game-header { font-size: 0.66rem; padding: 5px 6px; }
  .timer-seconds { font-size: 0.96rem; }
  .opp-top-meld-strip .card-sm { width: 24px; height: 34px; }
  .joker-ref-pile { width: 50px; height: 72px; }
}

@media (min-width: 900px) {
  :root { --card-w: 68px; --card-h: 96px; --card-sm-w: 44px; --card-sm-h: 62px; }
  .card-rank { font-size: 1.35rem; }
  .card-suit { font-size: 1.6rem; }
  .my-hand { padding: 36px 14px 12px; min-height: 134px; }
  /* Pin side pods to top corners of opponents-area (position:relative ancestor) */
  #opp-left, #opp-right {
    position: absolute;
    top: 10px;
    display: flex; flex-direction: column;
    width: 130px;
    z-index: 5;
  }
  #opp-left  { left: 10px; }
  #opp-right { right: 10px; }
  /* padding-left/right: keep center-area clear of absolute pods
     padding-top: push center-area down to give room for opp-top meld strip */
  .side-opponents { padding: 90px 145px 0; }
  .opp-avatar { width: 72px; height: 72px; }
  .opp-avatar::before { font-size: 1.8rem; }
  .opp-name { font-size: 0.92rem; }
  .opp-score { font-size: 0.8rem; }
  #opp-top .opp-name { font-size: 1rem; max-width: 200px; }
  #opp-top .opp-score { font-size: 0.82rem; }
  .card-pile    { width: 86px; height: 122px; }
  .joker-ref-pile { width: 86px; height: 122px; }
  .discard-pile { width: var(--card-w); height: var(--card-h); }
  .card-hit-zone { margin-left: -20px; }
  .side-meld-panel { padding: 8px 10px; gap: 5px; }
  /* Opp meld cards — card size fixed, font bigger */
  #opp-left-melds .card-sm, #opp-right-melds .card-sm { width: 34px; height: 48px; font-size: 13px; }
  #opp-left-melds .card-sm .card-rank, #opp-right-melds .card-sm .card-rank { font-size: 1em; line-height: 1; }
  #opp-left-melds .card-sm .card-suit, #opp-right-melds .card-sm .card-suit { font-size: 1.1em; line-height: 1; }
  .opp-top-meld-strip .card-sm { width: 34px; height: 48px; font-size: 13px; }
  .opp-top-meld-strip .card-sm .card-rank { font-size: 1em; line-height: 1; }
  .opp-top-meld-strip .card-sm .card-suit { font-size: 1.1em; line-height: 1; }
  .opp-top-meld-strip { max-width: 500px; }

  /* Lobby on wide screen */
  .lobby-panel { flex: 0 0 440px; }
}

/* ===== ACCESSIBILITY: Reduced Motion ===== */
/* css-animation-creator skill: always honor 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;
  }
  /* Keep visibility transitions (not motion) for usability */
  .toast { transition: opacity 0.15ms !important; }
  .my-hand .card { will-change: auto; }
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: rgba(0,0,0,0.2); }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.14); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.24); }

/* ===== MOBILE ENHANCEMENTS ===== */
/* Extends/overrides the base 600px block above for better mobile UX */

@media (max-width: 600px) {
  /* ── Lobby: compact brand so form is visible without scroll ── */
  .brand-tagline { display: none; }
  .brand-suits   { display: none; }
  .brand-stats   { display: none; }
  .lobby-brand   { padding: 14px 20px 10px; gap: 6px; }
  .brand-title   { font-size: 2rem; }
  .brand-aka     { margin-top: 4px; }
  .lobby-bg-suit { font-size: 160px; bottom: -50px; right: -20px; }
  /* Panel fills remaining viewport height */
  .lobby-panel   { flex: 1 1 auto; min-height: 0; }
  .lobby-wrap    { min-height: 100vh; }

  /* ── Game header: allow wrapping so turn info gets its own row ── */
  .game-header   { flex-wrap: wrap; min-height: auto; padding: 4px 10px; row-gap: 2px; }
  .joker-info    { order: 1; flex-shrink: 0; }
  .timer-wrapper { order: 2; flex-shrink: 0; margin-left: auto; }
  .btn-mute      { order: 3; flex-shrink: 0; }
  .btn-show-scores { order: 4; flex-shrink: 0; }
  .header-center {
    order: 5;
    flex: 1 1 100%;          /* full-width second row */
    justify-content: center;
    padding: 1px 0 3px;
    border-top: 1px solid rgba(255,255,255,0.05);
  }
  .turn-info { max-width: 100%; width: 100%; text-align: center; }

  /* Top meld strip: scrollable if many melds */
  .opp-top-meld-strip { max-width: 86vw; overflow-x: auto; }

  /* ── Center area: ensure it fills the space between side pods ── */
  .center-area { flex: 1; justify-content: space-evenly; gap: 6px; }
  .joker-ref-chip { gap: 3px; }
  .joker-chip-label { font-size: 0.5rem; }

  /* ── My area: more breathing room ── */
  .my-info { flex-wrap: wrap; gap: 6px; }
  .my-name  { flex-shrink: 0; }
  .my-score { flex-shrink: 0; }
  .declare-bar     { flex: 1 1 100%; order: 9; margin-left: 0; }
  .return-discard-bar { flex: 1 1 100%; order: 8; margin-left: 0; }
  .declare-bar .btn-gold { width: 100%; justify-content: center; display: flex; }

  /* Fixed info overlays: reposition so they sit above hand without overlapping */
  .selected-info {
    left: 8px; right: 8px; bottom: 155px;
    width: auto; border-radius: 10px;
    justify-content: center; text-align: center;
    font-size: 0.76rem;
  }
  .action-hint { font-size: 0.74rem; max-width: 180px; }
  .action-hint:not(:empty) { max-width: 180px; }

  /* Meld area: horizontal scroll, no wrap */
  .my-melds-area { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .melds-container { flex-wrap: nowrap; min-width: max-content; }

  /* ── Score overlay ── */
  #screen-scores { padding: 0; }
  .scores-container {
    width: calc(100% - 24px);
    max-width: 100%;
    padding: 20px 12px 0;
    border-radius: 16px;
    max-height: 92vh;
  }
  .scores-container h2 { font-size: 1.3rem; margin-bottom: 14px; }
  .score-breakdown { gap: 4px; flex-wrap: wrap; }
  .sc-part { font-size: 0.65rem; padding: 2px 5px; }
  .scores-actions { margin: 16px -12px 0; border-radius: 0 0 16px 16px; }
  .scores-actions .btn { font-size: 0.82rem; padding: 13px 6px; }

  /* ── Popup ── */
  .popup-content {
    padding: 22px 16px;
    width: calc(100% - 32px);
    max-width: 100%;
    border-radius: 16px;
  }
  .popup-actions .btn { padding: 10px 10px; min-width: 70px; font-size: 0.82rem; }

  /* ── Touch targets ── */
  .btn-sm    { min-height: 40px; }
  .btn-small { padding: 8px 12px; font-size: 0.82rem; }

  /* ── Toast: below header ── */
  .toast { top: 64px; font-size: 0.82rem; padding: 8px 18px; }
}

/* ── Very small phones (≤380px) additions ── */
@media (max-width: 380px) {
  .lobby-brand { padding: 10px 16px 8px; }
  .brand-title { font-size: 1.7rem; }
  .brand-aka-text { font-size: 0.9rem; }

  /* Game header: shrink further */
  .joker-info { font-size: 0.62rem; }
  #joker-rank-display { padding: 1px 4px; font-size: 0.78rem; }
  .round-info { font-size: 0.62rem; }
  .turn-info  { font-size: 0.65rem; padding: 2px 6px; }
  .timer-seconds { font-size: 0.82rem; min-width: 22px; }
  .timer-bar-track { width: 40px; }

  /* Fixed overlays */
  .selected-info { bottom: 140px; font-size: 0.72rem; }
  .action-hint   { font-size: 0.72rem; }

  /* Scores */
  .scores-container { padding: 16px 10px 0; }
  .score-breakdown { gap: 3px; }
  .scores-actions { margin: 16px -10px 0; border-radius: 0 0 16px 16px; }
  .scores-actions .btn { font-size: 0.78rem; padding: 12px 4px; }
  .scores-actions .btn { font-size: 0.78rem; padding: 9px 6px; }
}

/* ===== HISTORY PANEL ===== */
.btn-show-history {
  background: none;
  border: none;
  color: rgba(255,255,255,0.75);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
  line-height: 1;
}
.btn-show-history:hover { background: rgba(255,255,255,0.12); color: #fff; }

.history-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 320px;
  max-width: 92vw;
  height: 100vh;
  background: #0d2a14;
  border-left: 1px solid rgba(255,255,255,0.08);
  z-index: 800;
  display: flex;
  flex-direction: column;
  box-shadow: -4px 0 24px rgba(0,0,0,0.5);
  transform: translateX(0);
  transition: transform 0.25s cubic-bezier(0.4,0,0.2,1);
}
.history-panel.hidden {
  display: none;
}

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}
.history-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--gold);
  letter-spacing: 0.03em;
}
.btn-close-history {
  background: none;
  border: none;
  color: rgba(255,255,255,0.6);
  font-size: 1rem;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: background 0.15s;
}
.btn-close-history:hover { background: rgba(255,255,255,0.1); color: #fff; }

.history-log {
  flex: 1;
  overflow-y: auto;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.history-log::-webkit-scrollbar { width: 4px; }
.history-log::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }


.hlog-empty {
  color: rgba(255,255,255,0.35);
  font-size: 0.8rem;
  padding: 8px 4px;
  text-align: center;
}
.hlog-entry {
  font-size: 0.78rem;
  line-height: 1.5;
  padding: 6px 10px;
  border-radius: 6px;
  background: rgba(255,255,255,0.04);
  color: rgba(255,255,255,0.8);
  border-left: 3px solid transparent;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.hlog-desc {
  flex: 1;
  min-width: 0;
}
.hlog-cards {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 3px;
  max-width: 108px;
  font-size: 0.88rem;
  font-weight: 700;
  line-height: 1.4;
}
.hlog-cards-dd { flex-direction: column; align-items: flex-end; gap: 2px; }
.hlog-card-pair {
  display: flex; flex-direction: column; align-items: flex-end;
  font-size: 0.84rem; font-weight: 700; line-height: 1.3;
}
.hlog-co-name {
  font-size: 0.66rem;
  font-weight: 400;
  color: rgba(255,179,0,0.85);
  font-style: italic;
}

.hlog-hidden-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 10px;
  margin-top: 2px;
  background: rgba(255,255,255,0.03);
  border-radius: 6px;
  border: 1px dashed rgba(255,255,255,0.14);
  font-size: 0.73rem;
  color: #fff;
  font-style: italic;
}
.hlog-hidden-count {
  font-style: normal;
  font-weight: 600;
  color: rgba(245,197,24);
  font-size: 0.8rem;
}
.hlog-entry.hlog-round-start {
  background: rgba(245,197,24,0.12);
  border-left-color: var(--gold);
  color: var(--gold);
  font-weight: 600;
  margin-top: 8px;
}
.hlog-entry.hlog-draw-stock  { border-left-color: #4db6ac; }
.hlog-entry.hlog-draw-discard { border-left-color: #ffb300; }
.hlog-entry.hlog-meld         { border-left-color: #81c784; }
.hlog-entry.hlog-discard      { border-left-color: rgba(255,255,255,0.25); }
.hlog-entry.hlog-close {
  background: rgba(129,199,132,0.12);
  border-left-color: #81c784;
  font-weight: 600;
}
.hlog-entry.hlog-round-end {
  background: rgba(255,255,255,0.06);
  border-left-color: rgba(255,255,255,0.3);
  margin-bottom: 8px;
  flex-direction: column;
}
.hlog-entry.hlog-steal-penalty { border-left-color: #e57373; color: #ef9a9a; }

/* round_start timestamp */
.hlog-time {
  font-size: 0.68rem;
  color: rgba(255,255,255,0.4);
  margin-right: 6px;
}
.hlog-joker {
  background: rgba(245,197,24,0.2);
  padding: 1px 5px;
  border-radius: 4px;
  color: var(--gold);
}
/* Icons */
.hlog-icon { margin-right: 5px; }
/* Meld type label */
.hlog-meld-type {
  font-size: 0.7rem;
  font-weight: 700;
  background: rgba(129,199,132,0.18);
  color: #a5d6a7;
  padding: 1px 5px;
  border-radius: 4px;
  vertical-align: middle;
}
/* Steal/karma */
.hlog-steal { color: #ffb300; font-style: italic; }
.hlog-karma {
  margin-top: 3px;
  font-size: 0.72rem;
  color: #e57373;
}
/* Bonus */
.hlog-bonus { color: #81c784; font-weight: 700; }
/* Joker penalty */
.hlog-penalty { color: #ef9a9a; font-size: 0.72rem; }
/* Round end score grid */
.hlog-round-end-title {
  font-weight: 700;
  font-size: 0.75rem;
  color: rgba(255,255,255,0.6);
  margin-bottom: 5px;
}
.hlog-score-grid {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 100%;
}
.hlog-score-row {
  display: grid;
  grid-template-columns: 1fr 44px 60px;
  align-items: center;
  gap: 0 6px;
  font-size: 0.76rem;
  width: 100%;
}
.hlog-score-name {
  color: rgba(255,255,255,0.85);
  font-weight: 600;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: left;
  white-space: nowrap;
}
.hlog-score-pos { color: #81c784; font-weight: 700; text-align: right; }
.hlog-score-neg { color: #ef9a9a; font-weight: 700; text-align: right; }
.hlog-score-total { color: rgba(255,255,255,0.4); font-size: 0.7rem; text-align: right; }
.hlog-declare-tag { font-size: 0.68rem; font-weight: 400; color: rgba(245,197,24,0.75); margin-left: 4px; }
.hlog-round-stats {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 4px 0;
  margin-top: 8px; padding-top: 7px;
  border-top: 1px solid rgba(255,255,255,0.08);
  width: 100%;
}
.hlog-rstat {
  font-size: 0.7rem; color: rgba(255,255,255,0.45);
}
.hlog-rstat:nth-child(2) { text-align: center; }
.hlog-rstat:nth-child(3) { text-align: right; }
.hlog-rstat strong { color: rgba(255,255,255,0.8); font-weight: 600; }
.hlog-suit-red  { color: #e57373; }
.hlog-suit-black{ color: #ccc; }

/* Ronde lampau: accordion collapsed */
.hlog-accordion { margin-bottom: 4px; }
.hlog-accordion-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 0.78rem;
  color: rgba(255,255,255,0.7);
  background: rgba(255,255,255,0.05);
  border-radius: 4px;
  user-select: none;
  border-left: 3px solid rgba(245,197,24,0.4);
}
.hlog-accordion-header:hover { background: rgba(255,255,255,0.09); }
.hlog-acc-toggle { font-size: 0.6rem; color: rgba(255,255,255,0.35); flex-shrink: 0; }
.hlog-acc-count  { margin-left: auto; font-size: 0.7rem; color: rgba(255,255,255,0.3); }
.hlog-accordion-body { overflow: hidden; }
.hlog-accordion.collapsed .hlog-accordion-body { display: none; }

@media (max-width: 600px) {
  .history-panel { width: 100vw; max-width: 100vw; }
}

/* ===== HOW TO PLAY ===== */
.btn-how-to-play {
  background: none;
  border: 1px solid rgba(255,255,255,0.3);
  color: rgba(255,255,255,0.75);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  padding: 2px 8px;
  border-radius: 50%;
  width: 26px;
  height: 26px;
  line-height: 1;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.btn-how-to-play:hover { background: rgba(255,255,255,0.15); color: #fff; border-color: rgba(255,255,255,0.6); }

.htp-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  backdrop-filter: blur(2px);
}
.htp-overlay.hidden { display: none; }

.htp-box {
  background: #0d2a14;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 14px;
  width: 100%;
  max-width: 560px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 60px rgba(0,0,0,0.6);
  overflow: hidden;
}

.htp-header {
  display: flex;
  flex-direction: column;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
  padding: 0;
}
.htp-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px 12px;
}
.htp-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 0.02em;
}
.btn-close-htp {
  background: none;
  border: none;
  color: rgba(255,255,255,0.55);
  font-size: 1rem;
  cursor: pointer;
  padding: 3px 8px;
  border-radius: 6px;
  transition: background 0.15s;
}
.btn-close-htp:hover { background: rgba(255,255,255,0.1); color: #fff; }

.htp-body {
  overflow-y: auto;
  padding: 16px 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  font-size: 0.83rem;
  line-height: 1.6;
  color: rgba(255,255,255,0.82);
}
.htp-body::-webkit-scrollbar { width: 4px; }
.htp-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }

.htp-section { display: flex; flex-direction: column; gap: 8px; }
.htp-section-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: #fff;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.htp-body ul, .htp-body ol { padding-left: 18px; display: flex; flex-direction: column; gap: 4px; }
.htp-body p { margin: 0; }

.htp-meld-grid {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.htp-meld-item {
  display: flex;
  gap: 10px;
  background: rgba(255,255,255,0.04);
  border-radius: 6px;
  padding: 6px 10px;
  align-items: baseline;
}
.htp-meld-name {
  font-weight: 600;
  color: #fff;
  min-width: 80px;
  flex-shrink: 0;
  font-size: 0.8rem;
}
.htp-meld-desc { color: rgba(255,255,255,0.7); font-size: 0.78rem; }

.htp-bonus-grid {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
}
.htp-bonus-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: rgba(255,255,255,0.06);
  border-radius: 8px;
  padding: 8px 14px;
  flex: 1;
  min-width: 60px;
}
.htp-bonus-card { font-size: 0.75rem; color: rgba(255,255,255,0.6); }
.htp-bonus-val  { font-size: 1rem; font-weight: 700; color: #81c784; }
.htp-red { color: #ef9a9a; }

/* ── Two-panel layout ── */
.htp-box { max-width: 1100px; width: min(1100px, 96vw); }

.htp-body {
  display: flex;
  flex-direction: row;
  padding: 0;
  gap: 0;
  overflow: hidden;
  flex: 1;
  min-height: 0;
}

.htp-left {
  flex: 1;
  width: 100%;
  min-width: 0;
  flex-shrink: 1;
  overflow-y: auto;
  padding: 14px 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  border-right: none;
  font-size: 0.8rem;
  color: rgba(255,255,255,0.82);
}
.htp-left::-webkit-scrollbar { width: 3px; }
.htp-left::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 2px; }

.htp-right {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: rgba(0,0,0,0.22);
  min-width: 0;
  overflow-y: auto;
  overflow-x: hidden;
}
.htp-right::-webkit-scrollbar { width: 3px; }
.htp-right::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 2px; }

/* ── Demo tabs ── */
.demo-tabs {
  display: flex;
  gap: 3px;
  padding: 10px 12px 0;
  background: rgba(0,0,0,0.15);
  border-bottom: 1px solid rgba(255,255,255,0.07);
  flex-shrink: 0;
}
.demo-tab {
  padding: 6px 13px;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.1);
  border-bottom: none;
  border-radius: 7px 7px 0 0;
  color: rgba(255,255,255,0.45);
  font-size: 0.75rem;
  cursor: pointer;
  transition: color 0.18s, background 0.18s;
  font-family: 'Inter', sans-serif;
}
.demo-tab.active  { background: rgba(255,255,255,0.09); color: #f5c518; border-color: rgba(255,255,255,0.18); }
.demo-tab:hover:not(.active) { color: rgba(255,255,255,0.75); background: rgba(255,255,255,0.05); }

/* ── Demo viewport ── */
.demo-viewport {
  flex: 1;
  min-height: 240px;
  position: relative;
  overflow: hidden;
}
.demo-scene {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: stretch;
}
.demo-scene.hidden { display: none; }

/* ── Game-like demo scene layout (matches actual game board) ── */
.dg-scene {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #1f6b2e;
}

/* Green felt top half: piles + meld zone */
.dg-board-top {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 10px 14px 8px;
  gap: 8px;
  overflow: hidden;
}

/* Piles row: joker | stock | discard (+ optional badge) */
.dg-piles-row {
  display: flex;
  align-items: flex-end;
  gap: 20px;
  justify-content: center;
  flex-shrink: 0;
}

/* Single pile column: card + labels */
.dg-pile-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

/* Uppercase label matching game's .pile-label */
.dg-pile-lbl {
  font-size: 0.58rem;
  color: rgba(255,255,255,0.35);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  margin-top: 8px;
  text-align: center;
}

.dg-pile-sublbl {
  font-size: 0.54rem;
  color: rgba(255,255,255,0.25);
  font-family: 'Inter', sans-serif;
  margin-top: 2px;
}

/* Stock pile with depth illusion (3 stacked backs) */
.dg-stock-wrap {
  position: relative;
  width: 52px;
  height: 66px;
  flex-shrink: 0;
}
.dg-stock-wrap .dc {
  position: absolute;
}
.dg-stock-wrap .dc:nth-child(1) { top: 4px; left: 4px; opacity: 0.3; }
.dg-stock-wrap .dc:nth-child(2) { top: 2px; left: 2px; opacity: 0.6; }
.dg-stock-wrap .dc:nth-child(3) { top: 0; left: 0; }

/* Count badge on stock — matching game's pill badge */
.dg-stock-badge {
  position: absolute;
  bottom: -9px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.58rem;
  color: rgba(255,255,255,0.6);
  background: rgba(0,0,0,0.62);
  padding: 1px 6px;
  border-radius: 9px;
  font-family: 'Inter', sans-serif;
  pointer-events: none;
  white-space: nowrap;
  z-index: 5;
}

/* Joker ref card: gold dashed border matching game's joker-ref-pile */
.dg-joker-card {
  border: 1.5px dashed rgba(245,197,24,0.65) !important;
  box-shadow: 0 0 12px rgba(245,197,24,0.22), 0 3px 10px rgba(0,0,0,0.45) !important;
}

/* Discard fan: 3 overlapping cards, fan spread right */
.dg-discard-fan {
  position: relative;
  width: 66px;
  height: 62px;
  flex-shrink: 0;
}
.dg-discard-fan .dc {
  position: absolute;
  top: 0;
  left: 11px;
  transform-origin: 50% 90%;
}
.dg-discard-fan .dc:nth-child(1) { transform: rotate(-12deg) translateX(-13px); opacity: 0.5; }
.dg-discard-fan .dc:nth-child(2) { transform: rotate(-5deg)  translateX(-6px);  opacity: 0.75; }
.dg-discard-fan .dc:nth-child(3) { transform: rotate(0deg); }

/* Combo type badge — standalone row between piles and meld zone */
.dg-combo-badge {
  text-align: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: #f5c518;
  font-family: 'Inter', sans-serif;
  align-self: center;
  padding: 3px 10px;
  background: rgba(0,0,0,0.22);
  border-radius: 5px;
  border: 1px solid rgba(245,197,24,0.2);
  white-space: nowrap;
  flex-shrink: 0;
}

/* Joker tab: ref panel + badge on same row */
.dg-joker-info-row {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Joker ref info box (joker tab) */
.dg-joker-ref-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 4px 8px 5px;
  background: rgba(0,0,0,0.22);
  border-radius: 6px;
  border: 1px solid rgba(245,197,24,0.25);
  flex-shrink: 0;
}
.dg-joker-ref-lbl {
  font-size: 0.55rem;
  color: rgba(245,197,24,0.75);
  font-family: 'Inter', sans-serif;
  font-weight: 700;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.dg-joker-ref-sublbl {
  font-size: 0.54rem;
  color: rgba(255,255,255,0.4);
  font-family: 'Inter', sans-serif;
  white-space: nowrap;
}

/* Meld zone inside board top (matching game table feel) */
.dg-meld-zone {
  flex: none;
  height: 72px;
  border: 2px dashed rgba(255,255,255,0.2);
  border-radius: 8px;
  background: rgba(0,0,0,0.18);
  padding: 6px 12px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Zone label cutout — bg matches felt */
.dg-zone-label {
  position: absolute;
  top: -8px;
  left: 12px;
  background: #1f6b2e;
  padding: 0 6px;
  font-size: 0.56rem;
  color: rgba(255,255,255,0.35);
  font-family: 'Inter', sans-serif;
  white-space: nowrap;
}

.dg-meld-cards {
  display: flex;
  gap: 5px;
  align-items: flex-end;
  justify-content: center;
  flex-wrap: wrap;
}

/* Gold separator matching game's my-turn-active gold border */
.dg-board-sep {
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(197,160,40,0.45) 20%, rgba(197,160,40,0.45) 80%, transparent);
  flex-shrink: 0;
}

/* Dark hand area matching game's .my-area gradient */
.dg-board-hand {
  flex-shrink: 0;
  background: linear-gradient(0deg, rgba(0,0,0,0.55) 0%, rgba(0,0,0,0.38) 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 6px 10px 8px;
}

/* "TANGAN KAMU" label — uppercase matching .my-info style */
.dg-board-hand-lbl {
  font-size: 0.56rem;
  color: rgba(255,255,255,0.28);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  align-self: flex-start;
}

.dg-hand {
  display: flex;
  gap: 5px;
  align-items: flex-end;
  flex-wrap: wrap;
  justify-content: center;
}

/* Joker card: gold on dark brown */
.dc.joker {
  background: linear-gradient(135deg, #5c3300, #7a4800);
  border-color: #f5c518;
  color: #f5c518;
  box-shadow: 0 0 10px rgba(245,197,24,0.45), 0 3px 10px rgba(0,0,0,0.45);
}

.demo-caption {
  padding: 10px 14px;
  font-size: 0.74rem;
  color: rgba(255,255,255,0.5);
  text-align: center;
  border-top: 1px solid rgba(255,255,255,0.06);
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-family: 'Inter', sans-serif;
}

/* ── Meld combo static reference ── */
.ds-combo-ref {
  border-top: 1px solid rgba(255,255,255,0.08);
  padding: 8px 14px 4px;
  flex: 0 0 auto;
  max-height: 280px;
  overflow-y: auto;
  background: rgba(0,0,0,0.18);
}
.ds-combo-ref::-webkit-scrollbar { width: 3px; }
.ds-combo-ref::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }
.ds-combo-ref-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 5px;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}
.ds-combo-col-lbl {
  flex: 1;
  text-align: center;
  font-size: 0.64rem;
  font-weight: 700;
  color: rgba(245,197,24,0.65);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-family: 'Inter', sans-serif;
}
.ds-combo-list { display: flex; flex-direction: column; gap: 6px; }
.ds-combo-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.ds-combo-name {
  font-size: 0.72rem;
  font-weight: 700;
  color: rgba(255,255,255,0.8);
  font-family: 'Inter', sans-serif;
  width: 74px;
  flex-shrink: 0;
}
.ds-combo-cards {
  display: flex;
  gap: 4px;
  align-items: flex-end;
  flex: 1;
}
.ds-combo-cards .dc {
  width: 28px;
  height: 40px;
  font-size: 0.8rem;
  padding: 2px 1px;
  gap: 1px;
}
.ds-combo-cards .dc .dc-rank { font-size: 0.9rem; }
.ds-combo-cards .dc .dc-suit { font-size: 1rem; }
.ds-combo-no-joker {
  flex: 1;
  font-size: 0.66rem;
  color: rgba(255,100,100,0.65);
  font-family: 'Inter', sans-serif;
  text-align: center;
}
.ds-combo-footer {
  display: flex;
  justify-content: center;
  padding: 8px 12px 6px;
  border-top: 1px solid rgba(255,255,255,0.06);
  margin-top: 4px;
}
.btn-combo-shuffle {
  padding: 6px 20px;
  background: rgba(245,197,24,0.1);
  border: 1.5px solid rgba(245,197,24,0.3);
  border-radius: 8px;
  color: rgba(245,197,24,0.85);
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  transition: background 0.18s, border-color 0.18s, transform 0.15s;
  letter-spacing: 0.02em;
}
.btn-combo-shuffle:hover {
  background: rgba(245,197,24,0.22);
  border-color: rgba(245,197,24,0.6);
  transform: scale(1.04);
}
.btn-combo-shuffle:active { transform: scale(0.96); }

/* ── Demo helper layout ── */
.demo-row        { display: flex; gap: 8px; align-items: center; }
.demo-hand-row   { display: flex; gap: 7px; align-items: flex-end; }
.demo-label      { font-size: 0.68rem; color: rgba(255,255,255,0.4); font-family: 'Inter', sans-serif; text-align: center; }
.demo-arrow-anim { color: rgba(255,255,255,0.35); font-size: 1.3rem; animation: demo-arrow-pulse 1.4s ease-in-out infinite; }
@keyframes demo-arrow-pulse {
  0%,100% { opacity: 0.25; transform: translateX(0); }
  50%      { opacity: 0.8;  transform: translateX(4px); }
}

.demo-stack {
  position: relative;
  width: 44px;
  height: 62px;
}
.demo-stack .dc { position: absolute; top: 0; left: 0; }
.demo-stack .dc:nth-child(1) { top: 4px; left: 4px; }
.demo-stack .dc:nth-child(2) { top: 2px; left: 2px; }
.demo-stack .dc:nth-child(3) { top: 0;   left: 0; }

.demo-table-area {
  background: rgba(31,107,46,0.28);
  border: 1px dashed rgba(255,255,255,0.15);
  border-radius: 10px;
  padding: 24px 16px 12px;
  display: flex;
  gap: 7px;
  align-items: center;
  justify-content: center;
  min-width: 180px;
  position: relative;
}
.demo-table-label {
  position: absolute;
  top: 6px;
  left: 0; right: 0;
  text-align: center;
  font-size: 0.65rem;
  color: rgba(255,255,255,0.35);
  font-family: 'Inter', sans-serif;
}

.demo-win-bubble {
  font-size: 1rem;
  font-weight: 700;
  color: #f5c518;
  background: rgba(245,197,24,0.12);
  border: 1px solid rgba(245,197,24,0.35);
  border-radius: 20px;
  padding: 8px 20px;
  opacity: 0;
  transform: scale(0.7) translateY(10px);
  transition: opacity 0.4s ease, transform 0.4s cubic-bezier(0.34,1.56,0.64,1);
  text-align: center;
  font-family: 'Cinzel', serif;
  letter-spacing: 0.04em;
}
.demo-win-bubble.show { opacity: 1; transform: scale(1) translateY(0); }

/* ── Demo cards (dc) ── */
.dc {
  width: 44px;
  height: 62px;
  background: #fff;
  border-radius: 6px;
  border: 1px solid rgba(0,0,0,0.12);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: 'Cinzel', serif;
  box-shadow: 0 3px 10px rgba(0,0,0,0.45);
  position: relative;
  flex-shrink: 0;
  backface-visibility: hidden;
  transition: transform 0.25s cubic-bezier(0.34,1.56,0.64,1),
              box-shadow 0.25s ease,
              opacity 0.3s ease;
}

/* Flying cards — pinned to top-left, moved via transform (GPU layer) */
#dp-fly, #dd-fly, #dc-fly, #dj-fly {
  position: absolute;
  left: 0;
  top: 0;
  will-change: transform, opacity;
  backface-visibility: hidden;
}
.dc.red   { color: #cc1f1f; }
.dc.black { color: #111; }
.dc.back  { background: linear-gradient(135deg, #1a5a8a 0%, #0d3055 100%); border-color: #2a7abf; }
.dc-rank  { font-size: 0.85rem; font-weight: 700; line-height: 1.1; }
.dc-suit  { font-size: 1rem; line-height: 1; }

.dc.selected {
  transform: translateY(-12px) scale(1.05);
  box-shadow: 0 0 0 2.5px #f5c518, 0 10px 24px rgba(245,197,24,0.45);
}
/* Demo: card arrives in hand — flip + gold landing flash (matches game's cardFlip + newCardGlow) */
@keyframes dc-flip-in {
  0%   { opacity: 0; transform: perspective(600px) rotateY(90deg) scale(0.88); box-shadow: 0 3px 10px rgba(0,0,0,0.45); }
  52%  { opacity: 1; transform: perspective(600px) rotateY(-8deg) scale(1.1);  box-shadow: 0 0 32px 14px rgba(245,197,24,0.92); }
  78%  { transform: perspective(600px) rotateY(2deg) scale(1.02);               box-shadow: 0 0 14px 5px rgba(245,197,24,0.5); }
  100% { transform: perspective(600px) rotateY(0deg) scale(1);                  box-shadow: 0 0 0 2px rgba(245,197,24,0.3), 0 3px 10px rgba(0,0,0,0.3); }
}
.dc.dc-flip-in {
  animation: dc-flip-in 0.52s cubic-bezier(0.34,1.56,0.64,1) both;
}

/* Demo: meld card spring-pop (matches game's meldSlideIn 3-step overshoot) */
@keyframes dc-meld-pop {
  0%   { opacity: 0; transform: scale(0.48) translateY(22px); }
  52%  { opacity: 1; transform: scale(1.14) translateY(-8px); }
  78%  { transform: scale(0.96) translateY(3px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}
.dc.dc-meld-pop {
  animation: dc-meld-pop 0.5s cubic-bezier(0.34,1.56,0.64,1) both;
}

/* Demo: hand cards tossed toward meld zone (starts at selected=−12px lift) */
@keyframes dc-toss-meld {
  0%   { transform: translateY(-12px) scale(1.05) rotate(0deg);   opacity: 1; }
  38%  { transform: translateY(-38px) scale(0.9)  rotate(-5deg);  opacity: 0.85; }
  100% { transform: translateY(-84px) scale(0.7)  rotate(-10deg); opacity: 0; }
}
.dc.dc-toss-meld {
  animation: dc-toss-meld 0.34s cubic-bezier(0.4,0,0.55,1) both;
}

/* Combo ref shuffle-in: card flips in when replaced via shuffle button */
@keyframes dc-combo-in {
  0%   { opacity: 0; transform: perspective(500px) rotateY(90deg) scale(0.85); }
  100% { opacity: 1; transform: perspective(500px) rotateY(0deg)  scale(1); }
}
.dc.dc-combo-in {
  animation: dc-combo-in 0.3s cubic-bezier(0.34,1.56,0.64,1) both;
}

/* Demo: soft glow pulse on new card (shown AFTER flip-in lands) */
.dc.new-card {
  animation: dc-new-pulse 1.1s ease-in-out infinite alternate;
}
@keyframes dc-new-pulse {
  from { box-shadow: 0 0 0 2px rgba(245,197,24,0.35), 0 3px 10px rgba(0,0,0,0.3); }
  to   { box-shadow: 0 0 0 3px rgba(245,197,24,0.65), 0 6px 20px rgba(245,197,24,0.35); transform: scale(1.03); }
}

/* ── HTP Main tabs (Panduan / Demo) ── */
.htp-main-tabs {
  display: flex;
  padding: 0 16px;
  border-top: 1px solid rgba(255,255,255,0.05);
  flex-shrink: 0;
}
.htp-main-tab {
  padding: 9px 22px;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  color: rgba(255,255,255,0.38);
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  transition: color 0.18s, border-color 0.2s;
  margin-bottom: -1px;
  letter-spacing: 0.01em;
}
.htp-main-tab.active {
  color: #f5c518;
  border-bottom-color: #f5c518;
}
.htp-main-tab:hover:not(.active) {
  color: rgba(255,255,255,0.72);
}

/* Panel hide/show */
.htp-panel--hidden { display: none !important; }

/* Modal open spring animation */
@keyframes htp-box-in {
  from { opacity: 0; transform: scale(0.95) translateY(14px); }
  to   { opacity: 1; transform: scale(1)    translateY(0); }
}
.htp-overlay:not(.hidden) .htp-box {
  animation: htp-box-in 0.32s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

/* Panel fade-in when becoming visible */
@keyframes htp-panel-in {
  from { opacity: 0; transform: translateX(10px); }
  to   { opacity: 1; transform: translateX(0); }
}
.htp-left:not(.htp-panel--hidden),
.htp-right:not(.htp-panel--hidden) {
  animation: htp-panel-in 0.22s ease both;
}

/* ── Responsive ── */
@media (max-width: 750px) {
  .htp-overlay { padding: 0; align-items: stretch; justify-content: stretch; }
  .htp-box {
    max-height: 100dvh; height: 100dvh;
    border-radius: 0;
    max-width: 100%; width: 100%;
  }
  .htp-title { font-size: 0.88rem; }
  .htp-main-tab { padding: 8px 14px; font-size: 0.78rem; }
  .demo-tab { padding: 5px 8px; font-size: 0.68rem; }
  .dg-combo-badge { display: none; }
}

/* ===== MOBILE POLISH — LOBBY & WAITING ROOM ===== */
@media (max-width: 600px) {

  /* ── Lobby: brand hero ── */
  .lobby-brand {
    flex: none;
    padding: 28px 24px 20px;
    gap: 8px;
    /* subtle radial glow at top */
    background: radial-gradient(ellipse at 50% -20%, rgba(245,197,24,0.12) 0%, transparent 65%);
    position: relative;
  }
  /* gold bar at bottom edge of brand area */
  .lobby-brand::after {
    display: block;
    position: absolute;
    top: auto;
    bottom: 0; right: 0; left: 0;
    width: 100%; height: 1px;
    background: linear-gradient(90deg, transparent, rgba(245,197,24,0.28) 30%, rgba(245,197,24,0.28) 70%, transparent);
  }
  .brand-deco { display: none; }
  .brand-suits { display: flex; gap: 18px; font-size: 1.35rem; margin-top: 2px; }
  .brand-stats { display: none; }
  .brand-title { font-size: 2.4rem; letter-spacing: 2px; line-height: 1.05; }
  .brand-aka { margin-top: 6px; gap: 10px; }
  .brand-aka-text { font-size: 0.88rem; letter-spacing: 2px; }

  /* ── Lobby: form panel ── */
  .lobby-panel {
    flex: 1 1 auto;
    padding: 22px 20px 32px;
    justify-content: flex-start;
    border-radius: 0;
    /* softer top edge connecting to brand */
    box-shadow: 0 -2px 0 rgba(245,197,24,0.1), inset 0 1px 0 rgba(245,197,24,0.08);
  }
  .lp-header { margin-bottom: 18px; padding-bottom: 16px; }
  .lp-header h2 { font-size: 1.2rem; }
  .lp-eyebrow { font-size: 0.58rem; letter-spacing: 2px; }

  /* player name input — taller touch target */
  .lobby-panel input[type="text"],
  .lobby-panel input[type="number"] {
    padding: 14px 16px;
    font-size: 1rem;
    border-radius: 10px;
  }

  /* tabs — equal width, larger hit area */
  .lp-tabs { margin: 14px 0 16px; }
  .lp-tab { padding: 13px 8px; font-size: 0.85rem; }

  /* settings card — bordered, left-accent style */
  .settings-card {
    padding: 0 14px 12px;
    border-radius: 12px;
    border-color: rgba(255,255,255,0.09);
    background: rgba(255,255,255,0.03);
    box-shadow: inset 3px 0 0 rgba(245,197,24,0.22);
  }
  .settings-card-title {
    font-size: 0.56rem;
    padding: 11px 0 9px;
    letter-spacing: 2px;
  }
  .setting-row {
    padding: 12px 0;
    font-size: 0.88rem;
  }
  /* selects — taller, full gold chevron */
  .setting-ctrl { width: 130px; }
  .setting-ctrl select,
  .setting-ctrl input[type="number"] {
    padding: 9px 12px;
    font-size: 0.86rem;
    border-radius: 8px;
    border-color: rgba(255,255,255,0.12);
  }

  /* CTA button */
  #btn-confirm-create,
  #btn-confirm-join {
    padding: 16px;
    font-size: 0.92rem;
    letter-spacing: 1.8px;
    border-radius: 12px;
    box-shadow: 0 6px 24px rgba(245,197,24,0.38), inset 0 1px 0 rgba(255,255,255,0.55), inset 0 -1px 0 rgba(0,0,0,0.2);
    position: relative;
    overflow: hidden;
  }
  /* shimmer sweep on CTA */
  #btn-confirm-create::after,
  #btn-confirm-join::after {
    content: '';
    position: absolute;
    top: 0; left: -100%; width: 60%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.22), transparent);
    animation: btn-shimmer 3.2s ease-in-out infinite;
    pointer-events: none;
  }
  @keyframes btn-shimmer {
    0%   { left: -100%; }
    40%  { left: 160%; }
    100% { left: 160%; }
  }

  /* room join row */
  .rb-join-row { gap: 8px; }
  .rb-code-input { font-size: 1.1rem; letter-spacing: 4px; }
  .rb-join-btn { padding: 14px 20px; }

  /* room browser */
  .room-browser { border-radius: 12px; }
  .rb-list { max-height: 200px; }
}
