/* ═══════════════════════════════════════════════════════════════
   Shithead Card Game — Premium CSS
   ═══════════════════════════════════════════════════════════════ */

/* ── Reset & Base ──────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg-dark: #0a0f0d;
  --felt-green: #1a5c34;
  --felt-dark: #0e3a1f;
  --felt-light: #237a45;
  --gold: #d4a843;
  --gold-light: #f0d078;
  --gold-dark: #a07820;
  --card-white: #f5f0e8;
  --card-shadow: rgba(0,0,0,0.45);
  --red-suit: #c0392b;
  --black-suit: #1a1a2e;
  --glass-bg: rgba(15, 25, 18, 0.75);
  --glass-border: rgba(212, 168, 67, 0.25);
  --text-primary: #e8e0d0;
  --text-dim: #8a8070;
  --danger: #e74c3c;
  --success: #27ae60;
  --radius: 12px;
  /* Dynamic card sizing: scales with the smaller viewport dimension */
  --card-w: clamp(48px, 6vw, 120px);
  --card-h: clamp(68px, 8.5vw, 170px);
  --card-radius: clamp(5px, 0.6vw, 12px);
  --card-rank-size: clamp(0.85rem, 1.2vw, 2rem);
  --card-suit-size: clamp(1rem, 1.4vw, 2.4rem);
  --mini-card-w: clamp(24px, 3vw, 56px);
  --mini-card-h: clamp(34px, 4.2vw, 78px);
  --mini-font: clamp(0.4rem, 0.55vw, 0.9rem);
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --font-main: 'Inter', system-ui, sans-serif;
  --font-display: 'Playfair Display', serif;
}

html, body {
  height: 100%;
  font-family: var(--font-main);
  color: var(--text-primary);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  touch-action: manipulation;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  overscroll-behavior: none;
}

body {
  background:
    radial-gradient(ellipse at 50% 40%, var(--felt-light) 0%, var(--felt-green) 35%, var(--felt-dark) 70%, var(--bg-dark) 100%);
  background-attachment: fixed;
}

/* Felt texture overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23000000' fill-opacity='0.06'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
}

/* ── Screens ───────────────────────────────────────────────── */
.screen {
  position: fixed;
  inset: 0;
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 1;
}
.screen.active {
  display: flex;
}

/* ── Glass Panel ───────────────────────────────────────────── */
.glass-panel {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow:
    0 8px 32px rgba(0,0,0,0.5),
    inset 0 1px 0 rgba(255,255,255,0.05);
}

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  font-family: var(--font-main);
  font-weight: 600;
  font-size: 0.95rem;
  padding: 12px 28px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all var(--transition);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.btn-primary {
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  color: #1a1a1a;
  box-shadow: 0 4px 15px rgba(212,168,67,0.3);
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 25px rgba(212,168,67,0.45);
  background: linear-gradient(135deg, var(--gold-light), var(--gold));
}

.btn-secondary {
  background: rgba(212,168,67,0.15);
  color: var(--gold);
  border: 1px solid var(--glass-border);
}
.btn-secondary:hover {
  background: rgba(212,168,67,0.25);
  transform: translateY(-1px);
}

.btn-danger {
  background: linear-gradient(135deg, var(--danger), #c0392b);
  color: white;
  box-shadow: 0 4px 15px rgba(231,76,60,0.3);
}
.btn-danger:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(231,76,60,0.45);
}

.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid rgba(255,255,255,0.1);
}
.btn-ghost:hover {
  color: var(--text-primary);
  border-color: rgba(255,255,255,0.25);
}

.btn-icon {
  background: transparent;
  border: 1px solid var(--glass-border);
  padding: 8px 12px;
  font-size: 1.1rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all var(--transition);
}
.btn-icon:hover {
  background: rgba(212,168,67,0.15);
}

.btn:disabled {
  opacity: 0.4;
  pointer-events: none;
}

/* ═══════════════ MENU SCREEN ═════════════════════════════════ */
.menu-container {
  padding: 48px 42px;
  width: 420px;
  max-width: 95vw;
  text-align: center;
  position: relative;
  z-index: 2;
}

