/* ==========================================================================
   Russian Hand (هاند روسي) - 100x Luxury Casino Theme & Overhaul (RTL & LTR)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;600;700;800&family=Tajawal:wght@400;500;700;800&family=Outfit:wght@400;500;600;700;800&family=Inter:wght@400;500;600&display=swap');

:root {
  --bg-table: radial-gradient(circle at 50% 45%, #1d5236 0%, #0d2c1c 65%, #05140c 100%);
  --felt-overlay: radial-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px);
  --gold-accent: #f59e0b;
  --gold-glow: rgba(245, 158, 11, 0.65);
  --brass: #d4af37;
  --panel-bg: rgba(10, 20, 15, 0.88);
  --panel-border: rgba(245, 158, 11, 0.25);
  --card-width: 86px;
  --card-height: 126px;
  --card-radius: 9px;
  --red-suit: #dc2626;
  --black-suit: #0f172a;
  --joker-purple: #7e22ce;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --shadow-card: 0 6px 16px rgba(0, 0, 0, 0.45);
  --shadow-selected: 0 0 24px rgba(245, 158, 11, 0.95), 0 16px 32px rgba(0, 0, 0, 0.6);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

body {
  font-family: 'Outfit', 'Tajawal', 'Inter', 'Cairo', sans-serif;
  background: var(--bg-table);
  background-size: cover;
  color: var(--text-main);
  height: 100vh;
  height: 100dvh;
  width: 100vw;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
}

[dir="rtl"] body {
  font-family: 'Tajawal', 'Cairo', sans-serif;
}

/* Side Leather Armrest Overlays */
.leather-armrest {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 48px;
  z-index: 10;
  pointer-events: none;
  background: linear-gradient(90deg, #180a04 0%, #3a1c0d 45%, #180a04 100%);
  box-shadow: inset 0 0 16px rgba(0, 0, 0, 0.95), 0 0 30px rgba(0, 0, 0, 0.85);
}

.leather-armrest.left {
  left: 0;
  border-right: 3px solid #5a2e12;
  border-top-right-radius: 36px;
  border-bottom-right-radius: 36px;
}

.leather-armrest.right {
  right: 0;
  border-left: 3px solid #5a2e12;
  border-top-left-radius: 36px;
  border-bottom-left-radius: 36px;
}

/* App Header */
.app-header {
  height: 50px;
  background: rgba(6, 15, 10, 0.95);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--panel-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 54px;
  z-index: 100;
}

.header-left-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-right-brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-ticker-tip {
  font-size: 0.8rem;
  color: var(--gold-accent);
  font-weight: 600;
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.25);
  padding: 3px 12px;
  border-radius: 12px;
}

@media (max-width: 900px) {
  .header-ticker-tip {
    display: none;
  }
}

.brand-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--gold-accent);
  letter-spacing: 0.5px;
}

.brand-badge {
  font-size: 0.75rem;
  font-weight: 700;
  background: rgba(245, 158, 11, 0.18);
  color: var(--gold-accent);
  padding: 2px 8px;
  border-radius: 10px;
  border: 1px solid rgba(245, 158, 11, 0.35);
}

.btn-action {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border: 1px solid var(--panel-border);
  padding: 6px 14px;
  border-radius: 8px;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-action:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.18);
  border-color: var(--gold-accent);
}

.btn-action.primary {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: #0f172a;
  border: none;
  font-weight: 800;
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.4);
}

.btn-micro {
  padding: 4px 10px;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(15, 23, 42, 0.85);
  color: #fff;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-micro:hover {
  background: var(--gold-accent);
  color: #0f172a;
}

/* Main Game Viewport Grid Layout */
.game-viewport {
  flex: 1;
  display: grid;
  grid-template-rows: 85px 1fr 220px;
  grid-template-columns: 210px 1fr 210px;
  gap: 12px;
  padding: 10px 54px 60px 54px;
  position: relative;
  background-image: var(--felt-overlay);
  background-size: 20px 20px;
}

/* Kammelna Mobile Slots & Strip - display: contents keeps desktop grid untouched */
.opponents-top-strip {
  display: contents;
}

.mobile-self-slot,
.mobile-piles-slot,
.mobile-ticker-slot,
.mobile-menu-toggle,
.mobile-menu-panel {
  display: none;
}

/* Player Zones */
.player-zone {
  display: flex;
  align-items: center;
  justify-content: center;
}

.player-zone.top {
  grid-row: 1;
  grid-column: 2;
}

.player-zone.left {
  grid-row: 2;
  grid-column: 1;
  flex-direction: column;
  gap: 10px;
}

.player-zone.right {
  grid-row: 2;
  grid-column: 3;
  flex-direction: column;
  gap: 10px;
}

.player-zone.bottom {
  grid-row: 3;
  grid-column: 1 / span 3;
  flex-direction: column;
  justify-content: flex-end;
  gap: 6px;
  position: relative;
}

/* Player Badges & Bot Mini Hands */
.player-badge {
  background: var(--panel-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 8px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: all 0.3s ease;
  min-width: 175px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.player-badge.mini-player-badge {
  min-width: 130px;
  padding: 4px 10px;
}

.player-badge.active-turn {
  border-color: var(--gold-accent);
  box-shadow: 0 0 20px var(--gold-glow), 0 6px 18px rgba(0, 0, 0, 0.5);
}

.player-badge.opened-status {
  border-color: rgba(16, 185, 129, 0.5);
}

.badge-avatar {
  font-size: 1.6rem;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 50%;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--panel-border);
}

.badge-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.badge-name {
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 6px;
}

.dealer-icon {
  font-size: 0.75rem;
  color: var(--gold-accent);
}

.badge-stats {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.7rem;
}

.card-count-pill, .open-status-pill {
  background: rgba(255, 255, 255, 0.08);
  padding: 1px 6px;
  border-radius: 6px;
  color: var(--text-muted);
}

.badge-score {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--gold-accent);
}

