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

:root {
  --accent: #0ea5e9;
  --accent-2: #14b8a6;
  --accent-dark: #0369a1;
  --text: #1e293b;
  --glass: rgba(255, 255, 255, 0.92);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
}

html,
body {
  height: 100%;
}

body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 12% 16%, rgba(255, 255, 255, 0.16), transparent 34%),
    radial-gradient(circle at 88% 84%, rgba(255, 255, 255, 0.12), transparent 36%),
    linear-gradient(135deg, #0f766e, #4338ca);
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

.app {
  max-width: 600px;
  margin: 0 auto;
  padding: 16px 14px 30px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 100vh;
}

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #fff;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 54px;
  height: 54px;
  border-radius: 16px;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.28));
  background: #fff;
  flex-shrink: 0;
}

.brand h1 {
  font-size: 1.42rem;
  line-height: 1.08;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.22);
}

.tagline {
  font-size: 0.74rem;
  opacity: 0.85;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 600;
  margin-top: 2px;
}

.topbar-actions {
  display: flex;
  gap: 8px;
}

.icon-btn {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  border: none;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.2);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  color: #fff;
  font-size: 1.2rem;
  transition: transform 0.15s ease, background 0.2s ease;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.34);
  transform: translateY(-1px);
}

.icon-btn:active {
  transform: scale(0.94);
}

/* ---------- Controls ---------- */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  align-items: flex-end;
  justify-content: space-between;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.92);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  border: none;
  cursor: pointer;
  font-weight: 800;
  font-family: inherit;
  color: #fff;
  background: rgba(255, 255, 255, 0.22);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.28);
  transition: transform 0.12s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.chip:hover:not(:disabled) {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.4);
}

.chip.active {
  background: var(--accent);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.28);
}

.chip.level {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  font-size: 1rem;
}

.topic-label {
  color: #fff;
  font-weight: 700;
  font-size: 1.02rem;
  background: rgba(255, 255, 255, 0.18);
  padding: 9px 14px;
  border-radius: 12px;
  white-space: nowrap;
}

/* ---------- Caller ---------- */
.caller {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  background: var(--glass);
  border-radius: 20px;
  padding: 12px 18px 14px;
  box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.caller-row {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
}

.call-label {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-dark);
}

.call-hint {
  font-size: 0.78rem;
  font-weight: 700;
  color: #64748b;
}

.call-main {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 64px;
}

.call-text {
  font-size: clamp(1.7rem, 7vw, 2.6rem);
  font-weight: 900;
  color: #0f172a;
  text-align: center;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.call-emoji {
  font-size: 2.6rem;
  line-height: 1;
  flex-shrink: 0;
}

.call-swatch {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.12), 0 4px 12px rgba(0, 0, 0, 0.2);
  flex-shrink: 0;
}

.caller-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.progress-track {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.14);
}

.progress-fill {
  height: 100%;
  width: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

/* ---------- Stats ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  background: var(--glass);
  border-radius: 18px;
  padding: 10px;
  box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.stat-value {
  font-weight: 800;
  font-size: 1.12rem;
  color: #0f172a;
  font-variant-numeric: tabular-nums;
}

.stat-label {
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #64748b;
}

/* ---------- Bingo card ---------- */
.board-wrap {
  position: relative;
  flex: 1;
  display: flex;
  align-items: flex-start;
}

.board {
  display: grid;
  gap: clamp(8px, 2.2vw, 14px);
  width: min(100%, 540px);
  margin: 0 auto;
  padding: 6px 0;
}

.board.grid-3 {
  grid-template-columns: repeat(3, 1fr);
  max-width: 430px;
}

.board.grid-4 {
  grid-template-columns: repeat(4, 1fr);
  max-width: 520px;
}

.board.grid-5 {
  grid-template-columns: repeat(5, 1fr);
  max-width: 540px;
}

.cell {
  aspect-ratio: 1 / 1;
  border: none;
  border-radius: 16%;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  font-family: inherit;
  background: rgba(255, 255, 255, 0.94);
  box-shadow:
    inset 0 -5px 0 rgba(15, 23, 42, 0.08),
    0 6px 16px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 4px;
  transition: transform 0.12s ease, box-shadow 0.18s ease, background 0.18s ease, filter 0.18s ease;
  animation: deal 0.45s ease both;
}

.cell-text {
  font-weight: 800;
  color: #0f172a;
  text-align: center;
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.cell-emoji {
  font-size: clamp(1.2rem, 6vw, 2.2rem);
  line-height: 1;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.16));
}

.cell-swatch {
  width: clamp(14px, 5vw, 24px);
  height: clamp(14px, 5vw, 24px);
  border-radius: 50%;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.14), 0 2px 6px rgba(0, 0, 0, 0.18);
}

.grid-3 .cell-text {
  font-size: clamp(1.1rem, 5.5vw, 1.7rem);
}

.grid-4 .cell-text {
  font-size: clamp(0.85rem, 3.8vw, 1.2rem);
}

.grid-5 .cell-text {
  font-size: clamp(0.62rem, 2.7vw, 0.92rem);
}

.cell:hover:not(.marked):not(.missed) {
  transform: translateY(-3px);
  box-shadow:
    inset 0 -5px 0 rgba(15, 23, 42, 0.08),
    0 10px 22px rgba(0, 0, 0, 0.24);
}

