/* Nordpol-Spiele – cute cartoon Christmas look: chunky outlines, candy colours.
 *
 * Performance rules (the target laptops have a slow, virtualised GPU):
 *   - nothing animates while a screen just sits there; the few animations
 *     are short, one-off and touch only small elements,
 *   - no filter, backdrop-filter, blur or blurred shadow anywhere
 *     (shadows are solid offsets),
 *   - no fixed background painting, no full-screen animated layers.
 * scripts/perf.mjs checks the idle screens and the minigames. */

@font-face {
  font-family: 'Fredoka';
  src: url('/fonts/fredoka-latin-400-normal.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Fredoka';
  src: url('/fonts/fredoka-latin-600-normal.woff2') format('woff2');
  font-weight: 600;
  font-display: swap;
}
@font-face {
  font-family: 'Fredoka';
  src: url('/fonts/fredoka-latin-700-normal.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
}

:root {
  --ink: #1d2b53;
  --night: #16245c;
  --night-2: #2f4aa0;
  --cream: #fff9ec;
  --paper: #ffffff;
  --red: #e63946;
  --red-dark: #b3202c;
  --green: #2f9e5b;
  --green-dark: #1f7541;
  --gold: #ffb703;
  --gold-dark: #d98f00;
  --sky: #dbe8ff;
  --muted: #5d6a92;
  --radius: 22px;
  --shadow: 0 7px 0 rgba(10, 16, 48, 0.55);
  --font: 'Fredoka', 'Trebuchet MS', 'Segoe UI', system-ui, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; touch-action: manipulation; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--night);
  overflow-x: hidden;
}

h1, h2, h3, p { margin: 0; }
h2 { font-size: 1.45rem; line-height: 1.2; }
h3 { font-size: 1.1rem; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }

:focus-visible {
  outline: 4px solid var(--gold);
  outline-offset: 2px;
}

/* ---- backdrop ---------------------------------------------------------------- */

.sky {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  background: linear-gradient(180deg, #111c4d 0%, var(--night) 35%, var(--night-2) 78%, #6f93dc 100%);
}
/* Still snow: painted once, never animated. */
.snow {
  position: absolute;
  inset: 0;
  background-repeat: repeat;
  background-image:
    radial-gradient(circle at 30px 40px, rgba(255, 255, 255, 0.7) 0 2px, transparent 3px),
    radial-gradient(circle at 130px 110px, rgba(255, 255, 255, 0.6) 0 2px, transparent 3px),
    radial-gradient(circle at 200px 190px, rgba(255, 255, 255, 0.7) 0 1.5px, transparent 2.5px),
    radial-gradient(circle at 60px 170px, rgba(255, 255, 255, 0.85) 0 3px, transparent 4px),
    radial-gradient(circle at 170px 30px, rgba(255, 255, 255, 0.8) 0 3px, transparent 4px),
    radial-gradient(circle at 100px 100px, rgba(255, 255, 255, 0.95) 0 4.5px, transparent 5.5px);
  background-size: 240px 240px;
}
.hills {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 170px;
}

/* ---- shell ------------------------------------------------------------------- */

.topbar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  max-width: 1120px;
  margin: 0 auto;
  padding: 12px max(18px, env(safe-area-inset-right)) 4px max(18px, env(safe-area-inset-left));
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px 6px 8px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-weight: 700;
  font-size: 1.1rem;
}
.brand:hover { background: rgba(255, 255, 255, 0.22); }
.brand-icon { font-size: 1.5rem; }
body[data-route='start'] .brand { visibility: hidden; }

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 3px solid var(--ink);
  border-radius: 50%;
  background: var(--cream);
  font-size: 1.25rem;
  line-height: 1;
  box-shadow: 0 4px 0 rgba(10, 16, 48, 0.55);
}
.icon-button:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(10, 16, 48, 0.55); }

.app {
  position: relative;
  z-index: 1;
  max-width: 1120px;
  margin: 0 auto;
  padding: 8px max(18px, env(safe-area-inset-right)) max(120px, calc(env(safe-area-inset-bottom) + 100px)) max(18px, env(safe-area-inset-left));
}

.panel {
  background: var(--cream);
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 22px;
}
.panel-sub { color: var(--muted); margin: 2px 0 14px; }
.section-title { margin: 18px 0 8px; }
.empty-note { color: var(--muted); padding: 8px 0; }