.game-title {
  font-family: var(--font-display);
  font-size: 3.5rem;
  font-weight: 900;
  background: linear-gradient(135deg, var(--gold-light), var(--gold), var(--gold-dark));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
  text-shadow: none;
  filter: drop-shadow(0 2px 8px rgba(212,168,67,0.3));
}

.game-subtitle {
  color: var(--text-dim);
  font-size: 0.85rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-bottom: 36px;
}

.menu-input-group {
  text-align: left;
  margin-bottom: 28px;
}
.menu-input-group label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 8px;
}

input[type="text"] {
  width: 100%;
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 12px 16px;
  font-family: var(--font-main);
  font-size: 1rem;
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--transition);
}
input[type="text"]:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(212,168,67,0.15);
}
input[type="text"]::placeholder {
  color: var(--text-dim);
  opacity: 0.6;
}

.menu-actions {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.menu-actions .btn-primary {
  width: 100%;
}

.divider {
  display: flex;
  align-items: center;
  gap: 16px;
  color: var(--text-dim);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
}
.divider::before, .divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(255,255,255,0.1);
}

.join-row {
  display: flex;
  gap: 10px;
}
.join-row input {
  flex: 1;
  text-transform: uppercase;
  text-align: center;
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: 0.2em;
}

/* Floating background cards */
.menu-bg-cards {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}
.floating-card {
  position: absolute;
  font-size: 6rem;
  opacity: 0.04;
  animation: floatCard 20s ease-in-out infinite;
}
.fc1 { top: 10%; left: 5%; animation-delay: 0s; color: var(--black-suit); }
.fc2 { top: 60%; left: 80%; animation-delay: -5s; color: var(--red-suit); }
.fc3 { top: 20%; right: 10%; animation-delay: -10s; color: var(--red-suit); }
.fc4 { bottom: 15%; left: 40%; animation-delay: -15s; color: var(--black-suit); }

@keyframes floatCard {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  25% { transform: translateY(-30px) rotate(5deg); }
  50% { transform: translateY(10px) rotate(-3deg); }
  75% { transform: translateY(-20px) rotate(2deg); }
}

/* ═══════════════ LOBBY SCREEN ════════════════════════════════ */
.lobby-container {
  padding: 42px;
  width: 460px;
  max-width: 95vw;
  text-align: center;
}

.lobby-title {
  font-family: var(--font-display);
  font-size: 1.8rem;
  color: var(--gold);
  margin-bottom: 28px;
}

.room-code-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 32px;
  padding: 16px;
  background: rgba(0,0,0,0.25);
  border-radius: 10px;
  border: 1px solid rgba(212,168,67,0.15);
}
.room-code-display .label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-dim);
}
.room-code-display .code {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: 0.25em;
  color: var(--gold-light);
  font-family: 'Inter', monospace;
}

.player-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 28px;
}
.player-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(0,0,0,0.2);
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.05);
}
.player-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  color: #1a1a1a;
}
.player-item .name {
  flex: 1;
  text-align: left;
  font-weight: 500;
}
.player-item .host-badge {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--gold);
  background: rgba(212,168,67,0.15);
  padding: 3px 10px;
  border-radius: 20px;
}

.lobby-status {
  color: var(--text-dim);
  font-size: 0.85rem;
  margin-top: 8px;
}

.lobby-actions {
  margin-bottom: 20px;
}

/* ═══════════════ GAME SCREEN ═════════════════════════════════ */
#game-screen {
  flex-direction: column;
  padding: clamp(28px, 4vh, 48px) clamp(4px, 1vw, 16px) clamp(4px, 1vh, 16px);
  gap: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

/* ── Opponents ─────────────────────────────────────────────── */
.opponents-area {
  display: flex;
  justify-content: center;
  gap: clamp(8px, 1.5vw, 32px);
  width: 100%;
  padding: clamp(4px, 0.8vh, 12px) clamp(8px, 1vw, 20px);
  min-height: clamp(80px, 12vh, 180px);
  flex-shrink: 0;
}