/* Compact Turn Timer HUD Pill near Active Player Badge */
.badge-turn-timer {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.22) 0%, rgba(217, 119, 6, 0.28) 100%);
  border: 1px solid rgba(245, 158, 11, 0.7);
  color: #fef08a;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
  letter-spacing: 0.3px;
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.35);
  flex-shrink: 0;
  transition: all 0.25s ease;
  user-select: none;
}

[dir="rtl"] .badge-turn-timer {
  margin-left: 0;
  margin-right: auto;
}

.badge-turn-timer .timer-sand {
  font-size: 0.8rem;
  display: inline-block;
  animation: sandPulse 2s infinite ease-in-out;
}

.badge-turn-timer .timer-sec {
  font-variant-numeric: tabular-nums;
  min-width: 22px;
  text-align: center;
}

.badge-turn-timer.urgent {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.32) 0%, rgba(220, 38, 38, 0.42) 100%);
  border-color: #ef4444;
  color: #fee2e2;
  box-shadow: 0 0 16px rgba(239, 68, 68, 0.7), inset 0 0 8px rgba(239, 68, 68, 0.3);
  animation: timerUrgentBlink 0.8s infinite alternate ease-in-out;
}

.badge-turn-timer.urgent .timer-sand {
  animation: timerUrgentSpin 0.8s infinite linear;
}

@keyframes sandPulse {
  0%, 100% { transform: rotate(0deg) scale(1); opacity: 0.85; }
  50% { transform: rotate(180deg) scale(1.1); opacity: 1; }
}

@keyframes timerUrgentBlink {
  0% { transform: scale(1); box-shadow: 0 0 10px rgba(239, 68, 68, 0.5); }
  100% { transform: scale(1.05); box-shadow: 0 0 20px rgba(239, 68, 68, 0.95); }
}

@keyframes timerUrgentSpin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.bot-mini-hand {
  display: flex;
  gap: -18px;
  margin-top: 4px;
}

.bot-mini-card {
  width: 28px;
  height: 42px;
  border-radius: 4px;
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

/* Center Stage: Exposed Melds Table Board */
.table-center-zone {
  grid-row: 2;
  grid-column: 2;
  background: rgba(6, 20, 14, 0.78);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: 16px;
  box-shadow: inset 0 0 35px rgba(0, 0, 0, 0.7), 0 8px 24px rgba(0, 0, 0, 0.4);
  padding: 12px 18px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.exposed-melds-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px dashed rgba(245, 158, 11, 0.3);
}

.table-mat-title {
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: var(--gold-accent);
}

.table-stage-body {
  flex: 1;
  display: flex;
  min-height: 0;
  position: relative;
  overflow: hidden;
}

.melds-grid-container {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: min-content;
  gap: 12px;
  overflow-y: auto;
  padding-right: 4px;
}

@media (max-width: 1250px) {
  .melds-grid-container {
    grid-template-columns: repeat(2, 1fr);
  }
}

.no-melds-msg {
  grid-column: 1 / span 3;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 40px;
  font-style: italic;
}

.table-meld-card-group,
.table-meld-group {
  background: rgba(15, 23, 42, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: all 0.2s ease;
  position: relative;
  overflow: visible;
}

.table-meld-card-group:hover,
.table-meld-group:hover {
  border-color: var(--gold-accent);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
}

.meld-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.75rem;
}

.meld-owner {
  font-weight: 700;
  color: var(--gold-accent);
}

.meld-type-tag {
  background: rgba(255, 255, 255, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
  color: #e2e8f0;
  font-weight: 600;
}

.meld-cards-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: visible;
  padding: 4px 4px 6px 4px;
  min-height: 76px;
  scrollbar-width: thin;
  scrollbar-color: rgba(245, 158, 11, 0.3) transparent;
}

.meld-cards-row::-webkit-scrollbar {
  height: 4px;
}

.meld-cards-row::-webkit-scrollbar-thumb {
  background: rgba(245, 158, 11, 0.35);
  border-radius: 3px;
}

.exposed-meld-card {
  width: 48px !important;
  height: 70px !important;
  min-width: 48px !important;
  max-width: 48px !important;
  border-radius: 6px !important;
  padding: 3px 4px !important;
  margin-left: -18px !important;
  margin-right: 0 !important;
  margin-bottom: 0 !important;
  flex-shrink: 0 !important;
  transform: none !important;
  position: relative;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35) !important;
  transition: transform 0.15s ease, z-index 0.15s ease, box-shadow 0.15s ease;
}

.exposed-meld-card:first-child {
  margin-left: 0 !important;
}

[dir="rtl"] .exposed-meld-card {
  margin-left: 0 !important;
  margin-right: -18px !important;
}

[dir="rtl"] .exposed-meld-card:first-child {
  margin-right: 0 !important;
}

.exposed-meld-card:hover {
  transform: translateY(-4px) !important;
  z-index: 20 !important;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.5) !important;
}

.exposed-meld-card .card-corner {
  line-height: 1;
}

.exposed-meld-card .card-rank {
  font-size: 0.72rem !important;
  font-weight: 800 !important;
  line-height: 1 !important;
}

.exposed-meld-card .card-suit {
  font-size: 0.62rem !important;
  line-height: 1 !important;
}

.exposed-meld-card .card-center {
  font-size: 1rem !important;
  line-height: 1 !important;
}

.exposed-meld-card .face-card-badge {
  font-size: 0.75rem !important;
  line-height: 1 !important;
}

.exposed-meld-card.joker-card .card-rank {
  font-size: 0.52rem !important;
  letter-spacing: -0.5px;
}

