/* ============================================================
   Splendour - Styles (Authentic card design)
   ============================================================ */

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

* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg-dark: #0a0a14;
  --bg-surface: #13132a;
  --bg-elevated: #1a1a38;
  --bg-hover: #22224a;
  --text-primary: #e4e4ef;
  --text-secondary: #7a7a9e;
  --text-accent: #f5c211;
  --border: #252548;
  --border-light: #35356a;
  --gold: #f5c211;
  --gold-dark: #b8900a;
  --success: #2dd4a0;
  --danger: #f0475a;
  --info: #5b9cf5;
  --r: 10px;
  --r-sm: 6px;
  --r-lg: 14px;
}

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg-dark);
  background-image:
    radial-gradient(ellipse at 15% 50%, rgba(26, 95, 180, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 85% 20%, rgba(192, 28, 40, 0.04) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 100%, rgba(200, 136, 0, 0.03) 0%, transparent 40%);
  color: var(--text-primary);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  /* Subtle noise texture for felt effect */
  background-blend-mode: normal;
}

#app {
  max-width: 1480px;
  margin: 0 auto;
  padding: 10px 14px;
  position: relative;
}

h1, h2, h3 { font-family: 'Cinzel', serif; color: var(--text-accent); }

.section-label {
  font-family: 'Cinzel', serif;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 8px;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 5px 12px; border: none; border-radius: var(--r-sm);
  font-family: 'Inter', sans-serif; font-size: 11px; font-weight: 600;
  cursor: pointer; transition: all 0.15s; text-transform: uppercase;
  letter-spacing: 0.5px; white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); filter: brightness(1.15); }
.btn:active { transform: translateY(0); }

