/* ---------------------------------------------------------------
   Poopie Slider - UI Styles
   Alles was hier steht dient nur den Overlays (Menue, HUD, Game Over).
   Das Spiel selbst wird komplett auf dem <canvas> gezeichnet.
   --------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0d0a05;
}

body {
  /* iOS: verhindert das "Gummiband"-Scrollen und die Pull-to-Refresh-Geste */
  position: fixed;
  inset: 0;
  overscroll-behavior: none;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  font-family: "Trebuchet MS", "Segoe UI", system-ui, -apple-system, sans-serif;
  color: #fff;
}

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

/* ---- Overlay-Grundgeruest ------------------------------------- */

#ui {
  position: absolute;
  inset: 0;
  /* Klicks gehen standardmaessig durch zum Canvas; nur Buttons fangen sie ab. */
  pointer-events: none;
}

.layer {
  position: absolute;
  inset: 0;
  padding: calc(env(safe-area-inset-top, 0px) + 14px)
           calc(env(safe-area-inset-right, 0px) + 16px)
           calc(env(safe-area-inset-bottom, 0px) + 18px)
           calc(env(safe-area-inset-left, 0px) + 16px);
}

/* Muss `!important` sein: `#hud { display:flex }` weiter unten hat als
   ID-Regel die hoehere Spezifitaet und wuerde sonst gewinnen. */
[hidden] { display: none !important; }

/* Menue + Game Over: mittig gestapelt, mit abdunkelndem Hintergrund */
.panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
  background: radial-gradient(ellipse at center, rgba(10,7,3,.72) 0%, rgba(10,7,3,.92) 100%);
  animation: fade .25s ease-out;
}

@keyframes fade { from { opacity: 0 } to { opacity: 1 } }

/* ---- Titel ---------------------------------------------------- */

.title {
  margin: 0;
  font-size: clamp(34px, 12vmin, 76px);
  line-height: .92;
  font-weight: 900;
  letter-spacing: -.02em;
  text-transform: uppercase;
  color: #c98a3f;
  text-shadow: 0 3px 0 #6b451c, 0 6px 18px rgba(0,0,0,.6);
}
.title span {
  display: block;
  color: #f4e2b8;
  text-shadow: 0 3px 0 #7a5a2a, 0 6px 18px rgba(0,0,0,.6);
}

.tag {
  margin: 2px 0 14px;
  font-size: clamp(12px, 3.6vmin, 17px);
  color: #bda87f;
  font-style: italic;
}

/* ---- Buttons -------------------------------------------------- */

.btn {
  pointer-events: auto;
  appearance: none;
  border: 0;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .05em;
  font-size: clamp(15px, 4.2vmin, 21px);
  color: #3a2409;
  padding: 14px 40px;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffd479 0%, #e0a13c 100%);
  box-shadow: 0 5px 0 #96631d, 0 10px 22px rgba(0,0,0,.45);
  transition: transform .06s ease, box-shadow .06s ease;
  touch-action: manipulation;
}
.btn:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 #96631d, 0 4px 12px rgba(0,0,0,.45);
}

.icon-btn {
  pointer-events: auto;
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  right: calc(env(safe-area-inset-right, 0px) + 10px);
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  font-size: 19px;
  line-height: 1;
  color: #fff;
  background: rgba(0,0,0,.38);
  backdrop-filter: blur(4px);
  touch-action: manipulation;
}
.icon-btn:active { transform: scale(.92); }
.icon-btn.off { opacity: .45; }

/* ---- Hinweise / Bestwert -------------------------------------- */

.hint {
  margin: 16px 0 0;
  max-width: 30ch;
  font-size: clamp(11px, 3.2vmin, 15px);
  line-height: 1.55;
  color: #cdbb96;
}
.hint b { color: #ffd479; }

.best {
  margin: 6px 0 0;
  font-size: clamp(11px, 3.2vmin, 15px);
  color: #9a8763;
}
.best b { color: #e6d3ab; }

/* ---- HUD waehrend des Spiels ---------------------------------- */

#hud {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  background: none;
}

.hud-score {
  display: flex;
  align-items: baseline;
  gap: 7px;
  font-size: clamp(26px, 8vmin, 46px);
  font-weight: 900;
  line-height: 1;
  color: #fff;
  text-shadow: 0 2px 0 rgba(0,0,0,.5), 0 4px 14px rgba(0,0,0,.6);
}

/* Multiplikator taucht erst ab drei Treffern in Folge auf */
.streak {
  font-size: .42em;
  padding: 3px 7px;
  border-radius: 999px;
  background: #1d7f9c;
  color: #d8f6ff;
  box-shadow: 0 2px 8px rgba(0,0,0,.45);
  animation: pop .35s ease-out;
}

.hud-lives {
  display: flex;
  gap: 5px;
  margin-top: 8px;
  margin-right: 52px; /* Platz fuer den Ton-Button */
}
.hud-lives i {
  width: clamp(11px, 3vmin, 15px);
  height: clamp(11px, 3vmin, 15px);
  border-radius: 50%;
  background: #e8564a;
  box-shadow: 0 2px 6px rgba(0,0,0,.5), inset 0 -2px 0 rgba(0,0,0,.25);
}
.hud-lives i.spent {
  background: rgba(255,255,255,.16);
  box-shadow: none;
}

/* ---- Game Over ------------------------------------------------ */

.over-title {
  margin: 0 0 4px;
  font-size: clamp(26px, 9vmin, 54px);
  font-weight: 900;
  text-transform: uppercase;
  color: #f4e2b8;
  text-shadow: 0 3px 0 #6b451c, 0 6px 18px rgba(0,0,0,.6);
}

.score-row {
  display: flex;
  gap: 12px;
  margin: 6px 0 2px;
}
.score-box {
  min-width: 108px;
  padding: 10px 14px;
  border-radius: 14px;
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.1);
}
.score-label {
  display: block;
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: #a89170;
  margin-bottom: 3px;
}
.score-val {
  font-size: clamp(17px, 5vmin, 26px);
  font-weight: 900;
}

.total {
  margin-top: 8px;
  font-size: clamp(12px, 3.4vmin, 16px);
  letter-spacing: .1em;
  text-transform: uppercase;
  color: #a89170;
}
.total b {
  display: block;
  margin-top: 2px;
  font-size: clamp(30px, 10vmin, 52px);
  letter-spacing: -.01em;
  color: #ffd479;
  text-shadow: 0 3px 0 #8a5b1c, 0 6px 16px rgba(0,0,0,.5);
}

#over .btn { margin-top: 18px; }

/* ---- Wenig Hoehe (Querformat, kleine Geraete) ------------------
   Nur die Abstaende zusammenziehen - die Schriftgroessen regelt
   bereits vmin. Sonst rutscht der Button aus dem Bild. */

@media (max-height: 520px) {
  .panel { gap: 4px; }
  .tag { margin-bottom: 4px; }
  .hint { margin-top: 6px; line-height: 1.4; }
  .score-row { margin: 2px 0 0; }
  .score-box { padding: 6px 12px; }
  .total { margin-top: 2px; }
  .btn { padding: 10px 32px; }
  #over .btn { margin-top: 8px; }
}

/* Kurzer Aufblitz, wenn ein neuer Rekord faellt */
.record {
  color: #7fe07f !important;
  animation: pop .5s ease-out;
}
@keyframes pop {
  0%   { transform: scale(1) }
  40%  { transform: scale(1.18) }
  100% { transform: scale(1) }
}
