/* Chamäleon-Chaos - chamaeleon.herrsack.de */

@font-face {
  font-family: 'Fredoka';
  src: url('assets/fonts/fredoka-latin.woff2') format('woff2');
  font-weight: 300 700;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Fredoka';
  src: url('assets/fonts/fredoka-latin-ext.woff2') format('woff2');
  font-weight: 300 700;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --nacht: #13261d;
  --dschungel: #1d4b3c;
  --dschungel-dunkel: #0f2e24;
  --blatt: #4ec45c;
  --blatt-dunkel: #2d7d3b;
  --creme: #fbfbf0;
  --zunge: #ff5c92;
  --zunge-dunkel: #b8285c;
  --sonne: #ffd84a;
  --fokus: #ffd84a;
  --schatten: 0 8px 26px rgba(4, 22, 14, 0.4);
  --rund: 18px;
  color-scheme: light;
}

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

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

body {
  font-family: 'Fredoka', 'Trebuchet MS', system-ui, sans-serif;
  color: var(--nacht);
  background: radial-gradient(circle at 50% 30%, #2b6a52 0%, #143a2e 70%, #0c241c 100%);
  display: grid;
  place-items: center;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

/* --- frame ------------------------------------------------------------ */
.rahmen {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  background: var(--dschungel);
}

@media (min-width: 900px) and (min-height: 620px) {
  .rahmen {
    width: min(1280px, calc(100vw - 48px));
    height: min(780px, calc(100dvh - 48px));
    border-radius: 26px;
    box-shadow: 0 18px 60px rgba(0, 0, 0, 0.45);
  }
}
/* big screens and digital boards: use more of the room */
@media (min-width: 1500px) and (min-height: 900px) {
  .rahmen { width: min(1600px, calc(100vw - 64px)); height: min(960px, calc(100dvh - 64px)); }
  html { font-size: 19px; }
}

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

/* Schwarmzeit: the edge glows */
.rahmen::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  opacity: 0;
  box-shadow: inset 0 0 0 0 rgba(255, 120, 60, 0);
}
.rahmen.schwarm::after { opacity: 1; animation: schwarm 0.9s ease-in-out infinite; }
@keyframes schwarm {
  0%, 100% { box-shadow: inset 0 0 18px 4px rgba(255, 120, 60, 0.35); }
  50% { box-shadow: inset 0 0 46px 12px rgba(255, 90, 60, 0.6); }
}

.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: 600;
  font-size: 1.15rem;
  line-height: 1.1;
  color: var(--dschungel-dunkel);
  background: var(--creme);
  border: 3px solid var(--blatt-dunkel);
  border-radius: 999px;
  padding: 0.55em 1.3em 0.5em;
  min-height: 48px;
  cursor: pointer;
  box-shadow: 0 4px 0 var(--dschungel-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: #eaf8dc; }
.knopf:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--dschungel-dunkel); }
.knopf:focus-visible, .pausenknopf:focus-visible, a:focus-visible, input:focus-visible {
  outline: 4px solid var(--fokus);
  outline-offset: 3px;
}
.knopf.haupt { color: #fff; background: var(--zunge); border-color: var(--zunge-dunkel); box-shadow: 0 4px 0 var(--zunge-dunkel); font-size: 1.45rem; padding: 0.5em 1.8em 0.45em; }
.knopf.haupt:hover { background: #ff74a3; }
.knopf.haupt:active { box-shadow: 0 1px 0 var(--zunge-dunkel); }
.knopf.klein { font-size: 1rem; padding: 0.45em 1em 0.4em; min-height: 44px; }
.knopf.mini { font-size: 0.9rem; padding: 0.35em 0.9em 0.3em; min-height: 44px; border-width: 2px; box-shadow: 0 3px 0 var(--dschungel-dunkel); }
.knopf[aria-pressed="false"][data-aktion="ton"] { color: #5d6b63; border-color: #8a9a90; box-shadow: 0 3px 0 #5d6b63; }

kbd, .taste {
  font: inherit;
  font-size: 0.7em;
  font-weight: 600;
  line-height: 1;
  padding: 0.25em 0.45em 0.2em;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--dschungel-dunkel);
  border: 1.5px solid currentColor;
  box-shadow: 0 2px 0 rgba(19, 38, 29, 0.25);
}
.knopf.haupt .taste { background: rgba(255, 255, 255, 0.2); color: #fff; }
/* key hints only where there is a keyboard and a mouse */
.taste { display: none; }
@media (hover: hover) and (pointer: fine) { .taste { display: inline-block; } }

/* --- title ------------------------------------------------------------------ */
.titel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  text-align: center;
  gap: 10px;
}
.titel-kopf { margin-top: 1vh; }
.spielname {
  margin: 0;
  font-size: clamp(2.4rem, 8vw, 4.4rem);
  font-weight: 700;
  line-height: 0.95;
  color: #fff;
  letter-spacing: 0.01em;
  text-shadow: 0 4px 0 var(--dschungel-dunkel), 0 10px 24px rgba(0, 0, 0, 0.35);
}
.spielname span { color: var(--zunge); }
.titel-mitte { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.kurz {
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: 600px;
  padding: 10px 16px 10px 10px;
  border-radius: var(--rund);
  background: rgba(10, 36, 26, 0.7);
  color: #f4fbe9;
  text-align: left;
  box-shadow: var(--schatten);
}
.kurz p { margin: 0; font-size: 1.05rem; line-height: 1.35; }
.kurz-bild { width: 186px; height: 105px; flex: none; border-radius: 12px; background: rgba(40, 110, 80, 0.55); }
.knopfzeile { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.rekord {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 500;
  background: rgba(251, 251, 240, 0.9);
  border-radius: 999px;
  padding: 0.2em 1em 0.15em;
}
.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: 500;
  background: rgba(251, 251, 240, 0.85);
  border-radius: 8px;
  padding: 0.15em 0.5em 0.05em;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.links a:hover { background: #fff; color: var(--dschungel); }

@media (max-width: 560px) {
  .kurz { flex-direction: column; text-align: center; padding: 10px 12px 12px; }
  .kurz-bild { width: 165px; height: 93px; }
  .kurz p { font-size: 0.98rem; }
}
/* landscape phones: title in two columns */
@media (orientation: landscape) and (max-height: 540px) {
  .titel { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: auto 1fr auto; align-items: center; justify-items: center; gap: 6px 14px; }
  .titel-kopf { margin: 0; grid-column: 1; grid-row: 1; }
  .titel-mitte { display: contents; }
  .kurz { grid-column: 1; grid-row: 2; flex-direction: column; text-align: center; padding: 8px 10px; }
  .kurz-bild { width: 150px; height: 85px; }
  .kurz p { font-size: 0.9rem; }
  .titel-mitte > .knopf.haupt { grid-column: 2; grid-row: 1; }
  .titel-mitte > .knopfzeile { grid-column: 2; grid-row: 2; align-self: start; }
  .titel-mitte > .rekord { grid-column: 2; grid-row: 2; align-self: end; }
  .titel-fuss { grid-column: 1 / -1; grid-row: 3; flex-direction: row; justify-content: center; flex-wrap: wrap; }
  .spielname { font-size: 2.3rem; }
}

/* --- in game ---------------------------------------------------------------- */
.spiel { touch-action: none; cursor: crosshair; }
.hud {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  left: max(14px, env(safe-area-inset-left));
  right: max(78px, calc(env(safe-area-inset-right) + 70px));
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: none;
  color: #fff;
  text-shadow: 0 2px 0 rgba(8, 30, 20, 0.8), 0 3px 10px rgba(0, 0, 0, 0.35);
}
.hud-links { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.hud-punkte { display: flex; align-items: baseline; gap: 6px; min-width: 6em; }
.phase {
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.1em 0.7em 0.05em;
  border-radius: 999px;
  background: rgba(8, 30, 20, 0.45);
  white-space: nowrap;
}
.phase[data-phase="mittag"] { background: rgba(170, 120, 10, 0.55); }
.phase[data-phase="regen"] { background: rgba(40, 70, 120, 0.6); }
.phase[data-phase="daemmerung"] { background: rgba(150, 60, 110, 0.6); }
.phase[data-phase="nacht"] { background: rgba(20, 24, 80, 0.75); }
.hud-punkte span { font-size: clamp(1.9rem, 5.5vw, 2.7rem); font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.hud-punkte small { font-size: 1rem; font-weight: 600; }
.hud-mitte {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.uhr {
  position: relative;
  display: flex;
  align-items: baseline;
  gap: 3px;
  padding: 0.05em 0.6em 0;
  border-radius: 999px;
  background: rgba(8, 30, 20, 0.45);
  transition: transform 0.2s ease, background-color 0.2s ease;
}
.uhr span { font-size: clamp(1.9rem, 5.5vw, 2.6rem); font-weight: 700; line-height: 1.05; font-variant-numeric: tabular-nums; }
.uhr small { font-size: 1rem; font-weight: 600; }
.uhr.knapp { background: rgba(214, 48, 49, 0.85); transform: scale(1.18); }
.uhr.knapp span { animation: puls 0.5s ease-in-out infinite alternate; }
@keyframes puls { from { opacity: 1; } to { opacity: 0.7; } }
.bonus {
  position: absolute;
  left: 100%;
  top: 0.1em;
  margin-left: 8px;
  font-size: 1.4rem;
  font-weight: 700;
  color: #fff27a;
  white-space: nowrap;
  opacity: 0;
}
.bonus.minus { color: #ff8a80; }
.bonus.zeigen { animation: bonus 1.4s ease-out forwards; }
@keyframes bonus {
  0% { opacity: 0; transform: scale(0.5); }
  15% { opacity: 1; transform: scale(1.3); }
  30% { transform: scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-10px); }
}

.serie {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.1em 0.75em 0.05em 0.35em;
  border-radius: 999px;
  background: rgba(8, 30, 20, 0.45);
  white-space: nowrap;
}
.serie i, .stufe::before {
  display: inline-block;
  width: 0.95em;
  height: 0.95em;
  border-radius: 50%;
  border: 2px solid #fff;
  background: var(--stufe, #4ec45c);
}
[data-stufe="0"] { --stufe: #4ec45c; }
[data-stufe="1"] { --stufe: #f6d034; }
[data-stufe="2"] { --stufe: #ff922e; }
[data-stufe="3"] { --stufe: #ff60aa; }
[data-stufe="4"] { --stufe: conic-gradient(#ff5d5d, #ffd84a, #6ee36e, #4fc3ff, #b27bff, #ff5d5d); }

.pausenknopf {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  right: max(14px, env(safe-area-inset-right));
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 3px solid #fff;
  background: rgba(29, 75, 60, 0.85);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: var(--schatten);
}
.pausenknopf:hover { background: var(--blatt-dunkel); }
.pausenknopf svg { width: 26px; height: 26px; fill: currentColor; }

.zeichenhinweis, .meldung, .ruf {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  text-align: center;
  pointer-events: none;
}
.zeichenhinweis {
  top: 40%;
  width: min(92%, 380px);
  font-size: 1.2rem;
  font-weight: 600;
  background: rgba(251, 251, 240, 0.92);
  border-radius: var(--rund);
  padding: 0.6em 1em 0.5em;
  box-shadow: var(--schatten);
}
.zeichenhinweis small { font-size: 0.95rem; font-weight: 500; }
.meldung, .ruf {
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  text-shadow: 0 3px 0 var(--dschungel-dunkel), 0 8px 20px rgba(0, 0, 0, 0.4);
  opacity: 0;
}
.meldung { top: 22%; font-size: clamp(1.6rem, 6vw, 2.6rem); }
.meldung.gross { font-size: clamp(2rem, 8vw, 3.4rem); color: #fff6c9; }
.ruf { top: 34%; font-size: clamp(1.5rem, 5vw, 2.2rem); color: #ffe45c; }
.meldung.zeigen, .ruf.zeigen { animation: meldung 1.2s ease-out forwards; }
@keyframes meldung {
  0% { opacity: 0; transform: translateX(-50%) scale(0.6); }
  15% { opacity: 1; transform: translateX(-50%) scale(1.08); }
  25% { transform: translateX(-50%) scale(1); }
  75% { opacity: 1; }
  100% { opacity: 0; transform: translateX(-50%) translateY(-12px); }
}
.fps {
  position: absolute;
  left: 14px;
  bottom: 10px;
  margin: 0;
  max-width: 70%;
  white-space: pre-wrap;
  font: 500 0.8rem/1.3 ui-monospace, monospace;
  background: rgba(0, 0, 0, 0.6);
  color: #9f9;
  padding: 4px 6px;
  border-radius: 6px;
  pointer-events: none;
}

/* --- layers (pause, end, dialogs) ---------------------------------------------- */
.schicht {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(6, 26, 18, 0.45);
  overflow-y: auto;
  z-index: 10;
}
.karte {
  width: min(100%, 460px);
  background: var(--creme);
  border-radius: 24px;
  padding: 22px 22px 20px;
  box-shadow: var(--schatten);
  text-align: center;
  animation: auf 0.22s ease-out;
}
.karte.breit { width: min(100%, 720px); }
.karte.breiter { width: min(100%, 860px); }
.anleitung-satz.mitte { text-align: center; }
@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(--dschungel); }
.karte p { margin: 0.3em 0; font-size: 1.1rem; }
.karte .schalter { margin-top: 14px; }
.knopfreihe { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 16px; }

.ende-satz { color: #43574c; }
.ende-punkte { font-size: 1.4rem !important; font-weight: 600; }
.ende-punkte strong { font-size: 3.2rem; color: var(--zunge-dunkel); line-height: 1; font-variant-numeric: tabular-nums; }
.ende-werte { display: grid; gap: 4px; margin: 10px auto 0; max-width: 320px; text-align: left; }
.ende-werte div { display: flex; justify-content: space-between; gap: 12px; padding: 4px 10px 2px; border-radius: 10px; background: #eef4e4; }
.ende-werte dt { font-weight: 500; color: #43574c; }
.ende-werte dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.stufe { display: inline-flex; align-items: center; gap: 6px; }
.stufe::before { content: ""; border-color: #43574c; }
.abzeichen.neu { background: #bfe8c9; color: #11532a; }
.abzeichen {
  display: inline-block;
  margin: 6px 4px 0 !important;
  padding: 0.2em 0.9em 0.1em;
  border-radius: 999px;
  background: var(--sonne);
  color: #4a3200;
  font-weight: 700;
  animation: hurra 0.6s ease-out 0.2s both;
}
@keyframes hurra { 0% { transform: scale(0.4) rotate(-8deg); opacity: 0; } 60% { transform: scale(1.15) rotate(3deg); opacity: 1; } 100% { transform: none; } }

.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(--blatt-dunkel);
  border-radius: 14px;
  background: #fff;
  color: var(--nacht);
  user-select: text;
  -webkit-user-select: text;
}
.eintrag-info { font-size: 1rem !important; color: #43574c; min-height: 1.2em; }
.eintrag-info.fehler { color: #a3222e; font-weight: 600; }
.eintrag-info.gut { color: #11632f; font-weight: 600; }

.anleitung-satz { text-align: left; line-height: 1.4; }
.tiere { list-style: none; margin: 12px 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 8px; text-align: left; }
.tiere li { display: grid; grid-template-columns: 84px 1fr; gap: 10px; align-items: center; padding: 4px; border-radius: 14px; background: #eef4e4; }
.tiere li.gefahr { background: #ffe7c2; outline: 3px dashed #c97a00; outline-offset: -3px; }
.tiere canvas { width: 84px; height: 64px; border-radius: 10px; background: #2a6650; }
.tiere p { margin: 0; font-size: 1rem; line-height: 1.25; }

.liste { margin: 8px 0 0; padding: 0; list-style: none; text-align: left; max-height: 50vh; 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: #eef4e4; }
.liste li.du { background: #ffeeb0; font-weight: 700; }
.liste .platz { font-weight: 700; color: var(--blatt-dunkel); }
.liste .wert { font-weight: 600; }

/* --- storage note ------------------------------------------------------------------- */
.hinweis {
  position: absolute;
  left: 50%;
  bottom: max(12px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(94%, 520px);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px 10px 16px;
  border-radius: var(--rund);
  background: rgba(251, 251, 240, 0.96);
  box-shadow: var(--schatten);
  z-index: 5;
}
.hinweis p { margin: 0; font-size: 0.95rem; line-height: 1.3; }

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

/* calm mode: no moving decorations */
[data-ruhig] .meldung.zeigen, [data-ruhig] .ruf.zeigen { animation: ruhig 1.2s linear forwards; }
[data-ruhig] .uhr.knapp span, [data-ruhig] .abzeichen, [data-ruhig] .karte { animation: none; }
[data-ruhig] .bonus.zeigen { animation: ruhig 1.4s linear forwards; }
@keyframes ruhig { 0%, 85% { opacity: 1; } 100% { opacity: 0; } }

/* narrow phones: the label goes under the number, so big scores never touch the clock */
@media (max-width: 480px) {
  .hud-punkte { flex-direction: column; align-items: flex-start; gap: 0; min-width: 0; }
  .hud-punkte small { font-size: 0.85rem; }
}

/* --- choosing a chameleon -------------------------------------------------------- */
.wahl { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; margin-top: 10px; max-height: 60vh; overflow-y: auto; padding: 4px; }
.wahl-karte {
  font: inherit;
  border: 3px solid #d3dccb;
  background: #fff;
  border-radius: 16px;
  padding: 8px 8px 6px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  color: var(--nacht);
  text-align: center;
}
.wahl-karte:hover { border-color: var(--blatt-dunkel); }
.wahl-karte:focus-visible { outline: 4px solid var(--fokus); outline-offset: 2px; }
.wahl-karte[aria-pressed="true"] { border-color: var(--blatt-dunkel); background: #eaf8dc; box-shadow: 0 0 0 3px var(--blatt) inset; }
.wahl-karte.besonders { border-color: #e2b84a; }
.wahl-karte.besonders[aria-pressed="true"] { background: #fff4cf; box-shadow: 0 0 0 3px #e2b84a inset; }
.wahl-karte:disabled { cursor: not-allowed; background: #f3f5ef; }
.wahl-karte canvas { width: 160px; height: 96px; border-radius: 10px; background: #2a6650; }
.wahl-karte strong { font-size: 1rem; line-height: 1.15; }
.wahl-karte small { font-size: 0.85rem; line-height: 1.2; color: #4d5e54; }
@media (max-width: 480px) {
  .wahl { grid-template-columns: repeat(2, 1fr); }
  .wahl-karte canvas { width: 100%; height: auto; aspect-ratio: 5 / 3; }
  .phase { font-size: 0.8rem; }
}
