:root {
  --bg0: #070a12;
  --bg1: #0b1220;
  --card: rgba(255, 255, 255, 0.06);
  --card2: rgba(255, 255, 255, 0.09);
  --text: rgba(255, 255, 255, 0.92);
  --muted: rgba(255, 255, 255, 0.6);
  --line: rgba(255, 255, 255, 0.12);
  --accent: #8b5cf6;
  --accent2: #22c55e;
  --danger: #ef4444;
  --shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  font-family: "Noto Sans Ethiopic", "Noto Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1000px 600px at 10% 10%, rgba(139,92,246,0.25), transparent 55%),
    radial-gradient(900px 600px at 90% 20%, rgba(34,197,94,0.18), transparent 55%),
    linear-gradient(180deg, var(--bg0), var(--bg1));
}

#app {
  padding: 14px 14px 22px;
  max-width: 980px;
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.brand { display: flex; align-items: center; gap: 10px; }
.logo {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  font-weight: 800;
  letter-spacing: 0.5px;
  background: linear-gradient(135deg, rgba(139,92,246,0.9), rgba(34,197,94,0.75));
}
.title { font-weight: 800; font-size: 16px; line-height: 1.1; }
.subtitle { color: var(--muted); font-size: 12px; margin-top: 2px; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.chip {
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.18);
  font-size: 12px;
  color: rgba(255,255,255,0.86);
}
.chip-accent {
  border-color: rgba(139,92,246,0.55);
  background: rgba(139,92,246,0.15);
}

.notice {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(239,68,68,0.35);
  background: rgba(239,68,68,0.12);
  color: rgba(255,255,255,0.92);
}

.view { margin-top: 14px; }

.h { font-weight: 800; font-size: 15px; }
.p { color: var(--muted); font-size: 12px; margin-top: 4px; }

.btn {
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.9);
  padding: 9px 12px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 700;
  font-size: 12px;
}
.btn:active { transform: translateY(1px); }
.btn-sm { padding: 6px 10px; font-size: 11px; }
.btn-primary {
  border-color: rgba(34,197,94,0.5);
  background: rgba(34,197,94,0.16);
}

/* ── Wallet Balance Bar ── */
.wallet-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  box-shadow: var(--shadow);
  font-size: 14px;
  font-weight: 600;
}
.wallet-bar-icon { font-size: 18px; }
.wallet-bar-amount {
  margin-left: auto;
  font-weight: 900;
  font-size: 16px;
}