.opponent-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(3px, 0.5vh, 8px);
  padding: clamp(6px, 0.8vh, 14px) clamp(8px, 1vw, 20px);
  background: rgba(0,0,0,0.25);
  border-radius: clamp(6px, 0.8vw, 14px);
  border: 1px solid rgba(255,255,255,0.06);
  min-width: clamp(90px, 12vw, 220px);
  transition: all var(--transition);
}
.opponent-panel.active-turn {
  border-color: var(--gold);
  box-shadow: 0 0 20px rgba(212,168,67,0.25);
}
.opponent-panel.is-out {
  opacity: 0.4;
}

.opponent-name {
  font-size: clamp(0.6rem, 0.85vw, 1.1rem);
  font-weight: 600;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.opponent-cards {
  display: flex;
  gap: clamp(2px, 0.3vw, 6px);
}

.opponent-hand-count {
  font-size: clamp(0.55rem, 0.7vw, 0.95rem);
  color: var(--text-dim);
  margin-top: 2px;
}

.mini-card {
  width: var(--mini-card-w);
  height: var(--mini-card-h);
  border-radius: clamp(3px, 0.4vw, 7px);
  font-size: var(--mini-font);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1.1;
  font-weight: 700;
}
.mini-card.face-up {
  background: var(--card-white);
  color: var(--black-suit);
  border: 1px solid rgba(0,0,0,0.15);
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}
.mini-card.face-up.red {
  color: var(--red-suit);
}
.mini-card.face-down {
  background: linear-gradient(135deg, #1a3a6e, #0d2040);
  border: 1px solid rgba(100,150,255,0.2);
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}
.mini-card.face-down::after {
  content: '✦';
  font-size: clamp(0.5rem, 0.7vw, 1.1rem);
  color: rgba(100,150,255,0.5);
}

/* ── Table Center ──────────────────────────────────────────── */
.table-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(4px, 0.8vh, 12px);
  flex: 1;
  min-height: 0;
  position: relative;
  z-index: 1;
}

.pile-group {
  display: flex;
  align-items: center;
  gap: clamp(20px, 4vw, 60px);
}

.pile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(2px, 0.4vh, 8px);
  position: relative;
}

.pile-count {
  font-size: clamp(0.55rem, 0.7vw, 1rem);
  color: var(--text-dim);
  font-weight: 600;
  line-height: 1;
}

/* ── Cards ─────────────────────────────────────────────────── */
.card {
  width: var(--card-w);
  height: var(--card-h);
  border-radius: var(--card-radius);
  position: relative;
  transition: all var(--transition);
  flex-shrink: 0;
}

.card-face {
  background: var(--card-white);
  border: 1.5px solid rgba(0,0,0,0.12);
  box-shadow:
    0 2px 8px rgba(0,0,0,0.25),
    inset 0 1px 0 rgba(255,255,255,0.8);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: default;
  padding: 4px;
}

.card-face .rank {
  font-size: var(--card-rank-size);
  font-weight: 800;
  line-height: 1;
}
.card-face .suit-symbol {
  font-size: var(--card-suit-size);
  line-height: 1;
}

.card-face.red { color: var(--red-suit); }
.card-face.black { color: var(--black-suit); }

.card-face.playable {
  cursor: pointer;
  box-shadow:
    0 2px 8px rgba(0,0,0,0.25),
    0 0 0 2px rgba(212,168,67,0.4);
}
@media (hover: hover) {
  .card-face.playable:hover {
    transform: translateY(-8px);
    box-shadow:
      0 8px 20px rgba(0,0,0,0.35),
      0 0 0 2px var(--gold);
  }
}
.card-face.playable:active {
  transform: translateY(-4px);
  box-shadow:
    0 4px 12px rgba(0,0,0,0.35),
    0 0 0 2px var(--gold);
}

.card-face.selected {
  transform: translateY(-16px);
  box-shadow:
    0 12px 28px rgba(0,0,0,0.4),
    0 0 0 3px var(--gold),
    0 0 15px rgba(212,168,67,0.3);
}

