/* Kimsa – Das Rätsel des Sonnentempels. Inka-Stil: Basalt, Gold, Türkis, Nachthimmel über den Anden. */
@font-face {
  font-family: "Cinzel";
  font-weight: 700;
  font-display: swap;
  src: url("assets/fonts/cinzel-latin-700-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Cinzel";
  font-weight: 900;
  font-display: swap;
  src: url("assets/fonts/cinzel-latin-900-normal.woff2") format("woff2");
}
/* Cinzels „1“ sieht aus wie ein römisches I – Ziffern kommen deshalb aus Playfair Display. */
@font-face {
  font-family: "Kimsa Digits";
  font-weight: 700 900;
  font-display: swap;
  src: url("assets/fonts/playfair-display-latin-900-normal.woff2") format("woff2");
  unicode-range: U+0030-0039, U+002E, U+002C;
}
@font-face {
  font-family: "Cinzel Decorative";
  font-weight: 900;
  font-display: swap;
  src: url("assets/fonts/cinzel-decorative-latin-900-normal.woff2") format("woff2");
}

:root {
  --sky-top: #1A4148;
  --sky-mid: #0F272B;
  --sky-bottom: #071214;
  --basalt: #0B1A1D;
  --plate-top: rgba(24, 50, 54, .94);
  --plate-bottom: rgba(9, 22, 25, .96);
  --gold: #E8B54A;
  --gold-light: #FFE3A0;
  --gold-deep: #B98326;
  --bronze: #8A5A12;
  --turquoise: #2CC4C0;
  --terracotta: #C4532F;
  --text: #F6EBD3;
  --muted: #C8B48C;
  --radius: 12px;
  --display: "Kimsa Digits", "Cinzel", "Trajan Pro", Georgia, "Times New Roman", serif;
  --deco: "Cinzel Decorative", "Cinzel", Georgia, serif;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --fret: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 width=%2236%22 height=%2212%22 viewBox=%220 0 36 12%22%3E%3Cpath fill=%22none%22 stroke=%22%23E8B54A%22 stroke-width=%221.6%22 d=%22M0 10.5h5v-3h4v-3h4v-3h10v3h4v3h4v3h5%22/%3E%3Crect x=%2216%22 y=%226%22 width=%224%22 height=%224%22 fill=%22%23E8B54A%22/%3E%3C/svg%3E");
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  font-family: var(--font);
  color: var(--text);
  background: linear-gradient(180deg, var(--sky-top) 0%, var(--sky-mid) 55%, var(--sky-bottom) 100%);
  background-color: var(--sky-bottom);
  font-variant-numeric: lining-nums;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

/* ---------- Kulisse: Sternenhimmel, Sonnenschein, Anden ---------- */
/* Gemalte Kulisse (tools/paint-background.py): Anden vor Sonnenaufgang, Tempel mit Fackeln */
.sky {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: #071116 url("assets/bg-portrait.webp") center bottom / cover no-repeat;
  transition: filter .6s ease;
}
@media (orientation: landscape) {
  .sky { background-image: url("assets/bg-landscape.webp"); }
}
/* funkelnde Sterne über dem gemalten Himmel */
.sky::after {
  content: "";
  position: absolute;
  inset: 0 0 45% 0;
  background: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 width=%22240%22 height=%22240%22%3E%3Cg fill=%22%23FFF4D6%22%3E%0A%3Ccircle cx=%2218%22 cy=%2230%22 r=%221.1%22 opacity=%22.8%22/%3E%3Ccircle cx=%2292%22 cy=%2212%22 r=%22.8%22 opacity=%22.6%22/%3E%3Ccircle cx=%22150%22 cy=%2258%22 r=%221.3%22 opacity=%22.9%22/%3E%0A%3Ccircle cx=%22210%22 cy=%2224%22 r=%22.7%22 opacity=%22.5%22/%3E%3Ccircle cx=%2260%22 cy=%2296%22 r=%22.9%22 opacity=%22.7%22/%3E%3Ccircle cx=%22196%22 cy=%22120%22 r=%221%22 opacity=%22.6%22/%3E%0A%3Ccircle cx=%22120%22 cy=%22150%22 r=%22.7%22 opacity=%22.5%22/%3E%3Ccircle cx=%2234%22 cy=%22186%22 r=%221.2%22 opacity=%22.8%22/%3E%3Ccircle cx=%22168%22 cy=%22204%22 r=%22.8%22 opacity=%22.6%22/%3E%0A%3Ccircle cx=%22230%22 cy=%22176%22 r=%22.6%22 opacity=%22.4%22/%3E%3Ccircle cx=%2296%22 cy=%22222%22 r=%22.9%22 opacity=%22.6%22/%3E%3C/g%3E%3C/svg%3E") 0 0 / 240px 240px repeat;
  -webkit-mask-image: linear-gradient(180deg, #000 0%, transparent 100%);
  mask-image: linear-gradient(180deg, #000 0%, transparent 100%);
  animation: twinkle 5s ease-in-out infinite alternate;
}
/* Im Spiel tritt die Kulisse zurück */
body:has(#game:not([hidden])) .sky { filter: brightness(.55) saturate(.85); }

/* Ziehende Nebelbänke vor den Bergen */
.mist {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 14%;
  height: 34vh;
  pointer-events: none;
  overflow: hidden;
  opacity: .55;
  transition: opacity .6s ease;
}
/* Nahtlos: Kachel 1200 px breit, Ebene um genau eine Kachel verschoben (nur transform → GPU) */
.mist::before, .mist::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: calc(100% + 1200px);
  background: url("assets/fog.webp") 0 50% / 1200px 100% repeat-x;
  animation: drift 150s linear infinite;
  will-change: transform;
}
.mist::after {
  top: 35%;
  opacity: .55;
  background-position: 600px 50%;
  animation-duration: 95s;
}
body:has(#game:not([hidden])) .mist { opacity: .25; }

#app {
  position: fixed;
  inset: 0;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

.screen {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: calc(8px + var(--safe-t)) calc(10px + var(--safe-r)) calc(8px + var(--safe-b)) calc(10px + var(--safe-l));
}

button {
  font: inherit;
  color: inherit;
  border: 0;
  background: none;
  cursor: pointer;
  touch-action: manipulation;
}
button:focus { outline: none; }
button:focus-visible {
  outline: 2px solid var(--gold-light);
  outline-offset: 3px;
}
canvas { display: block; }

/* Tempelplatte: gemeinsamer Look für HUD, Leisten, Dialoge */
.plate, .hud-moves, .hud-time, .goals, .game-bar, .coach, .panel {
  background: url("assets/stone.webp") 0 0 / 256px 256px, linear-gradient(180deg, var(--plate-top), var(--plate-bottom));
  background-blend-mode: overlay, normal;
  border: 1.5px solid rgba(232, 181, 74, .6);
  border-radius: var(--radius);
  box-shadow:
    inset 0 0 0 2px rgba(0, 0, 0, .35),
    inset 0 1px 0 3px rgba(255, 227, 160, .06),
    0 8px 22px rgba(0, 0, 0, .4);
}

/* ---------- Buttons ---------- */
.btn {
  --cut: 10px;
  min-height: 50px;
  padding: 10px 24px;
  font-family: var(--display);
  font-weight: 900;
  font-size: 1.02rem;
  letter-spacing: .06em;
  color: var(--gold-light);
  border: 1.5px solid rgba(232, 181, 74, .7);
  border-radius: 10px;
  background: url("assets/stone.webp") 0 0 / 256px 256px, linear-gradient(180deg, rgba(36, 70, 75, .95), rgba(14, 32, 36, .95));
  background-blend-mode: overlay, normal;
  box-shadow: inset 0 1px 0 rgba(255, 227, 160, .15), inset 0 -3px 0 rgba(0, 0, 0, .35), 0 4px 10px rgba(0, 0, 0, .3);
  transition: transform .08s ease, filter .15s ease;
}
.btn:active { transform: translateY(2px) scale(.985); filter: brightness(.92); }
.btn.primary {
  border: 0;
  border-radius: 0;
  clip-path: polygon(var(--cut) 0, calc(100% - var(--cut)) 0, 100% var(--cut), 100% calc(100% - var(--cut)), calc(100% - var(--cut)) 100%, var(--cut) 100%, 0 calc(100% - var(--cut)), 0 var(--cut));
  color: #2A1802;
  text-shadow: 0 1px 0 rgba(255, 240, 200, .6);
  background: linear-gradient(180deg, #FFEDB8 0%, var(--gold) 45%, var(--gold-deep) 100%);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, .55),
    inset 0 -4px 0 var(--bronze),
    inset 0 0 0 1.5px rgba(90, 55, 6, .6);
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, .45));
}
.btn.primary:active { filter: drop-shadow(0 2px 4px rgba(0, 0, 0, .45)) brightness(.95); }
.btn.big {
  --cut: 14px;
  min-height: 60px;
  padding: 12px 38px;
  font-size: 1.2rem;
}

.icon-btn {
  width: 48px;
  height: 48px;
  flex: none;
  display: grid;
  place-items: center;
  clip-path: polygon(8px 0, calc(100% - 8px) 0, 100% 8px, 100% calc(100% - 8px), calc(100% - 8px) 100%, 8px 100%, 0 calc(100% - 8px), 0 8px);
  background: linear-gradient(180deg, #FFEDB8, var(--gold) 50%, var(--gold-deep));
  box-shadow: inset 0 -3px 0 var(--bronze), inset 0 2px 0 rgba(255, 255, 255, .5);
}
.icon-btn svg { width: 22px; height: 22px; fill: #2A1802; }
.icon-btn:active { transform: scale(.94); }

.toggle {
  min-height: 44px;
  padding: 8px 18px;
  border-radius: 999px;
  font-family: var(--display);
  font-weight: 700;
  font-size: .9rem;
  letter-spacing: .05em;
  color: var(--muted);
  background: rgba(8, 20, 23, .7);
  box-shadow: inset 0 0 0 1.5px rgba(232, 181, 74, .35);
}
.toggle span {
  margin-left: 6px;
  color: var(--gold-light);
}
.toggle[aria-pressed="false"] span { color: rgba(200, 180, 140, .55); }

/* ---------- Startseite ---------- */
.home {
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}
.home-inner {
  width: 100%;
  max-width: 460px;
  margin: auto;
  padding: 12px 4px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 12px;
}
.logo-stones {
  position: relative;
  width: 150px;
  height: 150px;
  display: grid;
  place-items: center;
  margin-bottom: -6px;
}
.logo-stones::before {
  content: "";
  position: absolute;
  inset: -40px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 210, 110, .45) 0%, rgba(255, 190, 80, .12) 45%, rgba(255, 190, 80, 0) 70%);
  animation: glow 4s ease-in-out infinite;
}
.logo-sun {
  position: relative;
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, .5));
  animation: spin 90s linear infinite;
}
.home h1 {
  margin: 0;
  font-family: var(--deco);
  font-weight: 900;
  font-size: clamp(3rem, 15vw, 4.4rem);
  letter-spacing: .06em;
  line-height: 1;
  color: var(--gold);
  background: linear-gradient(180deg, #FFF3CF 0%, #FFE3A0 35%, var(--gold) 60%, #A8701A 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 3px 0 #3A2405) drop-shadow(0 8px 16px rgba(0, 0, 0, .55));
}
.subtitle {
  margin: -2px 0 0;
  font-family: var(--display);
  font-weight: 700;
  font-size: .95rem;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--turquoise);
}
.fret {
  width: min(260px, 70%);
  height: 12px;
  background: var(--fret) center / 36px 12px repeat-x;
  opacity: .8;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 20%, #000 80%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 20%, #000 80%, transparent);
}
.tagline {
  margin: 0 0 8px;
  max-width: 30ch;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.45;
}
.section-title {
  margin: 16px 0 2px;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  font-family: var(--display);
  font-size: .82rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .3em;
  color: var(--gold);
}
.section-title::before, .section-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(232, 181, 74, .6));
}
.section-title::after { transform: scaleX(-1); }
.levels {
  list-style: none;
  margin: 0;
  padding: 0;
  width: 100%;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}
