/* release.css — Release-Schicht (v6): Vollbild-Layout, kompaktes HUD,
 * Auto-Fit-Brett, Toolbar mit Extra-Röhre, Level-Auswahl, Farbsymbole.
 * Wird als letztes Stylesheet geladen und überschreibt ältere Schichten. */

@font-face {
  font-family: 'Baloo 2';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url('../assets/fonts/baloo2.woff2') format('woff2');
}

html, body { height: 100%; overscroll-behavior: none; }
body {
  font-family: 'Baloo 2', 'Nunito', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* ---- App-Rahmen: exakt eine Bildschirmhöhe ---- */

#app {
  height: 100dvh;
  min-height: 0;
  max-width: 820px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding:
    max(8px, env(safe-area-inset-top))
    max(10px, env(safe-area-inset-right))
    max(10px, env(safe-area-inset-bottom))
    max(10px, env(safe-area-inset-left));
  gap: 10px;
}

/* ---- HUD ---- */

#topbar,
#topbar:is(*) {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto 44px;
  grid-template-rows: auto;
  align-items: center;
  gap: 8px;
  padding: 7px;
  width: 100%;
  border-radius: 20px;
  flex: 0 0 auto;
}

#topbar #btn-menu,
#topbar #btn-settings,
#topbar #lives-display,
#topbar #level-info { grid-row: 1; }
#topbar #btn-menu { grid-column: 1; }
#topbar #level-info { grid-column: 2; }
#topbar #lives-display { grid-column: 3; }
#topbar #btn-settings { grid-column: 4; }

#topbar .icon-btn {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  color: var(--text);
}

.ico { width: 22px; height: 22px; display: block; flex: 0 0 auto; }

#level-info {
  min-width: 0;
  text-align: center;
  line-height: 1.1;
}

#level-label {
  font-size: 1.12rem;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#level-sub {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 2px;
  font-size: .78rem;
  font-weight: 700;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

#par::before { content: '·'; margin-right: 6px; opacity: .6; }
#par[hidden] { display: none; }

#topbar #lives-display {
  height: 40px;
  padding: 4px 11px 4px 9px;
  gap: 6px;
  font-size: .9rem;
}

#lives-timer { min-width: 0; }
#lives-timer.full { display: none; }

/* ---- Spielfeld: füllt den Rest, Röhren skaliert per JS (fitBoard) ---- */

#game {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: stretch;
}

#board-wrap {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  display: flex;
}

#board,
#board:is(*) {
  flex: 1 1 auto;
  min-height: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  align-content: center;
  justify-content: center;
  align-items: flex-end;
  gap: var(--fit-gy, 26px) var(--fit-gx, 16px);
  padding: calc(12px + var(--fit-head, 14px)) var(--fit-pad-x, 12px) 12px;
  border-radius: 26px;
}

#board .bottle-wrap { --bottle-w: var(--fit-w, 54px); }

/* ---- Toolbar ---- */

#toolbar {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 0;
  margin: 0;
}

#toolbar .tb-btn {
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 6px;
  border-radius: 18px;
  font-size: .92rem;
  font-weight: 800;
  line-height: 1.05;
  white-space: nowrap;
  min-width: 0;
}

#toolbar .tb-btn span { overflow: hidden; text-overflow: ellipsis; }

#toolbar .tb-tube {
  position: relative;
  background: linear-gradient(180deg, #ffd978, var(--gold));
  color: #4d2c00;
  border-color: transparent;
  box-shadow: 0 4px 0 #b46a05, 0 10px 22px rgba(245, 158, 11, .28);
}

#toolbar .tb-tube:disabled {
  background: linear-gradient(180deg, var(--surface), var(--surface-2));
  color: var(--muted);
  box-shadow: 0 3px 0 color-mix(in srgb, var(--border) 76%, transparent);
  opacity: .6;
}

/* Kleines Play-Abzeichen, wenn die Belohnung ein Video kostet (App). */
.has-ad { position: relative; }
.has-ad::after {
  content: '▶\FE0E';
  position: absolute;
  top: -6px;
  right: -4px;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: 9px;
  line-height: 1;
  color: #fff;
  background: #e5484d;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .3);
}
.has-ad:disabled::after { display: none; }

@media (max-width: 360px) {
  #toolbar .tb-btn { font-size: .8rem; gap: 5px; }
  #toolbar .tb-btn .ico { width: 19px; height: 19px; }
  #topbar #lives-display { padding-inline: 8px; }
}

@media (max-height: 520px) and (orientation: landscape) {
  #app { gap: 6px; }
  #toolbar .tb-btn { min-height: 42px; }
  #topbar { padding: 4px 7px; }
}

/* ---- Modals über dem Startmenü ---- */

#modal-root { z-index: 9500; }
.modal { z-index: 9500; }
#toast { z-index: 9800; }
#confetti { z-index: 9400; }

.modal-card {
  max-height: calc(100dvh - 40px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.modal-actions { gap: 10px; }
.modal-actions .btn { min-height: 50px; border-radius: 16px; font-size: 1rem; }

.win-best {
  margin: 4px 0 0;
  font-weight: 800;
  color: var(--gold);
}

/* Lade-Hinweis während ein Video vorbereitet wird */
.ad-loading { text-align: center; padding: 8px 4px; }
.spinner {
  width: 40px;
  height: 40px;
  margin: 4px auto 12px;
  border-radius: 50%;
  border: 4px solid color-mix(in srgb, var(--primary) 22%, transparent);
  border-top-color: var(--primary);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Level-Auswahl ---- */

.modal-levels .modal-card { max-width: 520px; }

.level-picker {
  max-height: min(58dvh, 520px);
  overflow-x: hidden;
  overflow-y: auto;
  padding: 4px 2px 8px;
}

.level-picker .level-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(54px, 1fr));
  gap: 8px;
  max-height: none;
  overflow: visible;
  padding: 2px;
}

.level-picker .level-btn {
  position: relative;
  aspect-ratio: 1;
  min-height: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, var(--surface), var(--surface-2));
  font-weight: 800;
}