.card-back {
  background:
    linear-gradient(135deg, #1a3a6e 0%, #0d2040 100%);
  border: 2px solid rgba(100,150,255,0.15);
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  overflow: hidden;
}
.card-back::before {
  content: '';
  position: absolute;
  inset: 4px;
  border: 1px solid rgba(100,150,255,0.2);
  border-radius: 4px;
  background:
    repeating-linear-gradient(
      45deg,
      transparent,
      transparent 5px,
      rgba(100,150,255,0.05) 5px,
      rgba(100,150,255,0.05) 10px
    );
}
.card-back::after {
  content: '✦';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(1rem, 1.5vw, 2.8rem);
  color: rgba(100,150,255,0.35);
}

.placeholder-card {
  background: rgba(255,255,255,0.04);
  border: 2px dashed rgba(255,255,255,0.1);
  border-radius: var(--card-radius);
}

/* Stacked draw pile effect */
.draw-pile .card-back {
  box-shadow:
    0 2px 8px rgba(0,0,0,0.3),
    2px 2px 0 rgba(13,32,64,0.8),
    4px 4px 0 rgba(13,32,64,0.6);
}

/* ── Section Labels ────────────────────────────────────────── */
.section-label {
  font-size: clamp(0.55rem, 0.75vw, 0.85rem);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--text-dim);
  text-align: center;
  padding: clamp(2px, 0.3vh, 4px) 0;
  width: 100%;
  opacity: 0.7;
}
.ground-label {
  color: rgba(212, 168, 67, 0.5);
  margin-bottom: clamp(4px, 0.6vh, 10px);
}
.hand-label {
  color: rgba(232, 224, 208, 0.5);
}

/* ── Cards Divider ─────────────────────────────────────────── */
.cards-divider {
  width: clamp(120px, 30vw, 400px);
  height: 1px;
  background: linear-gradient(90deg,
    transparent,
    rgba(212, 168, 67, 0.3) 20%,
    rgba(212, 168, 67, 0.5) 50%,
    rgba(212, 168, 67, 0.3) 80%,
    transparent
  );
  margin: clamp(2px, 0.5vh, 6px) auto;
  flex-shrink: 0;
}

/* ── Ground Cards ──────────────────────────────────────────── */
.your-ground {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: clamp(4px, 0.5vh, 10px) 0;
  flex-shrink: 0;
}

.ground-slots {
  display: flex;
  gap: clamp(8px, 1.5vw, 24px);
}

.ground-slot {
  position: relative;
  width: var(--card-w);
  height: var(--card-h);
}
.ground-slot .card {
  position: absolute;
  top: 0;
  left: 0;
}
.ground-slot .face-down-card {
  z-index: 1;
}
.ground-slot .face-up-card {
  z-index: 2;
  top: -4px;
  left: 4px;
}

.ground-slot .card-face.playable,
.ground-slot .card-back.playable {
  cursor: pointer;
  box-shadow:
    0 2px 8px rgba(0,0,0,0.25),
    0 0 0 2px rgba(212,168,67,0.4);
}
@media (hover: hover) {
  .ground-slot .card-face.playable:hover,
  .ground-slot .card-back.playable:hover {
    transform: translateY(-6px);
    box-shadow:
      0 6px 16px rgba(0,0,0,0.35),
      0 0 0 2px var(--gold);
  }
}
.ground-slot .card-face.playable:active,
.ground-slot .card-back.playable:active {
  transform: translateY(-3px);
  box-shadow:
    0 3px 10px rgba(0,0,0,0.35),
    0 0 0 2px var(--gold);
}

/* ── Your Hand ─────────────────────────────────────────────── */
.your-hand-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(4px, 0.6vh, 10px);
  padding: clamp(4px, 0.5vh, 10px) 0 clamp(8px, 1vh, 20px);
  flex-shrink: 0;
}

.hand-cards {
  display: flex;
  gap: clamp(3px, 0.5vw, 10px);
  flex-wrap: wrap;
  justify-content: center;
  max-width: 95vw;
}
.hand-cards .card {
  will-change: transform;
}