.btn-primary { background: linear-gradient(135deg, var(--gold), var(--gold-dark)); color: #0a0a14; }
.btn-buy { background: linear-gradient(135deg, var(--success), #1a8a6c); color: #0a0a14; font-weight: 700; }
.btn-reserve { background: linear-gradient(135deg, var(--info), #3060c0); color: white; }
.btn-danger { background: rgba(240,71,90,0.15); color: var(--danger); border: 1px solid rgba(240,71,90,0.25); }
.btn-info { background: rgba(91,156,245,0.1); color: var(--info); border: 1px solid rgba(91,156,245,0.2); }
.btn-small { padding: 2px 6px; font-size: 10px; }
.btn-large { padding: 12px 32px; font-size: 14px; border-radius: var(--r); letter-spacing: 1px; }

.btn-deselect {
  position: absolute; top: 50%; right: 8px; transform: translateY(-50%);
  background: rgba(240,71,90,0.2); color: var(--danger);
  border-radius: 50%; width: 22px; height: 22px; font-size: 11px; padding: 0;
  border: 1px solid rgba(240,71,90,0.3);
}
.btn-close {
  position: absolute; top: 16px; right: 16px;
  background: rgba(255,255,255,0.05); border: 1px solid var(--border);
  color: var(--text-secondary); width: 36px; height: 36px;
  border-radius: 50%; font-size: 16px; cursor: pointer; transition: all 0.15s;
  display: flex; align-items: center; justify-content: center;
}
.btn-close:hover { background: rgba(255,255,255,0.1); color: white; }

.btn-start {
  display: flex; flex-direction: column; align-items: center;
  padding: 20px 36px; background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); cursor: pointer; transition: all 0.2s; color: var(--text-primary);
}
.btn-start:hover:not(:disabled) { border-color: var(--gold); background: var(--bg-elevated); transform: translateY(-3px); box-shadow: 0 8px 24px rgba(0,0,0,0.4); }
.btn-start:disabled, .btn:disabled { opacity: 0.35; cursor: not-allowed; transform: none !important; filter: none !important; }
.btn-start-num { font-family: 'Cinzel', serif; font-size: 36px; font-weight: 900; color: var(--gold); line-height: 1; }
.btn-start-label { font-size: 12px; text-transform: uppercase; letter-spacing: 2px; color: var(--text-secondary); margin-top: 4px; }

/* ===== Top Bar ===== */
.top-bar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 16px; background: var(--bg-surface);
  border-radius: var(--r); border: 1px solid var(--border); margin-bottom: 10px;
}
.game-title {
  font-family: 'Cinzel', serif; font-size: 20px; font-weight: 900;
  color: var(--text-accent); text-shadow: 0 0 20px rgba(245,194,17,0.2); letter-spacing: 2px;
}
.game-title-link {
  color: inherit; text-decoration: none;
  transition: all 0.15s;
  cursor: pointer;
}
.game-title-link:hover {
  text-shadow: 0 0 24px rgba(245,194,17,0.5);
  filter: brightness(1.2);
}
.top-center { display: flex; align-items: center; gap: 10px; }
.turn-indicator { font-size: 13px; font-weight: 500; color: var(--text-primary); }
.turn-timer {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 44px; padding: 3px 10px;
  background: rgba(91,156,245,0.1); color: var(--info);
  border: 1px solid rgba(91,156,245,0.3); border-radius: 20px;
  font-family: 'Cinzel', serif; font-size: 13px; font-weight: 700;
  font-variant-numeric: tabular-nums;
  transition: all 0.2s;
}
.turn-timer-warning {
  background: rgba(245,194,17,0.12); color: var(--gold);
  border-color: rgba(245,194,17,0.4);
}
.turn-timer-critical {
  background: rgba(240,71,90,0.18); color: var(--danger);
  border-color: rgba(240,71,90,0.5);
  animation: pulse-glow 1s ease-in-out infinite;
}
.last-round-badge {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px;
  padding: 3px 10px; border-radius: 20px;
  background: rgba(240,71,90,0.15); color: var(--danger); border: 1px solid rgba(240,71,90,0.3);
  animation: pulse-glow 2s ease-in-out infinite;
}
@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(240,71,90,0); }
  50% { box-shadow: 0 0 12px 2px rgba(240,71,90,0.15); }
}
.top-actions { display: flex; gap: 6px; }

/* ===== Start Screen ===== */
.start-screen {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 90vh; gap: 48px; text-align: center;
}
.start-crown { font-size: 48px; color: var(--gold); filter: drop-shadow(0 4px 12px rgba(245,194,17,0.3)); margin-bottom: -8px; }
.start-logo h1 {
  font-size: 80px; font-weight: 900; color: var(--text-accent);
  text-shadow: 0 0 60px rgba(245,194,17,0.3), 0 4px 16px rgba(0,0,0,0.5); letter-spacing: 10px;
}
.start-subtitle { font-size: 16px; color: var(--text-secondary); margin-top: 8px; font-weight: 300; letter-spacing: 3px; text-transform: uppercase; }
.start-gems { display: flex; gap: 20px; }
.start-gem {
  width: 58px; height: 58px; border-radius: 50%;
  animation: float 4s ease-in-out infinite;
  position: relative;
}
.start-gem::after {
  content: ''; position: absolute;
  top: 12%; left: 18%; width: 35%; height: 25%;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(255,255,255,0.55), transparent 70%);
  pointer-events: none;
}
.start-gem-1 { background: radial-gradient(circle at 35% 30%, #fff, #d0d0d8 40%, #8888a0); box-shadow: 0 8px 24px rgba(0,0,0,0.5), inset 0 3px 8px rgba(255,255,255,0.5), inset 0 -3px 6px rgba(0,0,0,0.3), 0 0 20px rgba(255,255,255,0.15); animation-delay: 0s; }
.start-gem-2 { background: radial-gradient(circle at 35% 30%, #42a5f5, #1565c0 40%, #0a3a7a); box-shadow: 0 8px 24px rgba(0,0,0,0.5), inset 0 3px 8px rgba(255,255,255,0.35), inset 0 -3px 6px rgba(0,0,0,0.3), 0 0 20px rgba(66,165,245,0.2); animation-delay: 0.6s; }
.start-gem-3 { background: radial-gradient(circle at 35% 30%, #4cdf8a, #1b8a50 40%, #0a5030); box-shadow: 0 8px 24px rgba(0,0,0,0.5), inset 0 3px 8px rgba(255,255,255,0.35), inset 0 -3px 6px rgba(0,0,0,0.3), 0 0 20px rgba(76,223,138,0.15); animation-delay: 1.2s; }
.start-gem-4 { background: radial-gradient(circle at 35% 30%, #ef5350, #c62828 40%, #7a1520); box-shadow: 0 8px 24px rgba(0,0,0,0.5), inset 0 3px 8px rgba(255,255,255,0.35), inset 0 -3px 6px rgba(0,0,0,0.3), 0 0 20px rgba(239,83,80,0.2); animation-delay: 1.8s; }
.start-gem-5 { background: radial-gradient(circle at 35% 30%, #8b6240, #5c3a1e 40%, #2e1a0a); box-shadow: 0 8px 24px rgba(0,0,0,0.5), inset 0 3px 8px rgba(255,255,255,0.25), inset 0 -3px 6px rgba(0,0,0,0.3), 0 0 15px rgba(139,98,64,0.15); animation-delay: 2.4s; }
.start-gem-6 { background: radial-gradient(circle at 35% 30%, #ffd54f, #c88800 40%, #7a5200); box-shadow: 0 8px 24px rgba(0,0,0,0.5), inset 0 3px 8px rgba(255,255,255,0.4), inset 0 -3px 6px rgba(0,0,0,0.3), 0 0 20px rgba(255,213,79,0.25); animation-delay: 3.0s; }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-14px); } }
.start-options { display: flex; gap: 20px; }

/* ===== Game Area ===== */
.game-area {
  display: grid;
  grid-template-columns: 250px 1fr 210px;
  gap: 10px;
  min-height: calc(100vh - 110px);
}

/* ===== Players ===== */
.players-column { display: flex; flex-direction: column; gap: 8px; }

.player-panel {
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--r); padding: 12px; transition: all 0.25s ease;
}
.player-active {
  border-color: var(--gold);
  box-shadow: 0 0 20px rgba(245,194,17,0.08), inset 0 0 20px rgba(245,194,17,0.02);
  background: linear-gradient(135deg, var(--bg-surface), rgba(245,194,17,0.03));
}
.player-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.player-identity { display: flex; align-items: center; gap: 8px; }
.player-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: white; flex-shrink: 0;
}
.player-name { font-family: 'Cinzel', serif; font-size: 13px; font-weight: 600; line-height: 1.2; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-card-count { font-size: 10px; color: var(--text-secondary); }
.token-count { font-weight: 700; color: var(--text-secondary); }
.token-count-warn { color: var(--gold); }
.token-count-full { color: var(--danger); animation: pulse-glow 1.5s ease-in-out infinite; }

.gem-bank-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.gem-bank-header .section-label { margin-bottom: 0; }
.my-tokens {
  font-size: 11px; font-weight: 600; color: var(--text-secondary);
  padding: 3px 8px; border-radius: 10px;
  background: var(--bg-elevated); border: 1px solid var(--border);
}
.my-tokens span { font-weight: 800; color: var(--text-primary); }
.my-tokens.token-count-warn { border-color: rgba(245,194,17,0.4); color: var(--gold); }
.my-tokens.token-count-warn span { color: var(--gold); }
.my-tokens.token-count-full { border-color: rgba(240,71,90,0.5); color: var(--danger); animation: pulse-glow 1.5s ease-in-out infinite; }
.my-tokens.token-count-full span { color: var(--danger); }
.turn-badge {
  display: inline-block; background: var(--gold); color: var(--bg-dark);
  font-family: 'Inter', sans-serif; font-size: 9px; font-weight: 700;
  padding: 1px 6px; border-radius: 8px; text-transform: uppercase; vertical-align: middle;
}
.player-points { font-size: 28px; font-weight: 900; color: var(--text-accent); font-family: 'Cinzel', serif; line-height: 1; }

.player-gems { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 6px; }
.player-gem-item {
  display: flex; align-items: center; gap: 3px;
  padding: 3px 6px; background: var(--bg-elevated); border-radius: var(--r-sm);
  font-size: 12px; font-weight: 600;
}
.gem-returnable {
  cursor: pointer; border: 1px solid rgba(240,71,90,0.4);
  animation: pulse-glow 1.5s ease-in-out infinite;
}
.mini-gem {
  width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.4), inset 0 1px 2px rgba(255,255,255,0.25);
}
.gem-label { color: var(--text-primary); font-size: 12px; }
.bonus-label { font-size: 10px; color: var(--success); font-weight: 700; }

/* Tiny card-shape badge showing number of owned cards of a color */
.bonus-card {
  width: 14px; height: 18px;
  border-radius: 2px;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Cinzel', serif;
  font-size: 9px; font-weight: 900;
  color: #fff;
  text-shadow: 0 1px 1px rgba(0,0,0,0.6);
  border: 1px solid;
  box-shadow: 0 1px 3px rgba(0,0,0,0.5), inset 0 1px 1px rgba(255,255,255,0.15);
  flex-shrink: 0;
  position: relative;
}
.bonus-card::before {
  content: '';
  position: absolute; inset: 1px 2px;
  border-top: 1px solid rgba(255,255,255,0.15);
  border-bottom: 1px solid rgba(0,0,0,0.2);
  pointer-events: none;
}
.bonus-card span { position: relative; z-index: 1; }

.player-reserved { margin-top: 8px; }
.player-reserved .section-label { font-size: 10px; margin-bottom: 6px; }
.reserved-cards { display: flex; gap: 4px; }

/* ===== CARDS - Authentic Splendor design ===== */

.card {
  width: 140px;
  min-height: 190px;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: all 0.2s ease;
  position: relative;
  border: 1px solid rgba(180,150,80,0.12);
  box-shadow: 0 3px 10px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.04);
  cursor: default;
}

.card:hover {
  transform: translateY(-6px) scale(1.02);
  box-shadow: 0 18px 36px rgba(0,0,0,0.5), 0 0 20px rgba(200,170,100,0.06);
  border-color: rgba(200,170,100,0.25);
}

/* Full-bleed scenic background */
.card-scene {
  position: absolute;
  inset: 0;
  z-index: 0;
}

.card-scene-details {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

/* Frosted left strip (like the real cards) */
.card-strip {
  position: absolute;
  top: 0;
  left: 0;
  width: 38%;
  height: 50%;
  background: linear-gradient(
    135deg,
    rgba(230, 225, 215, 0.85) 0%,
    rgba(220, 215, 200, 0.75) 40%,
    rgba(210, 205, 195, 0.5) 70%,
    rgba(200, 195, 185, 0.2) 100%
  );
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 8px 8px;
  gap: 4px;
}

/* Cut gemstone (octagonal — premium with inner glow) */
.card-gemstone {
  width: 34px;
  height: 30px;
  clip-path: polygon(20% 0%, 80% 0%, 100% 25%, 100% 75%, 80% 100%, 20% 100%, 0% 75%, 0% 25%);
  position: relative;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}

.gemstone-facet {
  position: absolute;
  top: 10%;
  left: 12%;
  width: 45%;
  height: 38%;
  background: radial-gradient(ellipse at center, rgba(255,255,255,0.6), rgba(255,255,255,0.15) 60%, transparent);
  clip-path: polygon(0% 0%, 100% 0%, 60% 100%, 0% 80%);
}

.card-points {
  font-family: 'Cinzel', serif;
  font-size: 20px;
  font-weight: 900;
  color: #1a1a2e;
  text-shadow: 0 1px 0 rgba(255,255,255,0.3);
  line-height: 1;
}

/* Cost row at bottom (like real card badges) */
.card-cost-row {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 3;
  display: flex;
  justify-content: flex-end;
  gap: 3px;
  padding: 6px 8px;
  background: linear-gradient(0deg, rgba(0,0,0,0.5) 0%, transparent 100%);
}

.cost-badge {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  box-shadow:
    0 2px 5px rgba(0,0,0,0.6),
    inset 0 2px 4px rgba(255,255,255,0.35),
    inset 0 -2px 3px rgba(0,0,0,0.35),
    0 0 8px rgba(0,0,0,0.3);
  border: 1px solid rgba(255,255,255,0.1);
}

.cost-badge::after {
  content: '';
  position: absolute;
  top: 8%;
  left: 20%;
  width: 35%;
  height: 25%;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(255,255,255,0.4), transparent);
  pointer-events: none;
}

.cost-num {
  font-size: 15px;
  font-weight: 900;
  color: white;
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
  font-family: 'Cinzel', serif;
}

.cost-free { opacity: 0.25; }

/* Card action overlay */
/* Legacy card-actions no longer visible — replaced by action modal */
.card-actions { display: none; }

/* Card action modal (click card to open) */
.card-action-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.75); backdrop-filter: blur(6px);
  z-index: 900;
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* Custom confirm dialog — replaces native confirm() */
.confirm-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7); backdrop-filter: blur(6px);
  z-index: 1500;
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn 0.18s ease;
  padding: 20px;
}
.confirm-modal {
  background: var(--bg-surface);
  border: 1px solid rgba(200,170,100,0.25);
  border-radius: var(--r-lg);
  padding: 22px 24px;
  display: flex; flex-direction: column; gap: 14px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.6);
  max-width: 380px; width: 100%;
}
.confirm-title {
  font-family: 'Cinzel', serif;
  font-size: 16px; letter-spacing: 1.5px;
  color: var(--text-accent); text-transform: uppercase;
  text-align: center;
}
.confirm-message {
  font-size: 14px; line-height: 1.5;
  color: var(--text-primary);
  text-align: center;
}
.confirm-buttons {
  display: flex; gap: 10px; margin-top: 4px;
}
.confirm-buttons .btn { flex: 1; padding: 12px; font-size: 13px; letter-spacing: 1px; }

@media (max-width: 700px) {
  .confirm-modal { padding: 18px; gap: 12px; }
  .confirm-title { font-size: 14px; }
  .confirm-message { font-size: 13px; }
  .confirm-buttons .btn { padding: 14px; min-height: 48px; }
}

.card-action-modal {
  background: var(--bg-surface);
  border: 1px solid rgba(200,170,100,0.3);
  border-radius: var(--r-lg);
  padding: 24px;
  display: flex; flex-direction: column; align-items: center; gap: 18px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.6);
  max-width: 320px;
}

.card-action-preview {
  /* The card inside the modal is rendered at normal size */
}
.card-action-modal .card {
  transform: scale(1.2);
  margin: 10px 0;
  cursor: default;
}
.card-action-modal .card:hover {
  transform: scale(1.2) !important;
  box-shadow: 0 3px 10px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.04) !important;
}

.card-action-title {
  font-family: 'Cinzel', serif;
  font-size: 15px; letter-spacing: 1px;
  color: var(--text-secondary); text-transform: uppercase;
}

.card-action-buttons {
  display: flex; flex-direction: column; gap: 8px; width: 100%;
  margin-top: 6px;
}
.card-action-buttons .btn { width: 100%; padding: 12px; font-size: 13px; letter-spacing: 1px; }

.card-actions .btn { flex: 1; font-size: 10px; padding: 5px 3px; }

/* Compact cards for reserved */
.card-compact {
  width: 72px !important;
  min-height: 95px !important;
}
.card-compact .card-strip { width: 42%; padding: 6px 4px 4px; }
.card-compact .card-gemstone { width: 20px; height: 18px; }
.card-compact .card-points { font-size: 14px; }
.card-compact .cost-badge { width: 20px; height: 20px; }
.card-compact .cost-num { font-size: 10px; }
.card-compact .card-cost-row { padding: 4px 4px; gap: 2px; }
.card-compact .card-body { padding: 4px; }

/* Card back (like real Splendor card backs) */
.card-back {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: default;
  width: 80px;
  min-height: 190px;
  position: relative;
  overflow: hidden;
}

.card-back::before {
  content: '';
  position: absolute;
  inset: 5px;
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 5px;
}

.card-back:hover { transform: none; box-shadow: 0 2px 8px rgba(0,0,0,0.4); }
.card-back-clickable { cursor: pointer; }
.card-back-clickable:hover { transform: translateY(-3px) !important; box-shadow: 0 8px 20px rgba(0,0,0,0.5) !important; border-color: var(--gold) !important; }
.card-back-hint {
  font-size: 8px; color: rgba(255,255,255,0.3); text-align: center;
  margin-top: 4px; text-transform: uppercase; letter-spacing: 0.5px;
}

.card-back-tier-1 { background: linear-gradient(160deg, #1f6b30, #0d3518); border: 1px solid #2a8a40; }
.card-back-tier-2 { background: linear-gradient(160deg, #c8960e, #6b4f0a); border: 1px solid #d4a800; }
.card-back-tier-3 { background: linear-gradient(160deg, #2050c8, #0d2070); border: 1px solid #3868e0; }

.card-back-emblem {
  font-family: 'Cinzel', serif;
  font-size: 11px;
  font-weight: 700;
  color: rgba(245, 194, 17, 0.5);
  letter-spacing: 1px;
  writing-mode: vertical-rl;
  text-orientation: mixed;
}

.card-back-tier {
  font-family: 'Cinzel', serif;
  font-size: 18px;
  font-weight: 900;
  color: rgba(255,255,255,0.5);
  letter-spacing: 2px;
}

.card-back-count { font-size: 11px; color: rgba(255,255,255,0.25); font-weight: 500; }

/* ===== Board ===== */
.board-column { display: flex; flex-direction: column; gap: 8px; }

.nobles-row {
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--r); padding: 10px 12px;
}
.nobles-container { display: flex; gap: 8px; flex-wrap: wrap; }

.noble-tile {
  width: 100px;
  background: linear-gradient(160deg, #2a1848, #150e28);
  border: 1px solid #4a2878; border-radius: var(--r);
  padding: 6px 8px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  box-shadow: 0 2px 8px rgba(74,40,120,0.15);
  transition: all 0.2s;
}
.noble-tile:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(74,40,120,0.25); }

.noble-portrait { font-size: 24px; line-height: 1; filter: drop-shadow(0 1px 3px rgba(0,0,0,0.5)); }
.noble-info { display: flex; align-items: center; gap: 6px; }
.noble-name { font-family: 'Cinzel', serif; font-size: 8px; font-weight: 600; color: rgba(255,255,255,0.5); letter-spacing: 0.5px; }
.noble-pts { font-family: 'Cinzel', serif; font-size: 14px; font-weight: 900; color: var(--gold); }

.noble-requires { display: flex; gap: 4px; margin-top: 2px; }
.noble-req {
  width: 22px; height: 22px; border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 800; color: white;
  text-shadow: 0 1px 2px rgba(0,0,0,0.7);
  box-shadow: 0 1px 3px rgba(0,0,0,0.4), inset 0 1px 1px rgba(255,255,255,0.2);
}

.noble-req-gem { display: none; }

.tier-row { display: flex; gap: 8px; align-items: stretch; }
.tier-cards { display: flex; gap: 8px; flex: 1; }

/* ===== Gem Bank (poker chip style) ===== */
.gems-column {
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--r); padding: 12px;
  display: flex; flex-direction: column;
}
.gems-grid { display: flex; flex-direction: column; gap: 6px; }

.gem-bank-item {
  position: relative; display: flex; align-items: center; gap: 10px;
  padding: 6px 10px; background: var(--bg-elevated);
  border-radius: var(--r-sm); border: 1px solid transparent;
  transition: all 0.15s ease;
}
.gem-bank-item:hover { background: var(--bg-hover); }
.gem-selected {
  border-color: var(--gold) !important;
  background: rgba(245,194,17,0.06) !important;
  box-shadow: 0 0 12px rgba(245,194,17,0.08);
}
.gem-bank-info { flex: 1; }
.gem-bank-label { font-size: 12px; font-weight: 500; color: var(--text-secondary); }
.gem-selected-badge { font-size: 11px; font-weight: 700; color: var(--gold); }

/* 3D Poker-chip gem tokens — premium */
.gem-token {
  position: relative;
  width: 52px;
  height: 52px;
  cursor: default;
  flex-shrink: 0;
}

.gem-clickable { cursor: pointer; }
.gem-disabled { opacity: 0.15; cursor: not-allowed; filter: grayscale(0.8); }

.gem-stack {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.2s ease;
}

.gem-clickable:hover .gem-stack { transform: translateY(-4px) scale(1.05); }
.gem-clickable:active .gem-stack { transform: translateY(-1px) scale(0.98); }

.gem-chip {
  position: absolute;
  left: 0;
  width: 100%;
  height: 82%;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.gem-chip.gem-empty {
  position: relative;
  height: 82%;
}

.gem-specular {
  position: absolute;
  top: 10%;
  left: 18%;
  width: 38%;
  height: 28%;
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(255,255,255,0.6), rgba(255,255,255,0.1) 60%, transparent 100%);
  z-index: 2;
  pointer-events: none;
}

.gem-icon {
  width: 48%;
  height: 48%;
  object-fit: contain;
  z-index: 1;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.5));
  pointer-events: none;
}

.gem-rim {
  position: absolute;
  inset: 2px;
  border-radius: 50%;
  border: 1.5px solid;
  pointer-events: none;
  z-index: 3;
}

.gem-count {
  position: absolute;
  bottom: -2px;
  right: -4px;
  background: var(--bg-dark);
  color: var(--text-primary);
  font-size: 11px;
  font-weight: 800;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--border);
  z-index: 20;
  box-shadow: 0 2px 4px rgba(0,0,0,0.4);
}

.btn-confirm-gems {
  width: 100%; margin-top: 12px; padding: 10px;
  font-size: 13px; letter-spacing: 1px;
}

.btn-skip-turn {
  width: 100%; margin-top: 12px; padding: 10px;
  font-size: 12px; letter-spacing: 1.5px;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-light);
}
.btn-skip-turn:hover { color: var(--text-primary); border-color: var(--text-secondary); }
@media (max-width: 700px) {
  .btn-skip-turn { padding: 12px; font-size: 12px; min-height: 40px; }
}

/* ===== Status / Winner / Log ===== */
.status-message {
  padding: 8px 12px; border-radius: var(--r-sm);
  font-size: 12px; font-weight: 600; margin-bottom: 8px; text-align: center;
}
.status-message.warning {
  background: rgba(245,194,17,0.08); border: 1px solid rgba(245,194,17,0.2); color: var(--gold);
}

.winner-banner {
  text-align: center; padding: 32px;
  background: linear-gradient(135deg, rgba(245,194,17,0.06), rgba(200,136,0,0.03));
  border: 1px solid rgba(245,194,17,0.3); border-radius: var(--r-lg); margin-bottom: 12px;
}
.winner-crown { font-size: 56px; line-height: 1; margin-bottom: 8px; filter: drop-shadow(0 4px 16px rgba(245,194,17,0.4)); }
.winner-text { font-family: 'Cinzel', serif; font-size: 32px; font-weight: 900; color: var(--text-accent); margin-bottom: 6px; }
.winner-score { font-size: 16px; color: var(--text-secondary); margin-bottom: 20px; }

.game-log {
  margin-top: 10px; background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--r); padding: 10px 14px;
}
.log-list { display: flex; flex-direction: column; max-height: 160px; overflow-y: auto; }
.log-item { padding: 3px 0; font-size: 11px; color: var(--text-secondary); border-bottom: 1px solid rgba(255,255,255,0.02); }
.log-latest { color: var(--text-primary); font-weight: 500; }

/* ===== Instructions ===== */
.instructions-overlay {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.75); backdrop-filter: blur(6px);
  z-index: 1000; display: flex; align-items: center; justify-content: center;
}
.instructions-modal {
  position: relative; background: var(--bg-surface);
  border: 1px solid var(--border); border-radius: 16px;
  padding: 36px 40px; max-width: 660px; max-height: 85vh;
  overflow-y: auto; box-shadow: 0 24px 64px rgba(0,0,0,0.6);
}
.instructions-page { max-width: 660px; margin: 0 auto; padding: 40px 20px; }
.instructions-content h2 { font-size: 26px; margin-bottom: 24px; text-align: center; letter-spacing: 2px; }
.instruction-section { margin-bottom: 22px; }
.instruction-section h3 { font-size: 15px; margin-bottom: 8px; color: var(--gold); letter-spacing: 1px; }
.instruction-section p { font-size: 13px; line-height: 1.7; color: var(--text-secondary); }
.instruction-section ul { list-style: none; padding: 0; }
.instruction-section li {
  font-size: 13px; line-height: 1.7; color: var(--text-secondary);
  padding: 3px 0 3px 18px; position: relative;
}
.instruction-section li::before {
  content: '\25C6'; position: absolute; left: 0; color: var(--gold); font-size: 8px; top: 7px;
}
.instruction-grid { display: flex; flex-direction: column; gap: 10px; }
.instruction-item {
  display: flex; align-items: center; gap: 12px; padding: 10px;
  background: var(--bg-elevated); border-radius: var(--r-sm);
  font-size: 13px; color: var(--text-secondary); line-height: 1.5;
}
.instruction-icon {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3), inset 0 2px 3px rgba(255,255,255,0.2);
}
.gem-icon-white { background: radial-gradient(ellipse at 30% 25%, #fff, #e8e8e8 50%, #a0a0a0); }
.card-icon { background: linear-gradient(135deg, #26a269, #1a7a4c); border-radius: 6px !important; }
.noble-icon { background: linear-gradient(135deg, #6a3fa0, #3d2060); }

.action-card {
  display: flex; gap: 12px; padding: 10px 12px; margin-bottom: 8px;
  background: var(--bg-elevated); border-radius: var(--r-sm);
  border-left: 2px solid var(--gold);
}
.action-number {
  width: 28px; height: 28px;
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  color: var(--bg-dark); font-family: 'Cinzel', serif; font-size: 14px; font-weight: 900;
  border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.action-detail strong { color: var(--text-primary); font-size: 13px; }
.action-detail p { margin-top: 3px; font-size: 12px; }

/* Scrollbar */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ===== Multiplayer: Connection / Error ===== */
.connection-badge {
  font-size: 12px; font-weight: 600; padding: 4px 14px;
  border-radius: 20px; text-transform: uppercase; letter-spacing: 1px;
}
.connection-badge.connected { background: rgba(45,212,160,0.15); color: var(--success); border: 1px solid rgba(45,212,160,0.3); }
.connection-badge.disconnected { background: rgba(240,71,90,0.15); color: var(--danger); border: 1px solid rgba(240,71,90,0.3); }

.error-toast-container { position: fixed; left: 0; right: 0; top: 0; z-index: 2000; pointer-events: none; }
.error-toast {
  position: absolute; left: 50%; transform: translateX(-50%);
  background: rgba(240,71,90,0.95); color: white; padding: 10px 24px;
  border-radius: var(--r); font-size: 13px; font-weight: 600;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4); animation: slideDown 0.3s ease;
  pointer-events: auto;
  max-width: calc(100vw - 32px); text-align: center;
  word-break: break-word;
}
@keyframes slideDown { from { transform: translateX(-50%) translateY(-20px); opacity: 0; } to { transform: translateX(-50%) translateY(0); opacity: 1; } }

/* ===== Main Menu (multiplayer) ===== */
.menu-section { text-align: left; width: 100%; max-width: 380px; }
.menu-section h3 { font-size: 13px; margin-bottom: 6px; }

.input-field {
  width: 100%; padding: 10px 14px;
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--r-sm); color: var(--text-primary);
  font-family: 'Inter', sans-serif; font-size: 14px;
  outline: none; transition: border-color 0.15s;
}
.input-field:focus { border-color: var(--gold); }
.input-field::placeholder { color: var(--text-secondary); }

.input-code {
  text-transform: uppercase; text-align: center;
  font-family: 'Cinzel', serif; font-size: 18px; font-weight: 700;
  letter-spacing: 4px; width: 180px;
}

.menu-actions { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; justify-content: center; }
.menu-bottom-row { display: flex; align-items: center; gap: 12px; }
.home-link {
  font-size: 12px; color: var(--text-secondary); text-decoration: none;
  letter-spacing: 0.5px; margin-top: 20px;
  transition: color 0.15s;
}
.home-link:hover { color: var(--gold); }

.join-section { display: flex; align-items: center; gap: 8px; }

/* ===== Lobby ===== */
.lobby-screen {
  max-width: 520px; margin: 0 auto; padding: 40px 20px;
  display: flex; flex-direction: column; gap: 20px;
}

.lobby-header {
  display: flex; justify-content: space-between; align-items: center;
}
.lobby-header h2 { font-size: 24px; letter-spacing: 2px; }

.lobby-code-section {
  padding: 20px;
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--r-lg);
}
.lobby-share-row {
  display: flex; gap: 0; align-items: stretch;
}
.share-item {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  gap: 8px; padding: 12px 16px;
}
.share-divider {
  width: 1px; background: var(--border); margin: 8px 0;
}
.share-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: 2px;
  color: var(--text-secondary); font-weight: 600;
}
.share-value {
  font-family: 'Cinzel', serif; font-weight: 700; color: var(--text-primary);
  text-align: center; word-break: break-all;
}
.share-code {
  font-size: 32px; color: var(--gold); letter-spacing: 6px;
  text-shadow: 0 0 16px rgba(245,194,17,0.25);
}
.share-link {
  font-family: 'Inter', sans-serif; font-size: 11px; font-weight: 500;
  color: var(--text-secondary); line-height: 1.4;
}
.btn-copy { font-size: 11px; padding: 6px 16px; }
.btn-copied { background: linear-gradient(135deg, var(--success), #1a8a6c) !important; }

.lobby-players {
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--r); padding: 14px;
}
.lobby-player {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 12px; background: var(--bg-elevated);
  border-radius: var(--r-sm); margin-bottom: 6px;
}
.lobby-player:last-child { margin-bottom: 0; }
.lobby-player.disconnected { opacity: 0.4; }
.lobby-player-name { font-weight: 600; font-size: 14px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
.lobby-player-right { display: flex; align-items: center; gap: 8px; }
.lobby-player-status { font-size: 12px; color: var(--success); }
.lobby-player.disconnected .lobby-player-status { color: var(--danger); }
.btn-kick {
  font-size: 10px; padding: 3px 10px;
  background: rgba(240,71,90,0.15); color: var(--danger);
  border: 1px solid rgba(240,71,90,0.3); border-radius: var(--r-sm);
  cursor: pointer; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;
}
.btn-kick:hover { background: rgba(240,71,90,0.3); }

.host-badge {
  display: inline-block; background: var(--gold); color: var(--bg-dark);
  font-size: 9px; font-weight: 700; padding: 1px 6px; border-radius: 8px;
  text-transform: uppercase; margin-left: 4px;
}
.bot-badge {
  display: inline-block; background: rgba(45,212,160,0.2); color: var(--success);
  font-size: 9px; font-weight: 700; padding: 1px 6px; border-radius: 8px;
  text-transform: uppercase; margin-left: 4px; border: 1px solid rgba(45,212,160,0.35);
  letter-spacing: 0.5px;
}
.lobby-bots-section {
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--r); padding: 14px; margin-bottom: 8px;
}
.lobby-bot-row { display: flex; gap: 8px; }
.lobby-add-bot {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: rgba(45,212,160,0.08); color: var(--success);
  border: 1px solid rgba(45,212,160,0.25);
  padding: 10px 8px;
  min-height: 54px;
  text-transform: none;
  letter-spacing: normal;
}
.lobby-add-bot:hover:not(:disabled) {
  background: rgba(45,212,160,0.16);
  border-color: rgba(45,212,160,0.5);
}
.bot-btn-title {
  font-size: 13px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.bot-btn-desc {
  font-size: 10px; font-weight: 400;
  color: var(--text-secondary); opacity: 0.9;
  letter-spacing: 0.2px;
}
.me-badge {
  display: inline-block; background: rgba(91,156,245,0.2); color: var(--info);
  font-size: 9px; font-weight: 700; padding: 1px 6px; border-radius: 8px;
  text-transform: uppercase; margin-left: 4px; border: 1px solid rgba(91,156,245,0.3);
}

/* "Invite players from Card Game Lobby" toggle */
.lobby-looking { display: flex; justify-content: center; }
.lobby-looking-toggle {
  width: 100%;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  border-radius: var(--r);
  cursor: pointer; transition: all 0.18s ease;
  text-align: left;
  font-family: inherit;
  border: 1px solid var(--border);
}
.lobby-looking-icon {
  font-size: 22px;
  line-height: 1;
  flex-shrink: 0;
}
.lobby-looking-text {
  display: flex; flex-direction: column; gap: 2px;
  min-width: 0;
}
.lobby-looking-label {
  font-size: 14px; font-weight: 600; letter-spacing: 0.2px;
}
.lobby-looking-hint {
  font-size: 11px; opacity: 0.7;
  font-weight: 400;
}

/* OFF: subdued but obviously clickable, gold accent on the icon */
.lobby-looking-toggle.looking-off {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--border-light);
}
.lobby-looking-toggle.looking-off .lobby-looking-icon { filter: drop-shadow(0 0 4px rgba(245,194,17,0.5)); }
.lobby-looking-toggle.looking-off:hover {
  background: var(--bg-hover);
  border-color: var(--gold);
}

/* ON: solid gold filled CTA */
.lobby-looking-toggle.looking-on {
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  color: #1a1a2e;
  border-color: var(--gold);
  box-shadow: 0 0 18px rgba(245,194,17,0.4);
}
.lobby-looking-toggle.looking-on .lobby-looking-hint { opacity: 0.85; color: #1a1a2e; }

.lobby-settings {
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--r); padding: 14px;
}
.setting-row {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 10px;
}
.setting-row:last-child { margin-bottom: 0; }
.setting-row label { font-size: 13px; font-weight: 500; color: var(--text-secondary); }
.setting-buttons { display: flex; gap: 4px; }
.setting-buttons .btn { min-width: 40px; font-size: 11px; padding: 5px 10px; }

.lobby-start { width: 100%; }
.lobby-start:disabled { opacity: 0.4; cursor: not-allowed; }
.lobby-waiting {
  text-align: center; padding: 16px; color: var(--text-secondary);
  font-size: 14px; font-style: italic;
}

/* ===== In-game multiplayer additions ===== */
.room-code-badge {
  font-size: 11px; font-weight: 700; background: var(--bg-elevated);
  padding: 2px 8px; border-radius: 6px; color: var(--text-secondary);
  margin-left: 8px; letter-spacing: 1px; border: 1px solid var(--border);
}

.player-me { border-color: var(--info); box-shadow: 0 0 12px rgba(91,156,245,0.08); }

/* Rankings table */
.rankings-table {
  display: flex; flex-direction: column; gap: 6px;
  max-width: 320px; margin: 16px auto;
}
.ranking-row {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 14px; background: var(--bg-elevated);
  border-radius: var(--r-sm);
}
.ranking-winner {
  background: rgba(245,194,17,0.1); border: 1px solid rgba(245,194,17,0.3);
}
.ranking-pos {
  font-family: 'Cinzel', serif; font-weight: 900; font-size: 14px;
  color: var(--gold); min-width: 36px;
}
.ranking-name { flex: 1; font-weight: 600; font-size: 14px; }
.ranking-pts { font-size: 13px; color: var(--text-secondary); font-weight: 600; }

/* ===== Animations ===== */
@keyframes cardAppear {
  from { opacity: 0; transform: translateY(10px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes gemPulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.15); }
}
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* Card entrance animation removed — was causing flicker on every state update.
   Cards now render instantly and only the hover transitions remain. */

.player-active .player-points { animation: gemPulse 2s ease-in-out infinite; }

/* Gold shimmer on winner banner */
.winner-text {
  background: linear-gradient(90deg, var(--gold) 0%, #ffe082 25%, var(--gold) 50%, #ffe082 75%, var(--gold) 100%);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: shimmer 3s linear infinite;
}

/* ===== Noble choice overlay ===== */
.noble-choice-overlay {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.7); backdrop-filter: blur(4px);
  z-index: 900; display: flex; align-items: center; justify-content: center;
}
.noble-choice-modal {
  background: var(--bg-surface); border: 1px solid #4a2878;
  border-radius: 16px; padding: 28px 32px; text-align: center;
  box-shadow: 0 16px 48px rgba(0,0,0,0.5);
}
.noble-choice-modal h3 { font-size: 18px; margin-bottom: 6px; }
.noble-choice-modal p { font-size: 13px; color: var(--text-secondary); margin-bottom: 16px; }
.noble-choice-grid { display: flex; gap: 12px; justify-content: center; }
.noble-choice-item {
  cursor: pointer; border-radius: var(--r); padding: 4px;
  border: 2px solid transparent; transition: all 0.2s;
}
.noble-choice-item:hover {
  border-color: var(--gold); transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(245,194,17,0.15);
}

/* Responsive */
@media (max-width: 1200px) {
  .game-area { grid-template-columns: 220px 1fr 190px; }
  .card { width: 120px; min-height: 170px; }
  .card-gemstone { width: 26px; height: 22px; }
  .card-points { font-size: 16px; }
  .cost-badge { width: 24px; height: 24px; }
  .cost-num { font-size: 12px; }
}

@media (max-width: 900px) {
  .game-area { grid-template-columns: 1fr; }
  .players-column { flex-direction: row; overflow-x: auto; }
  .player-panel { min-width: 240px; }
  .tier-cards { flex-wrap: nowrap; overflow-x: auto; }
}

/* ===== Touch devices: kill sticky-hover and make taps reliable ===== */
@media (hover: none), (pointer: coarse) {
  /* Cards — no hover lift on touch (otherwise 1st tap shows hover, 2nd fires click) */
  .card:hover { transform: none; box-shadow: 0 3px 10px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.04); border-color: rgba(180,150,80,0.12); }
  .card-back:hover { transform: none; }
  .card-back-clickable:hover { transform: none !important; box-shadow: 0 2px 8px rgba(0,0,0,0.4) !important; border-color: inherit !important; }
  .noble-tile:hover { transform: none; box-shadow: none; }
  .btn:hover, .btn-start:hover:not(:disabled) { transform: none; filter: none; }
  .gem-bank-item:hover { background: transparent; }
  .gem-clickable:hover .gem-stack { transform: none; }

  /* Make taps fire immediately without 300ms delay, don't hijack for scroll */
  .card, .card-back, .noble-tile, .gem-bank-item, .gem-clickable, .btn,
  .lobby-add-bot, .lobby-player, .player-panel, .card-action-buttons .btn {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }

  /* A tapped card gets a quick visual ack so the user knows it registered */
  .card:active { transform: scale(0.97); transition: transform 0.08s ease; }
  .btn:active { filter: brightness(0.92); }
}

/* ===== Phone layout (<700px) ===== */
@media (max-width: 700px) {
  /* Prevent horizontal page scroll — internal rows still scroll with overflow-x: auto */
  html, body { overflow-x: hidden; max-width: 100vw; }
  #app { padding: 6px 8px; max-width: 100vw; overflow-x: hidden; }

  /* Top bar — compact */
  .top-bar { padding: 6px 8px; flex-wrap: wrap; gap: 6px; }
  .game-title { font-size: 15px; letter-spacing: 1px; }
  .top-center { order: 3; width: 100%; justify-content: center; }
  .turn-indicator { font-size: 11px; }
  .top-actions { gap: 4px; }
  .top-actions .btn { font-size: 9px; padding: 4px 6px; min-height: 28px; }

  /* Game area: single column, logical vertical stack — constrained to viewport
     (grid items default to min-width:auto which lets .players-column content
     expand the grid beyond the viewport; forcing min-width:0 caps them) */
  .game-area {
    grid-template-columns: 1fr;
    gap: 8px;
    min-height: auto;
    width: 100%;
    max-width: 100%;
  }
  .game-area > * { min-width: 0; max-width: 100%; }
  .tier-row, .nobles-row { max-width: 100%; }

  /* Player strip at top — compact horizontal scroll.
     Your panel (.player-me) is pinned first so you don't have to scroll to see it. */
  .players-column {
    order: 1;
    flex-direction: row;
    overflow-x: auto; overflow-y: hidden;
    gap: 6px;
    padding-bottom: 4px;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
  }
  .player-panel.player-me { order: -1; }
  .player-panel {
    min-width: 180px; max-width: 220px;
    flex-shrink: 0;
    padding: 8px;
    scroll-snap-align: start;
  }
  .player-active { min-width: 200px; }
  .player-panel .section-label { font-size: 9px; }
  .player-header { margin-bottom: 6px; }
  .player-points { font-size: 20px; }
  .player-avatar { width: 24px; height: 24px; font-size: 10px; }
  .player-name { font-size: 11px; max-width: 90px; }
  .player-card-count { font-size: 9px; }
  .player-gems { gap: 3px; }
  .player-gem-item { padding: 2px 4px; font-size: 11px; }
  .mini-gem { width: 12px; height: 12px; }
  .gem-label { font-size: 10px; }
  .bonus-card { width: 11px; height: 14px; font-size: 8px; }
  /* Hide reserved cards preview inside player panel on phones — they're still accessible via your own turn */
  .reserved-cards .card-compact { width: 56px !important; min-height: 72px !important; }

  /* Gem bank — all 6 gems fit viewport width without scrolling, equal widths */
  .gems-column { order: 2; padding: 8px; }
  .gem-bank-header { margin-bottom: 6px; }
  .gems-grid {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 4px;
    padding-bottom: 0;
  }
  .gem-bank-item {
    flex: 1 1 0;
    min-width: 0;
    flex-direction: column;
    padding: 4px 2px;
    gap: 2px;
    text-align: center;
    box-sizing: border-box;
  }
  .gem-bank-info { text-align: center; }
  .gem-bank-label { font-size: 9px; }
  /* Match clickable 44px so Gold (non-clickable) renders same size as other 5 */
  .gem-token { width: 44px; height: 44px; }
  .gem-count { width: 14px; height: 14px; font-size: 8px; }
  .btn-deselect {
    position: absolute; top: 2px; right: 2px;
    width: 18px; height: 18px; font-size: 10px;
  }
  .btn-confirm-gems { margin-top: 8px; padding: 10px; font-size: 12px; }

  /* Board — tiers, nobles */
  .board-column { order: 3; gap: 8px; }
  .nobles-row { padding: 8px; }
  .nobles-container { gap: 6px; overflow-x: auto; padding-bottom: 2px; -webkit-overflow-scrolling: touch; }
  .noble-tile { width: 78px; padding: 6px; flex-shrink: 0; }
  .noble-portrait { font-size: 20px; }
  .noble-name { font-size: 8px; }
  .noble-pts { font-size: 12px; }
  .noble-req { width: 18px; height: 18px; font-size: 10px; }

  /* Tier rows: all 4 cards + deck fit the viewport without scrolling.
     align-items: flex-start stops cards from being stretched to tier-row height. */
  .tier-row { gap: 6px; align-items: flex-start; }
  .tier-cards {
    flex: 1 1 0;
    min-width: 0;
    flex-wrap: nowrap;
    overflow: hidden;
    gap: 4px;
    padding-bottom: 0;
    align-items: flex-start;
  }
  /* Only cards inside .tier-cards flex-distribute; the deck card-back stays fixed.
     Use aspect-ratio to keep cards proportional regardless of flex-calculated width. */
  .tier-cards > .card {
    flex: 1 1 0;
    min-width: 0;
    width: auto;
    min-height: 0;
    aspect-ratio: 3 / 4;
    border-radius: 8px;
  }
  .card-strip { width: 40%; padding: 5px 3px; gap: 2px; }
  .card-gemstone { width: 18px; height: 15px; }
  .card-points { font-size: 12px; }
  .cost-badge { width: 16px; height: 16px; }
  .cost-num { font-size: 9px; }
  .card-cost-row {
    padding: 3px 3px;
    gap: 1px;
    flex-wrap: wrap;
    justify-content: flex-end;
    row-gap: 1px;
  }
  .card-back { width: 42px; min-height: 0; aspect-ratio: 3 / 4; flex-shrink: 0; align-self: flex-start; }
  .card-back-tier { font-size: 14px; }
  .card-back-emblem { font-size: 8px; }
  .card-back-count { font-size: 9px; }
  .card-back-hint { display: none; }

  /* Game log — compact below board */
  .game-log { padding: 8px 10px; margin-top: 6px; }
  .log-list { max-height: 100px; }
  .log-item { font-size: 10px; }

  /* Card action modal — fit phone width */
  .card-action-modal {
    max-width: 95vw;
    padding: 16px;
    gap: 12px;
  }
  .card-action-modal .card { transform: scale(1); }
  .card-action-modal .card:hover { transform: scale(1) !important; }
  .card-action-title { font-size: 13px; }
  .card-action-buttons .btn { padding: 16px; font-size: 14px; min-height: 48px; }

  /* Noble choice modal */
  .noble-choice-modal { padding: 16px; max-width: 95vw; }
  .noble-choice-grid { flex-wrap: wrap; gap: 8px; }

  /* Instructions modal */
  .instructions-modal { padding: 20px 16px; max-width: 95vw; max-height: 90vh; }

  /* Winner banner */
  .winner-banner { padding: 20px 12px; }
  .winner-text { font-size: 22px; }
  .winner-crown { font-size: 40px; }

  /* Start screen */
  .start-screen { gap: 28px; min-height: 100vh; padding: 20px 0; }
  .start-logo h1 { font-size: 44px; letter-spacing: 4px; }
  .start-crown { font-size: 36px; }
  .start-subtitle { font-size: 11px; letter-spacing: 2px; }
  .start-gems { gap: 12px; }
  .start-gem { width: 38px; height: 38px; }
  .menu-actions { flex-direction: column; gap: 14px; width: 100%; padding: 0 20px; }
  .btn-start { padding: 14px 24px; width: 100%; }
  .btn-start-num { font-size: 28px; }
  .join-section { width: 100%; flex-direction: column; gap: 8px; }
  .join-section .input-code { width: 100%; }
  .join-section .btn { width: 100%; }
  .menu-section { padding: 0 20px; }

  /* Lobby */
  .lobby-screen { padding: 16px 12px; gap: 12px; }
  .lobby-header h2 { font-size: 20px; }
  .lobby-code-section { padding: 14px; }
  .share-code { font-size: 22px; letter-spacing: 3px; }
  .lobby-share-row { flex-direction: column; gap: 10px; }
  .share-divider { width: 100%; height: 1px; margin: 4px 0; }
  .share-item { padding: 8px 4px; }
  .share-link { font-size: 10px; }
  .lobby-bot-row { flex-direction: column; gap: 6px; }
  .lobby-add-bot { min-height: 44px; }
  .bot-btn-title { font-size: 12px; }
  .bot-btn-desc { font-size: 9px; }
  .lobby-player { padding: 8px; }
  .lobby-player-name { font-size: 12px; }
  .lobby-player-status { font-size: 11px; }
  .setting-row { flex-direction: column; align-items: flex-start; gap: 6px; }
  .setting-buttons { flex-wrap: wrap; }
  .setting-buttons .btn { min-width: 40px; }

  /* Minimum tap targets (44px iOS guideline) */
  .btn { min-height: 36px; }
  .btn-large { min-height: 48px; }
  .top-actions .btn { min-height: 36px; padding: 6px 8px; font-size: 10px; }
  .gem-clickable { min-width: 44px; min-height: 44px; }
  /* Bigger card-back tap surface */
  .card-back { width: 60px; min-height: 142px; }

  /* Hide some less-essential UI elements */
  .section-label { font-size: 9px; }
  .last-round-badge { font-size: 9px; padding: 2px 6px; }
  .turn-timer { min-width: 36px; font-size: 11px; padding: 2px 8px; }
}

/* Small phones (<400px) */
@media (max-width: 400px) {
  .game-title { font-size: 13px; }
  .top-actions .btn { font-size: 8px; padding: 3px 5px; }
  .player-panel { min-width: 160px; padding: 6px; }
  .card { width: 88px; min-height: 126px; }
  .card-back { width: 50px; min-height: 126px; }
  .noble-tile { width: 70px; }
  .gem-token { width: 40px; height: 40px; }
  .gem-clickable { min-width: 40px; min-height: 40px; }
}