/* ── Room Table ── */
.room-table {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.room-table-header {
  display: grid;
  grid-template-columns: 1fr 1fr 1.2fr;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.room-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1.2fr;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.room-row:last-child { border-bottom: none; }

.room-bet {
  font-weight: 900;
  font-size: 15px;
  color: #facc15;
}
.room-win {
  font-weight: 700;
  font-size: 14px;
  color: var(--muted);
}
.room-status-join {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
}
.room-empty {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 8px 0;
}

.status-badge {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(0,0,0,0.18);
  color: var(--muted);
  white-space: nowrap;
}
.status-badge.status-running {
  border-color: rgba(34,197,94,0.45);
  background: rgba(34,197,94,0.12);
  color: rgba(34,197,94,0.9);
}

.btn-join {
  border: none;
  background: #ef4444;
  color: #fff;
  padding: 6px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
  font-size: 13px;
}
.btn-join:active { transform: translateY(1px); opacity: 0.9; }

.lobby-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  padding: 0 4px;
}
.lobby-footer-text {
  color: var(--muted);
  font-size: 11px;
}

.small { color: var(--muted); font-size: 12px; }

/* ── Game Layout (two-column like Wana Bingo) ── */
.game-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

/* Drawn numbers panel (left) */
.drawn-panel {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  padding: 8px;
  overflow: hidden;
}

.bingo-col-headers {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  margin-bottom: 6px;
}
.col-hdr {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 13px;
  color: #fff;
  justify-self: center;
}
.col-b { background: #3b82f6; }
.col-i { background: #ef4444; }
.col-n { background: #22c55e; }
.col-g { background: #a855f7; }
.col-o { background: #f97316; }

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

.drawn-num {
  padding: 5px 0;
  text-align: center;
  font-weight: 700;
  font-size: 12px;
  color: rgba(255,255,255,0.5);
  border-radius: 6px;
  background: rgba(255,255,255,0.04);
  border: 1px solid transparent;
}
.drawn-num.called {
  background: rgba(139,92,246,0.22);
  border-color: rgba(139,92,246,0.5);
  color: #fff;
}
.drawn-num.current-num {
  background: rgba(34,197,94,0.25);
  border-color: rgba(34,197,94,0.6);
  color: #fff;
}

/* Info panel (right) */
.info-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.countdown-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card);
  font-size: 13px;
  font-weight: 700;
}
.countdown-status {
  color: #22c55e;
  font-weight: 900;
  font-size: 14px;
}

.current-call-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card);
  font-size: 13px;
  font-weight: 600;
}
.current-call-bubble {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  height: 36px;
  border-radius: 18px;
  background: linear-gradient(135deg, #a855f7, #6366f1);
  color: #fff;
  font-weight: 900;
  font-size: 15px;
  padding: 0 12px;
}

.recent-calls {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}
.recent-chip {
  padding: 4px 10px;
  border-radius: 8px;
  font-weight: 800;
  font-size: 12px;
  color: #fff;
}
.recent-chip.rc-b { background: #3b82f6; }
.recent-chip.rc-i { background: #ef4444; }
.recent-chip.rc-n { background: #22c55e; }
.recent-chip.rc-g { background: #a855f7; }
.recent-chip.rc-o { background: #f97316; }

/* Player's bingo card */
.my-card-section {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  padding: 8px;
}
.bingo-card-headers { margin-bottom: 4px; }
.bingo-card-headers .col-hdr { width: 100%; height: auto; padding: 4px 0; border-radius: 6px; font-size: 12px; }

.bingo-card {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
}
.bc-cell {
  padding: 8px 0;
  text-align: center;
  font-weight: 800;
  font-size: 13px;
  border-radius: 8px;
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.85);
  border: 1px solid transparent;
}
.bc-cell.bc-marked {
  background: rgba(34,197,94,0.2);
  border-color: rgba(34,197,94,0.5);
  color: #fff;
}
.bc-cell.bc-free {
  background: rgba(139,92,246,0.2);
  border-color: rgba(139,92,246,0.5);
  color: #fff;
  font-size: 16px;
}

.cartela-number-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 6px;
  font-size: 13px;
  font-weight: 600;
}
.cartela-num-val {
  color: #22c55e;
  font-weight: 900;
  font-size: 16px;
}

/* Bingo button */
.btn-bingo {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 14px;
  background: linear-gradient(135deg, #f97316, #fb923c);
  color: #fff;
  font-weight: 900;
  font-size: 18px;
  cursor: pointer;
  letter-spacing: 1px;
}
.btn-bingo:active { transform: translateY(1px); opacity: 0.9; }

/* Bottom bar */
.game-bottom-bar {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}
.btn-leave {
  flex: 1;
  padding: 12px;
  border: 2px solid #f97316;
  border-radius: 12px;
  background: transparent;
  color: #f97316;
  font-weight: 800;
  font-size: 14px;
  cursor: pointer;
}
.btn-leave:active { opacity: 0.8; }
.btn-refresh {
  flex: 1;
  padding: 12px;
  border: none;
  border-radius: 12px;
  background: #22c55e;
  color: #fff;
  font-weight: 800;
  font-size: 14px;
  cursor: pointer;
}
.btn-refresh:active { opacity: 0.8; }
.poll-status { text-align: center; margin-top: 4px; }

/* ── Game Top Bar ── */
.game-topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  box-shadow: var(--shadow);
  flex-wrap: wrap;
}

.game-topbar-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.game-topbar-btn:active { transform: translateY(1px); }

.game-topbar-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(0,0,0,0.18);
  flex: 1;
  min-width: 50px;
}

.game-topbar-label {
  font-size: 9px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.game-topbar-value {
  font-weight: 800;
  font-size: 13px;
  color: var(--text);
}

/* ── Game Timer ── */
.game-timer {
  margin-top: 10px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid rgba(139,92,246,0.45);
  background: rgba(139,92,246,0.12);
  text-align: center;
  font-weight: 800;
  font-size: 14px;
  animation: timerPulse 1.5s infinite;
}

@keyframes timerPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* ── Cartela Selection (in game view) ── */
.cartela-header {
  margin: 10px 2px 4px;
  font-size: 14px;
}

.cartela-grid {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 6px;
  margin-top: 10px;
}

.cartela-cell {
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(0,0,0,0.22);
  padding: 10px 0;
  text-align: center;
  font-weight: 800;
  font-size: 13px;
  color: rgba(255,255,255,0.85);
  cursor: pointer;
  transition: all 0.15s;
}

.cartela-cell:hover:not(.taken) {
  border-color: rgba(34,197,94,0.5);
  background: rgba(34,197,94,0.08);
}

.cartela-cell.selected {
  border-color: rgba(34,197,94,0.7);
  background: rgba(34,197,94,0.2);
  color: #fff;
  box-shadow: 0 0 12px rgba(34,197,94,0.25);
}

.cartela-cell.taken {
  opacity: 0.3;
  cursor: not-allowed;
  text-decoration: line-through;
}

.cartela-footer {
  margin-top: 12px;
  text-align: center;
}

.btn-lg {
  padding: 12px 20px;
  font-size: 14px;
  width: 100%;
}

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

/* ── Game-Over Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: none;              /* hidden by default */
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
  animation: fadeIn 0.25s ease;
}
.modal-overlay.active {
  display: flex;              /* shown only when .active class is added */
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-box {
  background: var(--bg1);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 28px 24px 22px;
  max-width: 340px;
  width: 90%;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  animation: scaleIn 0.25s ease;
}
@keyframes scaleIn { from { transform: scale(0.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.modal-icon {
  font-size: 48px;
  margin-bottom: 8px;
}
.modal-title {
  font-weight: 900;
  font-size: 22px;
  margin-bottom: 6px;
}
.modal-subtitle {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 18px;
}
.modal-btn {
  width: 100%;
}

@media (min-width: 840px) {
  #app { padding: 18px 18px 26px; }
  .game-layout { grid-template-columns: 1.2fr 0.8fr; }
  .cartela-grid { grid-template-columns: repeat(13, minmax(0, 1fr)); }
}

@media (max-width: 480px) {
  .game-layout { gap: 6px; }
  .drawn-panel { padding: 5px; }
  .drawn-grid { gap: 2px; }
  .drawn-num { font-size: 10px; padding: 3px 0; }
  .col-hdr { width: 22px; height: 22px; font-size: 11px; }
  .bc-cell { padding: 5px 0; font-size: 11px; }
  .info-panel { gap: 5px; }
  .countdown-bar { padding: 6px 8px; font-size: 12px; }
  .current-call-box { padding: 6px 8px; font-size: 12px; }
  .current-call-bubble { min-width: 40px; height: 30px; font-size: 13px; padding: 0 8px; }
  .recent-chip { padding: 3px 6px; font-size: 10px; }
  .my-card-section { padding: 5px; }
  .btn-bingo { padding: 10px; font-size: 15px; }
  .cartela-grid { grid-template-columns: repeat(7, minmax(0, 1fr)); }
  .game-topbar { gap: 4px; padding: 6px 6px; }
  .game-topbar-chip { padding: 3px 6px; }
  .room-bet { font-size: 13px; }
  .room-win { font-size: 12px; }
}