/* ── Attack State Visuals ──────────────────────────────────── */
.opponent-panel.in-attack {
  border-color: var(--danger);
  box-shadow: 0 0 16px rgba(231,76,60,0.25);
}

.game-message.attack-message {
  color: var(--danger);
  animation: attackPulse 1.5s ease-in-out infinite;
  font-size: clamp(0.8rem, 1.1vw, 1.4rem);
  font-weight: 800;
}

@keyframes attackPulse {
  0%, 100% { opacity: 1; text-shadow: 0 0 8px rgba(231,76,60,0.2); }
  50% { opacity: 0.7; text-shadow: 0 0 20px rgba(231,76,60,0.5); }
}

#game-screen.attack-active {
  box-shadow: inset 0 0 80px rgba(231,76,60,0.08);
}

/* ── Game Message ──────────────────────────────────────────── */
.game-message {
  font-size: clamp(0.7rem, 1vw, 1.2rem);
  color: var(--gold);
  font-weight: 600;
  text-align: center;
  min-height: clamp(16px, 2vh, 28px);
  padding: clamp(2px, 0.4vh, 4px) clamp(8px, 1vw, 20px);
  line-height: 1.3;
  margin-top: clamp(2px, 0.3vh, 6px);
}

/* ── Turn Indicator ────────────────────────────────────────── */
.turn-indicator {
  position: fixed;
  top: clamp(4px, 0.6vh, 12px);
  left: 50%;
  transform: translateX(-50%);
  padding: clamp(4px, 0.5vh, 8px) clamp(12px, 1.5vw, 28px);
  border-radius: 20px;
  font-size: clamp(0.65rem, 0.85vw, 1.1rem);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  z-index: 10;
  transition: all var(--transition);
}
.turn-indicator.your-turn {
  background: rgba(212,168,67,0.2);
  color: var(--gold-light);
  border: 1px solid rgba(212,168,67,0.3);
  animation: pulse-glow 2s ease-in-out infinite;
}
.turn-indicator.waiting {
  background: rgba(0,0,0,0.3);
  color: var(--text-dim);
  border: 1px solid rgba(255,255,255,0.08);
}

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 8px rgba(212,168,67,0.15); }
  50% { box-shadow: 0 0 20px rgba(212,168,67,0.35); }
}

/* ── Attack Overlay ────────────────────────────────────────── */
.attack-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.attack-panel {
  padding: 32px 40px;
  text-align: center;
}
.attack-panel h3 {
  font-size: 1.4rem;
  margin-bottom: 24px;
  color: var(--gold);
}
.attack-targets {
  display: flex;
  gap: 16px;
  justify-content: center;
}
.attack-target-btn {
  padding: 16px 28px;
  background: rgba(231,76,60,0.15);
  border: 1px solid rgba(231,76,60,0.3);
  border-radius: 10px;
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}
.attack-target-btn:hover {
  background: rgba(231,76,60,0.3);
  border-color: var(--danger);
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(231,76,60,0.3);
}

/* ── Card Selection Phase ─────────────────────────────────── */
.card-selection-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 12, 8, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 60;
  padding: 16px;
}

.selection-panel {
  padding: clamp(24px, 3vh, 48px) clamp(20px, 3vw, 52px);
  text-align: center;
  max-width: 700px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
}

.selection-title {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 3vw, 2.4rem);
  color: var(--gold-light);
  margin-bottom: clamp(8px, 1.5vh, 16px);
}

.selection-subtitle {
  font-size: clamp(0.8rem, 1vw, 1rem);
  color: var(--text-dim);
  margin-bottom: clamp(16px, 2.5vh, 28px);
  line-height: 1.5;
}

.selection-count {
  display: inline-block;
  margin-top: 6px;
  font-weight: 700;
  color: var(--gold);
  font-size: clamp(0.9rem, 1.1vw, 1.15rem);
}

.selection-cards {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: clamp(6px, 1vw, 14px);
  margin-bottom: clamp(16px, 2.5vh, 28px);
}

.choosable-card {
  cursor: pointer;
  transition: all 0.2s ease;
  opacity: 0.7;
}

