* {
  box-sizing: border-box;
}

:root {
  --bg-dark: #0b2f1d;
  --bg-mid: #154734;
  --panel: rgba(255, 255, 255, 0.1);
  --panel-2: rgba(255, 255, 255, 0.14);
  --line: rgba(255, 255, 255, 0.16);
  --text: #ffffff;
  --muted: #eaf4ee;
  --gold: #f4c542;
  --gold-deep: #c79213;
  --red: #c62828;
  --green: #1f8f4e;
  --blue: #2563eb;
  --purple: #7c3aed;
  --cell-bg: #fffef8;
  --cell-text: #122218;
  --free-bg: #e9fbe9;
  --win: #ffd700;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.28);
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: Arial, Helvetica, sans-serif;
  background: radial-gradient(circle at top, #2a6d45 0%, var(--bg-mid) 35%, var(--bg-dark) 100%);
  color: var(--text);
}

body {
  overflow-x: hidden;
}

.snow-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.22;
  background-image:
    radial-gradient(circle, rgba(255,255,255,0.95) 1px, transparent 1px),
    radial-gradient(circle, rgba(255,255,255,0.75) 1.5px, transparent 1.5px),
    radial-gradient(circle, rgba(255,255,255,0.6) 2px, transparent 2px);
  background-size: 130px 130px, 220px 220px, 300px 300px;
  background-position: 0 0, 40px 60px, 100px 120px;
  animation: drift 20s linear infinite;
}

@keyframes drift {
  from { transform: translateY(-12px); }
  to { transform: translateY(35px); }
}

.caller-link-bar {
  text-align: center;
  padding: 6px 0 2px;
}

.caller-link {
  display: inline-block;
  color: var(--gold);
  font-size: 0.88rem;
  font-weight: 700;
  text-decoration: none;
  opacity: 0.85;
  transition: opacity 0.15s;
}

.caller-link:hover {
  opacity: 1;
  text-decoration: underline;
}

.app {
  width: min(1100px, 96%);
  margin: 0 auto;
  padding: 18px 0 28px;
  position: relative;
  z-index: 1;
}

.hero {
  text-align: center;
  margin-bottom: 18px;
}

.hero h1 {
  margin: 0 0 6px;
  font-size: clamp(2rem, 6vw, 3.5rem);
  text-shadow: 0 2px 10px rgba(0,0,0,0.35);
}

.hero p {
  margin: 0;
  color: var(--muted);
  font-size: 0.98rem;
}

.panel {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 16px;
  backdrop-filter: blur(6px);
  box-shadow: var(--shadow);
}

.top-section {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}

.status-card,
.controls-section,
.bingo-card-wrap,
.called-history-panel {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 18px;
}

.status-card {
  padding: 14px;
  display: grid;
  gap: 8px;
  color: var(--muted);
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

button,
select,
input {
  font: inherit;
}

button {
  border: none;
  border-radius: 999px;
  min-height: 46px;
  padding: 12px 14px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.12s ease;
}

button:hover {
  transform: translateY(-1px);
  filter: brightness(1.04);
}

button:active {
  transform: translateY(0);
}

#newCardBtn { background: linear-gradient(180deg, #d53434, #9e1d1d); color: #fff; }
#clearMarksBtn { background: linear-gradient(180deg, #f0c933, #c58d09); color: #1f230c; }
#shareBtn { background: linear-gradient(180deg, #3382ff, #2159c7); color: #fff; }
#bingoBtn { background: linear-gradient(180deg, #2cc862, #168b3f); color: #fff; }

.controls-section {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  padding: 14px;
  margin-bottom: 14px;
  align-items: end;
}

.control-block {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.control-block.grow {
  grid-column: span 2;
}

.control-block label,
.label-like {
  font-weight: 700;
  color: #fff;
}

select,
input[type="number"] {
  width: 100%;
  min-height: 46px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.2);
  padding: 10px 12px;
  background: rgba(255,255,255,0.92);
  color: #102317;
}

.called-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

#markCalledBtn {
  background: linear-gradient(180deg, #ef4444, #b91c1c);
  color: white;
  padding-inline: 18px;
}

.toggle-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
}

.toggle-wrap input {
  width: 18px;
  height: 18px;
}

.color-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.color-dot {
  width: 40px;
  min-width: 40px;
  height: 40px;
  min-height: 40px;
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,0.65);
  padding: 0;
}

.color-dot.active {
  box-shadow: 0 0 0 4px rgba(255,255,255,0.18);
  transform: scale(1.06);
}