.exposed-meld-card.joker-card .joker-center {
  font-size: 0.8rem !important;
}

.exposed-meld-card.joker-card .joker-star-badge,
.exposed-meld-card.joker-card .joker-title {
  display: none !important;
}

.joker-substituted {
  border: 2px solid var(--joker-purple) !important;
  box-shadow: 0 0 12px rgba(126, 34, 206, 0.6) !important;
}

.meld-actions-bar {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}

/* Floating Live Meld Badge & Calculator */
.floating-meld-badge {
  position: absolute;
  top: -46px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  padding: 4px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
  z-index: 40;
}

.hud-score-box {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hud-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.hud-points {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--gold-accent);
}

.hud-status-box {
  display: flex;
  flex-direction: column;
}

.hud-status-title {
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
}

.hud-status-desc {
  font-size: 0.68rem;
  color: var(--text-muted);
}

/* Human Hand Wrapper & Relocated Piles */
.player-hand-and-piles-wrapper,
.hand-container {
  width: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  position: relative;
  padding-right: 180px;
}

[dir="rtl"] .player-hand-and-piles-wrapper,
[dir="rtl"] .hand-container {
  padding-right: 0;
  padding-left: 180px;
}

.human-hand-wrapper,
.hand-container-inner {
  flex: 1;
  display: flex;
  justify-content: center;
}

.cards-container.fanned-hand,
#human-hand,
#player-hand {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: -34px;
  padding: 10px 0;
}

.side-piles-container {
  position: absolute;
  right: 0;
  bottom: 0;
  display: flex;
  gap: 14px;
  z-index: 30;
}

[dir="rtl"] .side-piles-container {
  right: auto;
  left: 0;
}

.pile-wrapper.side-pile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}

.pile-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--gold-accent);
}

.stock-card-stack, .discard-card-holder {
  width: var(--card-width);
  height: var(--card-height);
  border-radius: var(--card-radius);
  position: relative;
}

.stock-card-stack {
  box-shadow: 2px 2px 0 #0f172a, 4px 4px 0 #1e293b, var(--shadow-card);
}

.empty-pile-placeholder {
  width: 100%;
  height: 100%;
  border: 2px dashed rgba(255, 255, 255, 0.2);
  border-radius: var(--card-radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  color: var(--text-muted);
  text-align: center;
}

.badge-count-pill {
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid var(--panel-border);
  color: var(--gold-accent);
  font-size: 0.75rem;
  font-weight: 800;
  padding: 1px 8px;
  border-radius: 10px;
}

.discard-status-badge {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 6px;
  margin-top: 2px;
}

.discard-status-badge.valid {
  background: rgba(16, 185, 129, 0.2);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.discard-status-badge.invalid {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.4);
}

.hidden {
  display: none !important;
}

/* Playing Card Styling */
.card {
  width: var(--card-width);
  height: var(--card-height);
  border-radius: var(--card-radius);
  background: #ffffff;
  border: 1px solid #cbd5e1;
  box-shadow: var(--shadow-card);
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 6px;
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease;
  margin-left: -28px;
}

.card:first-child {
  margin-left: 0;
}

.card:hover:not(.face-down) {
  transform: translateY(-14px) scale(1.04);
  z-index: 50;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.5);
}

.card.selected {
  transform: translateY(-28px) scale(1.06);
  z-index: 100;
  border: 2px solid #f59e0b;
  box-shadow: 0 0 24px rgba(245, 158, 11, 0.95), 0 16px 32px rgba(0, 0, 0, 0.6);
}

/* Floating Selected Badge attached above card */
.card-floating-meld-badge {
  position: absolute;
  top: -38px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 4px;
  z-index: 120;
  pointer-events: none;
  animation: floatBadgeBounce 0.3s ease;
}

@keyframes floatBadgeBounce {
  0% { opacity: 0; transform: translate(-50%, -10px); }
  100% { opacity: 1; transform: translate(-50%, 0); }
}

.badge-title-capsule {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: #0f172a;
  font-weight: 900;
  font-size: 0.7rem;
  padding: 3px 8px;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.5);
  white-space: nowrap;
}

.badge-points-pill {
  background: #0f172a;
  border: 1px solid #f59e0b;
  color: #f59e0b;
  font-weight: 800;
  font-size: 0.75rem;
  padding: 2px 6px;
  border-radius: 8px;
  white-space: nowrap;
}

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

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

.card-corner {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
}

.card-corner.top-left {
  align-self: flex-start;
}

.card-corner.bottom-right {
  align-self: flex-end;
  transform: rotate(180deg);
}

.card-rank {
  font-size: 0.9rem;
  font-weight: 800;
}

.card-suit {
  font-size: 0.85rem;
}

.card-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 1.8rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.face-card-badge {
  font-size: 1.2rem;
}

.joker-card {
  background: linear-gradient(135deg, #fef08a 0%, #fef3c7 100%);
  color: var(--joker-purple);
  border: 1px solid #eab308;
}

.joker-center {
  font-size: 1rem;
}

.joker-graphic {
  font-size: 2rem;
}

.joker-title {
  font-weight: 800;
  font-size: 0.65rem;
  letter-spacing: 1px;
}

/* Card Back Pattern */
.card.face-down {
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 4px;
}

.card-back-pattern {
  width: 100%;
  height: 100%;
  border: 1px solid rgba(245, 158, 11, 0.4);
  border-radius: 6px;
  background: radial-gradient(circle at center, #334155 0%, #0f172a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-back-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  color: var(--gold-accent);
}

.back-icon {
  font-size: 1.4rem;
}

.back-text {
  font-size: 0.55rem;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: 0.5px;
}

/* Unified Bottom Glassmorphic Control Bar */
.bottom-control-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 52px;
  background: rgba(6, 15, 10, 0.95);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--panel-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 54px;
  z-index: 90;
}

.bar-left-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-micro-bar {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--panel-border);
  color: #fff;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-micro-bar:hover {
  background: rgba(255, 255, 255, 0.18);
  border-color: var(--gold-accent);
}