.level-picker .lvl-num { font-size: 1.05rem; line-height: 1; }
.level-picker .lvl-stars { font-size: .62rem; letter-spacing: 1px; color: var(--gold); line-height: 1; }
.level-picker .level-btn.completed {
  background: linear-gradient(180deg, var(--surface), var(--surface-2));
  border-color: color-mix(in srgb, var(--gold) 55%, var(--border));
  color: var(--text);
}
.level-picker .level-btn.current {
  background: linear-gradient(180deg, var(--primary-2), var(--primary));
  color: var(--primary-contrast, #fff);
  border-color: transparent;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 30%, transparent);
}
.level-picker .level-btn.current .lvl-stars { color: #ffe08a; }
.level-picker .level-btn.endless { font-size: 1.5rem; color: var(--primary); }
.level-picker .level-btn:disabled { opacity: .35; }

.level-picker .level-more {
  grid-column: 1 / -1;
  padding: 10px;
  text-align: center;
  color: var(--muted);
  font-weight: 700;
}

/* ---- Einstellungen ---- */

.settings-list .settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.settings-label { font-weight: 800; }
.settings-hint { font-size: .78rem; color: var(--muted); }

.segmented {
  display: flex;
  gap: 4px;
  padding: 3px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface-3) 80%, transparent);
  flex: 0 0 auto;
}
.segmented button {
  border: 0;
  background: transparent;
  padding: 6px 10px;
  border-radius: 9px;
  font-weight: 800;
  font-size: .85rem;
  color: var(--muted);
  min-width: 42px;
}
.segmented button.active {
  background: linear-gradient(180deg, var(--primary-2), var(--primary));
  color: #fff;
  box-shadow: 0 2px 8px color-mix(in srgb, var(--primary) 40%, transparent);
}

.settings-links { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; }
.settings-version { margin: 6px 0 0; text-align: center; font-size: .75rem; color: var(--muted); }

/* ---- Farbsymbole (Barrierefreiheit) ---- */

.cb-symbols .liquid .layer { position: relative; }
.cb-symbols .liquid .layer[data-color]::after {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: calc(var(--bottle-w, 54px) * .34);
  line-height: 1;
  color: rgba(255, 255, 255, .92);
  text-shadow: 0 1px 2px rgba(0, 0, 0, .55);
  font-family: system-ui, sans-serif;
  pointer-events: none;
}
.cb-symbols .layer[data-color='1']::after { content: '●'; }
.cb-symbols .layer[data-color='2']::after { content: '▲'; }
.cb-symbols .layer[data-color='3']::after { content: '■'; }
.cb-symbols .layer[data-color='4']::after { content: '◆'; color: rgba(60, 40, 0, .85); text-shadow: none; }
.cb-symbols .layer[data-color='5']::after { content: '▼'; }
.cb-symbols .layer[data-color='6']::after { content: '✚'; }
.cb-symbols .layer[data-color='7']::after { content: '◀\FE0E'; }
.cb-symbols .layer[data-color='8']::after { content: '✕'; }
.cb-symbols .layer[data-color='9']::after { content: '○'; }
.cb-symbols .layer[data-color='10']::after { content: '▶\FE0E'; }
.cb-symbols .layer[data-color='11']::after { content: '□'; }
.cb-symbols .layer[data-color='12']::after { content: '△'; }

/* ---- Startmenü: Floater-Emojis entfernt, Karte scrollbar auf kleinen Geräten ---- */

#mixlab-menu .menu-card { max-height: calc(100dvh - 32px); overflow-y: auto; }
#mixlab-menu .menu-btn.primary {
  background: linear-gradient(180deg, var(--primary-2), var(--primary));
  color: #fff;
  border-color: transparent;
  margin-top: 12px;
  width: 100%;
}
#mixlab-menu .howto-list li { margin-bottom: 6px; }

/* Toolbar-Reihenfolge fest (ältere Schichten setzen grid-column auf #btn-levels) */
#toolbar > #btn-restart { grid-column: 1; grid-row: 1; }
#toolbar > #btn-tube { grid-column: 2; grid-row: 1; }
#toolbar > #btn-levels { grid-column: 3; grid-row: 1; }

#toolbar,
#app > #toolbar {
  width: min(100%, 520px);
  align-self: center;
  padding: 6px;
  margin: 0 auto;
}

#toolbar > #btn-restart.tb-btn,
#toolbar > #btn-levels.tb-btn {
  color: var(--text);
  text-shadow: none;
  background: linear-gradient(160deg,
    color-mix(in srgb, var(--surface-2) 84%, white 16%),
    color-mix(in srgb, var(--surface-3) 82%, var(--primary) 18%));
  box-shadow:
    inset 0 1px 0 color-mix(in srgb, var(--ui-highlight) 74%, transparent),
    0 3px 0 color-mix(in srgb, var(--border) 88%, transparent);
}
