/* Eichhörnchensprung - eichhoernchen.herrsack.de */

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

:root {
  --wald: #4d7a4a;
  --fell: #b5532a;
  --text: #2b1d14;
  --text-leise: #5e4b3b;
  --karte: rgba(255, 250, 238, 0.95);
  --akzent: #d9622b;
  --fokus: #d9622b;
  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(--text);
  background: linear-gradient(#5f8f5a, #2f4f31);
  display: grid;
  place-items: center;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

.rahmen {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  background: var(--wald);
}

@media (min-width: 900px) and (min-height: 620px) {
  .rahmen {
    width: min(1180px, calc(100vw - 48px));
    height: min(760px, calc(100dvh - 48px));
    border-radius: 26px;
    box-shadow: 0 18px 50px rgba(20, 30, 15, 0.45);
  }
}

.buehne { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.ansicht { position: absolute; inset: 0; }

/* --- title ------------------------------------------------------------ */
.titel { display: grid; place-items: center; padding: 16px; }
.karte {
  max-width: min(92vw, 560px);
  padding: 22px 28px 20px;
  border-radius: 22px;
  background: var(--karte);
  box-shadow: 0 10px 30px rgba(20, 30, 15, 0.3);
  text-align: center;
}
.spielname {
  margin: 0;
  font-size: clamp(28px, 5vw, 46px);
  overflow-wrap: anywhere;
  font-weight: 800;
  line-height: 1;
  color: var(--fell);
  letter-spacing: -0.01em;
}
.spielname span { color: var(--wald); }
.untertitel { margin: 10px 0 16px; font-size: 19px; color: var(--text-leise); }
.tastenhilfe { margin: 14px 0 0; font-size: 15px; color: var(--text-leise); }
.beste { margin: 6px 0 0; font-weight: 700; min-height: 1.2em; }
.zurueck {
  position: absolute;
  left: 16px;
  bottom: 12px;
  color: #fff;
  font-weight: 700;
  text-decoration: none;
  opacity: 0.85;
}
.zurueck:hover { opacity: 1; text-decoration: underline; }

kbd {
  display: inline-block;
  min-width: 1.6em;
  padding: 0 0.35em;
  border-radius: 6px;
  border: 1px solid rgba(43, 29, 20, 0.3);
  background: #fff;
  font: inherit;
  font-size: 0.85em;
  line-height: 1.4;
}
.knopf kbd.taste { margin-left: 0.4em; font-size: 0.7em; opacity: 0.8; }

/* --- buttons ---------------------------------------------------------- */
.knopf {
  font: inherit;
  font-weight: 700;
  font-size: 19px;
  padding: 10px 22px;
  border: 0;
  border-radius: 999px;
  background: #fff8ea;
  color: var(--text);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.15);
  cursor: pointer;
}
.knopf.haupt { background: var(--akzent); color: #fff; font-size: 22px; padding: 12px 32px; }
.knopf.haupt kbd { background: rgba(255, 255, 255, 0.22); border-color: rgba(255, 255, 255, 0.55); color: #fff; }
.knopf:hover { filter: brightness(1.05); }
.knopf:focus-visible, a:focus-visible, .pausenknopf:focus-visible { outline: 3px solid var(--fokus); outline-offset: 3px; }
.knopfreihe { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 14px; }
.schalter { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin: 10px 0 0; }
.knopf.mini { font-size: 0.9rem; padding: 0.35em 0.9em 0.25em; min-height: 40px; }
.knopf.mini[aria-pressed="false"][data-aktion="ton"] { opacity: 0.7; }
[data-ruhig] * { transition: none !important; animation: none !important; }

/* --- game ------------------------------------------------------------- */
.spiel { pointer-events: none; }
.hud {
  /* top left, so knot holes on the trunk in the middle are never hidden */
  position: absolute;
  top: 10px;
  left: max(12px, env(safe-area-inset-left));
  display: flex;
  gap: 10px;
  align-items: center;
  margin: 0;
  white-space: nowrap;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.hoehe, .trage {
  padding: 2px 16px;
  border-radius: 999px;
  background: rgba(255, 250, 238, 0.88);
  font-size: 28px;
}
.trage { display: flex; gap: 8px; align-items: center; padding-left: 12px; }
/* carried nuts: an acorn before the number */
.nuesse::before {
  content: '';
  display: inline-block;
  width: 0.62em;
  height: 0.8em;
  margin-right: 0.25em;
  vertical-align: -0.08em;
  border-radius: 45% 45% 50% 50% / 30% 30% 70% 70%;
  background: linear-gradient(#6b4a2a 0 32%, #c98a3a 32%);
  border: 2px solid var(--text);
}
.nuesse.leer { opacity: 0.45; }
.faktor {
  min-width: 2.1em;
  padding: 0 0.35em;
  border-radius: 10px;
  color: #fff;
  font-size: 0.8em;
  text-align: center;
  background: #5e4b3b;
}
.faktor[data-stufe="2"] { background: #3f8a3a; }
.faktor[data-stufe="3"] { background: #c99a12; }
.faktor[data-stufe="4"] { background: #d9622b; }
.faktor[data-stufe="5"] { background: #c0392b; }
.puls { animation: puls 0.35s ease-out; }
@keyframes puls { 40% { transform: scale(1.3); } }
.pausenknopf {
  position: absolute;
  top: 12px;
  right: 14px;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 250, 238, 0.85);
  font: inherit;
  font-size: 16px;
  cursor: pointer;
  pointer-events: auto;
}

/* --- dialogs ---------------------------------------------------------- */
.schicht {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(20, 30, 15, 0.35);
}
.schicht h2 { margin: 0; font-size: 30px; }
.endstand { margin: 4px 0 0; font-size: 52px; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.ende-info { margin: 2px 0 0; color: var(--text-leise); font-weight: 600; }
.aufteilung { margin: 0; font-size: 18px; font-weight: 700; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* --- leaderboard ------------------------------------------------------------- */
.eintrag { margin: 6px 0 12px; text-align: left; }
.eintrag label { display: block; margin-bottom: 6px; font-weight: 600; }
.eintrag-zeile { display: flex; gap: 8px; }
.eintrag-zeile input { flex: 1; min-width: 0; padding: 8px 12px; border: 2px solid rgba(47, 42, 36, 0.25); border-radius: 12px; font: inherit; }
.eintrag-info { min-height: 1.2em; margin: 6px 0 0; font-size: 15px; }
.eintrag-info.fehler { color: #c0392b; }
.eintrag-info.gut { color: #2e7d32; }
.knopf.klein { font-size: 17px; padding: 8px 16px; }
.liste { margin: 8px 0 14px; padding: 0; list-style: none; min-width: min(80vw, 340px); }
.liste li { display: flex; gap: 10px; padding: 5px 10px; border-radius: 10px; }
.liste li:nth-child(odd) { background: rgba(240, 219, 166, 0.45); }
.liste li.du { background: #ffe08a; font-weight: 800; }
.liste .platz { width: 2em; text-align: right; }
.liste .name { flex: 1; text-align: left; }
.liste .wert { font-weight: 700; }
.liste .hoehe { min-width: 3.5em; text-align: right; color: var(--text-leise); }
.schicht.oben { z-index: 30; }

/* --- store and album --------------------------------------------------------- */
.vorrat, .album { max-width: min(94vw, 600px); max-height: 94vh; overflow-y: auto; background: #fbf4e4; }
.vorrat-stand, .album-stand { margin: 0 0 6px; font-weight: 700; color: var(--text-leise); }
.vorrat-bild { display: block; width: 100%; height: 170px; margin: 4px 0 8px; border-radius: 14px; background: linear-gradient(#d7ecd9, #9ccf9a); }
.laden { display: grid; grid-template-columns: repeat(auto-fill, minmax(9.5em, 1fr)); gap: 6px; }
.ware { display: flex; flex-direction: column; align-items: center; padding: 6px 8px 5px; border: 2px solid rgba(47, 42, 36, 0.25); border-radius: 12px; background: rgba(255, 255, 255, 0.7); font: inherit; font-size: 15px; font-weight: 700; color: var(--text); cursor: pointer; line-height: 1.2; }
.ware:hover { background: #fff; }
.ware .preis { font-size: 13px; font-weight: 600; color: var(--text-leise); }
.ware.besitz .preis { color: #2e7d32; }
.ware[aria-pressed="true"] { border-color: var(--akzent); background: #fff3d6; }
.ware:focus-visible { outline: 3px solid var(--fokus); outline-offset: 2px; }
.laden-info { min-height: 1.2em; margin: 8px 0 4px; font-size: 15px; }
.album-liste { text-align: left; }
.album-liste h3 { margin: 12px 0 6px; font-size: 18px; }
.album-gruppe { display: grid; grid-template-columns: repeat(auto-fill, minmax(15em, 1fr)); gap: 8px; }
.album-karte { display: flex; gap: 10px; align-items: flex-start; padding: 8px; border-radius: 12px; background: rgba(255, 255, 255, 0.7); border: 2px solid rgba(47, 42, 36, 0.12); }
.album-karte canvas { flex: none; width: 64px; height: 64px; border-radius: 10px; background: #e8f2e0; }
.album-karte strong { display: block; }
.album-karte p { margin: 2px 0 0; font-size: 14px; line-height: 1.3; }
.album-karte.fehlt { opacity: 0.55; }
.album-karte.fehlt canvas { filter: brightness(0); opacity: 0.35; }

/* --- step 11: touch -------------------------------------------------------- */
/* html[data-touch] is set by the app after the first touch (or on a touch-first device) */
.touch, .nur-touch { display: none; }
html[data-touch] .touch { display: block; }
html[data-touch] p.nur-touch { display: block; }
html[data-touch] .nur-tasten, html[data-touch] kbd.taste { display: none; }
.touch {
  position: absolute;
  inset: 0;
  z-index: 1;
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  pointer-events: auto;
}
.pausenknopf { z-index: 2; }
.lager-taste {
  position: absolute;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  min-width: 150px;
  min-height: 64px;
  padding: 10px 22px;
  border: 3px solid #fff;
  border-radius: 999px;
  background: var(--akzent);
  color: #fff;
  font: 800 22px "Baloo 2", system-ui, sans-serif;
  box-shadow: 0 4px 12px rgba(40, 25, 15, 0.35);
  touch-action: none;
}
.lager-taste.gedrueckt { filter: brightness(0.9); transform: translateX(-50%) scale(0.96); }
.nur-vorleser { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* phones held sideways: the tree is small, a hint to turn the phone */
.dreh-hinweis { display: none; margin: 6px 0 0; font-weight: 700; color: var(--akzent); }
@media (orientation: landscape) and (max-height: 520px) {
  html[data-touch] .dreh-hinweis { display: block; }
}
