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

:root, [data-theme="dark"] {
  --bg: #0d0d18;
  --text: #f0f0f8;
  --hint: #8e8ea8;
  --text-muted: #6e6e8c;
  --accent: #6c5ce7;
  --accent-text: #ffffff;
  --secondary: #17172c;
  --secondary-hover: #22223e;
  --card-bg: #1c1c34;
  --cell-bg: #1a1a32;
  --cell-border: #323254;
  --border-light: rgba(255, 255, 255, 0.08);
  --header-bar-bg: rgba(23, 23, 44, 0.88);
  --board-bg: #141426;
  --modal-backdrop: rgba(6, 6, 14, 0.78);
  --marked: #00b894;
  --marked-gradient: linear-gradient(135deg, #00b894 0%, #00cec9 100%);
  --called: #00e676;
  --called-chip-bg: #23233c;
  --called-chip-border: #38385a;
  --called-chip-color: #8b8ba8;
  --called-active-bg: linear-gradient(135deg, #00b894 0%, #00e676 100%);
  --called-active-text: #022415;
  --quick-input-bg: #131322;
  --quick-input-border: #323254;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

[data-theme="light"] {
  --bg: #f4f6fb;
  --text: #171926;
  --hint: #5a6478;
  --text-muted: #7b8599;
  --accent: #5843e4;
  --accent-text: #ffffff;
  --secondary: #ffffff;
  --secondary-hover: #f1f4f9;
  --card-bg: #ffffff;
  --cell-bg: #f8fafc;
  --cell-border: #dbe2ee;
  --border-light: rgba(0, 0, 0, 0.07);
  --header-bar-bg: rgba(255, 255, 255, 0.92);
  --board-bg: #ffffff;
  --modal-backdrop: rgba(15, 23, 42, 0.65);
  --marked: #00b894;
  --marked-gradient: linear-gradient(135deg, #00b894 0%, #00a884 100%);
  --called: #00b894;
  --called-chip-bg: #eef2f7;
  --called-chip-border: #d2dbe8;
  --called-chip-color: #55627a;
  --called-active-bg: linear-gradient(135deg, #00b894 0%, #00e676 100%);
  --called-active-text: #ffffff;
  --quick-input-bg: #f8fafc;
  --quick-input-border: #cbd5e1;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.25s ease, color 0.25s ease;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 12px 12px 24px;
}

.screen {
  display: none;
  flex-direction: column;
  align-items: center;
  min-height: calc(100vh - 36px);
}

.screen.active {
  display: flex;
}

.hidden {
  display: none !important;
}

/* Loading */
#screen-loading {
  justify-content: center;
  gap: 16px;
  opacity: 0.8;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--secondary);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* User Balance & Role Bar */
.user-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  margin-bottom: 12px;
  padding: 6px 12px;
  background: var(--secondary);
  border: 1px solid var(--border-light);
  border-radius: 14px;
  box-shadow: var(--shadow);
  transition: background 0.25s ease;
}

.balance-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 800;
  font-size: 0.95rem;
}

.balance-pill .currency {
  font-size: 0.75rem;
  color: var(--hint);
  font-weight: 600;
}

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

.theme-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--secondary-hover);
  border: 1px solid var(--border-light);
  color: var(--text);
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.theme-toggle-btn:hover {
  transform: scale(1.1);
}

.theme-toggle-btn:active {
  transform: scale(0.92);
}

.role-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.role-pill.role-spectator {
  background: rgba(253, 203, 110, 0.15);
  color: #fdcb6e;
}

.role-pill.role-player {
  background: rgba(0, 184, 148, 0.15);
  color: var(--marked);
}

.role-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* Header */
.game-header {
  text-align: center;
  width: 100%;
  padding: 8px 0 16px;
}

.game-header h1 {
  font-size: 1.35rem;
  font-weight: 800;
}

.game-header p {
  color: var(--hint);
  font-size: 0.85rem;
  margin-top: 2px;
}

.game-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 8px 12px;
  background: var(--header-bar-bg);
  border: 1px solid var(--border-light);
  border-radius: 14px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

.header-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.room-pill {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--accent);
  letter-spacing: 0.5px;
}

.header-stats {
  display: flex;
  gap: 6px;
  align-items: center;
}

.h-stat {
  display: flex;
  flex-direction: column;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--secondary-hover);
  border: 1px solid var(--border-light);
}