.level-btn {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  min-height: 66px;
  border-radius: 10px;
  background: url("assets/stone.webp") 0 0 / 256px 256px, linear-gradient(180deg, #23464B, #102629);
  background-blend-mode: overlay, normal;
  box-shadow:
    inset 0 0 0 1.5px rgba(232, 181, 74, .55),
    inset 0 2px 0 rgba(255, 227, 160, .12),
    0 4px 0 #061012,
    0 8px 14px rgba(0, 0, 0, .4);
  display: grid;
  grid-template-areas: "stone" "stars";
  grid-template-rows: auto auto;
  place-items: center;
  align-content: center;
  gap: 4px;
  padding: 6px 2px;
  transition: transform .08s ease;
}
.level-btn:not(:disabled):active { transform: translateY(3px); box-shadow: inset 0 0 0 1.5px rgba(232, 181, 74, .55), 0 1px 0 #061012; }
.level-stone {
  grid-area: stone;
  width: min(54px, 72%) !important;
  height: auto !important;
  aspect-ratio: 1;
}
.level-num {
  grid-area: stone;
  z-index: 1;
  font-family: var(--display);
  font-weight: 900;
  font-size: 1.12rem;
  color: #FFF8E6;
  text-shadow: 0 0 3px #000, 0 1px 2px #000, 0 0 8px rgba(0, 0, 0, .7);
}
.level-stars {
  grid-area: stars;
  font-size: .78rem;
  letter-spacing: .06em;
  color: var(--gold);
  min-height: 1em;
}
.level-btn:disabled {
  cursor: default;
  background: linear-gradient(180deg, #172A2D, #0B1A1C);
  box-shadow: inset 0 0 0 1.5px rgba(200, 180, 140, .18), 0 4px 0 #061012;
}
.level-btn:disabled .level-stone { opacity: .22; filter: grayscale(1); }
.level-btn:disabled .level-num { opacity: .0; }
.level-btn:disabled::after {
  content: "";
  grid-area: stone;
  width: 22px;
  height: 22px;
  background: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 24 24%22%3E%3Cpath fill=%22none%22 stroke=%22%23C8B48C%22 stroke-width=%222.2%22 d=%22M8 11V8a4 4 0 0 1 8 0v3%22/%3E%3Crect x=%225.5%22 y=%2211%22 width=%2213%22 height=%229%22 rx=%222%22 fill=%22%23C8B48C%22/%3E%3C/svg%3E") center / contain no-repeat;
  opacity: .7;
}
.settings {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 12px;
}

/* ---------- Spiel ---------- */
.game { gap: 8px; }

.hud {
  flex: none;
  display: flex;
  align-items: stretch;
  gap: 8px;
}
.hud-moves, .hud-time {
  flex: none;
  min-width: 78px;
  padding: 6px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.moves-num, .hud-time span {
  font-family: var(--display);
  font-size: 2.1rem;
  font-weight: 900;
  font-variant-numeric: lining-nums tabular-nums;
  color: var(--gold-light);
  text-shadow: 0 2px 0 rgba(0, 0, 0, .5);
}
.moves-label, .hud-time small {
  margin-top: 4px;
  font-family: var(--display);
  font-size: .68rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .16em;
}
.hud-moves.low { border-color: rgba(230, 110, 80, .9); }
.hud-moves.low .moves-num {
  color: #FF9B7A;
  animation: pulse 1s ease-in-out infinite;
}

.goals {
  flex: 1;
  min-width: 0;
  list-style: none;
  margin: 0;
  padding: 6px 8px;
  display: flex;
  align-items: center;
  justify-content: space-evenly;
  gap: 6px;
}
.goal {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-width: 44px;
}
.goal canvas { width: 32px; height: 32px; filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .5)); }
.goal-num {
  font-family: var(--display);
  font-size: .98rem;
  font-weight: 900;
  font-variant-numeric: lining-nums tabular-nums;
  color: var(--text);
}
.goal-check {
  position: absolute;
  right: -3px;
  bottom: 17px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #B9FFF8, var(--turquoise) 50%, #0E6E72);
  color: #fff;
  display: none;
  place-items: center;
  box-shadow: 0 0 0 2px #0B1A1D, 0 0 0 3px var(--gold);
}
.goal-check svg { width: 13px; height: 13px; }
.goal.done .goal-check {
  display: grid;
  animation: pop .35s cubic-bezier(.2, 1.6, .4, 1);
}
.goal.done .goal-num { color: var(--muted); }

.stage {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
#board {
  position: absolute;
  top: 0;
  left: 0;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.coach {
  flex: none;
  margin: 0 auto;
  max-width: 440px;
  padding: 10px 16px;
  font-weight: 600;
  font-size: .96rem;
  line-height: 1.4;
  text-align: center;
  color: var(--text);
  border-color: rgba(44, 196, 192, .65);
  pointer-events: none;
  animation: coachIn .3s ease-out;
}

.toast {
  position: absolute;
  left: 50%;
  top: 38%;
  transform: translate(-50%, -50%) scale(.6);
  padding: 12px 26px;
  clip-path: polygon(12px 0, calc(100% - 12px) 0, 100% 50%, calc(100% - 12px) 100%, 12px 100%, 0 50%);
  background: linear-gradient(180deg, #FFEDB8, var(--gold) 50%, var(--gold-deep));
  color: #2A1802;
  font-family: var(--display);
  font-weight: 900;
  font-size: 1.15rem;
  letter-spacing: .04em;
  white-space: nowrap;
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, .5));
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease, transform .25s cubic-bezier(.2, 1.5, .4, 1);
}
.toast.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.game-bar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
}
.score-block {
  flex: 1;
  min-width: 0;
}
.score-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.level-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--display);
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .05em;
  color: var(--muted);
}
.score-num {
  font-family: var(--display);
  font-size: 1.3rem;
  font-weight: 900;
  font-variant-numeric: lining-nums tabular-nums;
  color: var(--gold-light);
  display: inline-block;
}
.score-num.bump { animation: bump .22s ease-out; }