/* ---- buttons ----------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border: 3px solid var(--ink);
  border-radius: 16px;
  background: var(--red);
  color: #fff;
  font-weight: 700;
  font-size: 1.05rem;
  line-height: 1.2;
  box-shadow: 0 5px 0 var(--ink);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 7px 0 var(--ink); }
.btn:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
.btn:disabled { opacity: 0.5; }
.btn-green { background: var(--green); }
.btn-gold { background: var(--gold); color: var(--ink); }
.btn-ghost { background: var(--paper); color: var(--ink); }
.btn-small { padding: 6px 12px; font-size: 0.95rem; border-radius: 12px; box-shadow: 0 3px 0 var(--ink); }
.btn-large { padding: 12px 26px; font-size: 1.2rem; }
.btn-xl { padding: 16px 34px; font-size: 1.5rem; border-radius: 22px; box-shadow: 0 7px 0 var(--ink); }
.btn-icon { font-size: 1.1em; line-height: 1; }
.btn span:empty { display: none; }

.card-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 16px;
}

.input {
  width: 100%;
  padding: 10px 14px;
  border: 3px solid var(--ink);
  border-radius: 14px;
  background: var(--paper);
}
.input::placeholder { color: #8a94b5; }

/* ---- start screen ------------------------------------------------------------ */

.hero {
  text-align: center;
  color: #fff;
  padding: 0 0 26px;
}
.hero-lights {
  display: flex;
  justify-content: center;
  gap: clamp(10px, 3.4vw, 34px);
  margin-bottom: 8px;
  font-size: clamp(14px, 2.4vw, 22px);
}
.bulb:nth-child(odd) { opacity: 0.45; }
.lights-alt .bulb:nth-child(odd) { opacity: 1; }
.lights-alt .bulb:nth-child(even) { opacity: 0.45; }
.hero-kicker {
  display: inline-block;
  padding: 4px 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  font-weight: 600;
  letter-spacing: 0.04em;
}
.hero-title {
  margin: 10px 0 0;
  font-size: clamp(3rem, 11vw, 6.6rem);
  line-height: 0.95;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: #fff;
  text-shadow:
    0 4px 0 var(--red), 0 5px 0 var(--red), 0 6px 0 var(--red-dark), 0 7px 0 var(--red-dark),
    0 9px 0 var(--ink), 0 10px 0 var(--ink);
}
.hero-title span { display: inline-block; }
.hero-title span:first-child { transform: rotate(-3deg); }
.hero-title span:last-child { transform: rotate(2deg); color: #ffe38a; }
/* German joins the two words with a hyphen; English needs the space back. */
html[lang='en'] .hero-title span:first-child { margin-right: 0.28em; }
.hero-cast {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: clamp(6px, 2.2vw, 22px);
  margin: 22px 0 12px;
  font-size: clamp(2.2rem, 7vw, 3.8rem);
  line-height: 1;
}
.cast { display: inline-block; text-shadow: 0 6px 0 rgba(10, 16, 48, 0.4); }
.cast:nth-child(odd) { transform: rotate(-6deg); }
.cast:nth-child(even) { transform: rotate(5deg) translateY(-6px); }
.cast-hero { font-size: 1.35em; }
.hero-text {
  max-width: 620px;
  margin: 0 auto;
  font-size: 1.15rem;
  color: #eaf1ff;
}
.hero-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 18px;
  margin: 24px 0 14px;
}
.pool-note { min-height: 1.5em; color: #cfe0ff; font-weight: 600; }

.start-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
  align-items: start;
}
.how-list { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 12px; }
.how-list li { display: flex; gap: 12px; align-items: flex-start; }
.how-list p { color: var(--muted); font-size: 0.98rem; }
.how-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 3px solid var(--ink);
  border-radius: 14px;
  background: var(--sky);
  font-size: 1.4rem;
}

/* ---- high scores ------------------------------------------------------------- */

