/* Critical: do not rely only on Tailwind CDN for modal visibility */
.hidden {
  display: none !important;
}

:root {
  --bg: #eef1f6;
  --surface: #ffffff;
  --surface-muted: #f3f5f9;
  --border: #e4e8ef;
  --text: #1f2937;
  --text-muted: #6b7280;
  --navy: #1e2a44;
  --yellow: #f5c518;
  --green: #22a06b;
  --green-dark: #178a5c;
  --blue: #3b82f6;
  --red: #ef4444;
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
  --radius: 16px;
  --radius-sm: 12px;
}

* {
  box-sizing: border-box;
}

body.app-body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Poppins", system-ui, sans-serif;
  padding: 12px 12px 56px;
}

.app-shell {
  max-width: 480px;
  margin: 0 auto;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.app-title {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--navy);
}

.app-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.stats-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.stat-pill {
  border: none;
  border-radius: 14px;
  padding: 10px 12px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 58px;
  justify-content: center;
}

.stat-pill .pill-label {
  opacity: 0.85;
  font-size: 0.65rem;
}

.stat-pill .pill-value {
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: none;
}

.stat-room {
  background: var(--yellow);
  color: #3b2f00;
}

.stat-balance {
  background: var(--green);
  color: #fff;
}

.stat-bonus {
  background: var(--navy);
  color: #fff;
}

.stat-refresh {
  grid-column: span 2;
  background: var(--surface);
  color: var(--navy);
  border: 1px solid var(--border);
  cursor: pointer;
  align-items: center;
  flex-direction: row;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  font-size: 0.85rem;
}

.stat-refresh:active {
  transform: scale(0.98);
}

.rooms-section {
  display: none !important;
}

.rooms-title {
  margin: 0;
  padding: 14px 16px 10px;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--navy);
}

.rooms-header {
  display: grid;
  grid-template-columns: 0.9fr 1.1fr 0.8fr 1.2fr 0.8fr;
  gap: 8px;
  padding: 0 12px 10px;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.room-card {
  display: grid !important;
  grid-template-columns: 0.9fr 1.1fr 0.8fr 1.2fr 0.8fr;
  gap: 8px;
  align-items: center;
  margin: 0 !important;
  height: auto !important;
  min-height: 58px;
  padding: 12px !important;
  background: var(--surface-muted) !important;
  border-top: 1px solid var(--border);
  border-radius: 0 !important;
  color: var(--text) !important;
  font-size: 0.82rem !important;
  position: relative;
}

.room-card > div {
  width: auto !important;
  justify-content: flex-start !important;
}

.room-card [class*="_play"] {
  background: var(--green) !important;
  color: #fff !important;
  border-radius: 12px !important;
  padding: 8px 10px !important;
  font-weight: 700 !important;
  cursor: pointer;
  justify-content: center !important;
  box-shadow: 0 4px 12px rgba(34, 160, 107, 0.25);
}

.room-card [class*="_play"]:active {
  transform: scale(0.98);
}

.room-card [class*="insufficient_balance"] {
  color: var(--red) !important;
  background: rgba(239, 68, 68, 0.1);
  border-radius: 999px;
  padding: 2px 8px;
  font-weight: 700;
}

.room-card [class*="game_started_flag"] {
  background: var(--red) !important;
}

.app-footer {
  position: fixed;
  left: 50%;
  bottom: 10px;
  transform: translateX(-50%);
  color: var(--text-muted);
  font-size: 0.72rem;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 14px;
  backdrop-filter: blur(8px);
}

/* Modals only (avoid matching game_started_flag, etc.) */
div.fixed[class*="registery_"],
div.fixed[class*="game_"],
div.fixed[class*="winner_"],
.blocked_modal,
#loadingModal {
  background: rgba(30, 42, 68, 0.45) !important;
  backdrop-filter: blur(4px);
}

div.fixed[class*="winner_"] {
  padding: 16px !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch;
  align-items: safe center !important;
}

div.fixed[class*="registery_"] > div,
div.fixed[class*="game_"] > div,
.winner-modal {
  background: var(--bg) !important;
  color: var(--text) !important;
}

div.fixed[class*="registery_"] .grid.grid-cols-10 > div,
div.fixed[class*="registery_"] [class*="card_"] {
  background: #fff !important;
  color: var(--navy) !important;
  border: 1px solid var(--border) !important;
  border-radius: 10px !important;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.05);
  font-weight: 700;
}

div.fixed[class*="registery_"] .opacity-30 {
  opacity: 0.35 !important;
}

div.fixed[class*="registery_"] .cartela-selected {
  background: #ffc107 !important;
  color: #111 !important;
  border: none !important;
  box-shadow: 0 2px 4px rgba(15, 23, 42, 0.12) !important;
  border-radius: 8px !important;
  transform: none;
}

div.fixed[class*="registery_"] .bg-green-200,
div.fixed[class*="registery_"] .cartela-selected {
  background: #ffc107 !important;
  color: #111 !important;
  border: none !important;
  border-radius: 8px !important;
}

div.fixed[class*="registery_"] > div > div:first-child:not(.gb-super-hero),
div.fixed[class*="game_"] > div > div:first-child {
  background: var(--surface) !important;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
}

div.fixed[class*="registery_"] .bg-blue-900,
div.fixed[class*="game_"] .bg-blue-900 {
  background: var(--navy) !important;
  border-radius: 12px !important;
}

div.fixed[class*="game_"] .bingo-cell.bg-blue-800 {
  color: #fff !important;
  font-weight: 800;
}