.h-stat-label {
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--hint);
  text-transform: uppercase;
  line-height: 1.1;
}

.h-stat-value {
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--text);
  white-space: nowrap;
  line-height: 1.2;
}

.stat-derash .h-stat-value {
  color: #00e676;
  text-shadow: 0 0 6px rgba(0, 230, 118, 0.4);
}

.stat-players .h-stat-value {
  color: #00b0ff;
}

.stat-balls .h-stat-value {
  color: #f1c40f;
}

/* Stats */
.stats-row {
  display: flex;
  gap: 10px;
  width: 100%;
  margin-bottom: 20px;
}

.stat {
  flex: 1;
  background: var(--secondary);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 14px 8px;
  text-align: center;
  box-shadow: var(--shadow);
}

.stat-value {
  display: block;
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--accent);
}

#lobby-countdown {
  font-size: 1.1rem;
  white-space: nowrap;
  letter-spacing: -0.2px;
}

.stat-label {
  font-size: 0.7rem;
  color: var(--hint);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 700;
}

.hint {
  color: var(--hint);
  font-size: 0.85rem;
  text-align: center;
  margin-bottom: 16px;
}

/* Called ball */
.called-ball {
  background: linear-gradient(135deg, #00b894 0%, #00e676 100%);
  border-radius: 50%;
  width: 68px;
  height: 68px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 0 18px rgba(0, 230, 118, 0.65);
  animation: float-ball 3s ease-in-out infinite alternate;
}

@keyframes float-ball {
  from { transform: translateY(0); }
  to { transform: translateY(-3px); }
}

.ball-letter {
  font-size: 0.7rem;
  font-weight: 800;
  color: #022b18;
  opacity: 0.9;
}

.ball-number {
  font-size: 1.45rem;
  font-weight: 900;
  line-height: 1;
  color: #022b18;
}

/* Called numbers board (5 Rows with B, I, N, G, O Range Badges) */
.called-board {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  margin-bottom: 3px;
  padding: 4px 5px;
  background: var(--board-bg);
  border: 1px solid var(--border-light);
  border-radius: 8px;
}

.called-board-row {
  display: flex;
  align-items: center;
  gap: 2px;
  width: 100%;
}

.called-row-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  padding: 1px 0;
  border-radius: 4px;
  font-weight: 800;
  text-align: center;
  line-height: 1.05;
  flex-shrink: 0;
  border: 1px solid var(--border-light);
}

.called-row-label .c-letter {
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.2px;
}

.called-row-label .c-range {
  font-size: 0.40rem;
  font-weight: 700;
  opacity: 0.85;
  white-space: nowrap;
}

