:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --text: #172033;
  --muted: #687286;
  --line: #dfe4ec;
  --accent: #2563eb;
  --accent-soft: rgba(37, 99, 235, .20);
  --danger: #dc2626;
  --shadow: 0 10px 30px rgba(23, 32, 51, .08);
  --radius: 18px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-tap-highlight-color: transparent;
}
button, input { font: inherit; }
button { cursor: pointer; }

.app {
  width: min(100%, 760px);
  margin: 0 auto;
  padding: max(22px, env(safe-area-inset-top)) 14px max(28px, env(safe-area-inset-bottom));
}
.screen { min-height: calc(100dvh - 36px); }
.hidden { display: none !important; }

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 26px 6px 22px;
}
.brand-mark {
  width: 48px; height: 48px;
  display: grid; place-items: center;
  border-radius: 14px;
  background: var(--accent);
  color: #fff;
  font-size: 25px;
  font-weight: 800;
  box-shadow: 0 8px 20px rgba(37, 99, 235, .22);
}

.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  overflow: hidden;
  background: transparent;
}

.brand-mark img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

h1, h2, h3, p { margin: 0; }
.brand h1 { font-size: 25px; letter-spacing: -.5px; }
.brand p, .game-header p { color: var(--muted); font-size: 14px; margin-top: 3px; }

.panel {
  background: var(--panel);
  border: 1px solid rgba(223, 228, 236, .8);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}
.panel > label {
  display: block;
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 10px;
}
.panel > label:not(:first-child) { margin-top: 22px; }

.color-row {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 48px;
}
#marker-color {
  width: 58px; height: 42px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
#color-value {
  color: var(--muted);
  font: 700 13px ui-monospace, SFMono-Regular, Menlo, monospace;
}

.count-picker {
  display: grid;
  grid-template-columns: 48px 1fr 48px;
  height: 50px;
  border: 1px solid var(--line);
  border-radius: 13px;
  overflow: hidden;
  margin-bottom: 24px;
}
.count-picker button {
  border: 0;
  background: #f8f9fc;
  color: var(--text);
  font-size: 25px;
}
.count-picker button:active { background: #eef1f6; }
.count-picker output {
  display: grid;
  place-items: center;
  font-size: 18px;
  font-weight: 800;
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
}

.primary-btn, .secondary-btn, .danger-btn {
  min-height: 46px;
  border-radius: 12px;
  border: 1px solid transparent;
  padding: 0 16px;
  font-weight: 750;
}
.primary-btn {
  width: 100%;
  background: var(--accent);
  color: #fff;
}
.primary-btn:active { transform: translateY(1px); }
.secondary-btn {
  background: #fff;
  border-color: var(--line);
  color: var(--text);
}
.danger-btn { background: var(--danger); color: #fff; }
.hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  text-align: center;
  margin-top: 12px;
}

.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 2px 15px;
}
.game-header h2 { font-size: 22px; }
.game-header .secondary-btn { min-height: 40px; padding: 0 12px; font-size: 13px; }

.cards { display: grid; gap: 18px; }
.card-wrap {
  background: var(--panel);
  border: 1px solid rgba(223, 228, 236, .9);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: var(--shadow);
}
.card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 4px 10px;
  font-size: 13px;
  font-weight: 800;
  color: var(--muted);
}
.card-title .complete { color: var(--accent); }

.bingo-card {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 3px;
  background: var(--line);
  border: 3px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  touch-action: manipulation;
}
.cell {
  aspect-ratio: 1.05 / 1;
  min-width: 0;
  border: 0;
  border-radius: 0;
  background: #fff;
  position: relative;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: clamp(12px, 4vw, 23px);
  color: var(--text);
  padding: 0;
}
.cell.blank { background: var(--accent-soft); }
.cell.number { cursor: pointer; }
.cell.marked::after {
  content: "";
  position: absolute;
  width: 72%;
  height: 72%;
  border-radius: 50%;
  background: var(--accent-soft);
  border: 2px solid var(--accent);
  pointer-events: none;
}
.cell.marked { color: var(--text); }
.row-complete {
  box-shadow: inset 0 0 0 3px var(--accent);
}
.card-complete {
  box-shadow: 0 0 0 3px var(--accent);
}

.toast {
  position: fixed;
  z-index: 20;
  left: 12px;
  right: 12px;
  bottom: max(14px, env(safe-area-inset-bottom));
  margin: 0 auto;
  width: min(520px, calc(100% - 24px));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  background: #172033;
  color: #fff;
  border-radius: 14px;
  padding: 13px 14px 13px 16px;
  box-shadow: 0 15px 40px rgba(0,0,0,.22);
}
.toast strong, .toast span { display: block; }
.toast strong { font-size: 14px; }
.toast span { font-size: 12px; opacity: .82; margin-top: 2px; }
.toast button {
  flex: 0 0 auto;
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 25px;
  line-height: 1;
  padding: 3px 6px;
}

.dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(9, 14, 25, .48);
}
.dialog {
  width: min(100%, 390px);
  background: #fff;
  border-radius: 18px;
  padding: 21px;
  box-shadow: 0 25px 70px rgba(0,0,0,.25);
}
.dialog h3 { font-size: 19px; }
.dialog p { color: var(--muted); font-size: 14px; line-height: 1.5; margin-top: 8px; }
.dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 20px; }
.dialog-actions button { width: 100%; }

@media (min-width: 600px) {
  .app { padding-left: 20px; padding-right: 20px; }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card-wrap:last-child:nth-child(odd) { grid-column: 1 / -1; }
}
.blank-symbol {
  font-size: clamp(12px, 4vw, 23px);
  font-weight: 700;
  color: white;
  opacity: 0.7;
  user-select: none;
  pointer-events: none;
}
