/* =========================================================
   KHASINO – Landscape Beach Theme (v0.9.4)
   Tropical card game styling
   ========================================================= */

:root {
  --sky-top: #4fc3f7;
  --sky-mid: #81d4fa;
  --sky-bottom: #b3e5fc;
  --sand: #f5e6c8;
  --sand-dark: #e8d4a8;
  --ocean: #0288d1;
  --table-felt: #1b5e20;
  --table-felt-light: #2e7d32;
  --accent: #ffc107;
  --accent-hot: #ff9800;
  --gold: #ffd54f;
  --gold-dark: #ffb300;
  --purple: #7b1fa2;
  --purple-light: #9c27b0;
  --card-bg: #fffef7;
  --card-shadow: 0 4px 14px rgba(0,0,0,0.35);
  --text: #1a1a1a;
  --text-light: #ffffff;
  --radius: 16px;
  --safe-bottom: env(safe-area-inset-bottom, 8px);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  width: 100%;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: #0d47a1;
  color: var(--text);
  overflow: hidden;
  user-select: none;
  touch-action: manipulation;
}

.hidden { display: none !important; }

/* ========== ORIENTATION HINT ========== */
.orientation-hint {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: #0d47a1;
  color: white;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  font-size: 1.2rem;
}
.orientation-hint .rotate-icon {
  font-size: 4rem;
  margin-bottom: 16px;
  animation: spin 2s ease-in-out infinite;
}
@keyframes spin {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(90deg); }
}

@media (orientation: portrait) and (max-width: 900px) {
  .orientation-hint { display: flex; }
  .screen { display: none !important; }
}

/* ========== BEACH BACKGROUND ========== */
.beach-bg {
  background:
    linear-gradient(180deg, #4fc3f7 0%, #81d4fa 35%, #b3e5fc 55%, #fff8e1 70%, #f5e6c8 100%);
  position: relative;
  overflow: hidden;
}
.beach-bg::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 28%;
  background: linear-gradient(180deg, transparent 0%, #e8d4a8 40%, #d7c08a 100%);
  pointer-events: none;
}
.beach-bg::after {
  content: '🌴';
  position: absolute;
  font-size: 4.5rem;
  bottom: 18%;
  right: 4%;
  opacity: 0.85;
  pointer-events: none;
  filter: drop-shadow(0 4px 6px rgba(0,0,0,0.25));
}

/* ========== TOP CURRENCY BAR ========== */
.top-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 50;
  background: linear-gradient(180deg, rgba(13,71,161,0.55) 0%, transparent 100%);
}
.player-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255,255,255,0.92);
  border-radius: 24px;
  padding: 4px 14px 4px 4px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}
.player-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ec407a, #ab47bc);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
}
.player-meta {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}
.player-meta .name { font-weight: 700; font-size: 0.85rem; color: #222; }
.player-meta .id { font-size: 0.7rem; color: #666; }
.currency-group {
  display: flex;
  gap: 10px;
  align-items: center;
}
.currency {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.92);
  border-radius: 20px;
  padding: 5px 10px 5px 8px;
  font-weight: 700;
  font-size: 0.95rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.currency .icon { font-size: 1.15rem; }
.currency .add {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #43a047;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  font-weight: 700;
  margin-left: 2px;
}

/* ========== MAIN MENU ========== */
#main-menu {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
}
.menu-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px 40px;
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
}