.choosable-card:hover {
  opacity: 1;
  transform: translateY(-6px);
}

.choosable-card.selected {
  opacity: 1;
  transform: translateY(-10px);
  box-shadow:
    0 8px 24px rgba(0,0,0,0.4),
    0 0 0 3px var(--gold),
    0 0 16px rgba(212,168,67,0.3);
}

.selection-confirm {
  min-width: clamp(160px, 30vw, 280px);
  padding: clamp(10px, 1.5vh, 16px) clamp(20px, 3vw, 40px);
  font-size: clamp(0.9rem, 1.1vw, 1.15rem);
}

.selection-confirm:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.selection-progress {
  margin-top: clamp(8px, 1.5vh, 16px);
  font-size: clamp(0.7rem, 0.85vw, 0.9rem);
  color: var(--text-dim);
}

.selection-waiting-dots {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 16px;
}
.selection-waiting-dots span {
  font-size: 2rem;
  color: var(--gold);
  animation: dotPulse 1.4s infinite;
}
.selection-waiting-dots span:nth-child(2) { animation-delay: 0.2s; }
.selection-waiting-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dotPulse {
  0%, 80%, 100% { opacity: 0.2; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1.2); }
}

/* ── Winner Overlay ────────────────────────────────────────── */
.winner-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.winner-panel {
  padding: 48px 56px;
  text-align: center;
}
.winner-panel h2 {
  font-family: var(--font-display);
  font-size: 2.4rem;
  color: var(--gold-light);
  margin-bottom: 24px;
}
.winner-panel .btn {
  min-width: 200px;
}

/* ── Game Log ──────────────────────────────────────────────── */
.game-log {
  position: fixed;
  top: clamp(38px, 5vh, 56px);
  right: clamp(6px, 1vw, 16px);
  width: clamp(140px, 13vw, 260px);
  max-height: clamp(80px, 15vh, 200px);
  overflow-y: auto;
  background: rgba(0,0,0,0.45);
  border-radius: 8px;
  padding: clamp(4px, 0.5vw, 10px);
  font-size: clamp(0.5rem, 0.6vw, 0.8rem);
  color: var(--text-dim);
  z-index: 8;
  border: 1px solid rgba(255,255,255,0.06);
  pointer-events: auto;
}
.game-log::-webkit-scrollbar { width: 3px; }
.game-log::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }

.log-entry {
  padding: clamp(1px, 0.2vh, 3px) 0;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  line-height: 1.3;
}

/* ── Toast Notifications ───────────────────────────────────── */
.toast-container {
  position: fixed;
  top: 48px;
  right: 16px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  animation: toastIn 0.3s ease-out, toastOut 0.3s 2.7s ease-in forwards;
  max-width: 320px;
}
.toast.error {
  background: rgba(231,76,60,0.9);
  color: white;
  border: 1px solid rgba(231,76,60,1);
}
.toast.info {
  background: rgba(212,168,67,0.9);
  color: #1a1a1a;
  border: 1px solid var(--gold);
}

@keyframes toastIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
@keyframes toastOut {
  from { transform: translateX(0); opacity: 1; }
  to { transform: translateX(100%); opacity: 0; }
}

/* ── Volume Control Widget ─────────────────────────────────── */
.volume-control {
  position: fixed;
  bottom: clamp(8px, 1.5vh, 16px);
  left: clamp(8px, 1vw, 16px);
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0,0,0,0.5);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 20px;
  padding: 4px 10px 4px 4px;
  backdrop-filter: blur(8px);
  transition: opacity 0.3s;
  opacity: 0.6;
  touch-action: auto;
  -webkit-user-select: none;
  user-select: none;
}
.volume-control:hover {
  opacity: 1;
}

.volume-btn {
  background: none;
  border: none;
  font-size: clamp(1rem, 1.3vw, 1.4rem);
  cursor: pointer;
  padding: 4px 6px;
  line-height: 1;
  border-radius: 50%;
  transition: background 0.2s;
}
.volume-btn:hover {
  background: rgba(255,255,255,0.1);
}

