/* =========================================================
   Menue, Bestenliste, Ergebnisse

   Alle Groessen haengen an der Groesse des Spielrahmens (cqh/cqw),
   nicht am Fenster. So sieht das Menue auf dem iPad, auf dem iPhone
   und am Schreibtisch gleich aus - nur eben groesser oder kleiner.
   ========================================================= */

.overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 3cqh 3cqw;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(24, 44, 16, 0.36), rgba(12, 24, 8, 0.62));
  backdrop-filter: blur(14px) saturate(1.15);
  -webkit-backdrop-filter: blur(14px) saturate(1.15);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s var(--ease-out);
}

.overlay.is-visible {
  opacity: 1;
  pointer-events: auto;
}

/* ---------- Karte ---------- */

.card {
  width: min(94%, 720px);
  width: min(76cqw, 92cqh * 1.6);
  max-height: 94cqh;
  overflow: auto;
  padding: 22px;
  padding: clamp(16px, 4.4cqh, 40px) clamp(16px, 4cqw, 44px);
  border-radius: var(--r-xl);
  background: var(--panel);
  color: var(--ink);
  text-align: center;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.55),
    var(--shadow-3);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  animation: cardIn 0.42s var(--ease-spring) backwards;
}

.card.card-wide {
  width: min(90cqw, 104cqh * 1.6);
}

@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.965);
  }
}

/* Die Bausteine in der Karte kommen der Reihe nach herein. */
.card > * {
  animation: riseIn 0.44s var(--ease-out) backwards;
}

.card > *:nth-child(1) { animation-delay: 0.04s; }
.card > *:nth-child(2) { animation-delay: 0.08s; }
.card > *:nth-child(3) { animation-delay: 0.12s; }
.card > *:nth-child(4) { animation-delay: 0.16s; }
.card > *:nth-child(5) { animation-delay: 0.2s; }
.card > *:nth-child(6) { animation-delay: 0.24s; }

@keyframes riseIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
}

/* ---------- Ueberschriften ---------- */

.card h1,
.card h2 {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.02;
  letter-spacing: -0.015em;
}

.card h1 {
  font-size: 38px;
  font-size: clamp(28px, 9cqh, 66px);
  background: linear-gradient(150deg, #3c8f26 0%, #5fbf3d 38%, #ffb020 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.card h2 {
  font-size: 28px;
  font-size: clamp(21px, 6.4cqh, 44px);
}

.card p {
  margin: 6px 0 10px;
  font-size: 15px;
  font-size: clamp(12px, 2.9cqh, 19px);
  line-height: 1.5;
  color: var(--ink-soft);
}

.card p strong {
  color: var(--ink);
}

.kicker {
  margin: 0 0 2px;
  font-family: var(--font-display);
  font-size: clamp(10px, 2.2cqh, 14px);
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

/* ---------- Der Pudel im Menue ---------- */

.hero-dog {
  font-size: clamp(34px, 10cqh, 78px);
  line-height: 1;
  animation: hop 2.6s var(--ease-out) infinite;
}

@keyframes hop {
  0%, 62%, 100% {
    transform: translateY(0) rotate(0deg);
  }
  70% {
    transform: translateY(-14%) rotate(-6deg);
  }
  80% {
    transform: translateY(0) rotate(0deg);
  }
  88% {
    transform: translateY(-7%) rotate(4deg);
  }
}

/* ---------- Knoepfe ---------- */

.button-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: clamp(7px, 1.6cqh, 14px);
  margin-top: clamp(10px, 2.6cqh, 22px);
}

.btn {
  position: relative;
  overflow: hidden;
  min-height: 44px;
  min-height: clamp(38px, 8cqh, 58px);
  padding: 0 clamp(16px, 3cqw, 30px);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: var(--r-pill);
  font-family: var(--font-display);
  font-size: clamp(13px, 2.9cqh, 19px);
  font-weight: 600;
  color: #2a1a02;
  background: linear-gradient(160deg, #ffd469, #ffa60f);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.65),
    inset 0 -2px 0 rgba(150, 88, 0, 0.28),
    var(--glow-sun);
  transition: transform 0.14s var(--ease-spring), box-shadow 0.2s, filter 0.2s;
}

/* Ein Lichtstreifen wandert einmal ueber den Hauptknopf. */
.btn.primary::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 40%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.55), transparent);
  transform: translateX(-180%) skewX(-18deg);
  animation: shine 4.5s ease-in-out 1.2s infinite;
}

@keyframes shine {
  0% {
    transform: translateX(-180%) skewX(-18deg);
  }
  22%, 100% {
    transform: translateX(320%) skewX(-18deg);
  }
}

.btn:active {
  transform: translateY(2px) scale(0.985);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.5),
    inset 0 -1px 0 rgba(150, 88, 0, 0.3),
    0 3px 10px rgba(255, 176, 32, 0.32);
}

