:root {
  --paper: #fff7e8;
  --ink: #192342;
  --blue: #2a42cc;
  --coral: #f25d49;
  --yellow: #fae575;
  --mint: #d7ead7;
  --line: rgb(25 35 66 / .27);
  color: var(--ink);
  font: 400 1rem/1.45 system-ui, sans-serif;
  background: var(--paper);
}
*, *::before, *::after { box-sizing: border-box; }
body, h1, h2, h3, p { margin: 0; }
button, select, input { font: inherit; color: inherit; }
button, select { cursor: pointer; }
button:disabled { cursor: default; }
button:focus-visible, select:focus-visible, input:focus-visible, a:focus-visible, summary:focus-visible { outline: 3px solid var(--blue); outline-offset: 4px; }
[hidden] { display: none !important; }

.game { max-width: 69rem; margin-inline: auto; padding: .5rem .75rem 1.4rem; }
.game-head {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(8rem, .55fr); align-items: center; isolation: isolate;
  gap: .6rem; padding: clamp(.95rem, 3.5vw, 2.3rem); min-height: 10rem;
  color: var(--paper); background: var(--blue); border: 2px solid var(--ink); border-radius: 10px;
}
.game-head h1 { font: 800 clamp(3rem, 8vw, 6.35rem)/.95 var(--display); letter-spacing: -.065em; }
.game-head p { max-width: 35rem; margin-top: .7rem; font-size: clamp(.98rem, 2.3vw, 1.23rem); }
.head-balls { position: relative; min-width: 0; min-height: 6.8rem; }
.ball {
  position: absolute; display: grid; place-items: center; border: 2px solid var(--ink); box-shadow: 3px 4px 0 var(--ink);
  border-radius: 50%; width: clamp(2.1rem, 10.2vw, 5.7rem); aspect-ratio: 1; font: 700 clamp(1.1rem, 4vw, 2.6rem)/1 var(--display); color: var(--ink);
}
.ball-first { top: .3rem; left: 5%; transform: rotate(-18deg); background: var(--coral); }
.ball-second { top: -.35rem; left: 40%; transform: rotate(13deg); background: var(--paper); }
.ball-third { top: 58%; left: 51%; transform: rotate(17deg); background: var(--yellow); }