.bar-center-ticker {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  max-width: 450px;
  margin: 0 16px;
}

.ticker-label {
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--gold-accent);
  background: rgba(245, 158, 11, 0.15);
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
}

.turn-guide-text {
  font-size: 0.8rem;
  font-weight: 600;
  color: #e2e8f0;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bar-right-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-action-bar {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--panel-border);
  color: #fff;
  padding: 5px 12px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.btn-action-bar:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.18);
  border-color: var(--gold-accent);
}

.btn-action-bar:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-action-bar.primary-meld {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: #0f172a;
  border: none;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.35);
}

.btn-action-bar.accent-draw {
  background: rgba(16, 185, 129, 0.2);
  border-color: rgba(16, 185, 129, 0.5);
  color: #34d399;
}

.btn-action-bar.accent-discard {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.5);
  color: #f87171;
}

.btn-action-bar.accent-end-turn {
  background: rgba(59, 130, 246, 0.15);
  border-color: rgba(59, 130, 246, 0.4);
  color: #60a5fa;
}

.btn-action-bar.accent-end-turn:not(:disabled) {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  color: #ffffff;
  border-color: #60a5fa;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.45);
  cursor: pointer;
  animation: pulse-end-turn 2s infinite ease-in-out;
}

@keyframes pulse-end-turn {
  0%, 100% {
    transform: translateY(0);
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.45);
  }
  50% {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(59, 130, 246, 0.65);
  }
}

#discard-pile-wrapper {
  display: none !important;
}

/* Modal Overlay Base */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.modal.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  width: 90%;
  max-width: 540px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

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

.modal-header h2 {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--gold-accent);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.4rem;
  cursor: pointer;
}

.modal-body {
  padding: 20px;
  max-height: 75vh;
  overflow-y: auto;
  font-size: 0.9rem;
  line-height: 1.5;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.form-group label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}

.form-control {
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 8px 12px;
  color: #fff;
  font-family: inherit;
  font-size: 0.9rem;
}

.form-control:focus {
  outline: none;
  border-color: var(--gold-accent);
}

/* Summary Table Styling */
.summary-table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0;
}

.summary-table th, .summary-table td {
  padding: 8px 10px;
  font-size: 0.8rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.summary-table th {
  text-align: left;
  color: var(--gold-accent);
}

[dir="rtl"] .summary-table th {
  text-align: right;
}

.winner-row {
  background: rgba(245, 158, 11, 0.12);
}

.penalty-highlight {
  color: #ef4444;
  font-weight: 700;
}

/* ==========================================================================
   Mode Selection & Multiplayer Lobby Styling
   ========================================================================== */
.mode-modal-content {
  max-width: 650px;
}

.mode-options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-top: 10px;
}

@media (max-width: 600px) {
  .mode-options-grid {
    grid-template-columns: 1fr;
  }
}

.mode-card {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  transition: all 0.25s ease;
}

.mode-card:hover {
  border-color: var(--gold-accent);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.mode-card-icon {
  font-size: 2.8rem;
  margin-bottom: 10px;
}

.mode-card h3 {
  font-size: 1.15rem;
  color: var(--gold-accent);
  margin-bottom: 6px;
}

.mode-card p {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.width-full {
  width: 100%;
  justify-content: center;
}

.accent-green {
  background: #10b981 !important;
  color: #fff !important;
  border-color: #059669 !important;
}

.accent-green:hover {
  background: #059669 !important;
}

.multiplayer-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: left;
}

[dir="rtl"] .multiplayer-form {
  text-align: right;
}

.join-room-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.text-uppercase {
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 2px;
  text-align: center;
}

/* Room Lobby Styling */
.room-code-banner {
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.4);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 20px;
}

.code-pill {
  font-size: 1.6rem;
  font-weight: 900;
  color: var(--gold-accent);
  letter-spacing: 4px;
  background: rgba(0, 0, 0, 0.4);
  padding: 4px 14px;
  border-radius: 8px;
  border: 1px dashed var(--gold-accent);
}

.lobby-seats-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.lobby-seat-item {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.lobby-seat-item.occupied {
  border-color: rgba(16, 185, 129, 0.4);
  background: rgba(16, 185, 129, 0.08);
}

.seat-info {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 600;
}

.seat-avatar {
  font-size: 1.4rem;
}

.seat-tag {
  font-size: 0.75rem;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-muted);
}

.seat-tag.host {
  background: rgba(245, 158, 11, 0.2);
  color: var(--gold-accent);
}