.btn.secondary {
  color: #10240a;
  background: linear-gradient(160deg, #b6ea8a, #66c53f);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.6),
    inset 0 -2px 0 rgba(40, 100, 20, 0.3),
    0 8px 24px rgba(95, 191, 61, 0.34);
}

.btn.ghost {
  color: var(--ink);
  background: var(--panel-sunk);
  box-shadow: inset 0 0 0 1.5px var(--line-strong);
}

.btn.ghost:active {
  background: rgba(27, 42, 20, 0.1);
}

.btn.small {
  min-height: clamp(30px, 6cqh, 44px);
  padding: 0 clamp(12px, 2.2cqw, 20px);
  font-size: clamp(11px, 2.4cqh, 16px);
}

/* ---------- Auswahl in Segmenten ---------- */

.field {
  margin: clamp(8px, 2.4cqh, 20px) 0 0;
  padding: 0;
  border: 0;
  min-width: 0;
  min-inline-size: 0;
  text-align: left;
}

.field legend {
  padding: 0;
  margin-bottom: 6px;
  font-family: var(--font-display);
  font-size: clamp(10px, 2.2cqh, 14px);
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.segmented {
  display: inline-flex;
  padding: 4px;
  border-radius: var(--r-pill);
  background: var(--panel-sunk);
  box-shadow: inset 0 0 0 1.5px var(--line);
}

.segmented label {
  position: relative;
  cursor: pointer;
}

.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: clamp(58px, 12cqw, 96px);
  min-height: clamp(30px, 6cqh, 44px);
  padding: 0 clamp(10px, 2cqw, 18px);
  border-radius: var(--r-pill);
  font-family: var(--font-display);
  font-size: clamp(12px, 2.6cqh, 17px);
  color: var(--ink-soft);
  transition: color 0.2s, background 0.24s var(--ease-out), box-shadow 0.24s;
}

.segmented input:checked + span {
  color: #2a1a02;
  background: linear-gradient(160deg, #ffd469, #ffb020);
  box-shadow: 0 3px 10px rgba(255, 176, 32, 0.4);
}

.segmented input:focus-visible + span {
  outline: 3px solid var(--sky-deep);
  outline-offset: 2px;
}

/* ---------- Levelauswahl ---------- */

.level-rail {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: clamp(96px, 17cqw, 150px);
  gap: clamp(7px, 1.4cqw, 13px);
  margin-top: 8px;
  padding: 4px 2px 8px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}

.level-rail::-webkit-scrollbar {
  display: none;
}

.level-card {
  position: relative;
  scroll-snap-align: center;
  cursor: pointer;
}

.level-card input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.level-card .face {
  display: grid;
  gap: 2px;
  padding: clamp(8px, 1.8cqh, 15px) clamp(6px, 1.2cqw, 12px);
  border-radius: var(--r-md);
  background: var(--panel-sunk);
  box-shadow: inset 0 0 0 1.5px var(--line);
  text-align: center;
  transition: transform 0.24s var(--ease-spring), box-shadow 0.24s, background 0.24s;
}

.level-card .art {
  font-size: clamp(20px, 4.6cqh, 34px);
  line-height: 1.1;
}

.level-card .no {
  font-family: var(--font-display);
  font-size: clamp(9px, 1.9cqh, 12px);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.level-card .name {
  font-family: var(--font-display);
  font-size: clamp(11px, 2.4cqh, 16px);
  font-weight: 600;
}

.level-card .best {
  font-size: clamp(9px, 1.9cqh, 12px);
  color: var(--ink-faint);
  min-height: 1.2em;
}

.level-card input:checked + .face {
  transform: translateY(-3px);
  background: linear-gradient(165deg, rgba(255, 212, 105, 0.9), rgba(255, 176, 32, 0.75));
  box-shadow:
    inset 0 0 0 1.5px rgba(255, 255, 255, 0.6),
    0 10px 26px rgba(255, 176, 32, 0.4);
}

.level-card input:checked + .face .no,
.level-card input:checked + .face .best {
  color: rgba(42, 26, 2, 0.7);
}

.level-card input:checked + .face .name {
  color: #2a1a02;
}

/* ---------- Sterne ---------- */

.stars {
  display: inline-flex;
  gap: clamp(4px, 1cqw, 10px);
  margin: clamp(4px, 1.4cqh, 12px) 0;
  font-size: clamp(24px, 7cqh, 52px);
  line-height: 1;
}

.stars i {
  font-style: normal;
  color: var(--line-strong);
  transform: scale(0.78);
}

.stars i.on {
  color: #ffb020;
  transform: scale(1);
  text-shadow:
    0 2px 0 rgba(180, 110, 0, 0.35),
    0 6px 18px rgba(255, 176, 32, 0.55);
  animation: starPop 0.5s var(--ease-spring) backwards;
}

.stars i.on:nth-child(1) { animation-delay: 0.15s; }
.stars i.on:nth-child(2) { animation-delay: 0.35s; }
.stars i.on:nth-child(3) { animation-delay: 0.55s; }

@keyframes starPop {
  0% {
    transform: scale(0) rotate(-45deg);
  }
  60% {
    transform: scale(1.25) rotate(8deg);
  }
  100% {
    transform: scale(1) rotate(0deg);
  }
}

/* ---------- Ergebniszeilen ---------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(clamp(88px, 17cqw, 150px), 1fr));
  gap: clamp(6px, 1.4cqw, 12px);
  margin: clamp(8px, 2cqh, 18px) 0 0;
}

.stat {
  display: grid;
  gap: 2px;
  padding: clamp(8px, 1.8cqh, 15px) 10px;
  border-radius: var(--r-md);
  background: var(--panel-sunk);
  box-shadow: inset 0 0 0 1.5px var(--line);
}

.stat span {
  font-size: clamp(9px, 1.9cqh, 12px);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.stat b {
  font-family: var(--font-display);
  font-size: clamp(15px, 3.6cqh, 26px);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* ---------- Bestenliste ---------- */

.tabs {
  display: inline-flex;
  margin: 0 auto clamp(8px, 2cqh, 16px);
  padding: 4px;
  border-radius: var(--r-pill);
  background: var(--panel-sunk);
  box-shadow: inset 0 0 0 1.5px var(--line);
}

.tabs button {
  min-height: clamp(28px, 5.6cqh, 40px);
  padding: 0 clamp(12px, 2.4cqw, 22px);
  border-radius: var(--r-pill);
  font-family: var(--font-display);
  font-size: clamp(11px, 2.4cqh, 16px);
  color: var(--ink-soft);
  transition: color 0.2s, background 0.24s var(--ease-out);
}

.tabs button[aria-selected="true"] {
  color: #2a1a02;
  background: linear-gradient(160deg, #ffd469, #ffb020);
  box-shadow: 0 3px 10px rgba(255, 176, 32, 0.36);
}

.podium {
  display: grid;
  grid-template-columns: 1fr 1.15fr 1fr;
  align-items: end;
  gap: clamp(5px, 1.2cqw, 12px);
  margin: clamp(4px, 1.4cqh, 14px) 0 clamp(8px, 2cqh, 18px);
}

.podium .place {
  display: grid;
  justify-items: center;
  gap: 3px;
  padding: clamp(8px, 1.8cqh, 16px) 6px clamp(6px, 1.4cqh, 12px);
  border-radius: var(--r-md) var(--r-md) 8px 8px;
  background: var(--panel-sunk);
  box-shadow: inset 0 0 0 1.5px var(--line);
  animation: riseIn 0.5s var(--ease-spring) backwards;
}

.podium .place:nth-child(1) { animation-delay: 0.14s; }
.podium .place:nth-child(2) { animation-delay: 0.06s; }
.podium .place:nth-child(3) { animation-delay: 0.22s; }

.podium .p1 {
  padding-top: clamp(14px, 3.4cqh, 28px);
  background: linear-gradient(170deg, rgba(255, 212, 105, 0.95), rgba(255, 176, 32, 0.8));
  box-shadow:
    inset 0 0 0 1.5px rgba(255, 255, 255, 0.6),
    0 10px 28px rgba(255, 176, 32, 0.4);
}

.podium .medal {
  font-size: clamp(19px, 4.4cqh, 34px);
  line-height: 1;
}

.podium .who {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-display);
  font-size: clamp(11px, 2.4cqh, 16px);
  font-weight: 600;
}

.podium .pts {
  font-size: clamp(10px, 2.2cqh, 14px);
  font-variant-numeric: tabular-nums;
  color: var(--ink-faint);
}

.podium .p1 .pts {
  color: rgba(42, 26, 2, 0.75);
}

.podium .place.me {
  outline: 2.5px solid var(--leaf);
  outline-offset: 2px;
}

.rank-list {
  display: grid;
  gap: clamp(4px, 0.9cqh, 8px);
  margin: 0;
  padding: 0;
  list-style: none;
  text-align: left;
}

.rank-list li {
  display: grid;
  grid-template-columns: clamp(22px, 4cqw, 34px) 1fr auto;
  gap: clamp(6px, 1.2cqw, 12px);
  align-items: center;
  padding: clamp(6px, 1.4cqh, 12px) clamp(8px, 1.6cqw, 14px);
  border-radius: var(--r-sm);
  background: var(--panel-sunk);
  box-shadow: inset 0 0 0 1.5px var(--line);
  font-size: clamp(11px, 2.4cqh, 16px);
  animation: riseIn 0.4s var(--ease-out) backwards;
}

.rank-list li:nth-child(1) { animation-delay: 0.05s; }
.rank-list li:nth-child(2) { animation-delay: 0.09s; }
.rank-list li:nth-child(3) { animation-delay: 0.13s; }
.rank-list li:nth-child(4) { animation-delay: 0.17s; }
.rank-list li:nth-child(5) { animation-delay: 0.21s; }
.rank-list li:nth-child(6) { animation-delay: 0.25s; }
.rank-list li:nth-child(7) { animation-delay: 0.29s; }

.rank-list .rank {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}

.rank-list .who {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}

.rank-list .who small {
  display: block;
  font-size: 0.78em;
  font-weight: 600;
  color: var(--ink-faint);
}

.rank-list .pts {
  font-family: var(--font-display);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.rank-list li.me {
  background: linear-gradient(120deg, rgba(255, 212, 105, 0.7), rgba(255, 176, 32, 0.42));
  box-shadow:
    inset 0 0 0 1.5px rgba(255, 176, 32, 0.7),
    0 6px 18px rgba(255, 176, 32, 0.3);
}

.rank-list li.me .rank,
.rank-list li.me .who small {
  color: rgba(42, 26, 2, 0.7);
}

/* ---------- Namenseingabe ---------- */

.name-form {
  display: flex;
  justify-content: center;
  gap: clamp(6px, 1.2cqw, 12px);
  margin-top: clamp(8px, 2cqh, 16px);
}

.name-form input {
  width: min(58%, 260px);
  min-height: clamp(38px, 8cqh, 58px);
  padding: 0 clamp(12px, 2.4cqw, 20px);
  border: 0;
  border-radius: var(--r-pill);
  background: var(--panel-sunk);
  box-shadow: inset 0 0 0 1.5px var(--line-strong);
  font-family: var(--font-display);
  /* 16px verhindert, dass iOS beim Tippen ins Feld hineinzoomt. */
  font-size: max(16px, clamp(13px, 2.9cqh, 19px));
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.name-form input:focus {
  outline: 3px solid var(--sun);
  outline-offset: 1px;
}

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

.settings-grid {
  display: grid;
  gap: clamp(8px, 1.8cqh, 16px);
  margin-top: clamp(8px, 2cqh, 16px);
  text-align: left;
}

.settings-grid label {
  display: grid;
  gap: 6px;
  font-family: var(--font-display);
  font-size: clamp(11px, 2.4cqh, 16px);
}

.settings-grid input[type="range"] {
  width: 100%;
  height: 30px;
  accent-color: var(--sun);
}

.settings-grid select {
  min-height: clamp(36px, 7cqh, 52px);
  padding: 0 12px;
  border: 0;
  border-radius: var(--r-md);
  background: var(--panel-sunk);
  box-shadow: inset 0 0 0 1.5px var(--line);
  font-size: max(16px, clamp(12px, 2.6cqh, 17px));
}

.note {
  margin: clamp(8px, 1.8cqh, 14px) 0 0;
  padding: clamp(7px, 1.6cqh, 13px) clamp(9px, 1.8cqw, 16px);
  border-radius: var(--r-md);
  background: var(--panel-sunk);
  box-shadow: inset 0 0 0 1.5px var(--line);
  font-size: clamp(10px, 2.1cqh, 14px);
  line-height: 1.45;
  color: var(--ink-soft);
  text-align: left;
}

.empty {
  padding: clamp(14px, 3.4cqh, 30px) 10px;
  color: var(--ink-faint);
  font-size: clamp(12px, 2.6cqh, 17px);
}

.empty .big {
  display: block;
  font-size: clamp(28px, 7cqh, 52px);
  margin-bottom: 6px;
}

:focus-visible {
  outline: 3px solid var(--sky-deep);
  outline-offset: 2px;
}

/* ---------- Kleiner Rahmen ----------
   Auf dem quer gehaltenen iPhone ist der Rahmen nur gut 380 Punkte hoch.
   Dann faellt das Beiwerk weg, damit das Menue ohne Scrollen passt. */

@container shell (max-height: 430px) {
  .hero-dog {
    display: none;
  }

  .card {
    padding: 11px 16px;
  }

  .card p {
    margin: 3px 0 6px;
  }

  .field {
    margin-top: 8px;
  }

  .button-row {
    margin-top: 10px;
  }

  .stat-grid {
    margin-top: 8px;
  }

  .card h1 {
    font-size: clamp(21px, 7.4cqh, 40px);
  }

  .level-card .art {
    font-size: clamp(15px, 3.4cqh, 24px);
  }

  /* Die Bestzeit steht im grossen Menue - hier fehlt der Platz. */
  .level-card .best {
    display: none;
  }
}