.star-bar {
  position: relative;
  height: 12px;
  border-radius: 3px;
  background: #061113;
  box-shadow: inset 0 0 0 1px rgba(232, 181, 74, .45), inset 0 2px 3px rgba(0, 0, 0, .6);
  margin-right: 9px;
}
.star-bar i {
  position: absolute;
  inset: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--terracotta), var(--gold) 70%, var(--gold-light));
  box-shadow: 0 0 8px rgba(232, 181, 74, .5);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform .35s ease-out;
}
.star-mark {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: 19px;
  line-height: 1;
  color: #2E4447;
  text-shadow: 0 0 0 #000, 0 1px 1px rgba(0, 0, 0, .8);
  transition: color .2s ease;
}
.star-mark.reached {
  color: var(--gold-light);
  text-shadow: 0 0 6px rgba(255, 210, 110, .9), 0 1px 0 var(--bronze);
  animation: markPop .35s cubic-bezier(.2, 1.6, .4, 1);
}

/* Querformat / Tablet: HUD als Seitenleiste */
body.wide .game {
  display: grid;
  grid-template-columns: minmax(170px, 230px) 1fr;
  grid-template-rows: auto 1fr auto;
  grid-template-areas: "hud stage" "coach stage" "bar stage";
  column-gap: 12px;
}
body.wide .hud {
  grid-area: hud;
  flex-direction: column;
}
body.wide .goals {
  flex-wrap: wrap;
  padding: 10px;
}
body.wide .hud-moves, body.wide .hud-time { padding: 10px; }
body.wide .stage { grid-area: stage; }
body.wide .game-bar { grid-area: bar; }
body.wide .coach {
  grid-area: coach;
  align-self: center;
  margin: 0;
  font-size: .9rem;
}