.lobby-actions-bar {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

/* ==========================================================================
   Responsive Kammelna-Style Mobile Portrait Redesign (max-width: 900px)
   ========================================================================== */
@media (max-width: 900px) {
  :root {
    --card-width: 50px;
    --card-height: 72px;
    --card-radius: 6px;
  }

  html, body {
    height: 100dvh !important;
    min-height: 100dvh !important;
    max-height: 100dvh !important;
    overflow: hidden !important;
    position: fixed;
    width: 100vw;
    margin: 0;
    padding: 0;
    touch-action: pan-y;
  }

  .leather-armrest {
    display: none !important;
  }

  /* Compact App Header */
  .app-header {
    height: 40px;
    min-height: 40px;
    padding: 0 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    z-index: 120;
    background: rgba(6, 15, 10, 0.98);
  }

  /* Hamburger Menu Toggle */
  .mobile-menu-toggle {
    display: flex;
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    cursor: pointer;
    padding: 0;
    transition: all 0.2s ease;
    flex-shrink: 0;
  }

  .mobile-menu-toggle:hover {
    background: rgba(255, 255, 255, 0.16);
    border-color: var(--gold-accent);
  }

  .hamburger-line {
    display: block;
    width: 16px;
    height: 2px;
    background: var(--gold-accent);
    border-radius: 2px;
    transition: all 0.25s ease;
  }

  .mobile-menu-toggle[aria-expanded="true"] .hamburger-line:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
  }

  .mobile-menu-toggle[aria-expanded="true"] .hamburger-line:nth-child(2) {
    opacity: 0;
  }

  .mobile-menu-toggle[aria-expanded="true"] .hamburger-line:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
  }

  /* Header Left Actions: holds Start Game button on mobile */
  .header-left-actions {
    display: flex;
    align-items: center;
    gap: 6px;
  }

  #btn-start-game {
    padding: 4px 10px;
    font-size: 0.74rem;
    font-weight: 700;
    border-radius: 6px;
    height: 30px;
  }

  .header-ticker-tip {
    display: none !important;
  }

  .brand-title {
    font-size: 0.88rem;
    gap: 6px;
  }

  .brand-badge {
    font-size: 0.62rem;
    padding: 1px 5px;
  }

  /* Slide-Down Mobile Dropdown Menu Panel */
  .mobile-menu-panel {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 8px;
    background: rgba(10, 25, 18, 0.96);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border: 1px solid var(--gold-accent);
    border-radius: 12px;
    padding: 10px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.8), 0 0 16px rgba(245, 158, 11, 0.25);
    z-index: 1000;
    min-width: 190px;
    flex-direction: column;
    gap: 8px;
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    pointer-events: none;
  }

  [dir="rtl"] .mobile-menu-panel {
    left: auto;
    right: 8px;
  }

  .mobile-menu-panel.open {
    display: flex;
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
  }

  .mobile-menu-panel .btn-action,
  .mobile-menu-panel .btn-micro-bar {
    width: 100%;
    justify-content: flex-start;
    padding: 8px 12px;
    font-size: 0.82rem;
    font-weight: 600;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--panel-border);
    color: #fff;
    cursor: pointer;
    transition: all 0.2s ease;
  }

  .mobile-menu-panel .btn-action:hover,
  .mobile-menu-panel .btn-micro-bar:hover {
    background: rgba(255, 255, 255, 0.18);
    border-color: var(--gold-accent);
  }

  /* Game Viewport: Fills available space with bottom padding to clear the bottom control bar */
  .game-viewport {
    flex: 1 1 0;
    min-height: 0;
    height: auto;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 4px 6px calc(54px + max(4px, env(safe-area-inset-bottom, 0px))) 6px;
    gap: 4px;
    overflow: hidden;
    position: relative;
    box-sizing: border-box;
  }

  /* Kammelna Top Opponents & Player Strip */
  .opponents-top-strip {
    display: flex;
    flex-direction: row;
    gap: 4px;
    width: 100%;
    height: 48px;
    min-height: 48px;
    flex-shrink: 0;
    align-items: stretch;
    justify-content: space-between;
    z-index: 20;
    box-sizing: border-box;
  }

  .opponents-top-strip .player-zone,
  .opponents-top-strip .mobile-self-slot {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    align-items: stretch;
    justify-content: stretch;
    height: 100%;
    padding: 0;
    margin: 0;
  }

  .opponents-top-strip .player-badge {
    flex: 1 1 0;
    min-width: 0 !important;
    width: 100%;
    height: 100%;
    padding: 2px 4px;
    border-radius: 8px;
    gap: 4px;
    display: flex;
    align-items: center;
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid var(--panel-border);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    box-sizing: border-box;
    overflow: hidden !important;
    transition: all 0.25s ease;
  }

  .opponents-top-strip .count-label,
  .opponents-top-strip .score-label {
    display: none !important;
  }

  .opponents-top-strip .player-badge.active-turn {
    border-color: var(--gold-accent);
    box-shadow: 0 0 12px var(--gold-glow), 0 2px 8px rgba(0, 0, 0, 0.5);
    animation: turnBorderPulse 2s infinite ease-in-out;
  }

  @keyframes turnBorderPulse {
    0%, 100% { border-color: var(--gold-accent); box-shadow: 0 0 10px var(--gold-glow); }
    50% { border-color: #fef08a; box-shadow: 0 0 18px rgba(245, 158, 11, 0.8); }
  }

  .opponents-top-strip .player-badge.opened-status {
    border-color: rgba(16, 185, 129, 0.7);
  }

  .opponents-top-strip .badge-avatar {
    width: 22px;
    height: 22px;
    min-width: 22px;
    font-size: 0.85rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--panel-border);
  }

  .opponents-top-strip .badge-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 1px;
    line-height: 1.1;
    overflow: hidden;
  }

  .opponents-top-strip .badge-name {
    font-size: 0.63rem;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    gap: 2px;
  }

  .opponents-top-strip .dealer-icon {
    font-size: 0.58rem;
    color: var(--gold-accent);
  }

  .opponents-top-strip .badge-stats {
    font-size: 0.52rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    white-space: nowrap;
    overflow: hidden;
  }

  .opponents-top-strip .card-count-pill {
    padding: 1px 3px;
    border-radius: 4px;
    font-size: 0.52rem;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-muted);
    white-space: nowrap;
  }

  .opponents-top-strip .open-status-pill {
    display: none !important;
  }

  .opponents-top-strip .badge-score {
    font-size: 0.56rem;
    font-weight: 700;
    color: var(--gold-accent);
    white-space: nowrap;
  }

  .opponents-top-strip .bot-mini-hand {
    display: none !important;
  }

  .opponents-top-strip .badge-turn-timer {
    padding: 1px 4px;
    font-size: 0.52rem;
    gap: 2px;
    border-radius: 5px;
    box-shadow: 0 0 6px rgba(245, 158, 11, 0.3);
  }

  .opponents-top-strip .badge-turn-timer .timer-sand {
    font-size: 0.55rem;
  }

  .opponents-top-strip .badge-turn-timer .timer-sec {
    min-width: 16px;
  }

  /* Center Stage: Grand Casino Table Board */
  .table-center-zone {
    flex: 1 1 0;
    min-height: 0;
    padding: 6px 8px;
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: rgba(6, 20, 14, 0.85);
    border: 1px solid rgba(245, 158, 11, 0.35);
    box-shadow: inset 0 0 24px rgba(0, 0, 0, 0.7);
    margin: 0;
  }

  .exposed-melds-header {
    margin-bottom: 4px;
    padding-bottom: 3px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
    flex-shrink: 0;
    border-bottom: 1px dashed rgba(245, 158, 11, 0.3);
  }

  .table-mat-title {
    font-size: 0.65rem;
    letter-spacing: 0.5px;
    font-weight: 800;
    color: var(--gold-accent);
    white-space: nowrap;
  }

  .mobile-ticker-slot {
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0;
    margin: 0 4px;
    overflow: hidden;
  }

  .mobile-ticker-slot .bar-center-ticker {
    display: flex;
    align-items: center;
    gap: 4px;
    width: 100%;
    margin: 0;
    max-width: 100%;
  }

  .mobile-ticker-slot .turn-guide-text {
    font-size: 0.63rem;
    color: #e2e8f0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  #btn-reset-table {
    padding: 2px 6px;
    font-size: 0.62rem;
    flex-shrink: 0;
  }

  /* Table Stage Body: Melds area on left, Piles rail on right */
  .table-stage-body {
    display: flex;
    flex-direction: row;
    flex: 1;
    min-height: 0;
    gap: 6px;
    overflow: hidden;
    position: relative;
  }

  /* Exposed Table Melds Container with smooth vertical scroll */
  .melds-grid-container {
    flex: 1;
    min-width: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding-right: 4px;
    padding-bottom: 4px;
    scrollbar-width: thin;
  }

  .no-melds-msg {
    margin-top: 24px;
    font-size: 0.75rem;
  }

  .table-meld-card-group,
  .table-meld-group {
    padding: 6px 8px;
    gap: 4px;
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.88);
    border: 1px solid rgba(245, 158, 11, 0.22);
    flex-shrink: 0;
    overflow: visible;
  }

  .meld-header {
    font-size: 0.66rem;
    font-weight: 700;
  }

  .meld-cards-row {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    overflow-x: auto !important;
    overflow-y: visible !important;
    -webkit-overflow-scrolling: touch;
    padding: 3px 4px 5px 4px !important;
    min-height: 64px;
    scrollbar-width: thin;
    scrollbar-color: rgba(245, 158, 11, 0.35) transparent;
  }

  .meld-cards-row::-webkit-scrollbar {
    height: 3px;
    display: block;
  }

  .meld-cards-row::-webkit-scrollbar-thumb {
    background: rgba(245, 158, 11, 0.35);
    border-radius: 3px;
  }

  .exposed-meld-card {
    width: 40px !important;
    height: 58px !important;
    min-width: 40px !important;
    max-width: 40px !important;
    border-radius: 5px !important;
    padding: 2px 3px !important;
    margin-left: -18px !important;
    margin-right: 0 !important;
    margin-bottom: 0 !important;
    flex-shrink: 0 !important;
    transform: none !important;
    position: relative;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35) !important;
    transition: transform 0.15s ease, z-index 0.15s ease;
  }

  .exposed-meld-card:first-child {
    margin-left: 0 !important;
  }

  [dir="rtl"] .exposed-meld-card {
    margin-left: 0 !important;
    margin-right: -18px !important;
  }

  [dir="rtl"] .exposed-meld-card:first-child {
    margin-right: 0 !important;
  }

  .exposed-meld-card:hover,
  .exposed-meld-card:active {
    transform: translateY(-4px) !important;
    z-index: 15 !important;
  }

  .exposed-meld-card .card-corner {
    line-height: 1;
  }

  .exposed-meld-card .card-rank {
    font-size: 0.62rem !important;
    font-weight: 800 !important;
    line-height: 1 !important;
  }

  .exposed-meld-card .card-suit {
    font-size: 0.55rem !important;
    line-height: 1 !important;
  }

  .exposed-meld-card .card-center {
    font-size: 0.82rem !important;
    line-height: 1 !important;
  }

  .exposed-meld-card .card-center-suit {
    font-size: 0.82rem !important;
  }

  .exposed-meld-card .face-card-badge {
    font-size: 0.62rem !important;
    line-height: 1 !important;
    margin-bottom: 0 !important;
  }

  .exposed-meld-card.joker-card .card-rank {
    font-size: 0.46rem !important;
    letter-spacing: -0.5px;
  }

  .exposed-meld-card.joker-card .joker-center {
    font-size: 0.7rem !important;
  }

  .exposed-meld-card.joker-card .joker-star-badge,
  .exposed-meld-card.joker-card .joker-title {
    display: none !important;
  }

  /* Side Piles Rail Slot: Center-right of the felt */
  .mobile-piles-slot {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
    width: 66px;
    padding: 2px 0 2px 6px;
    border-left: 1px dashed rgba(245, 158, 11, 0.25);
  }

  [dir="rtl"] .mobile-piles-slot {
    padding: 2px 6px 2px 0;
    border-left: none;
    border-right: 1px dashed rgba(245, 158, 11, 0.25);
  }

  .mobile-piles-slot .side-piles-container {
    position: static;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    width: 100%;
    margin: 0;
    padding: 0;
  }

  .mobile-piles-slot .pile-wrapper.side-pile {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    width: 100%;
    cursor: pointer;
  }

  .mobile-piles-slot .pile-label {
    font-size: 0.52rem;
    font-weight: 700;
    color: var(--text-muted);
    text-align: center;
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    max-width: 60px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .mobile-piles-slot .stock-card-stack,
  .mobile-piles-slot .discard-card-holder {
    width: 46px;
    height: 64px;
    border-radius: 6px;
    position: relative;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
  }

  .mobile-piles-slot .stock-card-stack .card,
  .mobile-piles-slot .discard-card-holder .card {
    width: 46px;
    height: 64px;
    border-radius: 6px;
    margin: 0 !important;
    transform: none !important;
    position: absolute;
    top: 0;
    left: 0;
  }

  .mobile-piles-slot .stock-card-stack.pile-ready {
    box-shadow: 0 0 14px var(--gold-glow);
    border: 1px solid var(--gold-accent);
    border-radius: 6px;
    animation: pilePulse 1.8s infinite ease-in-out;
  }

  @keyframes pilePulse {
    0%, 100% { box-shadow: 0 0 8px var(--gold-glow); }
    50% { box-shadow: 0 0 18px var(--gold-accent); }
  }

  .mobile-piles-slot .badge-count-pill {
    font-size: 0.6rem;
    padding: 1px 5px;
    border-radius: 6px;
    background: rgba(245, 158, 11, 0.2);
    color: var(--gold-accent);
    border: 1px solid rgba(245, 158, 11, 0.4);
  }

  .mobile-piles-slot .discard-status-badge {
    font-size: 0.5rem;
    padding: 1px 3px;
    border-radius: 4px;
    white-space: nowrap;
  }

  .mobile-piles-slot .empty-pile-placeholder {
    width: 46px;
    height: 64px;
    font-size: 0.52rem;
    padding: 2px;
    border-radius: 6px;
  }

  /* Bottom Player Zone: Lifted above bottom control bar */
  .player-zone.bottom {
    flex: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    padding: 0 0 2px 0;
    width: 100%;
    z-index: 50;
    gap: 2px;
  }

  /* HUD Meld Value Calculator: Slim bar directly above the cards, never overlapping */
  .floating-meld-badge {
    position: static !important;
    top: auto !important;
    left: auto !important;
    transform: none !important;
    margin: 0 auto 2px auto;
    padding: 2px 10px;
    gap: 8px;
    border-radius: 12px;
    z-index: 40;
    flex-shrink: 0;
    width: 100%;
    max-width: 480px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(15, 23, 42, 0.92);
    border: 1px solid rgba(245, 158, 11, 0.4);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  }

  .floating-meld-badge #player-badge-0 {
    display: none !important; /* Relocated to mobile-self-slot at the top */
  }

  .hud-score-box {
    display: flex;
    align-items: center;
    gap: 4px;
  }

  .hud-label {
    font-size: 0.58rem;
    color: var(--text-muted);
    text-transform: uppercase;
  }

  .hud-points {
    font-size: 0.82rem;
    font-weight: 800;
    color: var(--gold-accent);
  }

  .hud-status-box {
    display: flex;
    align-items: center;
    gap: 6px;
    overflow: hidden;
  }

  .hud-status-title {
    font-size: 0.65rem;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .hud-status-desc {
    font-size: 0.58rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Human Hand Wrapper & Fanning: 100% full width, lifted above bottom bar */
  .player-hand-and-piles-wrapper,
  .hand-container {
    padding: 0 !important;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    min-height: 98px;
    margin: 0;
  }

  .human-hand-wrapper,
  .hand-container-inner {
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    padding: 24px 8px 6px 8px;
    scrollbar-width: none;
    -ms-overflow-style: none;
    z-index: 60;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    touch-action: pan-x;
    box-sizing: border-box;
  }

  .human-hand-wrapper::-webkit-scrollbar,
  .hand-container-inner::-webkit-scrollbar {
    display: none;
  }

  .human-hand-wrapper.is-scrollable,
  .hand-container-inner.is-scrollable {
    justify-content: flex-start;
  }

  .cards-container.fanned-hand,
  #human-hand,
  #player-hand {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 0;
    padding: 0 8px;
    margin: 0 auto;
    min-width: max-content;
  }

  .human-hand-wrapper.is-scrollable .cards-container.fanned-hand,
  .hand-container-inner.is-scrollable .cards-container.fanned-hand,
  .human-hand-wrapper.is-scrollable #human-hand,
  .hand-container-inner.is-scrollable #player-hand {
    justify-content: flex-start;
    padding: 0 14px;
  }

  /* Cards in Human Hand: Generous touch target, reduced negative margin, precise z-index */
  .cards-container.fanned-hand .card,
  #human-hand .card,
  #player-hand .card {
    width: var(--card-width, 50px);
    height: var(--card-height, 72px);
    border-radius: var(--card-radius, 6px);
    padding: 2px 3px;
    flex-shrink: 0;
    margin-left: calc(var(--hand-step, 34px) - var(--card-width, 50px));
    transform-origin: center bottom;
    transform: translateY(var(--fan-y, 0px)) rotate(var(--fan-rot, 0deg));
    transition: transform 0.15s ease, margin 0.15s ease, box-shadow 0.15s ease;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
    z-index: calc(var(--card-index, 0) * 2 + 2);
    position: relative;
    cursor: pointer;
  }

  .cards-container.fanned-hand .card:first-child,
  #human-hand .card:first-child,
  #player-hand .card:first-child {
    margin-left: 0 !important;
  }

  [dir="rtl"] .cards-container.fanned-hand .card,
  [dir="rtl"] #human-hand .card,
  [dir="rtl"] #player-hand .card {
    margin-left: 0;
    margin-right: calc(var(--hand-step, 34px) - var(--card-width, 50px));
  }

  [dir="rtl"] .cards-container.fanned-hand .card:first-child,
  [dir="rtl"] #human-hand .card:first-child,
  [dir="rtl"] #player-hand .card:first-child {
    margin-right: 0 !important;
  }

  /* Unselected Card Touch Hit Area Expander */
  .cards-container.fanned-hand .card::after,
  #human-hand .card::after,
  #player-hand .card::after {
    content: '';
    position: absolute;
    top: -12px;
    bottom: -8px;
    left: -2px;
    right: -2px;
    pointer-events: auto;
  }

  @media (hover: hover) {
    .cards-container.fanned-hand .card:hover:not(.face-down),
    #human-hand .card:hover:not(.face-down),
    #player-hand .card:hover:not(.face-down) {
      transform: translateY(calc(var(--fan-y, 0px) - 8px)) rotate(var(--fan-rot, 0deg));
      z-index: calc(var(--card-index, 0) * 2 + 3);
    }
  }

  /* Selected Card: Lifted upward without overriding adjacent cards' tap areas */
  .cards-container.fanned-hand .card.selected,
  #human-hand .card.selected,
  #player-hand .card.selected {
    transform: translateY(calc(var(--fan-y, 0px) - 20px)) rotate(var(--fan-rot, 0deg));
    border-color: var(--gold-accent);
    box-shadow: 0 0 14px var(--gold-glow), 0 8px 20px rgba(0, 0, 0, 0.65);
    z-index: calc(var(--card-index, 0) * 2 + 3);
  }

  .cards-container.fanned-hand .card-rank {
    font-size: 0.72rem;
    font-weight: 800;
  }

  .cards-container.fanned-hand .card-suit {
    font-size: 0.65rem;
  }

  .cards-container.fanned-hand .card-center {
    font-size: 1.15rem;
  }

  .cards-container.fanned-hand .face-card-badge {
    font-size: 0.85rem;
  }

  .cards-container.fanned-hand .joker-center {
    font-size: 0.78rem;
  }

  .cards-container.fanned-hand .joker-graphic {
    font-size: 1.25rem;
  }

  .cards-container.fanned-hand .joker-title {
    font-size: 0.52rem;
  }

  .cards-container.fanned-hand .card-floating-meld-badge {
    top: -24px;
    gap: 2px;
    pointer-events: none !important;
  }

  .cards-container.fanned-hand .badge-title-capsule {
    font-size: 0.55rem;
    padding: 1px 4px;
  }

  .cards-container.fanned-hand .badge-points-pill {
    font-size: 0.58rem;
    padding: 1px 4px;
  }

  /* Compact Bottom Control Bar */
  .bottom-control-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 48px;
    min-height: 48px;
    padding: 0 6px max(4px, env(safe-area-inset-bottom, 4px)) 6px;
    background: rgba(6, 15, 10, 0.96);
    backdrop-filter: blur(16px);
    border-top: 1px solid var(--panel-border);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    box-sizing: border-box;
  }

  .bar-left-controls {
    display: none !important;
  }

  .bar-center-ticker {
    display: none !important;
  }

  .bar-right-actions {
    display: flex;
    align-items: center;
    justify-content: space-around;
    width: 100%;
    gap: 4px;
    padding: 0;
    margin: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  .bar-right-actions::-webkit-scrollbar {
    display: none;
  }

  .btn-action-bar {
    flex: 1 1 0;
    min-width: 0;
    max-width: 76px;
    height: 36px;
    padding: 2px 2px;
    border-radius: 8px;
    font-size: 0.62rem;
    font-weight: 700;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    white-space: nowrap;
    line-height: 1.1;
  }

  .btn-action-bar .action-icon {
    font-size: 0.85rem;
    line-height: 1;
  }

  .btn-action-bar .action-text {
    font-size: 0.56rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
  }

  /* Touch Drag Ghost & Modals */
  .touch-drag-ghost {
    position: fixed;
    top: 0;
    left: 0;
    pointer-events: none;
    z-index: 10000;
    will-change: transform;
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.75), 0 0 20px var(--gold-glow);
    opacity: 0.95;
  }

  .modal-content {
    width: 95%;
    max-width: 440px;
  }

  .modal-header {
    padding: 10px 14px;
  }

  .modal-body {
    padding: 14px;
    max-height: 80dvh;
  }

  .mode-options-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .mode-card {
    padding: 14px;
  }

  .mode-card-icon {
    font-size: 2rem;
    margin-bottom: 4px;
  }
}

/* In-Game Notifications Toast System */
.game-toast-container {
  position: fixed;
  top: 72px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 99999;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.game-toast {
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid var(--panel-border);
  color: #fff;
  padding: 10px 22px;
  border-radius: 30px;
  font-size: 0.92rem;
  font-weight: 700;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.55), 0 0 15px rgba(245, 158, 11, 0.25);
  display: flex;
  align-items: center;
  gap: 10px;
  opacity: 0;
  transform: translateY(-18px) scale(0.92);
  transition: all 0.28s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  pointer-events: auto;
  backdrop-filter: blur(8px);
}

.game-toast.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.game-toast.warning {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.95) 0%, rgba(185, 28, 28, 0.95) 100%);
  border-color: #f87171;
  color: #fff;
  box-shadow: 0 10px 28px rgba(239, 68, 68, 0.45), 0 0 22px rgba(239, 68, 68, 0.6);
}

.game-toast .toast-icon {
  font-size: 1.15rem;
}

@media (max-width: 768px) {
  .game-toast-container {
    top: 58px;
    width: 90%;
  }

  .game-toast {
    font-size: 0.82rem;
    padding: 8px 16px;
    width: 100%;
    justify-content: center;
  }
}

