/* Thermix – Comic-Stil: dicke dunkle Konturen, Himmelblau, Sonnengelb, Orange. */
@font-face { font-family: "Fredoka"; src: url("../assets/fonts/fredoka-500.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Fredoka"; src: url("../assets/fonts/fredoka-700.woff2") format("woff2"); font-weight: 600 800; font-display: swap; }

:root {
  --kit-font: "Fredoka", ui-rounded, system-ui, sans-serif;
  --kit-ink: #2b2340;
  --kit-ink-soft: #5d5578;
  --kit-accent: #ff8c42;
  --kit-accent-ink: #2b2340;
  --kit-card: #fffaf0;
  --sun: #ffd23f;
  --sky: #5ec8f2;
  --text: #ffffff;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  background: linear-gradient(180deg, #5ec8f2, #bfeaff 55%, #8ed46b);
  color: var(--text); font-family: var(--kit-font); font-weight: 700;
  user-select: none; -webkit-user-select: none; touch-action: manipulation;
}
#stage { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#safe-b { position: fixed; bottom: 0; left: 0; width: 1px; height: var(--safe-b); visibility: hidden; pointer-events: none; }
#app { position: relative; height: 100%; pointer-events: none; }

.screen {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  padding: calc(var(--safe-t) + 10px) 12px calc(var(--safe-b) + 4px);
  opacity: 0; visibility: hidden; transform: translateY(18px) scale(.985);
  transition: opacity .3s ease, transform .45s cubic-bezier(.2, 1.3, .4, 1), visibility 0s .3s;
}
.screen.active { opacity: 1; visibility: visible; transform: none; transition-delay: 0s; }
.screen.active > * { pointer-events: auto; }
#screen-game.active > .tut { pointer-events: none; }

.tool:active { transform: translateY(3px); box-shadow: none; }

/* ---------- Footer (unten im Spiel, kompakt) ---------- */
.game-gap { flex: 1; min-height: 0; }
#screen-game.active > .game-gap { pointer-events: none; }
#screen-game footer { width: 100%; max-width: 560px; margin: 0 auto; background: rgba(255, 250, 240, .8); border-radius: 12px 12px 0 0; font-size: 12px; padding-top: 4px; padding-bottom: 4px; }
.kit-footer { color: var(--kit-ink); }
.kit-footer a, .kit-footer button { color: var(--kit-ink); }

/* ---------- Spiel ---------- */
.hud { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; width: 100%; max-width: 760px; margin: 0 auto; }
.hud-row { display: flex; align-items: center; gap: 6px; }
.hud-level { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.05; text-shadow: 0 2px 0 var(--kit-ink), 0 0 6px rgba(43,35,64,.6); }
.hud-level small { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; opacity: .95; }
.hud-level b { font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill {
  display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 58px; height: 46px; padding: 2px 8px;
  border-radius: 14px; background: var(--kit-card); color: var(--kit-ink); border: 2.5px solid var(--kit-ink); box-shadow: 0 3px 0 var(--kit-ink);
}
.pill small { font-size: 10px; text-transform: uppercase; letter-spacing: .3px; color: var(--kit-ink-soft); line-height: 1; }
.pill b { font-size: 20px; line-height: 1.1; font-variant-numeric: tabular-nums; }
#moves-pill.bump b, #moves.bump { animation: bump .35s cubic-bezier(.3, 1.8, .5, 1); display: inline-block; }
@keyframes bump { 40% { transform: scale(1.4); } }
.goal #goal { display: flex; align-items: baseline; gap: 3px; line-height: 1.1; white-space: nowrap; }
.goal-stars { color: #f29d00; font-size: 15px; letter-spacing: -1px; }
.goal-stars i { font-style: normal; color: rgba(43, 35, 64, .2); }
.goal #goal small { font-size: 13px; font-variant-numeric: tabular-nums; }
.tools { justify-content: center; flex-wrap: nowrap; }
.tool {
  flex: 1; max-width: 120px; min-width: 0; height: 46px; display: flex; align-items: center; justify-content: center; gap: 4px; padding: 0 6px;
  border-radius: 14px; border: 2.5px solid var(--kit-ink); background: var(--kit-card); color: var(--kit-ink); box-shadow: 0 3px 0 var(--kit-ink);
  font: 700 13px/1 var(--kit-font); cursor: pointer; position: relative;
}
.tool .ico { font-size: 17px; line-height: 1; flex-shrink: 0; }
#btn-extra { flex: 1.25; }
.tool span:not(.ico) { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tool em { position: absolute; top: -9px; right: -6px; font-style: normal; font-size: 11px; background: #e2553d; color: #fff; border: 2px solid var(--kit-ink); border-radius: 99px; padding: 1px 5px; }
.tool:disabled em { display: none; }
/* Gesperrt: Fläche bleibt deckend (sonst scheint der Himmel durch), nur Inhalt und Rand blass */
.tool:disabled { box-shadow: none; cursor: default; background: #e9e4dc; border-color: rgba(43, 35, 64, .35); color: rgba(43, 35, 64, .45); }
.tool:disabled .ico { opacity: .5; }
.tool.thinking .ico { animation: think .6s ease-in-out infinite alternate; }
@keyframes think { to { transform: scale(1.3) rotate(12deg); } }
.wind {
  height: 46px; min-width: 58px; display: flex; align-items: center; gap: 4px; padding: 0 8px; border-radius: 14px;
  background: #fff3d6; color: var(--kit-ink); border: 2.5px solid var(--kit-ink); box-shadow: 0 3px 0 var(--kit-ink); flex-shrink: 0;
}
.wind[hidden] { display: none; }
.wind b { font-size: 20px; }
.wind .sock { width: 26px; height: 14px; display: inline-block; transform-origin: left center; animation: sock 1.2s ease-in-out infinite alternate;
  background: repeating-linear-gradient(90deg, #e2553d 0 6px, #fff 6px 12px); border: 2px solid var(--kit-ink); border-radius: 2px 8px 8px 2px;
  clip-path: polygon(0 0, 100% 18%, 100% 82%, 0 100%); }
@keyframes sock { from { transform: rotate(4deg) scaleX(.9); } to { transform: rotate(-4deg) scaleX(1.05); } }
.wind.soon { background: #ffd23f; animation: soon .5s ease-in-out infinite alternate; }
@keyframes soon { to { transform: scale(1.08); } }

.tut {
  position: absolute; left: 50%; bottom: calc(var(--safe-b) + 14px); width: min(92%, 460px);
  display: flex; gap: 10px; align-items: center; padding: 12px 14px; border-radius: 18px;
  background: var(--kit-card); color: var(--kit-ink); border: var(--kit-line); box-shadow: 0 5px 0 var(--kit-ink);
  opacity: 0; transform: translate(-50%, 30px) scale(.9); transition: opacity .3s, transform .45s cubic-bezier(.3, 1.6, .5, 1);
}
.tut.show { opacity: 1; transform: translate(-50%, 0); }
.tut p { margin: 0; font-size: 15px; line-height: 1.35; font-weight: 600; }
.tut-icon { font-size: 28px; animation: float 2s ease-in-out infinite alternate; }
@keyframes float { to { transform: translateY(-5px) rotate(6deg); } }

/* ---------- Dialoge ---------- */
.win-card, .stuck-card { text-align: center; }
.win-card h2, .stuck-card h2 { font: 700 30px/1.1 var(--kit-font); color: var(--kit-accent); -webkit-text-stroke: 1.5px var(--kit-ink); paint-order: stroke fill; letter-spacing: .5px; margin: 0; }
.win-moves { margin: 0; font-size: 18px; }
.win-moves b { font-size: 28px; color: var(--kit-accent); -webkit-text-stroke: 2px var(--kit-ink); paint-order: stroke fill; }
.win-level { margin: 0; font-size: 14px; color: var(--kit-ink-soft); text-transform: uppercase; letter-spacing: .5px; }
.win-par, .win-best { margin: 0; font-size: 14px; color: var(--kit-ink-soft); }
.win-best:empty { display: none; }
.win-best { color: #1f9e5a; }
/* Große Sterne, die nacheinander hineinwirbeln */
.big-stars { display: flex; justify-content: center; gap: 10px; height: 64px; align-items: center; }
.big-stars i { font-style: normal; font-size: 52px; line-height: 1; color: rgba(43, 35, 64, .15); transform: scale(.4); opacity: .3; }
.big-stars i::before { content: "★"; }
.big-stars i.on { color: #ffc400; -webkit-text-stroke: 3px var(--kit-ink); paint-order: stroke fill; animation: starIn .5s cubic-bezier(.3, 1.8, .5, 1) forwards; }
.big-stars i.off { animation: starOff .3s ease forwards; }
.big-stars i:nth-child(2) { font-size: 62px; }
@keyframes starIn { from { transform: scale(2.2) rotate(-30deg); opacity: 0; } to { transform: scale(1) rotate(0); opacity: 1; } }
@keyframes starOff { to { transform: scale(.85); opacity: 1; } }
.stuck-card p { margin: 0 0 4px; font-weight: 500; }
/* Kurz warten, während ein neues endloses Level entsteht */
html.loading #btn-next { opacity: .7; }

/* Querformat mit wenig Höhe: HUD in einer Zeile */
@media (orientation: landscape) and (max-height: 520px) {
  .hud { grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); }
}