/* ---------- Dialoge ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: calc(16px + var(--safe-t)) calc(16px + var(--safe-r)) calc(16px + var(--safe-b)) calc(16px + var(--safe-l));
  background: rgba(3, 9, 10, 0);
  transition: background-color .2s ease;
}
.overlay.open {
  background: radial-gradient(ellipse at 50% 40%, rgba(10, 30, 33, .55), rgba(2, 6, 7, .85));
}
.panel {
  position: relative;
  width: 100%;
  max-width: 360px;
  max-height: 100%;
  overflow-y: auto;
  padding: 30px 20px 22px;
  border-width: 2px;
  border-color: var(--gold);
  border-radius: 14px;
  box-shadow:
    inset 0 0 0 4px rgba(6, 16, 18, .9),
    inset 0 0 0 5px rgba(232, 181, 74, .45),
    0 0 40px rgba(255, 196, 92, .12),
    0 24px 60px rgba(0, 0, 0, .6);
  text-align: center;
  transform: translateY(16px) scale(.94);
  opacity: 0;
  transition: transform .26s cubic-bezier(.2, 1.3, .4, 1), opacity .18s ease;
}
.panel::before, .panel::after {
  content: "";
  position: absolute;
  left: 18px;
  right: 18px;
  height: 12px;
  background: var(--fret) center / 36px 12px repeat-x;
  opacity: .7;
}
.panel::before { top: 10px; }
.panel::after { bottom: 8px; transform: scaleY(-1); opacity: .45; }
.overlay.open .panel {
  transform: none;
  opacity: 1;
}
.panel h2 {
  margin: 8px 0 8px;
  font-family: var(--display);
  font-size: 1.45rem;
  font-weight: 900;
  letter-spacing: .03em;
  line-height: 1.2;
  color: var(--gold-light);
  text-shadow: 0 2px 0 rgba(0, 0, 0, .5);
}
.panel p {
  margin: 0 0 12px;
  color: var(--muted);
  line-height: 1.45;
}
.panel-stars {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 6px;
  margin: 4px 0 2px;
}
.pstar {
  font-size: 44px;
  line-height: 1;
  color: #213538;
  text-shadow: 0 2px 0 rgba(0, 0, 0, .6);
}
.pstar:nth-child(2) { font-size: 58px; }
.pstar.on {
  color: var(--gold);
  background: linear-gradient(180deg, #FFF3CF, var(--gold) 55%, #A8701A);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 3px 0 #4A2E05) drop-shadow(0 0 10px rgba(255, 200, 90, .55));
  text-shadow: none;
  animation: starIn .45s cubic-bezier(.2, 1.6, .4, 1) both;
}
.panel-goals {
  list-style: none;
  margin: 6px 0 16px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
}
.panel-goals li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(0, 0, 0, .28);
  box-shadow: inset 0 0 0 1px rgba(232, 181, 74, .22);
  font-weight: 600;
}
.panel-goals canvas { flex: none; filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .5)); }
.panel-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
  margin-bottom: 8px;
}
.panel-actions .btn { width: 100%; }


/* ---------- Startseite: Rangliste & Profil ---------- */
.home-actions {
  display: flex;
  gap: 10px;
  width: 100%;
  max-width: 340px;
}
.home-actions .btn {
  flex: 1;
  min-width: 0;
  min-height: 46px;
  padding: 8px 12px;
  font-size: .9rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.home-actions svg { width: 18px; height: 18px; flex: none; fill: var(--gold); }
.profile-btn span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.profile-btn.is-online svg { fill: var(--turquoise); }
.level-timed {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 15px;
  height: 15px;
  background: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 24 24%22%3E%3Cpath fill=%22%23FFE3A0%22 d=%22M6 2h12v2h-1v3.2a5 5 0 0 1-2.1 4.1L13.6 12l1.3.7A5 5 0 0 1 17 16.8V20h1v2H6v-2h1v-3.2a5 5 0 0 1 2.1-4.1l1.3-.7-1.3-.7A5 5 0 0 1 7 7.2V4H6zm3 2v3.2c0 .9.5 1.8 1.3 2.3L12 10.6l1.7-1.1c.8-.5 1.3-1.4 1.3-2.3V4zm3 9.4-1.7 1.1c-.8.5-1.3 1.4-1.3 2.3V20h6v-3.2c0-.9-.5-1.8-1.3-2.3z%22/%3E%3Cpath fill=%22%23E8B54A%22 d=%22M9.5 19h5l-2.5-3z%22/%3E%3C/svg%3E") center / contain no-repeat;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .7));
}
.level-btn:disabled .level-timed { opacity: .35; }

/* ---------- Sonnenuhr (Zeitlevel) ---------- */
.hud-time { --p: 1; --ring: var(--gold); gap: 3px; order: -1; }
.time-ring {
  position: relative;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: radial-gradient(circle, rgba(0, 0, 0, .35) 0 58%, transparent 59%);
}
.time-ring::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(var(--ring) calc(var(--p) * 360deg), rgba(255, 255, 255, .08) 0);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 5px), #000 calc(100% - 4.5px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 5px), #000 calc(100% - 4.5px));
  filter: drop-shadow(0 0 3px rgba(232, 181, 74, .5));
}
.time-ring span {
  position: relative;
  font-family: var(--display);
  font-weight: 900;
  font-size: 1.3rem;
  font-variant-numeric: lining-nums tabular-nums;
  color: var(--gold-light);
  text-shadow: 0 2px 0 rgba(0, 0, 0, .5);
}
.hud-time small { margin-top: 0; }
.hud-time.warn { --ring: #F0A03A; border-color: rgba(240, 160, 58, .9); }
.hud-time.warn .time-ring span { color: #FFD08A; }
.hud-time.critical, .hud-time.over { --ring: #E5533A; border-color: rgba(229, 83, 58, .95); }
.hud-time.critical .time-ring span, .hud-time.over .time-ring span { color: #FF9B7A; }
.hud-time.critical .time-ring { animation: beat .5s ease-in-out infinite; }
.hud-time.critical { box-shadow: inset 0 0 0 2px rgba(0, 0, 0, .35), 0 0 18px rgba(229, 83, 58, .45), 0 8px 22px rgba(0, 0, 0, .4); }

/* Pause im Zeitlevel: Brett verhüllt */
#board { transition: filter .25s ease, opacity .25s ease; }
.stage.veiled #board { filter: blur(14px) saturate(.4); opacity: .5; }

/* Rand des Bildschirms glüht bei Zeitnot */
.danger {
  position: fixed;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  opacity: 0;
  transition: opacity .4s ease;
  background: radial-gradient(ellipse 75% 70% at center, transparent 55%, rgba(229, 83, 58, .42) 100%);
}
.stage.warn .danger {
  opacity: .6;
  background: radial-gradient(ellipse 75% 70% at center, transparent 62%, rgba(240, 160, 58, .3) 100%);
}
.stage.critical .danger {
  opacity: 1;
  animation: dangerPulse .5s ease-in-out infinite alternate;
}

/* ---------- Formulare in Dialogen ---------- */
.panel-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 4px 0 6px;
  text-align: left;
}
.field { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 0; }
.field-label {
  font-family: var(--display);
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--gold);
}
.field-input {
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1.5px solid rgba(232, 181, 74, .55);
  background: rgba(0, 0, 0, .35);
  color: var(--text);
  font: 600 1.05rem var(--font);
  user-select: text;
  -webkit-user-select: text;
}
.field-input:focus { outline: none; border-color: var(--gold-light); box-shadow: 0 0 0 3px rgba(232, 181, 74, .25); }
.field-row { display: flex; gap: 8px; align-items: flex-end; }
.field-row .btn { min-height: 48px; padding: 8px 14px; font-size: .9rem; }
.fineprint { margin: 0 !important; font-size: .8rem; line-height: 1.45; color: var(--muted); }
.form-error { margin: 0 !important; min-height: 1.2em; font-size: .88rem; color: #FF9B7A !important; }
.wide-toggle { width: 100%; display: flex; justify-content: space-between; border-radius: 10px; }
.btn.danger { color: #FFB49C; border-color: rgba(229, 83, 58, .65); background: rgba(60, 12, 6, .45); font-size: .85rem; }
.panel.busy .panel-actions { opacity: .5; pointer-events: none; }

.win-online {
  margin: -4px 0 6px;
  font-size: .9rem;
  font-weight: 600;
  color: var(--muted);
}
.win-online.good { color: var(--turquoise); }
.win-online.bad { color: #FF9B7A; }

/* ---------- Rangliste ---------- */
.panel-board { max-width: 400px; }
.board { margin: 0 0 4px; }
.board-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.board-title {
  font-family: var(--display);
  font-weight: 900;
  letter-spacing: .08em;
  color: var(--gold);
}
.icon-btn.small {
  width: 40px;
  height: 40px;
  font: 900 1.5rem/1 var(--display);
  color: #2A1802;
}
.icon-btn.small:disabled { opacity: .3; }
.board-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: min(46vh, 420px);
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
}
.board-row {
  display: grid;
  grid-template-columns: 2.2em minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 8px;
  background: rgba(0, 0, 0, .25);
  text-align: left;
}
.board-row.me { background: rgba(44, 196, 192, .16); box-shadow: inset 0 0 0 1.5px rgba(44, 196, 192, .6); }
.b-rank {
  font-family: var(--display);
  font-weight: 900;
  text-align: center;
  color: var(--muted);
}
.top1 .b-rank, .top2 .b-rank, .top3 .b-rank {
  width: 1.9em;
  height: 1.9em;
  line-height: 1.9em;
  border-radius: 50%;
  color: #2A1802;
  background: radial-gradient(circle at 35% 30%, #FFF3CF, var(--gold) 55%, #A8701A);
}
.top2 .b-rank { background: radial-gradient(circle at 35% 30%, #FFFFFF, #C9D1D3 55%, #7D8A8E); }
.top3 .b-rank { background: radial-gradient(circle at 35% 30%, #FFD9B8, #C47A3F 55%, #7A4520); }
.b-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.b-stars { color: var(--gold); font-size: .8rem; letter-spacing: .04em; }
.b-score {
  font-family: var(--display);
  font-weight: 900;
  font-variant-numeric: lining-nums tabular-nums;
  color: var(--gold-light);
}
.board-msg, .board-gap { padding: 14px 6px; color: var(--muted); text-align: center; }
.board-gap { padding: 0; line-height: 1; }
.board-foot { margin: 8px 0 0 !important; font-size: .8rem; }

@keyframes beat {
  0%, 100% { transform: scale(1); }
  30% { transform: scale(1.12); }
  60% { transform: scale(.98); }
}
@keyframes dangerPulse {
  from { opacity: .55; }
  to { opacity: 1; }
}


/* ---------- Teilen ---------- */
.btn-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.btn-pair .btn { padding-left: 10px; padding-right: 10px; font-size: .92rem; }
.btn svg {
  width: 17px;
  height: 17px;
  margin-right: 7px;
  vertical-align: -3px;
  fill: currentColor;
}
.duel {
  margin: -2px 0 8px;
  padding: 8px 12px;
  border-radius: 10px;
  font-weight: 700;
  font-size: .92rem;
}
.duel.won { color: #1B1203; background: linear-gradient(180deg, #FFEDB8, var(--gold)); }
.duel.lost { color: var(--gold-light); background: rgba(0, 0, 0, .3); box-shadow: inset 0 0 0 1px rgba(232, 181, 74, .4); }

.panel-share { max-width: 420px; }
.share { display: flex; flex-direction: column; gap: 12px; margin-bottom: 4px; }
.share-preview {
  align-self: center;
  width: min(100%, 230px, 30vh);
  aspect-ratio: 4 / 5;
  border-radius: 12px;
  overflow: hidden;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: .85rem;
  background: rgba(0, 0, 0, .35);
  box-shadow: 0 0 0 1.5px rgba(232, 181, 74, .55), 0 10px 26px rgba(0, 0, 0, .45);
}
.share-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.share-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.share-btn {
  min-height: 64px;
  padding: 8px 2px 6px;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-size: .72rem;
  font-weight: 600;
  color: var(--text);
  background: rgba(0, 0, 0, .3);
  box-shadow: inset 0 0 0 1px rgba(232, 181, 74, .3);
  transition: transform .08s ease, background-color .15s ease;
}
.share-btn:active { transform: scale(.95); }
.share-btn svg {
  width: 30px;
  height: 30px;
  padding: 6px;
  border-radius: 50%;
  fill: #fff;
  background: #2F4A4E;
}
.share-btn span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.share-share svg { fill: #2A1802; background: linear-gradient(180deg, #FFEDB8, var(--gold)); }
.share-whatsapp svg { background: #25D366; }
.share-telegram svg { background: #29A9EB; }
.share-x svg { background: #000; box-shadow: 0 0 0 1px rgba(255, 255, 255, .25); }
.share-facebook svg { background: #1877F2; }
.share-mail svg { background: #B98326; }
.share-link svg { background: var(--turquoise); fill: #062022; }
.share-save svg { background: #6C4FA0; }
.share-hint { text-align: center; }
.share-hint.ok { color: var(--turquoise) !important; }

.home-toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + var(--safe-b));
  z-index: 20;
  transform: translate(-50%, 20px);
  max-width: min(90vw, 420px);
  padding: 10px 18px;
  border-radius: 12px;
  background: rgba(8, 20, 23, .95);
  box-shadow: inset 0 0 0 1.5px rgba(44, 196, 192, .6), 0 10px 26px rgba(0, 0, 0, .5);
  color: var(--text);
  font-weight: 600;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .25s ease;
}
.home-toast.show { opacity: 1; transform: translate(-50%, 0); }
.toggle.share-app { color: var(--gold-light); }

/* ---------- Animationen ---------- */
@keyframes pop {
  0% { transform: scale(.3); }
  100% { transform: scale(1); }
}
@keyframes markPop {
  0% { transform: translate(-50%, -50%) scale(.4); }
  100% { transform: translate(-50%, -50%) scale(1); }
}
@keyframes bump {
  0% { transform: scale(1); }
  40% { transform: scale(1.14); }
  100% { transform: scale(1); }
}
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}
@keyframes starIn {
  0% { transform: scale(0) rotate(-40deg); opacity: 0; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}
@keyframes coachIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes twinkle { from { opacity: .35; } to { opacity: .85; } }
@keyframes drift { to { transform: translateX(-1200px); } }
@keyframes glow {
  0%, 100% { opacity: .75; transform: scale(.96); }
  50% { opacity: 1; transform: scale(1.04); }
}

@media (max-height: 640px) {
  .moves-num, .hud-time span { font-size: 1.7rem; }
  .goal canvas { width: 27px; height: 27px; }
  .game { gap: 6px; }
  .home-inner { gap: 8px; padding-top: 4px; }
  .logo-stones { width: 110px; height: 110px; }
  .logo-sun { width: 104px !important; height: 104px !important; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