.cell:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 3px;
}

.cell.marked {
  background: linear-gradient(145deg, #a7f3d0, #99f6e4);
  box-shadow:
    inset 0 -5px 0 rgba(15, 23, 42, 0.08),
    0 0 0 3px rgba(16, 185, 129, 0.35),
    0 6px 16px rgba(0, 0, 0, 0.16);
}

.cell.marked .cell-text {
  color: #065f46;
}

.cell.missed {
  background: #e2e8f0;
  opacity: 0.78;
}

.cell.missed .cell-text {
  color: #475569;
}

.cell.win {
  background: linear-gradient(145deg, #fde68a, #fbbf24);
  box-shadow:
    inset 0 -5px 0 rgba(0, 0, 0, 0.1),
    0 0 0 4px rgba(255, 255, 255, 0.9),
    0 0 34px rgba(251, 191, 36, 0.8);
  animation: winPop 0.5s ease both;
}

.cell.win .cell-text {
  color: #78350f;
}

.cell.shake {
  animation: shake 0.4s ease;
  filter: saturate(0.65);
}

/* ---------- Footer ---------- */
.footer {
  text-align: center;
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.78rem;
  margin-top: auto;
  padding-top: 10px;
}

/* ---------- Buttons ---------- */
.btn {
  padding: 13px 16px;
  border: none;
  border-radius: 14px;
  font-weight: 700;
  font-size: 0.98rem;
  font-family: inherit;
  cursor: pointer;
  background: #f1f5f9;
  color: #334155;
  transition: transform 0.12s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
}

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

.btn:disabled {
  opacity: 0.45;
  cursor: default;
  transform: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

.btn-primary:hover {
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.28);
}

.btn-ghost {
  background: transparent;
  color: #64748b;
}

.btn-small {
  padding: 9px 14px;
  font-size: 0.86rem;
  border-radius: 12px;
}

/* ---------- Bingo overlay ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.55);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  padding: 18px;
  animation: fadeIn 0.25s ease both;
}

.overlay[hidden] {
  display: none;
}

.modal {
  width: min(92vw, 400px);
  background: #fff;
  border-radius: 24px;
  padding: 26px 22px;
  text-align: center;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
  animation: popIn 0.35s cubic-bezier(0.34, 1.4, 0.64, 1) both;
}

.bingo-modal {
  width: min(88vw, 380px);
  background: linear-gradient(160deg, #fefce8, #fef3c7);
  border: 4px solid #fbbf24;
  border-radius: 28px;
  padding: 30px 24px;
  text-align: center;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.4);
  animation: bingoTada 0.55s cubic-bezier(0.34, 1.55, 0.64, 1) both;
}

.bingo-modal h2 {
  font-size: clamp(2rem, 10vw, 2.8rem);
  color: #b45309;
  letter-spacing: 0.02em;
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.7);
}

.modal-stars {
  font-size: 2.4rem;
  letter-spacing: 6px;
  line-height: 1;
}

.star {
  color: #cbd5e1;
}

.star.lit {
  color: #f59e0b;
  filter: drop-shadow(0 2px 5px rgba(245, 158, 11, 0.6));
}

.modal h2 {
  margin: 8px 0 2px;
  font-size: 1.5rem;
  color: #0f172a;
}

.modal-subtitle {
  color: #64748b;
  font-size: 0.9rem;
  margin-bottom: 14px;
}

.modal-stats {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin: 16px 0 20px;
}

.modal-stats div {
  background: #f1f5f9;
  border-radius: 12px;
  padding: 8px 4px;
}

.modal-stats span {
  display: block;
  font-weight: 800;
  font-size: 1rem;
  color: #0f172a;
  font-variant-numeric: tabular-nums;
}

.modal-stats label {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #64748b;
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ---------- Effects canvas ---------- */
.fx-canvas {
  position: fixed;
  inset: 0;
  z-index: 60;
  pointer-events: none;
}

/* ---------- No JS ---------- */
.noscript {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  background: #f8fafc;
  color: #334155;
  font-weight: 600;
}

/* ---------- Animations ---------- */
@keyframes deal {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.85);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes winPop {
  0% {
    transform: scale(0.7);
  }
  60% {
    transform: scale(1.12);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

@keyframes popIn {
  from {
    transform: scale(0.8);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes bingoTada {
  0% {
    transform: scale(0.5) rotate(-4deg);
    opacity: 0;
  }
  55% {
    transform: scale(1.08) rotate(2deg);
  }
  100% {
    transform: scale(1) rotate(0);
    opacity: 1;
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ---------- Small screens ---------- */
@media (max-width: 520px) {
  .stats {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px 4px;
    padding: 8px 4px;
  }

  .stat-value {
    font-size: 1rem;
  }

  .brand h1 {
    font-size: 1.18rem;
  }

  .brand-logo {
    width: 46px;
    height: 46px;
  }

  .icon-btn {
    width: 42px;
    height: 42px;
  }

  .modal-stats {
    grid-template-columns: repeat(3, 1fr);
  }

  .caller {
    padding: 10px 14px 12px;
  }

  .call-main {
    min-height: 54px;
  }
}
