/* Vejbingo – styling til små fingre på iPad/iPhone */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  font-family: -apple-system, "SF Pro Rounded", "Segoe UI", system-ui, sans-serif;
  background: linear-gradient(180deg, #4fc3f7 0%, #81d4fa 45%, #a5d6a7 100%);
  overflow: hidden;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.screen {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
}
.hidden { display: none !important; }

/* ---------- Header ---------- */
.game-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 2px 4px 8px;
  flex: 0 0 auto;
}
.game-title {
  font-size: clamp(1.4rem, 4.5vw, 2rem);
  font-weight: 800;
  color: #fff;
  text-shadow: 0 2px 0 rgba(0,0,0,.15);
  white-space: nowrap;
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.icon-btn {
  border: none;
  background: rgba(255,255,255,.85);
  font-size: 1.4rem;
  width: 52px;
  height: 52px;
  border-radius: 16px;
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(0,0,0,.12);
}
.icon-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0,0,0,.12); }
.icon-btn.spacer { visibility: hidden; }
.size-btn {
  width: auto;
  min-width: 52px;
  padding: 0 14px;
  font-size: 1.15rem;
  font-weight: 800;
  color: #37474f;
  white-space: nowrap;
}
.soft-btn {
  border: none;
  background: rgba(255,255,255,.85);
  color: #37474f;
  font-size: 1.05rem;
  font-weight: 700;
  padding: 12px 18px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(0,0,0,.12);
}
.soft-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0,0,0,.12); }
.soft-btn.danger { color: #c62828; margin: 6px 0 24px; flex: 0 0 auto; }
.found-count {
  font-weight: 800;
  color: #fff;
  font-size: 1.2rem;
  text-shadow: 0 2px 0 rgba(0,0,0,.12);
  white-space: nowrap;
}

/* ---------- Spilleplade ---------- */
/* Pladen fylder hele det tilgængelige område. Kolonner/rækker sættes af JS
   (--cols / --rows) alt efter antal brikker og iPad-orientering, så alle
   brikker altid er synlige uden at scrolle. */
.board {
  display: grid;
  grid-template-columns: repeat(var(--cols, 4), 1fr);
  grid-template-rows: repeat(var(--rows, 4), 1fr);
  gap: clamp(6px, 1.2vmin, 14px);
  width: 100%;
  flex: 1;
  min-height: 0;
}
.cell {
  position: relative;
  min-width: 0;
  min-height: 0;
  background: #fff;
  border: none;
  border-radius: clamp(12px, 2.2vmin, 24px);
  padding: 4px 4px 2px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(0,0,0,.15);
  transition: transform .1s;
  overflow: hidden;
}
.cell:active { transform: scale(.94); }
.cell svg { width: 80%; height: auto; flex: 1; min-height: 0; }
.cell .cell-label {
  font-size: clamp(.75rem, 2vmin, 1.25rem);
  font-weight: 800;
  color: #455a64;
  padding-bottom: 4px;
  white-space: nowrap;
}
.cell.marked { background: #dcedc8; }
.cell .count-badge {
  position: absolute;
  top: clamp(4px, 1vmin, 10px);
  right: clamp(4px, 1vmin, 10px);
  background: #ff7043;
  color: #fff;
  font-size: clamp(1rem, 3vmin, 1.6rem);
  font-weight: 900;
  min-width: clamp(30px, 5.5vmin, 46px);
  height: clamp(30px, 5.5vmin, 46px);
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
  box-shadow: 0 3px 0 rgba(0,0,0,.18);
}
.cell .count-badge.pop { animation: pop .35s cubic-bezier(.2, 2.2, .4, 1); }
@keyframes pop {
  0% { transform: scale(0); }
  100% { transform: scale(1); }
}

/* ---------- Landscape (fx iPad på tværs): knapper i sidebar, pladen fylder højden ---------- */
@media (orientation: landscape) {
  #screen-game {
    flex-direction: row;
    justify-content: center;
    gap: clamp(10px, 3vw, 40px);
  }
  #screen-game .game-header {
    width: auto;
    height: 100%;
    flex-direction: column;
    justify-content: flex-start;
    gap: 14px;
    padding: 8px 4px;
  }
  #screen-game .game-title {
    writing-mode: initial;
    font-size: clamp(1.1rem, 2.6vmin, 1.6rem);
  }
  #screen-game .header-actions {
    flex-direction: column;
    gap: 14px;
  }
  .board {
    flex: 1;          /* fyld den resterende bredde ved siden af knapperne */
    height: 100%;
    width: auto;
  }
}