.row-b .called-row-label { background: linear-gradient(135deg, rgba(235, 77, 75, 0.22), rgba(235, 77, 75, 0.1)); color: #ff6b6b; border-color: rgba(235, 77, 75, 0.4); }
.row-i .called-row-label { background: linear-gradient(135deg, rgba(240, 147, 43, 0.22), rgba(240, 147, 43, 0.1)); color: #f0932b; border-color: rgba(240, 147, 43, 0.4); }
.row-n .called-row-label { background: linear-gradient(135deg, rgba(106, 176, 76, 0.22), rgba(106, 176, 76, 0.1)); color: #6ab04c; border-color: rgba(106, 176, 76, 0.4); }
.row-g .called-row-label { background: linear-gradient(135deg, rgba(72, 52, 212, 0.22), rgba(72, 52, 212, 0.1)); color: #686de0; border-color: rgba(72, 52, 212, 0.4); }
.row-o .called-row-label { background: linear-gradient(135deg, rgba(224, 86, 253, 0.22), rgba(224, 86, 253, 0.1)); color: #e056fd; border-color: rgba(224, 86, 253, 0.4); }

.called-row-chips {
  display: grid;
  grid-template-columns: repeat(15, 1fr);
  gap: 1.5px;
  flex: 1;
}

.called-chip {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.52rem;
  font-weight: 700;
  border-radius: 3px;
  background: var(--called-chip-bg);
  border: 1px solid var(--called-chip-border);
  color: var(--called-chip-color);
  transition: background-color 0.15s ease, transform 0.15s ease;
}

/* Green luminous active chips on Game Board */
.called-chip.active {
  background: var(--called-active-bg);
  color: var(--called-active-text);
  border-color: #00e676;
  font-weight: 900;
  box-shadow: 0 0 8px rgba(0, 230, 118, 0.6), inset 0 1px 1px rgba(255, 255, 255, 0.4);
  transform: scale(1.06);
}

/* Latest called: radiant animated green light */
.called-chip.latest {
  background: linear-gradient(135deg, #00ff88 0%, #00e676 100%);
  color: #022415;
  border-color: #00ff88;
  font-weight: 900;
  z-index: 5;
  animation: pulse-latest-green 1.4s infinite alternate ease-in-out;
}

@keyframes pulse-latest-green {
    0%, 100% { opacity: 0.85; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.08); }
}

/* Bingo card */
.bingo-card-wrap {
  width: 100%;
  margin-bottom: 16px;
}

.bingo-card {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 5px;
  width: 100%;
}

.card-header-cell {
  color: #ffffff;
  font-weight: 800;
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  line-height: 1.1;
  padding: 2px 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.card-header-cell .hdr-letter {
  font-size: 0.95rem;
  font-weight: 900;
  letter-spacing: 0.5px;
}

.card-header-cell .hdr-range {
  font-size: 0.55rem;
  font-weight: 700;
  opacity: 0.88;
}

.hdr-b { background: linear-gradient(135deg, #eb4d4b, #ff7979); }
.hdr-i { background: linear-gradient(135deg, #f0932b, #ffbe76); }
.hdr-n { background: linear-gradient(135deg, #6ab04c, #badc58); }
.hdr-g { background: linear-gradient(135deg, #4834d4, #686de0); }
.hdr-o { background: linear-gradient(135deg, #be2edd, #e056fd); }

.card-cell {
  background: var(--cell-bg);
  border: 1.5px solid var(--cell-border);
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.88rem;
  font-weight: 700;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.15s ease;
  user-select: none;
  position: relative;
  overflow: hidden;
  color: var(--text);
}

.card-cell.free {
  background: linear-gradient(135deg, #f1c40f 0%, #e67e22 100%);
  color: #0f0f1a;
  font-size: 0.65rem;
  font-weight: 900;
  border-color: #f39c12;
  box-shadow: 0 0 10px rgba(241, 196, 15, 0.5);
  cursor: default;
}

/* Card cell called but not yet manually marked: keep normal cell appearance (no auto green coloring) */
.card-cell.called:not(.marked) {
  border-color: var(--cell-border);
  background: var(--cell-bg);
  color: var(--text);
}

/* Shake feedback when tapping an uncalled number */
.card-cell.shake-error {
  animation: cell-shake 0.35s ease-in-out;
  border-color: #ff4757 !important;
}

@keyframes cell-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
}

/* Marked cell: identical to Card Pool Selection green styling */
.card-cell.marked {
  background: var(--marked);
  background: var(--marked-gradient);
  border-color: #00b894;
  color: #ffffff;
  font-weight: 900;
  box-shadow: 0 0 14px rgba(0, 184, 148, 0.65);
  transform: scale(0.96);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.card-cell.marked::after {
  content: "✓";
  position: absolute;
  top: 1px;
  right: 2px;
  font-size: 0.55rem;
  font-weight: 900;
  color: #ffffff;
}

.card-cell.winning-cell {
  background: linear-gradient(135deg, #FF007A 0%, #7000FF 100%) !important;
  border-color: #FF007A !important;
  color: #ffffff !important;
  font-weight: 900;
  box-shadow: 0 0 18px rgba(255, 0, 122, 0.9) !important;
  animation: pulse-win 0.8s infinite alternate !important;
}

@keyframes pulse-win {
  from { transform: scale(0.95); box-shadow: 0 0 12px rgba(255, 0, 122, 0.7); }
  to { transform: scale(1.04); box-shadow: 0 0 22px rgba(255, 0, 122, 1); }
}

.card-cell:not(.free):not(.marked):active {
  transform: scale(0.92);
}

.card-preview .card-cell {
  font-size: 0.65rem;
  pointer-events: none;
}

/* Buttons */
.btn {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.2s;
}

.btn:active {
  opacity: 0.85;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-text);
  margin-top: 16px;
}

.btn-secondary {
  background: var(--secondary);
  color: var(--text);
  margin-top: 16px;
}

.btn-bingo {
  background: linear-gradient(135deg, #e17055, #d63031);
  color: #fff;
  font-size: 1.2rem;
  letter-spacing: 2px;
  box-shadow: 0 4px 20px rgba(214, 48, 49, 0.35);
}

.btn-bingo:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}

.auto-bingo-hint {
  font-size: 0.8rem;
  color: var(--text-muted, #888);
  text-align: center;
  padding: 10px 6px 2px;
  line-height: 1.35;
}

/* Error & Result */
.error-icon,
.result-icon {
  font-size: 3rem;
  margin: 40px 0 16px;
}

#screen-error,
#screen-result {
  text-align: center;
  padding-top: 20px;
}

#screen-error p,
#result-message {
  color: var(--hint);
  margin-bottom: 8px;
  line-height: 1.5;
  max-width: 300px;
}

#result-title {
  font-size: 1.5rem;
  margin-bottom: 8px;
}

.balance-line {
  margin: 12px 0 20px;
  font-size: 0.95rem;
}

.balance-line strong {
  color: var(--marked);
}

.loser .result-icon {
  filter: grayscale(0.5);
}

/* Schedule Banner */
.schedule-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  background: linear-gradient(135deg, rgba(108, 92, 231, 0.2), rgba(162, 155, 254, 0.1));
  border: 1px solid rgba(108, 92, 231, 0.3);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 14px;
}

.schedule-icon {
  font-size: 1.6rem;
}

.schedule-content {
  flex: 1;
}

.schedule-title {
  display: block;
  font-size: 0.85rem;
  font-weight: 700;
  color: #a29bfe;
}

.schedule-desc {
  display: block;
  font-size: 0.75rem;
  color: var(--hint);
  margin-top: 2px;
}

.schedule-countdown {
  display: inline-block;
  font-size: 0.85rem;
  font-weight: 800;
  color: #fdcb6e;
  margin-top: 4px;
}

/* Card Selection Wrap */
.card-selection-wrap {
  width: 100%;
  margin-bottom: 16px;
  background: var(--secondary);
  border: 1px solid var(--border-light);
  border-radius: 14px;
  padding: 14px;
  box-shadow: var(--shadow);
}

.card-action-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.card-action-title {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--text);
}

.my-cards-badge {
  flex-shrink: 0;
  padding: 4px 10px;
  border-radius: 16px;
  background: rgba(0, 184, 148, 0.15);
  color: var(--marked);
  font-size: 0.75rem;
  font-weight: 700;
}

/* Quick pick row */
.quick-pick-row {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 12px;
}

.quick-input {
  flex: 1;
  background: var(--quick-input-bg);
  border: 1px solid var(--quick-input-border);
  border-radius: 8px;
  color: var(--text);
  padding: 8px 10px;
  font-size: 0.85rem;
  font-weight: 600;
  outline: none;
  min-width: 0;
}

.quick-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 8px rgba(108, 92, 231, 0.4);
}

.btn-quick {
  background: var(--accent);
  color: #fff;
  white-space: nowrap;
  padding: 8px 12px;
}

.btn-random {
  background: rgba(253, 203, 110, 0.15);
  color: #fdcb6e;
  border: 1px solid rgba(253, 203, 110, 0.3);
  white-space: nowrap;
  padding: 8px 12px;
}

.btn-random:active {
  background: rgba(253, 203, 110, 0.25);
}

/* Card Pool */
.card-pool {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 4px;
  margin-bottom: 12px;
  max-height: 260px;
  overflow-y: auto;
  padding-right: 2px;
}

.card-pool::-webkit-scrollbar {
  width: 5px;
}

.card-pool::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.1);
  border-radius: 4px;
}

.card-pool::-webkit-scrollbar-thumb {
  background: rgba(108, 92, 231, 0.4);
  border-radius: 4px;
}

.pool-chip {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.62rem;
  font-weight: 700;
  border-radius: 6px;
  background: var(--cell-bg);
  border: 1px solid var(--cell-border);
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.pool-chip.available {
  border-color: rgba(108, 92, 231, 0.55);
}

.pool-chip.available:active {
  transform: scale(0.88);
  background: rgba(108, 92, 231, 0.25);
}

.pool-chip.mine {
  background: #00b894;
  border-color: #00b894;
  color: #fff;
  box-shadow: 0 0 8px rgba(0, 184, 148, 0.45);
}

.pool-chip.taken {
  background: #2a2a45;
  border-color: #e17055;
  color: #e17055;
  opacity: 0.85;
  cursor: not-allowed;
  font-size: 0.55rem;
  position: relative;
}

.pool-chip.taken::after {
  content: "🔒";
  position: absolute;
  font-size: 0.42rem;
  top: 1px;
  right: 1px;
}

/* Game banner (BINGO claim / forfeit notices) */
.game-banner {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(0, 230, 118, 0.15);
  border: 1px solid rgba(0, 230, 118, 0.4);
  color: #00e676;
  font-size: 0.82rem;
  font-weight: 600;
  text-align: center;
  margin-bottom: 10px;
}

.game-banner.banner-error {
  background: rgba(225, 112, 85, 0.15);
  border-color: rgba(225, 112, 85, 0.5);
  color: #fab1a0;
}

/* Stacked game layout: Board on top, player cards on bottom */
.game-layout {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
}

.board-panel {
  background: var(--secondary);
  border-radius: 10px;
  padding: 5px 6px;
}

.cards-panel {
  background: var(--secondary);
  border-radius: 10px;
  padding: 5px 6px;
}

.panel-title {
  font-size: 0.68rem;
  font-weight: 800;
  color: var(--hint);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 3px;
}

.card-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 3px;
  width: 100%;
}

/* Single card: centered, clean proportions */
.card-list:not(.two-cards) .mini-card {
  max-width: 320px;
  margin: 0 auto;
  width: 100%;
}

/* Two cards side-by-side: 85% scale, minmax(0, 1fr) prevents overlap */
.card-list.two-cards {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 4px;
  width: 100%;
}

.mini-card {
  background: var(--card-bg);
  border: 1.5px solid var(--cell-border);
  border-radius: 8px;
  padding: 5px 5px;
  transition: all 0.25s ease;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.card-list.two-cards .mini-card {
  padding: 3px 3px;
  border-radius: 7px;
  border-width: 1px;
}

.mini-card.has-bingo {
  border-color: #00e676;
  box-shadow: 0 0 12px rgba(0, 230, 118, 0.45);
}

.mini-card.card-locked {
  border-color: rgba(255, 71, 87, 0.6);
  background: rgba(255, 71, 87, 0.04);
}

.mini-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2px;
}

.mini-card-title {
  font-size: 0.76rem;
  font-weight: 800;
  color: var(--text);
  white-space: nowrap;
}

.card-list.two-cards .mini-card-title {
  font-size: 0.68rem;
}

.card-locked-badge {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 1px 4px;
  border-radius: 6px;
  font-size: 0.58rem;
  font-weight: 800;
  background: rgba(255, 71, 87, 0.2);
  color: #ff4757;
  border: 1px solid rgba(255, 71, 87, 0.4);
}

.mini-bingo-card {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 2px;
  width: 100%;
}

.card-list.two-cards .mini-bingo-card {
  gap: 1.5px;
}

.mini-bingo-card .card-header-cell {
  font-size: 0.68rem;
  font-weight: 800;
  padding: 1.5px 0;
  border-radius: 4px;
}

.mini-bingo-card .card-cell {
  font-size: 0.72rem;
  font-weight: 800;
  aspect-ratio: 1;
  min-height: unset;
  border-width: 1px;
  border-radius: 4px;
  pointer-events: auto;
  cursor: pointer;
  padding: 0;
}

.card-list.two-cards .mini-bingo-card .card-cell {
  font-size: 0.60rem;
  font-weight: 800;
  border-radius: 3px;
  border-width: 1px;
}

.card-list.two-cards .mini-bingo-card .card-header-cell {
  border-radius: 3px;
  padding: 1px 0;
}

.card-list.two-cards .mini-bingo-card .card-header-cell .hdr-letter {
  font-size: 0.58rem;
}

.card-list.two-cards .mini-bingo-card .card-header-cell .hdr-range {
  font-size: 0.33rem;
}

.mini-card.card-locked .mini-bingo-card .card-cell {
  pointer-events: none;
  opacity: 0.65;
}

.btn-card-bingo {
  width: 100%;
  margin-top: 4px;
  padding: 6px 8px;
  border-radius: 7px;
  font-size: 0.84rem;
  font-weight: 900;
  letter-spacing: 0.8px;
  background: linear-gradient(135deg, #ff4757 0%, #ff6b81 100%);
  color: #ffffff;
  border: none;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(255, 71, 87, 0.4);
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.card-list.two-cards .btn-card-bingo {
  margin-top: 3px;
  padding: 4px 6px;
  font-size: 0.70rem;
  border-radius: 6px;
}

.btn-card-bingo:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(255, 71, 87, 0.6);
}

.btn-card-bingo:active:not(:disabled) {
  transform: scale(0.97);
}

.btn-card-bingo:disabled {
  background: #2f3542;
  border: 1px solid #57606f;
  color: #747d8c;
  box-shadow: none;
  cursor: not-allowed;
  opacity: 0.6;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--modal-backdrop);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 16px;
}

.modal-backdrop.hidden {
  display: none;
}

.modal {
  width: 100%;
  max-width: 340px;
  background: var(--secondary);
  border: 1px solid var(--border-light);
  border-radius: 16px;
  padding: 20px;
  text-align: center;
  box-shadow: var(--shadow);
  animation: pop 0.2s ease;
}

@keyframes pop {
  from {
    transform: scale(0.92);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 800;
  margin-bottom: 6px;
}

.taken-title {
  color: #fab1a0;
}

.modal-icon {
  font-size: 2.2rem;
  margin-bottom: 8px;
}

.modal-prompt {
  color: var(--text);
  margin: 10px 0 6px;
  line-height: 1.4;
  font-size: 0.95rem;
}

.modal-fee {
  color: var(--hint);
  font-size: 0.85rem;
  margin-bottom: 14px;
}

.modal-fee.insufficient {
  color: #fab1a0;
  font-weight: 600;
}

.modal-card-preview {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 3px;
  margin: 10px 0;
}

.modal-card-preview .card-cell {
  font-size: 0.6rem;
  pointer-events: none;
}

.modal-actions {
  display: flex;
  gap: 10px;
}

.modal-actions .btn {
  flex: 1;
  margin-top: 0;
}

.btn-confirm-yes {
  background: #00b894;
  color: #fff;
}

.btn-confirm-no {
  background: var(--secondary);
  color: var(--text);
  border: 1px solid var(--cell-border);
}

.btn-confirm-yes:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-sm {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-sm:hover,
.btn-sm:active {
  background: rgba(255, 255, 255, 0.16);
}

.card-preview {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  width: 100%;
  margin-bottom: 12px;
}

.btn-select {
  background: linear-gradient(135deg, var(--accent), #4834d4);
  color: #fff;
  font-size: 1rem;
  box-shadow: 0 4px 14px rgba(108, 92, 231, 0.35);
}

.btn-select:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  box-shadow: none;
}

/* Card error / alert notice */
.card-error-notice {
  margin-top: 10px;
  padding: 10px 12px;
  background: rgba(225, 112, 85, 0.15);
  border: 1px solid rgba(225, 112, 85, 0.4);
  border-radius: 8px;
  color: #fab1a0;
  font-size: 0.8rem;
  line-height: 1.4;
  text-align: center;
}

/* Spectator View in Game */
.spectator-section {
  width: 100%;
  margin-top: 10px;
}

.spectator-card {
  background: var(--secondary);
  border-radius: 14px;
  padding: 24px 16px;
  text-align: center;
  border: 1px dashed rgba(253, 203, 110, 0.3);
}

.spectator-icon {
  font-size: 2.5rem;
  margin-bottom: 10px;
}

.spectator-card h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: #fdcb6e;
  margin-bottom: 6px;
}

.spectator-card p {
  color: var(--text);
  font-size: 0.85rem;
  line-height: 1.5;
  margin-bottom: 8px;
}

.spectator-hint {
  color: var(--hint) !important;
  font-size: 0.78rem !important;
}

/* ========================================================
   Winner Celebration Modal & Animated Winner Cards
   ======================================================== */
.modal-winner-box {
  max-width: 360px;
  width: 92%;
  background: linear-gradient(180deg, #1f1b3c 0%, #121026 100%);
  border: 2px solid rgba(241, 196, 15, 0.5);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.7), 0 0 30px rgba(241, 196, 15, 0.25);
  border-radius: 20px;
  padding: 20px 16px;
  position: relative;
  overflow: hidden;
  animation: winnerPop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes winnerPop {
  0% { transform: scale(0.85); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.winner-trophy-badge {
  font-size: 3rem;
  margin-bottom: 4px;
  animation: trophyBounce 1.2s ease-in-out infinite alternate;
  display: inline-block;
  filter: drop-shadow(0 0 12px rgba(241, 196, 15, 0.6));
}

@keyframes trophyBounce {
  0% { transform: translateY(0) scale(1); }
  100% { transform: translateY(-8px) scale(1.08); }
}

.winner-head-title {
  font-size: 1.35rem;
  font-weight: 900;
  background: linear-gradient(135deg, #FFE066 0%, #F59E0B 50%, #FBBF24 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 2px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.winner-sub-message {
  color: #c7c7e2;
  font-size: 0.85rem;
  margin-bottom: 12px;
}

.winner-cards-scroll {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 280px;
  overflow-y: auto;
  padding: 4px 2px;
  margin-bottom: 12px;
}

.winner-cards-scroll::-webkit-scrollbar {
  width: 4px;
}

.winner-cards-scroll::-webkit-scrollbar-thumb {
  background: rgba(241, 196, 15, 0.4);
  border-radius: 4px;
}

.winner-card-item {
  background: rgba(255, 255, 255, 0.04);
  border: 1.5px solid rgba(241, 196, 15, 0.4);
  border-radius: 14px;
  padding: 10px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
  position: relative;
}

.winner-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.winner-name-badge {
  display: flex;
  align-items: center;
  gap: 6px;
}

.winner-name-text {
  font-size: 0.9rem;
  font-weight: 800;
  color: #fff;
}

.winner-card-id-text {
  font-size: 0.72rem;
  color: #a0a0b8;
  font-weight: 600;
}

.winner-tags {
  display: flex;
  gap: 4px;
  align-items: center;
}

.winner-prize-tag {
  background: linear-gradient(135deg, #00E676 0%, #00B0FF 100%);
  color: #0b2014;
  font-size: 0.75rem;
  font-weight: 900;
  padding: 2px 8px;
  border-radius: 6px;
  box-shadow: 0 0 8px rgba(0, 230, 118, 0.4);
}

.winner-pattern-tag {
  background: rgba(241, 196, 15, 0.15);
  border: 1px solid rgba(241, 196, 15, 0.4);
  color: #FBBF24;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 6px;
}

.winner-mini-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 3px;
}

.winner-grid-cell {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 700;
  border-radius: 5px;
  pointer-events: none;
}

.winner-grid-cell.dimmed-cell {
  background: rgba(255, 255, 255, 0.03);
  color: rgba(255, 255, 255, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.winner-grid-cell.winning-cell {
  background: linear-gradient(135deg, #FF007A 0%, #7000FF 100%) !important;
  color: #fff !important;
  font-weight: 900 !important;
  box-shadow: 0 0 10px rgba(255, 0, 122, 0.7);
  animation: winGlowPulse 1s ease-in-out infinite alternate !important;
  border: 1px solid rgba(255, 255, 255, 0.6) !important;
}

.winner-grid-cell.free {
  background: linear-gradient(135deg, #f1c40f 0%, #e67e22 100%) !important;
  color: #000 !important;
  font-weight: 900 !important;
}

@keyframes winGlowPulse {
  0% { transform: scale(1); filter: brightness(1); box-shadow: 0 0 8px rgba(255, 0, 122, 0.6); }
  100% { transform: scale(1.06); filter: brightness(1.25); box-shadow: 0 0 16px rgba(255, 0, 122, 0.95); }
}

.winner-timer-bar {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

#winner-countdown-text {
  font-size: 0.75rem;
  color: #a0a0b8;
  font-weight: 600;
}

.timer-progress-track {
  width: 100%;
  height: 5px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  overflow: hidden;
}

.timer-progress-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #00E676, #F59E0B);
  transition: width 0.25s linear;
  border-radius: 3px;
}

/* ---------------------------------------------------------------------------
   Wallet Modal Styling (Deposit & Withdrawal)
   --------------------------------------------------------------------------- */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 12px;
  box-sizing: border-box;
}

.modal-backdrop.hidden {
  display: none !important;
}

.modal {
  background: #13141f;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
  color: var(--text-main, #fff);
  box-sizing: border-box;
  animation: modalFadeIn 0.2s ease-out;
}

@keyframes modalFadeIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}