.logo {
  text-align: center;
  margin-bottom: 18px;
}
.logo h1 {
  font-family: 'Playfair Display', serif;
  font-size: clamp(2.6rem, 6vw, 3.8rem);
  font-weight: 700;
  background: linear-gradient(180deg, #ffecb3 0%, #ffc107 40%, #ff8f00 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 3px 0 #e65100) drop-shadow(0 6px 12px rgba(0,0,0,0.3));
  letter-spacing: 2px;
}
.logo .tagline {
  color: #01579b;
  font-weight: 600;
  font-size: 0.95rem;
  margin-top: 4px;
  text-shadow: 0 1px 0 rgba(255,255,255,0.6);
}

/* Mode cards row – matches screenshots */
.mode-row {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
  width: 100%;
  max-width: 920px;
  margin: 12px 0 20px;
}
.mode-card {
  width: 200px;
  min-height: 260px;
  border-radius: 20px;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  border: 3px solid rgba(255,255,255,0.5);
  position: relative;
  overflow: hidden;
}
.mode-card:hover, .mode-card:active {
  transform: translateY(-6px) scale(1.03);
  box-shadow: 0 14px 32px rgba(0,0,0,0.3);
}
.mode-card .mode-art {
  width: 100%;
  height: 110px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3.2rem;
  margin-bottom: 12px;
  background: rgba(255,255,255,0.25);
}
.mode-card h3 {
  font-size: 1.15rem;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 2px 4px rgba(0,0,0,0.35);
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}
.mode-card p {
  font-size: 0.78rem;
  color: rgba(255,255,255,0.92);
  line-height: 1.3;
  flex: 1;
}
.mode-card.online {
  background: linear-gradient(165deg, #43a047 0%, #2e7d32 100%);
}
.mode-card.club {
  background: linear-gradient(165deg, #7b1fa2 0%, #4a148c 100%);
}
.mode-card.royal {
  background: linear-gradient(165deg, #0288d1 0%, #01579b 100%);
}
.mode-card.practice {
  background: linear-gradient(165deg, #ef6c00 0%, #e65100 100%);
}

/* Side games panel (left) – like screenshots */
.games-panel {
  position: absolute;
  left: 12px;
  top: 60px;
  width: 130px;
  background: rgba(255,255,255,0.88);
  border-radius: 16px;
  padding: 10px 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
  z-index: 10;
}
.games-panel h4 {
  font-size: 0.75rem;
  text-align: center;
  color: #555;
  margin-bottom: 8px;
  letter-spacing: 1px;
}
.game-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 4px;
  border-radius: 12px;
  margin-bottom: 6px;
  cursor: pointer;
  transition: background 0.15s;
}
.game-item.active {
  background: linear-gradient(135deg, #2e7d32, #43a047);
  color: white;
  box-shadow: 0 2px 8px rgba(46,125,50,0.4);
}
.game-item:not(.active):hover {
  background: rgba(0,0,0,0.06);
}
.game-item .g-icon { font-size: 1.6rem; margin-bottom: 2px; }
.game-item .g-name { font-size: 0.72rem; font-weight: 700; }

/* How to play button */
.how-to-play {
  position: absolute;
  top: 60px;
  right: 16px;
  background: rgba(255,255,255,0.9);
  border: none;
  border-radius: 20px;
  padding: 8px 16px;
  font-weight: 700;
  font-size: 0.85rem;
  color: #1565c0;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0,0,0,0.15);
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Bottom nav inspired by screenshots */
.bottom-nav {
  display: flex;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 10px 12px;
  background: rgba(255,255,255,0.82);
  border-radius: 20px 20px 0 0;
  margin-top: auto;
  width: 100%;
  max-width: 700px;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.12);
}
.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 10px;
  border-radius: 12px;
  cursor: pointer;
  min-width: 58px;
  transition: background 0.15s;
}
.nav-item:hover { background: rgba(0,0,0,0.06); }
.nav-item .n-icon { font-size: 1.35rem; }
.nav-item .n-label { font-size: 0.65rem; font-weight: 600; color: #444; margin-top: 2px; }

.difficulty-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0 4px;
  background: rgba(255,255,255,0.85);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
}
.difficulty-row select {
  border: 2px solid #43a047;
  border-radius: 10px;
  padding: 4px 10px;
  font-weight: 600;
  background: white;
}

.version {
  position: absolute;
  bottom: 8px;
  right: 14px;
  font-size: 0.7rem;
  color: rgba(0,0,0,0.45);
  z-index: 5;
}

.sfx-toggle {
  position: absolute;
  top: 58px;
  left: 150px;
  background: rgba(255,255,255,0.9);
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  z-index: 10;
}

/* ========== SECONDARY SCREENS ========== */
.screen {
  min-height: 100%;
  width: 100%;
}
#leaderboard-screen,
#matchmaking-screen,
#lobby-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #4fc3f7 0%, #81d4fa 50%, #f5e6c8 100%);
  padding: 24px;
}
.menu-content h2 {
  font-size: 1.8rem;
  color: #01579b;
  margin-bottom: 6px;
  text-shadow: 0 1px 0 rgba(255,255,255,0.5);
}
.lobby-code-display {
  font-size: 1.4rem;
  font-weight: 700;
  color: #e65100;
  background: rgba(255,255,255,0.9);
  padding: 10px 20px;
  border-radius: 12px;
  margin: 12px 0;
}
.lobby-players {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin: 12px 0;
}
.lobby-player {
  background: white;
  padding: 8px 14px;
  border-radius: 12px;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.lobby-player.ready { border: 2px solid #43a047; }

.btn {
  border: none;
  border-radius: 14px;
  padding: 12px 22px;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s;
  box-shadow: 0 3px 10px rgba(0,0,0,0.2);
}
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: linear-gradient(180deg, #66bb6a, #2e7d32);
  color: white;
}
.btn-secondary {
  background: linear-gradient(180deg, #42a5f5, #1565c0);
  color: white;
}
.btn-ghost {
  background: rgba(255,255,255,0.85);
  color: #333;
  box-shadow: 0 2px 6px rgba(0,0,0,0.12);
}
.btn-build {
  background: linear-gradient(180deg, #ffa726, #ef6c00);
  color: white;
}
.btn-shiya {
  background: linear-gradient(180deg, #ef5350, #c62828);
  color: white;
}
.btn-link {
  background: none;
  border: none;
  color: #01579b;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  padding: 6px 10px;
}
.menu-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-top: 12px;
}
.menu-footer {
  display: flex;
  gap: 16px;
  margin-top: 16px;
}

/* Leaderboard list */
.leaderboard-list {
  background: rgba(255,255,255,0.92);
  border-radius: 16px;
  padding: 12px;
  max-height: 360px;
  overflow-y: auto;
  width: 100%;
  max-width: 380px;
}
.lb-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 6px;
  border-bottom: 1px solid #eee;
  font-size: 0.9rem;
}
.lb-rank {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.8rem;
  background: #e0e0e0;
}
.lb-rank.gold { background: linear-gradient(135deg,#ffd54f,#ffb300); color: #5d4037; }
.lb-rank.silver { background: linear-gradient(135deg,#e0e0e0,#9e9e9e); }
.lb-rank.bronze { background: linear-gradient(135deg,#ffcc80,#ef6c00); color: white; }
.lb-name { flex: 1; font-weight: 600; }
.lb-score { font-weight: 700; color: #e65100; }

/* ========== GAME TABLE (Landscape optimized) ========== */
#game-table {
  display: flex;
  flex-direction: column;
  height: 100%;
  background:
    radial-gradient(ellipse at 50% 30%, #2e7d32 0%, transparent 55%),
    radial-gradient(ellipse at center, #1b5e20 0%, #0d3b12 100%);
  position: relative;
  overflow: hidden;
}

.game-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  background: rgba(0,0,0,0.35);
  color: white;
  flex-shrink: 0;
  z-index: 20;
}
.btn-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.2);
  color: white;
  font-size: 1.3rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.header-info {
  display: flex;
  gap: 14px;
  font-size: 0.85rem;
  font-weight: 600;
  flex: 1;
}
.turn-indicator {
  background: linear-gradient(90deg, #ffc107, #ff9800);
  color: #333;
  padding: 6px 14px;
  border-radius: 20px;
  font-weight: 800;
  font-size: 0.9rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.turn-timer {
  font-weight: 700;
  font-size: 1rem;
  min-width: 36px;
  text-align: center;
}

/* Opponent area */
.opponent-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 12px 4px;
  flex-shrink: 0;
}
.player-info {
  display: flex;
  gap: 12px;
  align-items: center;
  color: rgba(255,255,255,0.9);
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 4px;
}
.opponent-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.face-down-hand {
  display: flex;
  gap: 2px;
}
.face-down-hand .card {
  width: 38px;
  height: 54px;
  background: linear-gradient(145deg, #1565c0, #0d47a1);
  border: 2px solid #ffd54f;
  border-radius: 6px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
  position: relative;
}
.face-down-hand .card::after {
  content: 'K';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffd54f;
  font-weight: 800;
  font-size: 0.9rem;
  font-family: 'Playfair Display', serif;
}
.exposed-area {
  display: flex;
  gap: 4px;
}

/* Table centre */
.table-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  min-height: 0;
  position: relative;
}
.table-label {
  position: absolute;
  top: 4px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.7rem;
  color: rgba(255,255,255,0.35);
  letter-spacing: 2px;
  text-transform: uppercase;
}
.table-cards, .builds-area {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  align-items: center;
  max-width: 90%;
}
.builds-area {
  margin-top: 10px;
}

/* Player bottom area */
.player-area-bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4px 8px 0;
  flex-shrink: 0;
  background: linear-gradient(0deg, rgba(0,0,0,0.4) 0%, transparent 100%);
}
#player-hand {
  display: flex;
  gap: 4px;
  justify-content: center;
  flex-wrap: nowrap;
  overflow-x: auto;
  padding: 8px 4px 6px;
  width: 100%;
  max-width: 100%;
  scrollbar-width: none;
}
#player-hand::-webkit-scrollbar { display: none; }

/* Cards */
.card {
  width: 58px;
  height: 82px;
  background: linear-gradient(165deg, #fffef7 0%, #f5f0e0 100%);
  border-radius: 8px;
  box-shadow: var(--card-shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  position: relative;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  border: 1.5px solid rgba(0,0,0,0.08);
  flex-shrink: 0;
}
.card .rank {
  font-size: 1.25rem;
  line-height: 1;
}
.card .suit {
  font-size: 1.1rem;
  line-height: 1;
}
.card.red { color: #c62828; }
.card.black { color: #212121; }
.card.selected {
  transform: translateY(-14px) scale(1.06);
  box-shadow: 0 10px 24px rgba(255,193,7,0.5);
  border-color: #ffc107;
  z-index: 5;
}
.card.capture-ready {
  box-shadow: 0 0 0 3px #43a047, 0 4px 12px rgba(0,0,0,0.3);
}
.card.point-card {
  border: 2px solid #ffc107;
  box-shadow: 0 0 8px rgba(255,193,7,0.4), var(--card-shadow);
}

/* Build group */
.build-group {
  background: rgba(0,0,0,0.25);
  border: 2px solid #ffc107;
  border-radius: 12px;
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 70px;
}
.build-group .build-value {
  background: #ffc107;
  color: #333;
  font-weight: 800;
  font-size: 0.85rem;
  padding: 2px 10px;
  border-radius: 10px;
}
.build-group .build-cards {
  display: flex;
  gap: 3px;
}
.build-group .build-cards .card {
  width: 36px;
  height: 50px;
  font-size: 0.7rem;
}
.build-group.owner-you { border-color: #66bb6a; }
.build-group.owner-opp { border-color: #ef5350; }

/* Value picker */
.value-picker {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: rgba(0,0,0,0.5);
  border-radius: 12px;
  margin: 4px auto;
}
.value-picker.visible { display: flex; }
.picker-label { color: white; font-size: 0.8rem; font-weight: 600; }
.value-buttons { display: flex; gap: 4px; flex-wrap: wrap; }
.value-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  background: rgba(255,255,255,0.9);
  font-weight: 700;
  cursor: pointer;
}
.value-btn.selected { background: #ffc107; }

/* Action bar */
.action-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  padding: 8px 10px calc(8px + var(--safe-bottom));
  background: rgba(0,0,0,0.45);
  flex-shrink: 0;
}
.action-bar .btn {
  padding: 10px 14px;
  font-size: 0.85rem;
  border-radius: 12px;
}
.action-bar .btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.game-message {
  position: absolute;
  top: 56px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.75);
  color: white;
  padding: 8px 18px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 0.9rem;
  z-index: 30;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s;
  max-width: 80%;
  text-align: center;
}
.game-message.show { opacity: 1; }
.game-message.success { border-left: 4px solid #2ecc71; }
.game-message.error { border-left: 4px solid #e74c3c; }
.game-message.info { border-left: 4px solid #ffc107; }

/* ========== MODALS ========== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
}
.modal.hidden { display: none !important; }
.modal-content {
  background: linear-gradient(165deg, #fff8e1, #fff);
  border-radius: 20px;
  padding: 24px;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 16px 48px rgba(0,0,0,0.4);
  border: 2px solid rgba(255,193,7,0.4);
}
.modal-content h2 {
  text-align: center;
  color: #e65100;
  margin-bottom: 12px;
  font-size: 1.6rem;
}
.end-scores {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin: 16px 0;
}
.score-box {
  text-align: center;
  background: #f5f5f5;
  border-radius: 14px;
  padding: 12px 20px;
  min-width: 90px;
}
.score-label { font-size: 0.8rem; color: #666; font-weight: 600; }
.score-value { font-size: 2rem; font-weight: 800; color: #e65100; }
.score-divider { font-size: 1.5rem; color: #999; }
.end-breakdown {
  font-size: 0.85rem;
  color: #444;
  margin: 10px 0;
  text-align: center;
  line-height: 1.5;
}
.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 16px;
}
.rules-body {
  max-height: 50vh;
  overflow-y: auto;
  font-size: 0.9rem;
  line-height: 1.5;
  color: #333;
}

/* Extra opponents for 2v2 */
.extra-opponents {
  display: flex;
  gap: 16px;
  margin-top: 4px;
}
.teammate-info { color: #81c784; }

/* Larger screens / true landscape */
@media (min-width: 700px) and (orientation: landscape) {
  .card {
    width: 64px;
    height: 90px;
  }
  .face-down-hand .card {
    width: 42px;
    height: 60px;
  }
  .mode-card {
    width: 210px;
    min-height: 270px;
  }
  .games-panel {
    width: 140px;
  }
  #player-hand .card {
    width: 68px;
    height: 96px;
  }
}

@media (min-width: 1000px) {
  .mode-row {
    gap: 20px;
  }
  .mode-card {
    width: 220px;
  }
}

/* Small landscape phones */
@media (max-height: 420px) and (orientation: landscape) {
  .logo h1 { font-size: 1.8rem; }
  .mode-card { min-height: 180px; width: 160px; }
  .mode-card .mode-art { height: 70px; font-size: 2.2rem; }
  .games-panel { display: none; }
  .bottom-nav { padding: 4px; }
  .nav-item { min-width: 48px; padding: 4px 6px; }
  .card { width: 48px; height: 68px; }
  #player-hand .card { width: 52px; height: 74px; }
  .action-bar .btn { padding: 7px 10px; font-size: 0.78rem; }
}

/* =========================================================
   v0.9.5 – Stake lobby, End screen, Epic Deal, better cards
   ========================================================= */

/* ----- Better card faces ----- */
.card {
  width: 58px;
  height: 82px;
  background: linear-gradient(165deg, #fffef9 0%, #f7f0dc 55%, #efe6c8 100%);
  border-radius: 8px;
  box-shadow: 0 3px 10px rgba(0,0,0,0.28), inset 0 0 0 1.5px rgba(212,160,23,0.35);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 4px 3px;
  font-weight: 800;
  position: relative;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  border: none;
  flex-shrink: 0;
  overflow: hidden;
}
.card .card-value {
  font-size: 0.85rem;
  line-height: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}
.card .card-value.top { align-self: flex-start; padding-left: 2px; }
.card .card-value.bottom { align-self: flex-end; padding-right: 2px; transform: rotate(180deg); }
.card .card-suit-center {
  font-size: 1.35rem;
  line-height: 1;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.card .suit { font-size: 0.7rem; }
.card.red { color: #c62828; }
.card.black { color: #1a1a1a; }
.card.point-card {
  box-shadow: 0 0 0 2px #ffc107, 0 3px 12px rgba(255,193,7,0.45), inset 0 0 0 1.5px rgba(212,160,23,0.5);
}
.card.selected {
  transform: translateY(-14px) scale(1.07);
  box-shadow: 0 12px 28px rgba(255,193,7,0.55), 0 0 0 2px #ffc107;
  z-index: 5;
}
.card.small {
  width: 36px;
  height: 50px;
  padding: 2px;
}
.card.small .card-value { font-size: 0.65rem; }
.card.small .card-suit-center { font-size: 0.9rem; }
.card.deal-in {
  animation: dealIn 0.35s ease-out both;
}
@keyframes dealIn {
  from { opacity: 0; transform: translateY(-30px) scale(0.7); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes capturePop {
  0% { transform: scale(1); }
  40% { transform: scale(1.25); }
  100% { transform: scale(1); }
}
.card.capture-anim { animation: capturePop 0.4s ease; }

/* Face-down improved */
.face-down-hand .card {
  width: 38px;
  height: 54px;
  background: linear-gradient(145deg, #1565c0 0%, #0d47a1 60%, #002171 100%);
  border: 2px solid #ffd54f;
  box-shadow: 0 2px 6px rgba(0,0,0,0.35), inset 0 0 12px rgba(255,213,79,0.15);
  padding: 0;
}
.face-down-hand .card::after {
  content: 'K';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffd54f;
  font-weight: 800;
  font-size: 0.95rem;
  font-family: 'Playfair Display', serif;
  text-shadow: 0 1px 2px rgba(0,0,0,0.4);
}

/* ----- STAKE LOBBY ----- */
#stake-screen {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}
.stake-layout {
  flex: 1;
  display: flex;
  gap: 16px;
  padding: 56px 16px 20px;
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
  align-items: flex-start;
}
.gold-rank-panel {
  width: 240px;
  flex-shrink: 0;
  background: rgba(255,255,255,0.92);
  border-radius: 18px;
  padding: 14px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.15);
}
.gold-rank-panel h3 {
  text-align: center;
  color: #e65100;
  margin-bottom: 10px;
  font-size: 1.15rem;
}
.stake-lb {
  max-height: 320px;
  overflow-y: auto;
}
.stake-lb-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 4px;
  border-bottom: 1px solid #eee;
  font-size: 0.82rem;
}
.stake-lb-row .r {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.75rem;
  background: #e0e0e0;
  flex-shrink: 0;
}
.stake-lb-row .r.g1 { background: linear-gradient(135deg,#ffd54f,#ffb300); color:#5d4037; }
.stake-lb-row .r.g2 { background: linear-gradient(135deg,#e0e0e0,#9e9e9e); }
.stake-lb-row .r.g3 { background: linear-gradient(135deg,#ffcc80,#ef6c00); color:white; }
.stake-lb-row .nm { flex:1; font-weight:600; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.stake-lb-row .gl { font-weight:700; color:#e65100; white-space:nowrap; }
.stake-you-rank {
  margin-top: 10px;
  background: linear-gradient(90deg,#c8e6c9,#a5d6a7);
  border-radius: 12px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  font-weight: 600;
}
.rank-badge {
  background: #2e7d32;
  color: white;
  border-radius: 8px;
  padding: 2px 6px;
  font-size: 0.7rem;
}
.you-golds { margin-left: auto; color: #e65100; font-weight: 800; }

.stake-levels {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.stake-title {
  font-size: 1.8rem;
  color: #01579b;
  text-shadow: 0 1px 0 rgba(255,255,255,0.5);
  margin-bottom: 4px;
}
.recommend-label {
  color: #e65100;
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 10px;
}
.stake-cards {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
  width: 100%;
}
.stake-card {
  width: 150px;
  border-radius: 16px;
  padding: 14px 10px;
  text-align: center;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 6px 18px rgba(0,0,0,0.2);
  border: 3px solid transparent;
  position: relative;
  color: white;
}
.stake-card:hover { transform: translateY(-4px); }
.stake-card.selected {
  border-color: #ffc107;
  box-shadow: 0 0 0 3px #ffc107, 0 8px 24px rgba(0,0,0,0.3);
}
.stake-card.locked { opacity: 0.7; }
.stake-card .sc-name {
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
  text-transform: uppercase;
}
.stake-card .sc-base {
  font-size: 1.8rem;
  font-weight: 900;
  line-height: 1;
}
.stake-card .sc-base-label {
  font-size: 0.7rem;
  opacity: 0.9;
  margin-bottom: 8px;
}
.stake-card .sc-req {
  background: rgba(0,0,0,0.25);
  border-radius: 10px;
  padding: 4px 8px;
  font-size: 0.72rem;
  margin-bottom: 6px;
}
.stake-card .sc-entry {
  font-size: 0.78rem;
  font-weight: 700;
  background: rgba(255,255,255,0.2);
  border-radius: 10px;
  padding: 4px 6px;
}
.stake-card .lock-icon {
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 1.1rem;
}
.stake-card.newbie { background: linear-gradient(165deg,#4fc3f7,#0288d1); }
.stake-card.novice { background: linear-gradient(165deg,#42a5f5,#1565c0); }
.stake-card.amateur { background: linear-gradient(165deg,#7e57c2,#4527a0); }
.stake-card.apprentice { background: linear-gradient(165deg,#ff7043,#d84315); }

.stake-note {
  margin-top: 14px;
  font-size: 0.8rem;
  color: #555;
  text-align: center;
  max-width: 420px;
}
.stake-actions {
  display: flex;
  gap: 12px;
  margin-top: 16px;
  flex-wrap: wrap;
  justify-content: center;
}
.btn-epic {
  background: linear-gradient(90deg,#ab47bc,#7b1fa2);
  color: white;
  font-size: 0.9rem;
}
.btn-lg {
  padding: 14px 32px;
  font-size: 1.05rem;
}

/* ----- EPIC DEAL ----- */
.epic-content {
  max-width: 520px;
  text-align: center;
  position: relative;
}
.modal-close {
  position: absolute;
  top: 10px;
  right: 14px;
  background: none;
  border: none;
  font-size: 1.6rem;
  cursor: pointer;
  color: #888;
}
.epic-sub {
  font-size: 0.9rem;
  color: #555;
  margin-bottom: 16px;
}
.epic-packs {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}
.epic-pack {
  width: 140px;
  border-radius: 16px;
  padding: 14px 10px;
  background: linear-gradient(180deg,#e8f5e9,#c8e6c9);
  box-shadow: 0 4px 14px rgba(0,0,0,0.15);
  position: relative;
}
.epic-pack.popular {
  background: linear-gradient(180deg,#e3f2fd,#bbdefb);
  transform: scale(1.05);
}
.epic-pack .pack-amount {
  font-size: 1.6rem;
  font-weight: 900;
  color: #e65100;
}
.epic-pack .pack-off {
  position: absolute;
  top: -6px;
  right: -6px;
  background: #e53935;
  color: white;
  font-size: 0.65rem;
  font-weight: 800;
  padding: 3px 7px;
  border-radius: 10px;
}
.epic-pack .pack-coins { font-size: 1.3rem; margin: 6px 0; }
.epic-pack .pack-old {
  text-decoration: line-through;
  color: #999;
  font-size: 0.85rem;
}
.epic-pack .pack-buy {
  width: 100%;
  margin-top: 8px;
  padding: 8px;
}
.epic-timer-label {
  margin-top: 14px;
  font-size: 0.85rem;
  color: #1565c0;
  font-weight: 600;
}

/* ----- END SCREEN ----- */
.end-modal-content {
  max-width: 520px;
  padding: 20px 18px 16px;
}
.end-result-banner {
  text-align: center;
  font-size: 2.4rem;
  font-weight: 900;
  letter-spacing: 4px;
  margin-bottom: 12px;
  text-shadow: 0 3px 0 rgba(0,0,0,0.15);
}
.end-result-banner.win {
  color: #2e7d32;
  background: linear-gradient(90deg,transparent,#c8e6c9,transparent);
  padding: 6px 0;
}
.end-result-banner.lose {
  color: #c62828;
  background: linear-gradient(90deg,transparent,#ffcdd2,transparent);
  padding: 6px 0;
}
.end-result-banner.tie {
  color: #ef6c00;
}
.end-vs-row {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 10px;
  margin-bottom: 12px;
}
.end-side {
  flex: 1;
  background: #f5f5f5;
  border-radius: 14px;
  padding: 10px 8px;
  text-align: center;
  max-width: 200px;
}
.end-side.you-side { border: 2px solid #66bb6a; }
.end-side.opp-side { border: 2px solid #ef5350; }
.end-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg,#ec407a,#ab47bc);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  margin: 0 auto 4px;
  font-size: 1.1rem;
}
.end-side-name { font-weight: 700; font-size: 0.85rem; }
.end-side-score {
  font-size: 1.8rem;
  font-weight: 900;
  color: #e65100;
  line-height: 1.1;
}
.end-cards-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  justify-content: center;
  margin-top: 6px;
  min-height: 28px;
}
.end-cards-preview .mini {
  font-size: 0.7rem;
  background: white;
  border-radius: 4px;
  padding: 1px 3px;
  border: 1px solid #ddd;
  font-weight: 700;
}
.end-cards-preview .mini.plus { color: #2e7d32; }
.end-vs {
  font-weight: 900;
  font-size: 1.3rem;
  color: #ff9800;
  align-self: center;
  text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.end-breakdown {
  background: #fafafa;
  border-radius: 12px;
  padding: 10px;
  font-size: 0.82rem;
  margin-bottom: 8px;
}
.breakdown-row {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
  border-bottom: 1px solid #eee;
}
.breakdown-row:last-child { border-bottom: none; }
.end-gold-delta {
  text-align: center;
  font-size: 1.4rem;
  font-weight: 900;
  margin: 8px 0;
}
.end-gold-delta.neg { color: #c62828; }
.end-gold-delta.pos { color: #2e7d32; }
.end-actions {
  flex-wrap: wrap;
}

/* Landscape tweaks for stake */
@media (max-height: 500px) and (orientation: landscape) {
  .stake-layout { padding-top: 48px; gap: 10px; }
  .gold-rank-panel { width: 200px; }
  .stake-card { width: 120px; padding: 10px 6px; }
  .stake-card .sc-base { font-size: 1.4rem; }
  .stake-title { font-size: 1.4rem; }
}
@media (max-width: 700px) {
  .stake-layout { flex-direction: column; align-items: center; }
  .gold-rank-panel { width: 100%; max-width: 360px; }
}

/* ----- CLUB SCREEN ----- */
.club-panel {
  max-width: 900px;
  margin: 60px auto 20px;
  padding: 20px;
  background: rgba(255,255,255,0.92);
  border-radius: 20px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.18);
}
.club-panel h2 {
  color: #4a148c;
  margin-bottom: 4px;
}
.club-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
  justify-content: center;
}
.club-form input {
  padding: 10px 14px;
  border: 2px solid #ce93d8;
  border-radius: 12px;
  font-size: 0.95rem;
  min-width: 180px;
  flex: 1;
}
.club-or {
  text-align: center;
  color: #888;
  margin: 8px 0;
  font-weight: 600;
}
.club-list-section {
  margin-top: 18px;
  border-top: 1px solid #eee;
  padding-top: 12px;
}
.club-list-section h3 {
  font-size: 1rem;
  color: #555;
  margin-bottom: 8px;
}
.public-clubs-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 200px;
  overflow-y: auto;
}
.public-club-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: #f3e5f5;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s;
}
.public-club-row:hover { background: #e1bee7; }
.public-club-row .pc-name { font-weight: 700; flex: 1; }
.public-club-row .pc-meta { font-size: 0.8rem; color: #666; }
.public-club-row .pc-code { font-weight: 700; color: #6a1b9a; }

.club-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.club-code-line {
  font-size: 0.95rem;
  color: #555;
}
.club-desc {
  font-size: 0.85rem;
  color: #777;
  margin-top: 4px;
}
.club-columns {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}
.club-col {
  flex: 1;
  min-width: 240px;
  background: #fafafa;
  border-radius: 14px;
  padding: 12px;
}
.club-col h3 {
  font-size: 0.95rem;
  color: #4a148c;
  margin-bottom: 8px;
}
.club-members {
  max-height: 260px;
  overflow-y: auto;
}
.club-member {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 4px;
  border-bottom: 1px solid #eee;
  font-size: 0.88rem;
}
.club-member .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #bbb;
  flex-shrink: 0;
}
.club-member .dot.on { background: #43a047; }
.club-member .role {
  margin-left: auto;
  font-size: 0.7rem;
  background: #e1bee7;
  color: #4a148c;
  padding: 2px 6px;
  border-radius: 8px;
  font-weight: 700;
}
.club-member .role.owner { background: #ffd54f; color: #5d4037; }

.club-tables {
  min-height: 80px;
  margin-bottom: 10px;
}
.club-table-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  background: white;
  border-radius: 10px;
  margin-bottom: 6px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  font-size: 0.85rem;
}
.club-table-row .ct-mode {
  background: #7b1fa2;
  color: white;
  padding: 2px 8px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.75rem;
}
.club-table-row .ct-host { flex: 1; font-weight: 600; }
.club-table-row .ct-status { color: #666; font-size: 0.75rem; }
.club-table-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.club-table-empty {
  color: #999;
  font-size: 0.85rem;
  padding: 12px 0;
  text-align: center;
}

@media (max-height: 500px) and (orientation: landscape) {
  .club-panel { margin-top: 48px; padding: 12px; }
  .club-members, .club-tables { max-height: 140px; }
}

/* ----- CLUB CHAT ----- */
.club-chat-col {
  display: flex;
  flex-direction: column;
  min-height: 280px;
  max-width: 100%;
}
.club-chat-messages {
  flex: 1;
  overflow-y: auto;
  background: #fff;
  border-radius: 12px;
  padding: 10px;
  min-height: 160px;
  max-height: 240px;
  border: 1px solid #e1bee7;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.chat-msg {
  font-size: 0.85rem;
  line-height: 1.35;
  word-break: break-word;
}
.chat-msg .chat-name {
  font-weight: 700;
  color: #6a1b9a;
  margin-right: 6px;
}
.chat-msg .chat-time {
  font-size: 0.7rem;
  color: #999;
  margin-left: 6px;
}
.chat-msg.mine .chat-name {
  color: #2e7d32;
}
.chat-msg.system {
  color: #888;
  font-style: italic;
  text-align: center;
  font-size: 0.8rem;
}
.club-chat-input-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.club-chat-input-row input {
  flex: 1;
  padding: 10px 12px;
  border: 2px solid #ce93d8;
  border-radius: 12px;
  font-size: 0.9rem;
}
.club-chat-input-row .btn {
  padding: 10px 16px;
  flex-shrink: 0;
}

@media (max-height: 500px) and (orientation: landscape) {
  .club-chat-messages { max-height: 120px; min-height: 80px; }
}

/* ----- ROYAL TABLE ----- */
.royal-create-row {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 18px 0 8px;
}

/* ----- LOBBY CHAT ----- */
.lobby-chat-box {
  margin-top: 14px;
  background: #f5f5f5;
  border-radius: 12px;
  padding: 10px;
  max-width: 400px;
  width: 100%;
}
.lobby-chat-messages {
  max-height: 120px;
  overflow-y: auto;
  font-size: 0.85rem;
  margin-bottom: 8px;
  min-height: 40px;
}
.lobby-chat-messages .chat-msg {
  padding: 2px 0;
}

/* ----- IN-GAME TABLE CHAT ----- */
.table-chat-toggle {
  position: absolute;
  bottom: calc(70px + var(--safe-bottom));
  right: 12px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #7b1fa2, #4a148c);
  color: white;
  font-size: 1.4rem;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,0.35);
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
}
.table-chat-toggle.hidden { display: none !important; }
.table-chat-toggle .badge {
  position: absolute;
  top: -2px;
  right: -2px;
  background: #e53935;
  color: white;
  font-size: 0.65rem;
  font-weight: 800;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

.table-chat-panel {
  position: absolute;
  bottom: calc(70px + var(--safe-bottom));
  right: 12px;
  width: min(320px, calc(100vw - 24px));
  max-height: 280px;
  background: rgba(20, 30, 25, 0.95);
  border: 1px solid rgba(255,193,7,0.35);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  z-index: 45;
  box-shadow: 0 8px 28px rgba(0,0,0,0.45);
  overflow: hidden;
}
.table-chat-panel.hidden { display: none !important; }
.table-chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: rgba(0,0,0,0.35);
  color: #ffc107;
  font-weight: 700;
  font-size: 0.9rem;
}
.table-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 8px 10px;
  min-height: 100px;
  max-height: 180px;
  color: #eee;
  font-size: 0.85rem;
}
.table-chat-messages .chat-msg .chat-name {
  color: #ffc107;
}
.table-chat-messages .chat-msg.mine .chat-name {
  color: #81c784;
}
.table-chat-panel .club-chat-input-row {
  padding: 8px;
  background: rgba(0,0,0,0.25);
}
.table-chat-panel .club-chat-input-row input {
  background: rgba(255,255,255,0.12);
  border-color: rgba(255,193,7,0.4);
  color: white;
}
.table-chat-panel .club-chat-input-row input::placeholder {
  color: rgba(255,255,255,0.5);
}

/* ----- SPECTATOR ----- */
.spectator-banner {
  background: linear-gradient(90deg, #6a1b9a, #4a148c);
  color: white;
  text-align: center;
  padding: 6px 12px;
  font-weight: 800;
  font-size: 0.85rem;
  letter-spacing: 1px;
  flex-shrink: 0;
  z-index: 25;
}
.spectator-banner.hidden { display: none !important; }
#game-table.spectating .action-bar {
  opacity: 0.35;
  pointer-events: none;
}
#game-table.spectating .value-picker {
  display: none !important;
}
#game-table.spectating #player-hand .card {
  pointer-events: none;
}

/* ----- DRAG & DROP ----- */
.dnd-draggable {
  cursor: grab;
}
.dnd-draggable:active {
  cursor: grabbing;
}
.dnd-dragging-source {
  opacity: 0.35;
  transform: scale(0.92);
}
.dnd-ghost {
  position: fixed !important;
  z-index: 9999 !important;
  pointer-events: none !important;
  opacity: 0.92;
  transform: scale(1.08) rotate(3deg);
  box-shadow: 0 12px 32px rgba(0,0,0,0.45), 0 0 0 2px #ffc107 !important;
  margin: 0 !important;
  transition: none !important;
}
.dnd-dropzone.dnd-over,
.build-group.dnd-over,
.build.dnd-over,
#table-cards.dnd-over,
.table-area.dnd-over {
  outline: 3px dashed #ffc107;
  outline-offset: 4px;
  background: rgba(255, 193, 7, 0.12) !important;
  border-radius: 12px;
}
#table-cards .card.dnd-over {
  outline: 3px solid #43a047;
  outline-offset: 2px;
  transform: scale(1.08);
}
.build-group.dnd-over {
  box-shadow: 0 0 0 3px #ffc107, 0 6px 20px rgba(0,0,0,0.3);
}

/* Hint under hand */
.dnd-hint {
  text-align: center;
  font-size: 0.75rem;
  color: rgba(255,255,255,0.55);
  padding: 2px 0 4px;
  pointer-events: none;
}

/* DnD live preview label */
.dnd-preview-label {
  position: fixed;
  z-index: 10000;
  pointer-events: none;
  padding: 4px 10px;
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.3px;
  color: #fff;
  background: rgba(0,0,0,0.75);
  box-shadow: 0 2px 8px rgba(0,0,0,0.35);
  white-space: nowrap;
  transform: translateY(-4px);
}
.dnd-preview-label[data-kind="capture"] {
  background: linear-gradient(90deg, #2e7d32, #43a047);
}
.dnd-preview-label[data-kind="drift"] {
  background: linear-gradient(90deg, #1565c0, #42a5f5);
}
.dnd-preview-label[data-kind="build"] {
  background: linear-gradient(90deg, #ef6c00, #ffa726);
}
.dnd-preview-label[data-kind="cancel"] {
  background: rgba(80,80,80,0.85);
}

/* Stronger selected table cards for multi-select capture */
#table-cards .card.selected {
  transform: translateY(-8px) scale(1.05);
  box-shadow: 0 0 0 3px #43a047, 0 8px 18px rgba(0,0,0,0.35);
  z-index: 4;
}

.dnd-hint {
  text-align: center;
  font-size: 0.75rem;
  color: rgba(255,255,255,0.55);
  padding: 2px 0 4px;
}

/* Connection status */
.conn-status {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  margin-right: 8px;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.5);
}
.conn-status.online { background: #43a047; }
.conn-status.offline { background: #e53935; }
.conn-status.connecting { background: #ffc107; animation: pulse 1s infinite; }
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* Move history panel */
.move-history-panel {
  position: absolute;
  top: 52px;
  left: 12px;
  width: min(280px, 70vw);
  max-height: 240px;
  background: rgba(15, 25, 20, 0.95);
  border: 1px solid rgba(255,193,7,0.35);
  border-radius: 14px;
  z-index: 40;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.move-history-panel.hidden { display: none !important; }
.move-history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  color: #ffc107;
  font-weight: 700;
  font-size: 0.85rem;
  background: rgba(0,0,0,0.3);
}
.move-history-list {
  overflow-y: auto;
  padding: 8px 10px;
  font-size: 0.8rem;
  color: #ddd;
  flex: 1;
}
.move-history-list .mh-row {
  padding: 4px 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  line-height: 1.3;
}
.move-history-list .mh-row:last-child { border-bottom: none; color: #ffc107; font-weight: 600; }

/* Live rooms */
.live-rooms-section {
  margin-top: 20px;
  border-top: 1px solid #eee;
  padding-top: 12px;
  text-align: left;
}
.live-rooms-section h3 {
  font-size: 0.95rem;
  color: #01579b;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.live-rooms-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 180px;
  overflow-y: auto;
}
.live-room-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: #e3f2fd;
  border-radius: 10px;
  font-size: 0.85rem;
}
.live-room-row .lr-code { font-weight: 800; color: #1565c0; min-width: 56px; }
.live-room-row .lr-meta { flex: 1; color: #555; }
.live-room-row .lr-status {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 6px;
  background: #fff;
}
.live-room-row .lr-status.playing { color: #2e7d32; }
.live-room-row .lr-status.waiting { color: #ef6c00; }

/* Emoji bar */
.emoji-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 6px;
}
.emoji-btn {
  border: none;
  background: rgba(255,255,255,0.15);
  border-radius: 8px;
  padding: 4px 6px;
  font-size: 1.05rem;
  cursor: pointer;
  line-height: 1;
}
.emoji-btn:hover { background: rgba(255,255,255,0.3); transform: scale(1.1); }
.club-chat-col .emoji-btn { background: #f3e5f5; }
.club-chat-col .emoji-btn:hover { background: #e1bee7; }

/* Last move flash */
.card.last-move-flash {
  animation: lastMoveFlash 0.8s ease;
}
@keyframes lastMoveFlash {
  0%, 100% { box-shadow: var(--card-shadow); }
  40% { box-shadow: 0 0 0 4px #ffc107, 0 8px 20px rgba(255,193,7,0.5); }
}

/* Account dialog */
.account-content { width: min(94vw, 430px); max-height: 90vh; overflow-y: auto; text-align: left; }
.account-content label { display: block; font-size: .86rem; font-weight: 700; margin: 10px 0 5px; }
.account-content input { width: 100%; min-width: 0; padding: 10px; border: 1px solid #a9b9c6; border-radius: 8px; font: inherit; }
.account-content .account-actions { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.account-actions .btn { flex-shrink: 0; }
.account-note { font-size: .8rem; line-height: 1.4; margin-top: 14px; }
.account-guest { border-top: 1px solid #c7d0d8; margin-top: 14px; padding-top: 4px; }
#account-status { min-height: 1.3em; font-size: .9rem; }

/* Mobile play polish: compact table, larger tap targets and safe-area gutters. */
.landscape-cta { margin-top: 20px; min-height: 48px; padding: 12px 22px; }
.landscape-status { max-width: 360px; margin-top: 14px; font-size: .85rem; line-height: 1.4; opacity: .8; }
.fullscreen-toggle { position: absolute; top: 60px; right: 12px; z-index: 55; width: 42px; height: 42px; border: 1px solid rgba(255,255,255,.45); border-radius: 14px; color: white; background: rgba(5,48,69,.72); font-size: 25px; cursor: pointer; }
#game-table { height: 100dvh; padding-left: env(safe-area-inset-left, 0px); padding-right: env(safe-area-inset-right, 0px); background: radial-gradient(ellipse at 50% 42%, #22845f 0%, #0c634c 47%, #06392f 100%); }
#game-table::before { content: ''; position: absolute; inset: 6px; border: 1px solid rgba(239,205,119,.28); border-radius: 24px; pointer-events: none; }
.game-header { background: rgba(3,39,36,.8); padding-top: max(5px, env(safe-area-inset-top)); }
.turn-indicator { box-shadow: 0 3px 0 #b16b00, 0 6px 16px rgba(0,0,0,.25); }
.table-area { min-height: 70px; border-radius: 24px; }
.table-cards { min-width: 64px; min-height: 46px; }
#player-hand { overflow-x: auto; overscroll-behavior-x: contain; touch-action: pan-x; }
#player-hand .dnd-draggable { touch-action: none; }
.action-bar { padding-bottom: max(6px, env(safe-area-inset-bottom)); background: rgba(3,39,36,.88); }
.action-bar .btn { min-height: 38px; }
.value-btn.active, .value-btn.selected { background: #ffc107; box-shadow: 0 0 0 2px #fff; }
.btn, .mode-card, .nav-item { -webkit-tap-highlight-color: transparent; }
.btn:active, .mode-card:active { transform: scale(.97); }
@media (orientation: landscape) and (max-height: 500px) {
  .game-header { gap: 6px; padding: 4px 10px; }
  .game-header .btn-icon { width: 34px; height: 34px; font-size: 1rem; }
  .header-info { gap: 8px; font-size: .72rem; }
  .turn-indicator { font-size: .75rem; padding: 5px 10px; }
  .opponent-area { padding: 2px 8px; }
  .opponent-area .player-info { margin: 0; font-size: .68rem; }
  .face-down-hand .card { width: 28px; height: 38px; }
  .table-area { padding: 2px 8px; }
  .table-cards, .builds-area { gap: 4px; }
  .builds-area { margin-top: 2px; }
  .table-label { display: none; }
  .player-area-bottom { padding: 0 5px; }
  .player-area-bottom .player-info { font-size: .68rem; margin: 0; }
  #player-hand { padding: 4px 8px 2px; gap: 3px; }
  #player-hand .card { width: clamp(42px, 7vw, 56px); height: clamp(58px, 18vh, 78px); }
  .table-cards .card { width: clamp(38px, 6vw, 50px); height: clamp(53px, 16vh, 70px); }
  .dnd-hint { font-size: .65rem; padding: 1px; }
  .action-bar { gap: 4px; flex-wrap: nowrap; overflow-x: auto; justify-content: safe center; padding: 4px 6px max(4px, env(safe-area-inset-bottom)); }
  .action-bar .btn { white-space: nowrap; flex-shrink: 0; min-height: 34px; padding: 6px 10px; }
  .value-picker { margin: 2px auto; padding: 2px 6px; gap: 4px; }
  .value-buttons { flex-wrap: nowrap; }
  .value-btn { width: 28px; height: 28px; }
  .picker-label { font-size: .7rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
/* Keep the home screen usable on short landscape phone displays. */
.fullscreen-toggle { right: 165px; }
@media (orientation: landscape) and (max-height: 500px) {
  #main-menu { height: 100dvh; min-height: 0; overflow-y: auto; }
  #main-menu > .menu-content { flex: 0 0 auto; padding: 53px 8px 6px; }
  #main-menu .logo { margin-bottom: 2px; }
  #main-menu .logo h1 { font-size: 1.65rem; line-height: 1; }
  #main-menu .logo .tagline { font-size: .7rem; margin: 0; }
  #main-menu .difficulty-row { margin: 3px 0; }
  #main-menu .mode-row { flex-wrap: nowrap; justify-content: safe center; overflow-x: auto; gap: 7px; margin: 4px 0 5px; }
  #main-menu .mode-card { width: clamp(110px, 19vw, 150px); min-height: 105px; padding: 6px; border-width: 2px; border-radius: 14px; flex-shrink: 0; }
  #main-menu .mode-card .mode-art { height: 38px; font-size: 1.6rem; margin-bottom: 4px; }
  #main-menu .mode-card h3 { font-size: .75rem; margin-bottom: 2px; }
  #main-menu .mode-card p { font-size: .62rem; }
  #main-menu .menu-buttons { gap: 4px; }
  #main-menu .menu-buttons .btn { padding: 6px 9px; font-size: .7rem; }
  #main-menu .bottom-nav { flex-shrink: 0; margin-top: auto; }
  #main-menu .nav-item { min-height: 38px; }
  #main-menu .sfx-toggle { left: 10px; top: 53px; width: 34px; height: 34px; }
  #main-menu .how-to-play { top: 55px; right: 10px; padding: 6px 10px; font-size: .7rem; }
  #main-menu .fullscreen-toggle { top: 53px; right: 125px; width: 34px; height: 34px; font-size: 20px; }
}