/* ---------- Bingo-banner ---------- */
.bingo-banner {
  position: fixed;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-6deg);
  font-size: clamp(3rem, 14vmin, 7rem);
  font-weight: 900;
  color: #ffd600;
  -webkit-text-stroke: 3px #e65100;
  text-shadow: 0 6px 0 rgba(0,0,0,.2);
  pointer-events: none;
  z-index: 60;
  animation: bingoPop 1.6s ease forwards;
}
@keyframes bingoPop {
  0% { transform: translate(-50%, -50%) rotate(-6deg) scale(0); opacity: 1; }
  20% { transform: translate(-50%, -50%) rotate(-6deg) scale(1.15); }
  30% { transform: translate(-50%, -50%) rotate(-6deg) scale(1); }
  80% { opacity: 1; }
  100% { transform: translate(-50%, -50%) rotate(-6deg) scale(1.05); opacity: 0; }
}

/* ---------- Fuld plade ---------- */
.win-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 70;
  padding: 20px;
}
.win-card {
  background: #fff;
  border-radius: 28px;
  padding: 30px 26px;
  text-align: center;
  max-width: 420px;
  box-shadow: 0 10px 0 rgba(0,0,0,.2);
  animation: pop .4s cubic-bezier(.2, 2, .4, 1);
}
.win-emoji { font-size: 4.5rem; }
.win-card h2 { color: #ef6c00; margin: 8px 0; font-size: 1.6rem; }
.win-card p { color: #607d8b; font-weight: 600; margin-bottom: 18px; }
.big-btn {
  border: none;
  background: #66bb6a;
  color: #fff;
  font-size: 1.3rem;
  font-weight: 800;
  padding: 16px 30px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 5px 0 #388e3c;
}
.big-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 #388e3c; }

/* ---------- Konfetti ---------- */
#confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 65; }
.confetti-piece {
  position: absolute;
  top: -20px;
  width: 12px;
  height: 12px;
  animation: fall linear forwards;
}
@keyframes fall {
  to { transform: translateY(110vh) rotate(720deg); }
}

/* ---------- Samlebog ---------- */
#screen-book { overflow-y: auto; justify-content: flex-start; }
#screen-book .game-header { max-width: 900px; }
.book-total { color: #fff; font-weight: 800; font-size: 1.15rem; text-shadow: 0 2px 0 rgba(0,0,0,.12); padding-bottom: 10px; text-align: center; }
.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(clamp(96px, 14vmin, 150px), 1fr));
  gap: 10px;
  width: 100%;
  max-width: 900px;
  overflow-y: auto;
  padding-bottom: 20px;
  -webkit-overflow-scrolling: touch;
}
.book-item {
  position: relative;
  background: #fff;
  border-radius: 18px;
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 6px 4px 2px;
  box-shadow: 0 3px 0 rgba(0,0,0,.12);
}
.book-item svg { width: 68%; flex: 1; min-height: 0; }
.book-item .cell-label { font-size: clamp(.7rem, 1.6vmin, 1rem); font-weight: 800; color: #455a64; padding-bottom: 4px; }
.book-item.unfound { opacity: .95; }
.book-item.unfound svg { filter: grayscale(1); opacity: .3; }
.book-item .count-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  background: #ff7043;
  color: #fff;
  font-size: .85rem;
  font-weight: 800;
  min-width: 26px;
  height: 26px;
  border-radius: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  box-shadow: 0 2px 0 rgba(0,0,0,.15);
}

/* ---------- Print ---------- */
.print-area { display: none; }

@media print {
  html, body { background: #fff; overflow: visible; height: auto; }
  .screen, .bingo-banner, .win-overlay, #confetti { display: none !important; }
  .print-area { display: block; }

  .print-page {
    page-break-after: always;
    padding: 10mm 6mm;
    text-align: center;
    font-family: -apple-system, "Segoe UI", system-ui, sans-serif;
  }
  .print-page:last-child { page-break-after: auto; }
  .print-page h2 { font-size: 26pt; margin-bottom: 2mm; }
  .print-page .print-sub { font-size: 12pt; color: #555; margin-bottom: 6mm; }
  .print-board {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4mm;
    width: 180mm;
    margin: 0 auto;
  }
  .print-cell {
    border: 1.2mm solid #37474f;
    border-radius: 6mm;
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3mm 2mm 2mm;
  }
  .print-cell svg { width: 70%; flex: 1; min-height: 0; }
  .print-cell .cell-label { font-size: 11pt; font-weight: 800; color: #37474f; }
}