div.fixed[class*="game_"] .bingo-cell.bg-blue-800:nth-child(1) {
  background: #3b82f6 !important;
}
div.fixed[class*="game_"] .bingo-cell.bg-blue-800:nth-child(2) {
  background: #ef4444 !important;
}
div.fixed[class*="game_"] .bingo-cell.bg-blue-800:nth-child(3) {
  background: #eab308 !important;
}
div.fixed[class*="game_"] .bingo-cell.bg-blue-800:nth-child(4) {
  background: #22c55e !important;
}
div.fixed[class*="game_"] .bingo-cell.bg-blue-800:nth-child(5) {
  background: #a855f7 !important;
}

div.fixed[class*="game_"] .bingo-cell.bg-blue-500 {
  background: #fff !important;
  color: var(--text-muted) !important;
  border: 1px solid var(--border) !important;
  border-radius: 0 !important;
  font-weight: 600;
}

div.fixed[class*="game_"] .bingo-cell.bg-orange-500 {
  background: var(--yellow) !important;
  color: #111 !important;
  border-color: #f0b90b !important;
  font-weight: 800;
}

div.fixed[class*="game_"] .voice_5,
div.fixed[class*="game_"] .voice_10,
div.fixed[class*="game_"] .voice_20,
div.fixed[class*="game_"] .voice_50,
div.fixed[class*="game_"] .voice_100,
div.fixed[class*="game_"] .voice_500,
div.fixed[class*="game_"] .voice_1000 {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 12px;
}

div.fixed[class*="game_"] [class*="bingo_"]:not(.gb-bingo-btn),
div.fixed[class*="registery_"] [onclick*="enter_game"],
div.fixed[class*="registery_"] [onclick*="reload_page"] {
  border-radius: 14px !important;
  font-weight: 700 !important;
}

div.fixed[class*="game_"] [class*="bingo_"]:not(.gb-bingo-btn) {
  background: var(--green) !important;
  box-shadow: 0 6px 16px rgba(34, 160, 107, 0.28);
}

.playing_cartela_section_5,
.playing_cartela_section_10,
.playing_cartela_section_20,
.playing_cartela_section_50,
.playing_cartela_section_100,
.playing_cartela_section_500,
.playing_cartela_section_1000 {
  background: var(--surface) !important;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px;
}

div.fixed[class*="game_"] .playing_cartela_section_5,
div.fixed[class*="game_"] .playing_cartela_section_10,
div.fixed[class*="game_"] .playing_cartela_section_20,
div.fixed[class*="game_"] .playing_cartela_section_50,
div.fixed[class*="game_"] .playing_cartela_section_100,
div.fixed[class*="game_"] .playing_cartela_section_500,
div.fixed[class*="game_"] .playing_cartela_section_1000 {
  padding: 0 !important;
  border: none !important;
  box-shadow: none !important;
  background: transparent !important;
}

div.fixed[class*="game_"].gb-multi-cartela .playing_cartela_section_5,
div.fixed[class*="game_"].gb-multi-cartela .playing_cartela_section_10,
div.fixed[class*="game_"].gb-multi-cartela .playing_cartela_section_20,
div.fixed[class*="game_"].gb-multi-cartela .playing_cartela_section_50,
div.fixed[class*="game_"].gb-multi-cartela .playing_cartela_section_100,
div.fixed[class*="game_"].gb-multi-cartela .playing_cartela_section_500,
div.fixed[class*="game_"].gb-multi-cartela .playing_cartela_section_1000 {
  padding: 0 !important;
}

/* Winner modal */
.winner-modal {
  width: min(92vw, 380px);
  border: 3px solid var(--yellow);
  border-radius: 22px;
  padding: 18px 16px 16px;
  box-shadow: var(--shadow);
  text-align: center;
}

.winner-trophy {
  font-size: 2rem;
  margin-bottom: 6px;
}

.winner-title {
  color: var(--green-dark);
  font-weight: 800;
  font-style: italic;
  font-size: 1rem;
  margin-bottom: 12px;
}

.winner-pool {
  background: var(--surface-muted);
  border-radius: 999px;
  padding: 10px 14px;
  margin-bottom: 14px;
}

.winner-pool-label {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.06em;
}

.winner-pool-value {
  color: var(--green-dark);
  font-size: 1.35rem;
  font-weight: 800;
}

.winner-shares {
  margin: 0 0 14px;
  padding: 10px 12px;
  background: var(--surface-muted);
  border-radius: 12px;
  text-align: left;
  font-size: 0.9rem;
  line-height: 1.45;
}

.winner-share-row {
  color: var(--text);
}

.winner-share-row + .winner-share-row {
  margin-top: 4px;
}

.winner-card-wrap {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px;
  margin-bottom: 12px;
}

.winner-card-head {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-weight: 800;
  font-style: italic;
}

.winner-card-id {
  color: var(--blue);
}

.winner-card-name {
  color: var(--green-dark);
}

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

.winner-cell {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px solid var(--border);
  font-size: 0.8rem;
  font-weight: 700;
}

.winner-cell.called {
  background: #fef9c3;
  border-color: #fde047;
}

.winner-cell.win {
  background: #dcfce7;
  border: 2px solid var(--green);
  color: var(--green-dark);
}

.winner-cell.current {
  box-shadow: 0 0 0 2px var(--green);
}

.winner-continue {
  background: var(--yellow);
  color: #111;
  border-radius: 14px;
  padding: 12px 18px;
  font-weight: 800;
  cursor: pointer;
  margin-top: 8px;
}

.blocked_modal > div {
  background: #fff !important;
  color: var(--text) !important;
  border-radius: var(--radius);
  border: 2px solid var(--red);
}

#loadingModal > div {
  background: #fff !important;
  width: auto !important;
  height: auto !important;
  padding: 24px 28px !important;
  border-radius: var(--radius) !important;
  border: 1px solid var(--border);
}