.volume-slider {
  -webkit-appearance: none;
  appearance: none;
  width: clamp(60px, 8vw, 100px);
  height: 4px;
  border-radius: 2px;
  background: rgba(255,255,255,0.15);
  outline: none;
  cursor: pointer;
  touch-action: auto;
}
.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--gold);
  cursor: pointer;
  box-shadow: 0 0 4px rgba(0,0,0,0.3);
}
.volume-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--gold);
  cursor: pointer;
  border: none;
  box-shadow: 0 0 4px rgba(0,0,0,0.3);
}
.volume-slider::-moz-range-track {
  background: rgba(255,255,255,0.15);
  height: 4px;
  border-radius: 2px;
}

/* ═══════════════ RESPONSIVE BREAKPOINTS ══════════════════════ */

/* ── Portrait phones (< 480px) ─────────────────────────────── */
@media (max-width: 480px) {
  :root {
    --card-w: clamp(44px, 18vw, 60px);
    --card-h: clamp(62px, 25vw, 85px);
    --card-radius: 5px;
    --card-rank-size: clamp(0.8rem, 3.5vw, 1.1rem);
    --card-suit-size: clamp(0.9rem, 4vw, 1.3rem);
    --mini-card-w: clamp(22px, 8vw, 32px);
    --mini-card-h: clamp(30px, 11vw, 44px);
    --mini-font: clamp(0.35rem, 1.8vw, 0.5rem);
  }
  .menu-container {
    padding: 28px 20px;
    width: 95vw;
  }
  .game-title { font-size: clamp(2rem, 10vw, 2.8rem); }
  .game-subtitle { font-size: 0.7rem; margin-bottom: 24px; }
  .lobby-container { padding: 28px 20px; width: 95vw; }
  .room-code-display .code { font-size: 1.5rem; }
  .opponents-area {
    flex-wrap: wrap;
    gap: 6px;
    min-height: 70px;
    padding: 4px 6px;
  }
  .opponent-panel {
    min-width: 80px;
    padding: 6px 8px;
    gap: 3px;
  }
  .table-center { gap: 6px; }
  .pile-group { gap: 16px; }
  .ground-slots { gap: 6px; }
  .your-hand-area { padding: 4px 0 10px; gap: 6px; }
  .hand-cards { gap: 3px; }
  .game-log { display: none; }
  .btn { padding: 10px 18px; font-size: 0.8rem; }
  .attack-panel { padding: 24px 20px; }
  .attack-panel h3 { font-size: 1.1rem; }
  .attack-target-btn { padding: 12px 18px; font-size: 0.85rem; }
  .winner-panel { padding: 32px 24px; }
  .winner-panel h2 { font-size: 1.6rem; }
  .turn-indicator { padding: 4px 12px; font-size: 0.6rem; }
  .ground-slot .face-up-card { top: -3px; left: 3px; }
}

/* ── Landscape phones / small tablets (481px - 768px) ──────── */
@media (min-width: 481px) and (max-width: 768px) {
  :root {
    --card-w: clamp(52px, 8vw, 68px);
    --card-h: clamp(73px, 11.2vw, 96px);
    --card-rank-size: clamp(0.9rem, 1.5vw, 1.15rem);
    --card-suit-size: clamp(1rem, 1.8vw, 1.3rem);
    --mini-card-w: clamp(26px, 4vw, 34px);
    --mini-card-h: clamp(36px, 5.6vw, 48px);
    --mini-font: clamp(0.4rem, 0.7vw, 0.55rem);
  }
  .menu-container { padding: 36px 28px; }
  .game-title { font-size: clamp(2.5rem, 6vw, 3rem); }
  .opponents-area {
    flex-wrap: wrap;
    gap: 10px;
    min-height: 90px;
  }
  .game-log {
    width: 180px;
    max-height: 140px;
    bottom: 120px;
  }
  .ground-slot .face-up-card { top: -3px; left: 3px; }
}

/* ── Tablets (769px - 1024px) — default clamp() values work ── */
@media (min-width: 769px) and (max-width: 1024px) {
  :root {
    --card-w: clamp(58px, 6.5vw, 74px);
    --card-h: clamp(82px, 9.2vw, 105px);
  }
}