.color-dot[data-color="red"] { background: #dc2626; }
.color-dot[data-color="green"] { background: #16a34a; }
.color-dot[data-color="blue"] { background: #2563eb; }
.color-dot[data-color="gold"] { background: #eab308; }
.color-dot[data-color="purple"] { background: #7c3aed; }

.bingo-card-wrap {
  padding: 12px;
  margin-bottom: 14px;
}

.bingo-header {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-bottom: 8px;
}

.bingo-header > div {
  background: linear-gradient(180deg, var(--gold), var(--gold-deep));
  color: #5d1212;
  border-radius: 12px;
  text-align: center;
  font-size: clamp(1.15rem, 4vw, 2rem);
  font-weight: 900;
  padding: 10px 0;
}

.bingo-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.cell {
  position: relative;
  aspect-ratio: 1 / 1;
  background: var(--cell-bg);
  border: 2px solid #d6d6d6;
  border-radius: 14px;
  color: var(--cell-text);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(1rem, 4vw, 1.8rem);
  font-weight: 900;
  user-select: none;
  cursor: pointer;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

.cell span {
  position: relative;
  z-index: 2;
}

.cell.free {
  background: linear-gradient(180deg, #eeffef, #cef3d0);
  color: #14612d;
  text-align: center;
  font-size: clamp(0.75rem, 2.6vw, 1rem);
  line-height: 1.05;
  padding: 4px;
}

.cell.marked::after {
  content: "";
  position: absolute;
  width: 68%;
  height: 68%;
  border-radius: 50%;
  z-index: 1;
}

.cell.marked.red::after {
  background: rgba(220, 38, 38, 0.34);
  border: 4px solid rgba(185, 28, 28, 0.92);
}

.cell.marked.green::after {
  background: rgba(34, 197, 94, 0.34);
  border: 4px solid rgba(22, 163, 74, 0.92);
}

.cell.marked.blue::after {
  background: rgba(37, 99, 235, 0.28);
  border: 4px solid rgba(29, 78, 216, 0.92);
}

.cell.marked.gold::after {
  background: rgba(250, 204, 21, 0.34);
  border: 4px solid rgba(202, 138, 4, 0.92);
}

.cell.marked.purple::after {
  background: rgba(124, 58, 237, 0.30);
  border: 4px solid rgba(109, 40, 217, 0.92);
}

.cell.winner {
  border-color: var(--win);
  box-shadow:
    0 0 0 2px rgba(255,215,0,0.35),
    0 0 16px rgba(255,215,0,0.42);
}

.called-history-panel {
  padding: 14px;
}

.called-history-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.called-history-head h2 {
  margin: 0;
  font-size: 1.05rem;
}

.small-btn {
  min-height: 38px;
  padding: 8px 14px;
  background: linear-gradient(180deg, #f0c933, #c58d09);
  color: #1f230c;
}

.called-history {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 34px;
}

.called-chip {
  background: rgba(255,255,255,0.92);
  color: #102317;
  border-radius: 999px;
  padding: 7px 12px;
  font-weight: 800;
  font-size: 0.92rem;
}

.message-box {
  min-height: 28px;
  margin-top: 12px;
  font-weight: 700;
  color: #fff5bf;
}

.bingo-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 9999;
}

.bingo-overlay.hidden {
  display: none;
}

.bingo-overlay-card {
  width: min(92vw, 520px);
  background: linear-gradient(180deg, #fff8dc, #ffe9a8);
  color: #7a1010;
  border: 5px solid #ffd700;
  border-radius: 24px;
  padding: 28px 22px;
  text-align: center;
  box-shadow: 0 0 30px rgba(255, 215, 0, 0.45);
}

.bingo-big {
  font-size: clamp(2rem, 8vw, 4rem);
  font-weight: 900;
  line-height: 1.05;
  margin-bottom: 12px;
}

.bingo-overlay-text {
  font-size: clamp(1rem, 3.5vw, 1.3rem);
  font-weight: 700;
  margin-bottom: 18px;
}

#closeBingoOverlayBtn {
  background: linear-gradient(180deg, #2cc862, #168b3f);
  color: #fff;
  min-width: 140px;
}

@media (max-width: 900px) {
  .top-section {
    grid-template-columns: 1fr;
  }

  .controls-section {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .control-block.grow {
    grid-column: span 2;
  }
}

@media (max-width: 560px) {
  .panel {
    padding: 12px;
    border-radius: 16px;
  }

  .action-grid {
    grid-template-columns: 1fr 1fr;
  }

  .controls-section {
    grid-template-columns: 1fr;
  }

  .control-block.grow {
    grid-column: span 1;
  }

  .called-row {
    grid-template-columns: 1fr;
  }

  #markCalledBtn {
    width: 100%;
  }

  .bingo-header,
  .bingo-grid {
    gap: 6px;
  }

  .cell {
    border-radius: 12px;
  }
}

/* ── Welcome / Beta-Tester Modal ────────────────────────────── */
.welcome-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(10, 40, 20, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.welcome-overlay.hidden {
  display: none;
}

.welcome-box {
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(244, 197, 66, 0.45);
  border-radius: 1.4rem;
  padding: 2rem 2.4rem;
  max-width: 480px;
  width: 100%;
  color: #fffef8;
  text-align: center;
  box-shadow: 0 10px 48px rgba(0, 0, 0, 0.55);
}

.welcome-box h2 {
  color: var(--gold);
  margin: 0 0 1.1rem;
  font-size: clamp(1.2rem, 4vw, 1.65rem);
}

.welcome-box p {
  margin: 0 0 1rem;
  line-height: 1.7;
  font-size: clamp(0.85rem, 2.5vw, 1rem);
  color: var(--muted);
}

.welcome-box .reward-line {
  font-style: italic;
  font-size: 0.9em;
  opacity: 0.88;
}

.welcome-btn {
  margin-top: 0.4rem;
  padding: 0.72rem 1.9rem;
  background: linear-gradient(180deg, var(--gold), var(--gold-deep));
  color: #1a3d25;
  border: none;
  border-radius: 999px;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  transition: filter 0.15s ease, transform 0.1s ease;
}

.welcome-btn:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

/* ── End Welcome Modal ──────────────────────────────────────── */

@media print {
  .snow-layer,
  .controls-section,
  .called-history-panel,
  .message-box,
  .action-grid,
  .bingo-overlay {
    display: none;
  }

  body {
    background: #fff;
    color: #000;
  }

  .panel,
  .status-card,
  .bingo-card-wrap {
    background: #fff;
    border: none;
    box-shadow: none;
  }

  .hero h1,
  .hero p {
    color: #000;
    text-shadow: none;
  }
}