.view-nav { display: flex; flex-wrap: wrap; gap: .5rem; margin-block: 1.1rem; }
.view-nav a {
  border: 1px solid var(--ink); border-radius: 5px; color: var(--ink); font-weight: 700; text-decoration: none;
  padding: .48rem .85rem;
}
.view-nav a[aria-current] { background: var(--ink); color: var(--paper); }
.game-view { border: 1px solid var(--ink); border-radius: 9px; }
.play { display: grid; grid-template-columns: minmax(0,.78fr) minmax(0,1.22fr); align-items: stretch; }
.draw-console, .draw-side, .cards-options { padding: clamp(.85rem, 3.3vw, 2rem); }
.draw-console { border-right: 1px solid var(--ink); background: var(--mint); border-top-left-radius: 8px; }
.draw-console h2 { margin-top: 1.05rem; }
.game-view h2, #reset-dialog h2 { font: 800 clamp(1.72rem, 4vw, 2.55rem)/1.05 var(--display); letter-spacing: -.038em; }
.draw-intro, .cards-options p, #board-label { margin-top: .5rem; }
label { font-size: .92rem; font-weight: 700; display: block; margin-bottom: .25rem; }
select, input {
  width: 100%; min-height: 2.8rem; padding: .39rem .5rem; border: 1px solid var(--ink);
  border-radius: 5px; background: var(--paper);
}
.draw-stage { display: grid; gap: .15rem; justify-items: start; margin-block: 1rem; }
.draw-label, .draw-count { font-size: .94rem; font-weight: 700; }
.current-number {
  display: grid; place-items: center; width: 5.8rem; aspect-ratio: 1; border-radius: 50%; border: 2px solid var(--ink);
  box-shadow: 3px 3px 0 var(--ink); background: var(--yellow);
  font: 700 3.65rem/.9 var(--display); font-variant-numeric: tabular-nums; margin-block: .24rem;
}
.draw-actions, .card-actions, .dialog-actions { display: flex; align-items: center; flex-wrap: wrap; gap: .7rem 1.05rem; }
.action {
  min-height: 2.8rem; padding: .42rem .72rem; background: var(--coral); color: var(--ink); font-weight: 700;
  border: 2px solid var(--ink); box-shadow: 2px 2px 0 var(--ink); border-radius: 5px;
}
.action:hover:not(:disabled) { background: var(--yellow); }
.action-secondary { background: var(--paper); }
.action:disabled { background: #dfdbcc; box-shadow: none; }
.text-button { min-height: 2.8rem; background: transparent; border: 0; padding: 0; text-decoration: underline; text-underline-offset: .21em; font-weight: 600; }
.text-button:disabled { opacity: .48; }
.draw-side { min-width: 0; }
.number-board {
  display: grid; grid-template-columns: repeat(10, minmax(0,1fr)); gap: 4px;
  max-width: 100%; margin-top: .85rem;
}
.number-board span {
  display: grid; place-items: center; min-width: 0; aspect-ratio: 1.22; border: 1px solid var(--line);
  border-radius: 4px; font-size: clamp(.61rem, 1.7vw, .9rem); font-weight: 600; font-variant-numeric: tabular-nums;
}
.number-board [data-hit] { color: var(--paper); background: var(--ink); border-color: var(--ink); }
.number-board [aria-current] { color: var(--ink); background: var(--yellow); border: 2px solid var(--ink); }
.history-text { margin-top: .75rem; font-size: .91rem; overflow-wrap: anywhere; }
.rules { grid-column: 1 / -1; border-top: 1px solid var(--ink); padding: .75rem clamp(.85rem, 3.3vw, 2rem); }
.rules summary { font-weight: 700; cursor: pointer; }
.rules p { margin-top: .48rem; max-width: 47rem; }
.cards-options { background: #e4d7fd; border-radius: 8px 8px 0 0; border-bottom: 1px solid var(--ink); }
.form-fields { display: grid; grid-template-columns: minmax(9rem, 1.3fr) minmax(5rem, .65fr) minmax(7rem, .85fr); gap: .65rem; margin-block: 1rem; max-width: 34rem; }
.card-status { font-weight: 700; padding: 0 clamp(.85rem, 3.3vw, 2rem); }
.card-status:not(:empty) { margin-top: 1rem; }
.card-note { font-size: .91rem; padding: 0 clamp(.85rem, 3.3vw, 2rem); }
#card-sheets { margin: 1rem clamp(.75rem, 3.3vw, 2rem); }
.sheets-page { display: grid; gap: .75rem; }
.sheets-page + .sheets-page { margin-top: .75rem; }
.sheets-page[data-layout="4"] { grid-template-columns: repeat(2, minmax(0,1fr)); }
.bingo-card {
  --cols: 5;
  display: grid; align-content: center; gap: .65rem; border: 1px dashed #606573;
  border-radius: 4px; background: #fffdf7; padding: .75rem; break-inside: avoid;
}
.bingo-card[data-mode="90"] { --cols: 9; }
.card-header { display: flex; flex-wrap: wrap; gap: .35rem 1rem; justify-content: space-between; align-items: baseline; }
.card-header h3 { font: 800 1.5rem/.98 var(--display); letter-spacing: -.04em; }
.card-header span, .printed-credits { font-size: .76rem; }
.ticket { width: 100%; border-collapse: collapse; table-layout: fixed; border: 1.2px solid var(--ink); }
.ticket th, .ticket td {
  height: 1.9rem; width: calc(100% / var(--cols)); border: 1px solid var(--ink); text-align: center;
  font-weight: 700; font-variant-numeric: tabular-nums; padding: .1rem 0;
}
.ticket th { background: var(--yellow); }
.ticket td.free { background: #e7e3ef; font-size: .75rem; }
.ticket td.empty { background: #e7e3ef; }
#reset-dialog { max-width: min(95%,35rem); color: var(--ink); background: var(--paper); border: 2px solid var(--ink); border-radius: 9px; padding: 1.2rem; }
#reset-dialog p { margin: .7rem 0 1rem; }
#reset-dialog::backdrop { background: rgb(25 35 66 / .55); }

@media (max-width: 44rem) {
  .play { grid-template-columns: 1fr; }
  .draw-console { border: 0; border-bottom: 1px solid var(--ink); border-radius: 8px 8px 0 0; }
}
@media (max-width: 30rem) {
  .game-head { grid-template-columns: minmax(0,1fr) minmax(4.5rem,.4fr); }
  .form-fields { grid-template-columns: minmax(0,1fr) minmax(0,1fr); }
  .form-fields > div:first-child { grid-column: 1 / -1; }
  .number-board span { font-size: clamp(.68rem, 2.7vw, .85rem); height: 1.8rem; aspect-ratio: auto; }
  .sheets-page[data-layout="4"] { grid-template-columns: 1fr; }
}
@page { size: A4 portrait; margin: 11mm; }
@media print {
  :root { background: white; color: #111; }
  main.game { padding: 0; max-width: none; }
  .game-head, .view-nav, #trekning, .cards-options, .card-status, .card-note, dialog { display: none !important; }
  #bingokort { border: 0; }
  #card-sheets { margin: 0; }
  .sheets-page, .sheets-page + .sheets-page {
    height: 270mm; gap: 3mm; margin: 0;
    grid-template-rows: repeat(2, minmax(0,1fr));
    page-break-after: always; break-after: page;
  }
  .sheets-page[data-layout="4"] { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .sheets-page:last-child { break-after: auto; page-break-after: auto; }
  .bingo-card { border-color: #666; padding: 4mm; margin: 0; gap: 3mm; background: white; color: #111; }
  .card-header h3 { font-size: 17pt; }
  .card-header span, .printed-credits { font-size: 8pt; }
  .ticket, .ticket th, .ticket td { border-color: #222; }
  .ticket th, .ticket td { height: 12mm; font-size: 14pt; }
  .ticket th { background: white; border-bottom: 2px solid #111; }
  .ticket td.free { font-size: 10pt; background: white; }
  .ticket td.empty { background: #ededed; print-color-adjust: exact; }
  .ticket td.empty::after { content: "·"; color: #777; }
}