/* ── Large desktops (1601px - 2560px) ──────────────────────── */
@media (min-width: 1601px) {
  :root {
    --card-w: clamp(80px, 5vw, 120px);
    --card-h: clamp(113px, 7vw, 170px);
    --card-radius: clamp(8px, 0.5vw, 14px);
    --card-rank-size: clamp(1.3rem, 1.1vw, 2rem);
    --card-suit-size: clamp(1.6rem, 1.3vw, 2.4rem);
    --mini-card-w: clamp(36px, 2.5vw, 56px);
    --mini-card-h: clamp(50px, 3.5vw, 78px);
    --mini-font: clamp(0.55rem, 0.5vw, 0.9rem);
  }
  .menu-container { padding: 56px 52px; width: 500px; }
  .game-title { font-size: clamp(3.5rem, 3vw, 5rem); }
  .lobby-container { padding: 52px; width: 540px; }
  .room-code-display .code { font-size: 2.4rem; }
  .btn { padding: 14px 32px; font-size: 1.05rem; }
  .attack-panel { padding: 40px 52px; }
  .attack-panel h3 { font-size: 1.6rem; }
  .winner-panel { padding: 56px 72px; }
  .winner-panel h2 { font-size: 2.8rem; }
  .opponents-area { gap: 32px; }
  .ground-slots { gap: 20px; }
  .hand-cards { gap: 8px; }
  .ground-slot .face-up-card { top: -6px; left: 6px; }
}

/* ── Ultra-wide / 4K (2561px+) ─────────────────────────────── */
@media (min-width: 2561px) {
  :root {
    --card-w: clamp(100px, 4.5vw, 150px);
    --card-h: clamp(142px, 6.4vw, 212px);
    --card-radius: clamp(10px, 0.5vw, 16px);
    --card-rank-size: clamp(1.8rem, 1vw, 2.6rem);
    --card-suit-size: clamp(2rem, 1.2vw, 3rem);
    --mini-card-w: clamp(48px, 2.2vw, 70px);
    --mini-card-h: clamp(68px, 3.1vw, 98px);
    --mini-font: clamp(0.7rem, 0.45vw, 1rem);
  }
  .menu-container { padding: 64px 60px; width: 600px; }
  .game-title { font-size: clamp(4rem, 2.5vw, 6rem); }
  .game-subtitle { font-size: 1rem; }
  .lobby-container { padding: 60px; width: 640px; }
  .room-code-display .code { font-size: 2.8rem; }
  .btn { padding: 18px 40px; font-size: 1.15rem; }
  .opponents-area { gap: 48px; min-height: 200px; }
  .opponent-panel { gap: 8px; padding: 14px 24px; }
  .pile-group { gap: 60px; }
  .ground-slots { gap: 28px; }
  .hand-cards { gap: 12px; }
  .game-log { width: 320px; max-height: 280px; font-size: 0.85rem; }
  .ground-slot .face-up-card { top: -8px; left: 8px; }
  .card-back::before { inset: 6px; }
}

/* ── Very short screens (landscape phones) ─────────────────── */
@media (max-height: 500px) {
  :root {
    --card-w: clamp(40px, 8vh, 56px);
    --card-h: clamp(56px, 11vh, 80px);
    --card-rank-size: clamp(0.7rem, 2vh, 0.95rem);
    --card-suit-size: clamp(0.8rem, 2.4vh, 1.1rem);
    --mini-card-w: clamp(18px, 4vh, 28px);
    --mini-card-h: clamp(26px, 5.5vh, 38px);
    --mini-font: 0.4rem;
  }
  .opponents-area { min-height: 50px; padding: 2px 6px; }
  .opponent-panel { padding: 4px 6px; gap: 2px; min-width: 70px; }
  .table-center { gap: 4px; }
  .your-ground { padding: 2px 0; }
  .your-hand-area { padding: 2px 0 6px; gap: 4px; }
  .game-log { display: none; }
  .turn-indicator { top: 2px; padding: 3px 10px; font-size: 0.55rem; }
}
