/* Teichtaumel - teichtaumel.herrsack.de */

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

:root {
  --teich: #2b5f6f;
  --teich-dunkel: #183f4b;
  --teich-hell: #e3f1f2;
  --blatt: #4f9f4f;
  --nacht: #14272c;
  --papier: #fbf8f0;
  --gold: #f0b43b;
  --fokus: #ffcf3a;
  --schatten: 0 6px 22px rgba(10, 30, 36, 0.3);
  color-scheme: light;
}

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

html, body { height: 100%; margin: 0; }

body {
  font-family: "Baloo 2", "Trebuchet MS", system-ui, sans-serif;
  color: var(--nacht);
  background: linear-gradient(180deg, #2f5a3a 0%, #23453a 100%);
  display: grid;
  place-items: center;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

/* --- frame ------------------------------------------------------------ */
.rahmen {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  background: #3f6f37;
}

@media (min-width: 900px) and (min-height: 620px) {
  .rahmen {
    width: min(1280px, calc(100vw - 48px));
    height: min(820px, calc(100dvh - 48px));
    border-radius: 26px;
    box-shadow: 0 18px 60px rgba(10, 24, 20, 0.45);
  }
}
@media (min-width: 1500px) and (min-height: 960px) {
  .rahmen { width: min(1600px, calc(100vw - 64px)); height: min(1000px, calc(100dvh - 64px)); }
  html { font-size: 19px; }
}

.buehne {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.ansicht {
  position: absolute;
  inset: 0;
  padding: max(14px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

/* --- buttons -------------------------------------------------------------- */
.knopf {
  font: inherit;
  font-weight: 700;
  font-size: 1.15rem;
  line-height: 1.1;
  color: var(--teich-dunkel);
  background: var(--papier);
  border: 3px solid var(--teich);
  border-radius: 999px;
  padding: 0.55em 1.3em 0.45em;
  min-height: 48px;
  cursor: pointer;
  box-shadow: 0 4px 0 var(--teich-dunkel);
  transition: transform 0.08s ease, box-shadow 0.08s ease, background-color 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  touch-action: manipulation;
}
.knopf:hover { background: var(--teich-hell); }
.knopf:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--teich-dunkel); }
.knopf:focus-visible, .pausenknopf:focus-visible, a:focus-visible {
  outline: 4px solid var(--fokus);
  outline-offset: 3px;
}
.knopf.haupt { color: #fff; background: var(--teich); border-color: var(--teich-dunkel); font-size: 1.4rem; }
.knopf.haupt:hover { background: #357385; }
.knopf.klein { font-size: 1rem; padding: 0.45em 1em 0.35em; min-height: 44px; }
.knopf.mini { font-size: 0.9rem; padding: 0.35em 0.9em 0.25em; min-height: 40px; border-width: 2px; box-shadow: 0 3px 0 var(--teich-dunkel); }
.knopf[aria-pressed="false"][data-aktion="ton"] { color: #66706a; border-color: #9aa59d; box-shadow: 0 3px 0 #7f8a82; }

kbd, .taste {
  font: inherit;
  font-size: 0.72em;
  font-weight: 700;
  line-height: 1;
  padding: 0.25em 0.45em 0.15em;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--teich-dunkel);
  border: 1.5px solid currentColor;
  box-shadow: 0 2px 0 rgba(20, 30, 25, 0.25);
}
.knopf.haupt .taste { background: rgba(255, 255, 255, 0.18); color: #fff; }
/* key hints only where there is a keyboard and a mouse */
.taste, .tastenhinweis { display: none; }
@media (hover: hover) and (pointer: fine) {
  .taste { display: inline-block; }
  .tastenhinweis { display: flex; }
}

/* --- title ------------------------------------------------------------------ */
.titel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  text-align: center;
  background: linear-gradient(180deg, rgba(8, 24, 30, 0.45) 0%, rgba(8, 24, 30, 0.05) 45%, rgba(8, 24, 30, 0.05) 70%, rgba(8, 24, 30, 0.45) 100%);
}
.titel-kopf { margin-top: 2vh; }
.spielname {
  margin: 0;
  font-size: clamp(2.6rem, 9vw, 4.8rem);
  font-weight: 800;
  line-height: 0.95;
  color: #fff;
  letter-spacing: 0.01em;
  text-shadow: 0 4px 0 var(--teich-dunkel), 0 10px 24px rgba(10, 20, 30, 0.45);
}
.spielname span { color: #9be08f; }
.untertitel {
  margin: 0.5em auto 0;
  max-width: 34em;
  font-size: clamp(1rem, 3.3vw, 1.2rem);
  font-weight: 600;
  line-height: 1.3;
  color: #fff;
  text-shadow: 0 2px 6px rgba(10, 20, 30, 0.7);
}
.titel-mitte { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.rekord {
  margin: 4px 0 0;
  font-size: 1.05rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 999px;
  padding: 0.2em 1em 0.1em;
}
.titel-fuss { display: flex; flex-direction: column; align-items: center; gap: 8px; width: 100%; }
.schalter { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.links { display: flex; gap: 6px 18px; flex-wrap: wrap; justify-content: center; font-size: 0.95rem; }
.links a {
  color: var(--nacht);
  font-weight: 600;
  background: rgba(255, 255, 255, 0.85);
  border-radius: 8px;
  padding: 0.1em 0.5em 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.links a:hover { background: #fff; color: var(--teich); }

@media (orientation: landscape) and (max-height: 520px) {
  .titel { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr auto; align-items: center; justify-items: center; gap: 8px; }
  .titel-kopf { margin: 0; }
  .titel-fuss { grid-column: 1 / -1; flex-direction: row; justify-content: center; flex-wrap: wrap; }
  .spielname { font-size: 2.6rem; }
}

/* --- in game ---------------------------------------------------------------- */
.spiel { touch-action: none; cursor: crosshair; }
.hud {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  left: max(12px, env(safe-area-inset-left));
  display: flex;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}
.hud-wert {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #fff;
  background: rgba(10, 30, 36, 0.62);
  border-radius: 999px;
  padding: 4px 14px 2px;
  font-size: 1.15rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.hud-punkte { font-size: 1.5rem; font-weight: 800; padding-right: 6px; }
.faktor {
  display: inline-block;
  min-width: 2.4em;
  text-align: center;
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1;
  padding: 0.25em 0.45em 0.15em;
  border-radius: 999px;
  color: #3d2a00;
  background: #ffe066;
}
.faktor[data-stufe="3"] { background: #ffb347; }
.faktor[data-stufe="4"] { background: #ff8fb1; }
.faktor[data-stufe="5"] { background: #c9a2ff; }
.faktor.aus { color: #d9e4e6; background: rgba(255, 255, 255, 0.18); }
.faktor.faellt { animation: faellt 0.45s ease-out; }
@keyframes faellt {
  0% { transform: scale(1.35); background: #ff7a6b; color: #fff; }
  100% { transform: scale(1); }
}

.uhr {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  color: #fff;
  background: rgba(10, 30, 36, 0.62);
  border-radius: 999px;
  padding: 4px 16px 2px;
  font-size: 1.5rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}
.uhr.knapp { background: rgba(176, 58, 40, 0.88); animation: knapp 0.8s ease-in-out infinite; }
@keyframes knapp {
  0%, 100% { transform: translateX(-50%) scale(1); }
  50% { transform: translateX(-50%) scale(1.12); background: rgba(214, 64, 40, 0.95); }
}
@media (max-width: 560px) {
  @keyframes knapp {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.12); background: rgba(214, 64, 40, 0.95); }
  }
}

@media (max-width: 560px) {
  .hud { flex-direction: column; align-items: flex-start; gap: 4px; }
  .hud-wert { font-size: 1rem; padding: 2px 10px 0; }
  .hud-punkte { font-size: 1.25rem; }
  .uhr { left: auto; right: max(76px, calc(env(safe-area-inset-right) + 76px)); transform: none; font-size: 1.3rem; }
}

.pausenknopf {
  position: absolute;
  top: max(8px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: 3px solid #fff;
  background: rgba(43, 95, 111, 0.88);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: var(--schatten);
}
.pausenknopf:hover { background: var(--teich); }
.pausenknopf svg { width: 24px; height: 24px; fill: currentColor; }

.tastenhinweis {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 12px;
  margin: 0;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px 14px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--nacht);
  pointer-events: none;
}
.tastenhinweis span { background: rgba(255, 255, 255, 0.85); border-radius: 999px; padding: 0.15em 0.8em 0.05em; display: inline-flex; gap: 4px; align-items: center; }

.wischhinweis {
  position: absolute;
  left: 50%;
  bottom: max(16px, calc(env(safe-area-inset-bottom) + 12px));
  transform: translateX(-50%);
  width: min(92%, 340px);
  margin: 0;
  text-align: center;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.25;
  background: rgba(255, 255, 255, 0.92);
  border-radius: 18px;
  padding: 0.6em 1em 0.5em;
  box-shadow: var(--schatten);
  pointer-events: none;
}

.meldung {
  position: absolute;
  left: 50%;
  top: 30%;
  transform: translateX(-50%);
  margin: 0;
  text-align: center;
  font-size: clamp(1.4rem, 5vw, 2.2rem);
  font-weight: 800;
  color: #fff;
  white-space: nowrap;
  text-shadow: 0 3px 0 var(--teich-dunkel), 0 8px 20px rgba(10, 20, 30, 0.5);
  opacity: 0;
  pointer-events: none;
}
.meldung.zeigen { animation: meldung 1.8s ease-out forwards; }
@keyframes meldung {
  0% { opacity: 0; transform: translateX(-50%) scale(0.7); }
  12% { opacity: 1; transform: translateX(-50%) scale(1.05); }
  22% { transform: translateX(-50%) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translateX(-50%) translateY(-10px); }
}

.debug {
  position: absolute;
  left: 14px;
  bottom: 14px;
  margin: 0;
  font: 600 0.85rem/1.3 ui-monospace, monospace;
  background: rgba(0, 0, 0, 0.6);
  color: #9f9;
  padding: 4px 8px;
  border-radius: 6px;
  white-space: pre;
  pointer-events: none;
  z-index: 20;
}

/* --- layers (pause, end) ---------------------------------------------- */
.schicht {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(8, 24, 30, 0.45);
  overflow-y: auto;
  z-index: 10;
}
.karte {
  width: min(100%, 440px);
  background: var(--papier);
  border-radius: 24px;
  padding: 22px 22px 20px;
  box-shadow: var(--schatten);
  text-align: center;
  animation: auf 0.22s ease-out;
}
@keyframes auf { from { opacity: 0; transform: translateY(14px) scale(0.97); } to { opacity: 1; transform: none; } }
.karte h2 { margin: 0 0 6px; font-size: 2rem; line-height: 1.05; color: var(--teich); }
.karte p { margin: 0.3em 0; font-size: 1.1rem; }
.knopfreihe { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 16px; }

.ende-grund { color: #4a5a5e; }
.ende-punkte { font-size: 1.3rem !important; font-weight: 700; }
.ende-punkte strong { font-size: 2.6rem; color: var(--teich-dunkel); font-variant-numeric: tabular-nums; }
.ende-werte { margin: 10px 0 0; display: grid; gap: 4px; text-align: left; }
.ende-werte div { display: flex; justify-content: space-between; gap: 12px; padding: 4px 10px 2px; border-radius: 10px; background: #eef4f2; }
.ende-werte dt { font-weight: 600; }
.ende-werte dd { margin: 0; font-weight: 800; font-variant-numeric: tabular-nums; }

.abzeichen {
  display: inline-block;
  margin: 4px 4px 0 !important;
  padding: 0.2em 0.9em 0.1em;
  border-radius: 999px;
  background: var(--gold);
  color: #432800;
  font-weight: 800;
}

/* --- leaderboard ---------------------------------------------------------------------- */
.schicht.oben { z-index: 12; }
.eintrag { margin-top: 12px; text-align: left; }
.eintrag label { display: block; font-weight: 600; margin-bottom: 6px; }
.eintrag-zeile { display: flex; gap: 8px; }
.eintrag input {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 1.15rem;
  font-weight: 500;
  padding: 0.4em 0.7em 0.3em;
  border: 3px solid var(--teich);
  border-radius: 14px;
  background: #fff;
  color: var(--nacht);
  user-select: text;
  -webkit-user-select: text;
}
.eintrag input:focus-visible { outline: 4px solid var(--fokus); outline-offset: 2px; }
.eintrag-info { font-size: 1rem !important; color: #3f5357; min-height: 1.2em; }
.eintrag-info.fehler { color: #a3222e; font-weight: 600; }
.eintrag-info.gut { color: #11632f; font-weight: 600; }

.liste { margin: 8px 0 0; padding: 0; list-style: none; text-align: left; max-height: 55vh; overflow-y: auto; }
.liste li { display: grid; grid-template-columns: 2.2em 1fr auto; gap: 8px; padding: 6px 10px 4px; border-radius: 10px; font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.liste li:nth-child(odd) { background: #eef4f2; }
.liste li.du { background: #ffeeb0; font-weight: 700; }
.liste .platz { font-weight: 700; color: var(--teich-dunkel); }
.liste .wert { font-weight: 600; }

/* --- storage note ------------------------------------------------------------------- */
.hinweis {
  position: absolute;
  left: 50%;
  bottom: max(14px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(calc(100% - 24px), 560px);
  background: #fff;
  border-radius: 18px;
  padding: 12px 14px;
  box-shadow: var(--schatten);
  display: flex;
  gap: 12px;
  align-items: center;
  z-index: 4;
}
.hinweis p { margin: 0; font-size: 0.98rem; line-height: 1.3; }

.noscript { position: absolute; inset: auto 0 40% 0; text-align: center; font-size: 1.3rem; color: #fff; }

/* --- reduced motion ------------------------------------------------------------------- */
html[data-ruhig] *, html[data-ruhig] *::before, html[data-ruhig] *::after {
  animation: none !important;
  transition: none !important;
}
html[data-ruhig] .meldung.zeigen { opacity: 1; }