.scores-panel h2 { margin-bottom: 8px; }
.score-table { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; }
.score-row {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  border-radius: 12px;
  background: var(--paper);
  border: 2px solid #d7def2;
}
.score-row-me { border-color: var(--gold); background: #fff4cf; }
.score-rank-cell { font-weight: 700; text-align: center; font-size: 1.1rem; }
.score-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.score-meta { color: var(--muted); font-size: 0.85rem; white-space: nowrap; }
.score-points { font-size: 1.2rem; color: var(--red); min-width: 3ch; text-align: right; }

/* ---- play: hud + stage ------------------------------------------------------- */

.play-screen { display: grid; justify-items: center; }
.hud { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.hud-item {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 4px 14px;
  border: 3px solid var(--ink);
  border-radius: 999px;
  background: var(--paper);
}
.hud-label { font-size: 0.75rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.hud-value { font-size: 1.15rem; font-weight: 700; }
.stage-panel { padding: 14px; max-width: 100%; }

.loading-panel { text-align: center; max-width: 420px; margin: 40px auto; }
.spinner { font-size: 3rem; display: inline-block; animation: spin 1.6s steps(8) infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- end of run -------------------------------------------------------------- */

.end-panel, .scores-panel.panel, .saved-view { text-align: center; }
.end-panel { max-width: 620px; margin: 0 auto; }
.scores-panel { max-width: 720px; margin: 0 auto; }
.start-grid .scores-panel { max-width: none; text-align: left; }
.end-emoji { font-size: 4rem; line-height: 1; }
.end-sub { color: var(--muted); margin-top: 4px; }
.end-total {
  display: inline-flex;
  align-items: baseline;
  gap: 10px;
  margin: 16px 0 6px;
  padding: 8px 24px;
  border: 3px solid var(--ink);
  border-radius: 18px;
  background: #fff4cf;
}
.end-total strong { font-size: 3rem; line-height: 1; color: var(--red); }
.end-list { list-style: none; margin: 12px auto; padding: 0; max-width: 420px; display: grid; gap: 4px; text-align: left; }
.end-list li { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 4px 10px; border-radius: 10px; background: var(--paper); }
.end-points { display: inline-flex; align-items: baseline; gap: 8px; white-space: nowrap; }
.end-points small { color: var(--gold-dark); font-weight: 600; }
.end-bonus { background: #ffe3e6 !important; }
.score-form { display: flex; gap: 10px; max-width: 460px; margin: 16px auto 0; }
.score-rank { margin-top: 14px; font-weight: 700; font-size: 1.2rem; color: var(--green-dark); }
.score-table-slot { text-align: left; max-width: 520px; margin: 10px auto 0; }

/* ---- room stage (intro, minigame, result) -------------------------------------- */

.stage {
  --screen: min(580px, 100%, calc(100dvh - 300px));
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr);
  justify-items: stretch;
  width: min(580px, 100%);
  margin: 0 auto;
}
.stage-screen { width: max(240px, var(--screen)); max-width: 100%; justify-self: center; }
.stage-below { display: grid; gap: 8px; }
.stage-header { display: flex; align-items: center; gap: 12px; }
.stage-emoji {
  flex: none;
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border: 3px solid var(--ink);
  border-radius: 16px;
  background: #ffe08a;
  font-size: 2rem;
  line-height: 1;
}
.stage-titles { flex: 1; min-width: 0; }
.stage-titles h2 { font-size: 1.3rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stage-titles p { color: var(--muted); font-size: 0.95rem; }
.stage-close { width: 38px; height: 38px; font-size: 1rem; }

.timer {
  position: relative;
  height: 26px;
  border: 3px solid var(--ink);
  border-radius: 14px;
  background: #dfe7fb;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-weight: 700;
  font-size: 0.95rem;
}
.timer-fill {
  position: absolute;
  inset: 0;
  transform-origin: left center;
  background: linear-gradient(90deg, #52b788, #95d5b2);
}
.timer-icon, .timer-label { position: relative; z-index: 1; }
.timer-low .timer-fill { background: linear-gradient(90deg, var(--red), #ff8fa3); }

.stage-screen {
  position: relative;
  aspect-ratio: 1;
  border: 3px solid var(--ink);
  border-radius: 18px;
  overflow: hidden;
  background: var(--night);
}
.stage-mount { position: absolute; inset: 0; }
.room-frame { display: block; width: 100%; height: 100%; border: 0; }
.stage-card-slot {
  position: absolute;
  inset: 0;
  display: none;
  padding: 12px;
  overflow: auto;
  background: rgba(22, 36, 92, 0.8);
}
.stage-card-slot.is-open { display: grid; grid-template-columns: minmax(0, 1fr); }
.stage-card {
  /* auto margins centre the card but, unlike place-items, never push the top
     out of reach when the card is taller than the picture (small phones). */
  margin: auto;
  width: 100%;
  max-width: 460px;
  padding: 16px 18px;
  border: 3px solid var(--ink);
  border-radius: 18px;
  background: var(--cream);
  text-align: center;
}
@keyframes pop-in {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.intro-head { display: flex; align-items: center; gap: 12px; text-align: left; margin-bottom: 10px; }
.intro-emoji { flex: none; font-size: 3.6rem; line-height: 1; }
.intro-title { font-size: 1.35rem; font-weight: 700; line-height: 1.2; }
.speech {
  position: relative;
  padding: 8px 14px;
  border: 3px solid var(--ink);
  border-radius: 16px;
  background: var(--paper);
  font-weight: 600;
  font-style: italic;
}
.intro-story { margin-bottom: 8px; }
.intro-how { padding: 8px 12px; border-radius: 12px; background: #e3f5e8; }
.badges { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 10px; }
.badge {
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--sky);
  font-size: 0.88rem;
  font-weight: 600;
  text-align: center;
}
.result-emoji { font-size: 3.4rem; line-height: 1; }
.result-score { margin: 6px 0; font-size: 1.05rem; }
.result-score strong { font-size: 3rem; line-height: 1; margin-right: 6px; }
.result-won .result-score strong { color: var(--green); }
.result-lost .result-score strong { color: var(--red); }
.result-detail { color: var(--muted); }
.result-note { display: inline-block; margin-bottom: 6px; padding: 2px 12px; border-radius: 999px; background: #fff4cf; font-weight: 600; }
.stage-giveup { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; min-height: 40px; }
.giveup-question { font-weight: 600; }
.stage-status { min-height: 2.9em; text-align: center; font-weight: 600; display: grid; place-items: center; }

.touch-keys { display: flex; justify-content: center; gap: 10px; }
.touch-key {
  width: 58px;
  height: 58px;
  border: 3px solid var(--ink);
  border-radius: 16px;
  background: var(--paper);
  font-size: 1.4rem;
  box-shadow: 0 4px 0 var(--ink);
  touch-action: none;
}
.touch-key:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
@media (hover: hover) and (pointer: fine) {
  .touch-keys { display: none; }
}

/* Wide and not very tall (office laptops, phones held sideways): picture left,
   the rest beside it. */
@media (min-width: 900px), (min-width: 640px) and (max-height: 520px) {
  .stage {
    --screen: min(600px, calc(100dvh - 124px));
    width: auto;
    grid-template-columns: max(300px, var(--screen)) minmax(250px, 300px);
    grid-template-rows: auto auto auto 1fr;
    grid-template-areas: 'screen header' 'screen aside' 'screen timer' 'screen below';
    column-gap: 16px;
    align-items: start;
  }
  .stage-header { grid-area: header; }
  .stage-aside { grid-area: aside; }
  .timer { grid-area: timer; }
  .stage-screen { grid-area: screen; width: 100%; }
  .stage-below { grid-area: below; align-content: start; }
  .stage .hud { justify-content: flex-start; }
  .stage-status { min-height: 4.4em; text-align: left; place-items: center start; }
  .stage-giveup { justify-content: flex-start; }
}
/* A phone held sideways has under 400px of height: the picture takes all of it. */
@media (min-width: 640px) and (max-height: 520px) {
  .stage { --screen: max(300px, calc(100dvh - 84px)); }
}

/* ---- feedback, reports, dialogs ------------------------------------------------ */

.topbar-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; }
/* Music and sound-effect controls share one pill. */
.audio-pill {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  height: 44px;
  padding: 0 4px;
  border: 3px solid var(--ink);
  border-radius: 999px;
  background: var(--cream);
  box-shadow: 0 4px 0 rgba(10, 16, 48, 0.55);
}
.pill-icon {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  font-size: 1.15rem;
  line-height: 1;
}
.pill-icon:hover { background: rgba(10, 16, 48, 0.1); }
.pill-icon:active { background: rgba(10, 16, 48, 0.18); }
.music-player {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-right: 4px;
  padding-right: 6px;
  border-right: 2px solid rgba(10, 16, 48, 0.2);
}
.music-player[hidden] { display: none; }
.music-title {
  max-width: 170px;
  overflow: hidden;
  padding: 0 4px;
  color: var(--ink);
  font-weight: 700;
  font-size: 0.9rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.music-muted .music-title { opacity: 0.5; }
.pill-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 44px;
  padding: 0 16px;
  border: 3px solid var(--ink);
  border-radius: 999px;
  background: var(--cream);
  font-weight: 700;
  box-shadow: 0 4px 0 rgba(10, 16, 48, 0.55);
}
a.pill-button { color: var(--ink); text-decoration: none; }
.pill-button:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(10, 16, 48, 0.55); }
.link-button {
  padding: 2px 4px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.link-button:hover { color: var(--ink); }

.feedback-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 4px 10px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 2px dashed #d9cfb8;
  min-height: 56px;
}
.feedback-question { font-weight: 600; font-size: 0.95rem; }
.rating { display: inline-flex; gap: 6px; }
.rating-button {
  width: 40px;
  height: 40px;
  padding: 0;
  border: 3px solid var(--ink);
  border-radius: 12px;
  background: var(--paper);
  font-size: 1.3rem;
  line-height: 1;
  box-shadow: 0 3px 0 var(--ink);
}
.rating-button:hover { background: #fff4cf; }
.rating-button:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.rating-button.is-picked { background: var(--gold); }
.feedback-form { display: flex; align-items: center; gap: 8px; width: 100%; }
.feedback-picked { font-size: 1.4rem; line-height: 1; }
.feedback-input { flex: 1; min-width: 0; padding: 6px 12px; font-size: 0.95rem; }
.feedback-hint { width: 100%; color: var(--red-dark); font-size: 0.9rem; font-weight: 600; }
.feedback-hint:empty { display: none; }
.feedback-thanks { font-weight: 600; color: var(--green-dark); }
.feedback-rate { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; font-weight: 600; }

.dialog {
  width: min(520px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  padding: 18px 20px;
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  background: var(--cream);
  color: var(--ink);
  box-shadow: var(--shadow);
}
.dialog-wide { width: min(980px, calc(100vw - 24px)); }
.dialog::backdrop { background: rgba(10, 16, 48, 0.7); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.dialog-close { flex: none; width: 38px; height: 38px; font-size: 1rem; }
.dialog-form { display: grid; gap: 12px; }
.dialog-form textarea { resize: vertical; }
.dialog-note { color: var(--muted); font-size: 0.9rem; }
.choices { display: grid; gap: 6px; }
.choice {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border: 3px solid var(--ink);
  border-radius: 14px;
  background: var(--paper);
  font-weight: 600;
  cursor: pointer;
}
.choice:has(input:checked) { background: #fff4cf; }
.choice input { width: 18px; height: 18px; accent-color: var(--red); }

/* ---- create screen ----------------------------------------------------------- */

.create-screen {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
  gap: 20px;
  align-items: start;
}
.chat-panel { display: flex; flex-direction: column; gap: 12px; position: sticky; top: 12px; }
.chat-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.mode-badge {
  padding: 4px 12px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  background: #fff4cf;
}
.mode-azure { background: #d8f3dc; }
.chat-log {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 200px;
  max-height: min(46vh, 460px);
  overflow-y: auto;
  padding: 12px;
  border: 3px solid var(--ink);
  border-radius: 16px;
  background: #e9f0ff;
}
.bubble { display: flex; gap: 8px; max-width: 92%; }
.bubble p { padding: 8px 12px; border: 2px solid var(--ink); border-radius: 14px; background: var(--paper); overflow-wrap: anywhere; }
.bubble-avatar { flex: none; font-size: 1.6rem; line-height: 1.3; }
.bubble-user { align-self: flex-end; }
.bubble-user p { background: #c9f0d6; border-bottom-right-radius: 4px; }
.bubble-assistant p { border-bottom-left-radius: 4px; }
.bubble-system { align-self: center; max-width: 100%; }
.bubble-system p { background: #fff4cf; border-style: dashed; font-size: 0.93rem; text-align: center; }
.bubble-typing p { color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 5px 12px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--paper);
  font-size: 0.9rem;
  font-weight: 600;
  text-align: left;
}
.chip:hover:not(:disabled) { background: #ffe9b0; }
.chip:disabled { opacity: 0.5; }
.chat-form { display: grid; gap: 10px; }
.chat-input { resize: vertical; min-height: 84px; }
.chat-form .btn { justify-self: end; }

.room-panel { min-height: 420px; }
.empty-room { text-align: center; padding: 26px 8px; color: var(--muted); }
.empty-room h2 { color: var(--ink); margin: 8px 0; }
.empty-room-art { font-size: 4.4rem; line-height: 1; }
.steps {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 18px 0 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
}
.steps li {
  counter-increment: step;
  padding: 4px 12px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  font-weight: 600;
  font-size: 0.9rem;
}
.steps li::before { content: counter(step) '. '; color: var(--red); }

.room-card { display: grid; gap: 8px; padding: 14px 16px; border: 3px solid var(--ink); border-radius: 18px; background: var(--paper); }
.room-card-head { display: flex; align-items: center; gap: 12px; }
.room-card-emoji {
  flex: none;
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border: 3px solid var(--ink);
  border-radius: 18px;
  background: #ffe08a;
  font-size: 2.4rem;
  line-height: 1;
}
.room-card-villain { color: var(--muted); font-weight: 600; }
.room-card .badges { justify-content: flex-start; margin-top: 2px; }
.version-nav { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 12px; font-weight: 600; }
.room-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 16px; }

.checklist { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.check { display: flex; gap: 10px; padding: 8px 12px; border-radius: 12px; border: 2px solid transparent; }
.check p { font-size: 0.93rem; color: #44507a; overflow-wrap: anywhere; }
.check-icon { flex: none; font-size: 1.15rem; line-height: 1.4; }
.check-ok { background: #e4f6e9; }
.check-error { background: #ffe1e4; border-color: var(--red); }
.check-error p { color: #8f1722; }
.check-warning { background: #fff1c7; border-color: var(--gold-dark); }
.check-pending { background: #e9eefc; }
.check-todo { background: #eef0f6; border-style: dashed; border-color: #aab3cf; }

.save-box { margin-top: 6px; }
.save-hint { color: var(--muted); margin-bottom: 10px; }
.save-note { color: var(--muted); font-size: 0.9rem; margin-bottom: 8px; }
.save-rejected { margin-bottom: 8px; padding: 8px 12px; border-radius: 12px; background: #ffe1e4; color: var(--red-dark); }
.save-row { display: flex; gap: 10px; }
.save-row .input { flex: 1; min-width: 0; }
.save-row .btn { flex: none; }
.code-details { margin-top: 18px; }
.code-details summary { cursor: pointer; font-weight: 600; color: var(--muted); }
.code-view {
  max-height: 280px;
  overflow: auto;
  margin: 8px 0 0;
  padding: 12px;
  border-radius: 12px;
  background: var(--ink);
  color: #e8eeff;
  font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre;
  tab-size: 2;
}
.test-slot { margin: 0 auto; }
.create-screen.is-testing { grid-template-columns: minmax(0, 1fr); }
.create-screen.is-testing .chat-panel { display: none; }
.create-screen.is-testing .room-panel { justify-self: center; max-width: 100%; }
.saved-view { padding: 30px 8px; }
.saved-view h2 { margin: 10px 0 6px; }

/* ---- toasts ------------------------------------------------------------------ */

#toast-root {
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: 40;
  display: grid;
  gap: 8px;
  transform: translateX(-50%);
  width: min(92vw, 460px);
  pointer-events: none;
}
.toast {
  padding: 10px 16px;
  border: 3px solid var(--ink);
  border-radius: 14px;
  background: var(--paper);
  font-weight: 600;
  text-align: center;
  box-shadow: 0 4px 0 rgba(10, 16, 48, 0.55);
  animation: pop-in 0.2s ease-out;
  transition: opacity 0.5s ease;
}
.toast-error { background: #ffe1e4; }
.toast-warn { background: #fff1c7; }
.toast-out { opacity: 0; }

#validation-sandbox {
  position: fixed;
  left: -9999px;
  top: 0;
  width: 300px;
  height: 300px;
  overflow: hidden;
  visibility: hidden;
}

/* ---- responsive -------------------------------------------------------------- */

/* ---- creator journey: steps, self-check, test links ---------------------------- */

.chips-label { flex-basis: 100%; margin: 2px 0 -2px; color: var(--muted); font-size: 0.86rem; font-weight: 600; }
.chip-starter { background: #e3f5e8; }
.chip-bug { background: #ffe9ec; }

.journey { display: flex; gap: 6px; margin: 0 0 14px; padding: 0; list-style: none; }
.journey li {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  padding: 5px 8px;
  border: 2px solid #aab3cf;
  border-radius: 999px;
  background: #eef0f6;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 600;
  white-space: nowrap;
}
.journey li > span:last-child { overflow: hidden; text-overflow: ellipsis; }
.journey-dot {
  flex: none;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #aab3cf;
  color: #fff;
  font-size: 0.8rem;
  line-height: 1;
}
.journey .is-done { border-color: var(--green); background: #e4f6e9; color: var(--green-dark); }
.journey .is-done .journey-dot { background: var(--green); }
.journey .is-current { border-color: var(--ink); background: #fff4cf; color: var(--ink); }
.journey .is-current .journey-dot { background: var(--red); }
.empty-room .journey { margin-top: 18px; text-align: left; }

.intro-note { margin-top: 10px; padding: 8px 12px; border: 2px dashed var(--gold-dark); border-radius: 12px; background: #fff4cf; font-weight: 600; font-size: 0.95rem; }

.review-box { margin-top: 14px; padding: 4px 14px 14px; border: 3px solid var(--ink); border-radius: 18px; background: #f3f7ff; }
.review-box .section-title { margin-top: 10px; }
.review-note { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 8px 12px; border-radius: 12px; background: #e9eefc; font-size: 0.95rem; }
.review-note p { flex: 1 1 260px; }
.review-warn { background: #fff1c7; }
.review-good { background: #e4f6e9; }
.review-hint { margin-top: 6px; color: var(--muted); font-size: 0.9rem; }
.question { margin-top: 12px; }
.question-text { margin-bottom: 6px; font-weight: 600; }
.question .review-note { margin-top: 8px; }
.choice-row { display: flex; flex-wrap: wrap; gap: 8px; }
.choice-button {
  padding: 6px 14px;
  border: 3px solid var(--ink);
  border-radius: 12px;
  background: var(--paper);
  font-weight: 600;
  box-shadow: 0 3px 0 var(--ink);
}
.choice-button:hover { background: #fff4cf; }
.choice-button:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.choice-button.is-picked { background: var(--gold); }

.testlink-box { margin-top: 6px; }
.testlink-box .card-actions { justify-content: flex-start; margin-top: 8px; }
.link-field { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
.link-input { flex: 1; min-width: 0; padding: 6px 12px; font-size: 0.92rem; background: var(--paper); }
.saved-owner { max-width: 520px; margin: 10px auto 0; padding: 10px 14px; border-radius: 14px; background: #e3f5e8; }

.voice-list { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 8px; }
.voice { padding: 8px 12px; border: 2px solid var(--ink); border-radius: 14px; background: var(--paper); }
.voice .badges { justify-content: flex-start; margin-top: 0; }
.voice-text { margin-top: 4px; font-style: italic; overflow-wrap: anywhere; }
.voice-pending, .voice-date { color: var(--muted); font-size: 0.85rem; }

/* ---- "Meine Level" and the user-test page -------------------------------------- */

.hero-more { display: flex; justify-content: center; margin-top: 14px; }
.news-badge { margin-left: 4px; padding: 1px 8px; border-radius: 999px; background: var(--red); color: #fff; font-size: 0.78rem; }
.news-badge[hidden] { display: none; }

.mine-screen { display: grid; gap: 16px; }
.mine-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; color: #fff; }
.mine-top h2 { margin: 0; }
.mine-top .panel-sub { margin: 2px 0 0; color: #cfe0ff; }
.mine-top .card-actions { margin: 0; }
.mine-body { display: grid; gap: 16px; }
.mine-section { margin: 6px 0 -6px; color: #fff; }
.mine-card { display: grid; gap: 12px; }
.mine-card h4 { margin: 0 0 6px; font-size: 1rem; }
.mine-card .card-actions { justify-content: flex-start; margin-top: 0; }
.mine-head { display: flex; align-items: center; gap: 12px; }
.mine-emoji {
  flex: none;
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border: 3px solid var(--ink);
  border-radius: 16px;
  background: #ffe08a;
  font-size: 2rem;
  line-height: 1;
}
.mine-titles { flex: 1; min-width: 0; }
.mine-titles h3 { margin: 0; }
.mine-titles p { color: var(--muted); font-size: 0.9rem; }
.state-chip { flex: none; padding: 4px 12px; border: 2px solid var(--ink); border-radius: 999px; font-size: 0.88rem; font-weight: 700; }
.state-live { background: #c9f0d6; }
.state-paused { background: #ffe08a; }
.state-off { background: #e3e6f0; }
.nudges { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.nudge { display: flex; gap: 8px; padding: 8px 12px; border-radius: 12px; background: #fff1c7; font-weight: 600; }
.nudge-problem { background: #ffe1e4; color: #8f1722; }
.nudge-praise { background: #e4f6e9; color: var(--green-dark); }
.tiles { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.tile { display: grid; gap: 2px; padding: 8px 6px; border: 2px solid var(--ink); border-radius: 14px; background: var(--paper); text-align: center; }
.tile strong { font-size: 1.35rem; line-height: 1.2; }
.tile span { color: var(--muted); font-size: 0.82rem; font-weight: 600; }
.histogram { display: flex; align-items: flex-end; gap: 4px; height: 110px; padding: 6px 8px 0; border: 2px solid var(--ink); border-radius: 14px; background: var(--paper); }
.histogram-bar { flex: 1; display: flex; flex-direction: column; height: 100%; }
.histogram-track { flex: 1; display: flex; align-items: flex-end; }
.histogram-fill { display: block; width: 100%; min-height: 2px; border-radius: 5px 5px 0 0; background: var(--green); }
.histogram-bar.is-fail .histogram-fill { background: var(--red); }
.histogram-bar.is-perfect .histogram-fill { background: var(--gold); }
.histogram-label { height: 18px; color: var(--muted); font-size: 0.72rem; text-align: center; }
.chart-note { margin-top: 4px; color: var(--muted); font-size: 0.85rem; }
.rating-sums { display: flex; gap: 14px; font-weight: 700; }
.reports { margin-top: 10px; padding: 8px 12px; border-radius: 12px; background: #ffe1e4; }
.reports ul { margin: 0; padding-left: 20px; }
.mine-empty { text-align: center; }
.account-box h3 { margin: 0 0 6px; }
.account-box p { color: var(--muted); }
.account-box .card-actions { justify-content: flex-start; }
.transfer-code { padding: 12px; border: 3px dashed var(--ink); border-radius: 14px; background: var(--paper); font-size: 1.4rem; font-weight: 700; text-align: center; overflow-wrap: anywhere; user-select: all; }

.test-screen { max-width: 760px; margin: 0 auto; }
.test-welcome { text-align: center; }
.test-welcome .hero-kicker { color: var(--red); }
.test-welcome .link-field { max-width: 520px; margin: 12px auto; }
.test-own-feedback { max-width: 560px; margin: 0 auto; text-align: left; }
.test-questions textarea { width: 100%; margin-top: 14px; resize: vertical; }
.test-questions .card-actions { justify-content: flex-start; }
.badge-level { background: #fff4cf; }

/* ---- "Alle Level" and the invitations to make one ------------------------------ */

.hero-more { gap: 10px; flex-wrap: wrap; }
.hero-actions-create { align-items: center; }
.levels-filters .chip.is-picked { background: var(--gold); }
.levels-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; align-items: stretch; }
.level-card { display: flex; flex-direction: column; gap: 8px; }
.level-card .badges { justify-content: flex-start; margin-top: 0; }
.level-card .card-actions { justify-content: flex-start; margin-top: auto; padding-top: 6px; }
.level-villain { color: var(--muted); font-size: 0.92rem; }
.level-invite { align-items: center; justify-content: center; text-align: center; border-style: dashed; background: #f3fbf5; }
.level-invite h3 { margin: 4px 0 0; }
.level-invite p { color: var(--muted); }
.level-invite .card-actions { justify-content: center; margin-top: 6px; }
.levels-empty { color: #cfe0ff; }
.create-hook { margin-top: 18px; padding: 12px 14px; border: 3px dashed var(--green-dark); border-radius: 16px; background: #f3fbf5; }
.create-hook-text { font-weight: 600; }
.create-hook .card-actions { margin-top: 10px; }
.remix-hint { margin-top: 16px; }
.remix-hint .link-button { font-size: inherit; }

@media (max-width: 900px) {
  .create-screen, .start-grid { grid-template-columns: minmax(0, 1fr); }
  .chat-panel { position: static; }
  .chat-log { max-height: 300px; }
}
@media (max-width: 899px) {
  /* Phones: the intro and result cards are taller than the square picture. Let
     the picture grow to fit the card (the square stays as the minimum) instead
     of clipping the card's top. */
  .stage-screen.has-card { aspect-ratio: auto; display: grid; }
  .stage-screen.has-card::before { content: ''; grid-area: 1 / 1; padding-top: 100%; }
  .stage-screen.has-card .stage-card-slot { position: relative; inset: auto; grid-area: 1 / 1; overflow: visible; }
}
@media (max-width: 900px) {
  .music-title { display: none; }
}
@media (max-width: 560px) {
  /* Everything in the top bar has to fit one row on a 390px phone. */
  .topbar { padding-top: max(10px, env(safe-area-inset-top)); }
  .topbar-actions { gap: 6px; }
  .brand { padding: 4px 8px; }
  .brand-name { display: none; }
  .pill-button { width: 44px; padding: 0; justify-content: center; }
  .pill-button > span:not([aria-hidden]) { display: none; }
  .stage-card-slot { padding: 8px; }
  .stage-card { padding: 10px 12px; }
  .intro-head { margin-bottom: 6px; }
  .intro-emoji { font-size: 2.6rem; }
  .intro-title { font-size: 1.15rem; }
  .speech { padding: 6px 10px; }
  .badges { margin-top: 6px; gap: 4px; }
  .badge { padding: 2px 8px; font-size: 0.8rem; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .journey li > span:last-child { display: none; }
  .journey li { justify-content: center; }
  body { font-size: 16px; }
  .app { padding: 6px 12px 110px; }
  .panel { padding: 16px 14px; }
  .btn-xl { padding: 14px 24px; font-size: 1.3rem; }
  .score-meta { display: none; }
  .score-row { grid-template-columns: 34px minmax(0, 1fr) auto; }
  .save-row, .score-form { flex-direction: column; }
  .hud-item { padding: 5px 12px; gap: 6px; }
  .hud-label { font-size: 0.7rem; }
}

/* Touch screens: fingertip-sized controls; iOS zooms into any field below 16px. */
@media (pointer: coarse) {
  .pill-icon { width: 38px; height: 38px; }
  input, textarea, select { font-size: 16px !important; }
  button, .btn, .pill-button, .pill-icon, .chip, .touch-key { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
}

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