/* Bust Your Boss – Arcade-Optik: Cremeweiß, dicke Tinte, knallige Akzente */

@font-face {
  font-family: "Bungee";
  src: url("../fonts/bungee-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Rubik";
  src: url("../fonts/rubik-latin-500-normal.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: "Rubik";
  src: url("../fonts/rubik-latin-700-normal.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: "Rubik";
  src: url("../fonts/rubik-latin-800-normal.woff2") format("woff2");
  font-weight: 800;
  font-display: swap;
}

:root {
  --cream: #FFF4E0;
  --paper: #FFFBF3;
  --ink: #1E1B2E;
  --ink-soft: #4A4560;
  --tomato: #FF5436;
  --sun: #FFC233;
  --teal: #17B5A3;
  --blue: #3B5BFF;
  --pink: #FF6FB1;
  --grape: #6C4BD8;

  --border: 3px;
  --shadow: 4px 4px 0 var(--ink);
  --shadow-sm: 3px 3px 0 var(--ink);
  --radius: 14px;
  --gutter: clamp(10px, 2vw, 22px);

  --font-display: "Bungee", "Arial Black", Impact, sans-serif;
  --font-ui: "Rubik", system-ui, -apple-system, "Segoe UI", sans-serif;

  color-scheme: light;
}

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

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

body {
  background-color: var(--cream);
  background-image: radial-gradient(rgba(30, 27, 46, 0.07) 1.2px, transparent 1.4px);
  background-size: 18px 18px;
  color: var(--ink);
  font-family: var(--font-ui);
  font-weight: 500;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

button,
input { font: inherit; color: inherit; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- Layout ---------- */

.app {
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  grid-template-areas: "top" "stage" "controls" "foot";
  gap: clamp(8px, 1.4vh, 14px);
  padding:
    max(var(--gutter), env(safe-area-inset-top))
    max(var(--gutter), env(safe-area-inset-right))
    max(8px, env(safe-area-inset-bottom))
    max(var(--gutter), env(safe-area-inset-left));
  max-width: 1500px;
  margin: 0 auto;
}

.topbar {
  grid-area: top;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

/* ---------- Logo ---------- */

.logo {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  line-height: 0.9;
  display: flex;
  align-items: baseline;
  gap: 0.18em;
  font-size: clamp(20px, 3.1vw, 40px);
  letter-spacing: 0.01em;
  white-space: nowrap;
  user-select: none;
}
.logo span {
  display: inline-block;
  -webkit-text-stroke: 0;
  text-shadow: 3px 3px 0 var(--ink);
}
.logo__bust { color: var(--tomato); transform: rotate(-4deg); }
.logo__your {
  font-size: 0.48em;
  color: var(--paper);
  background: var(--ink);
  padding: 0.28em 0.38em 0.2em;
  border-radius: 6px;
  text-shadow: none !important;
  transform: translateY(-0.35em) rotate(3deg);
}
.logo__boss { color: var(--sun); transform: rotate(2deg); }

/* ---------- Anzeigen ---------- */

.scoreboard {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.stat {
  background: var(--ink);
  color: var(--paper);
  border-radius: 12px;
  padding: 6px 12px 7px;
  min-width: 78px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  box-shadow: 3px 3px 0 rgba(30, 27, 46, 0.25);
}
.stat__label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.75;
}
.stat__value {
  font-family: var(--font-display);
  font-size: clamp(18px, 2.3vw, 28px);
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
  color: var(--sun);
  display: block;
}
.stat--score { min-width: 112px; }
.stat--score .stat__value { color: var(--sun); }
.stat--record .stat__value { color: var(--teal); }
.stat--throws .stat__value { color: var(--pink); }
.stat--level .stat__value { color: #8FD3FF; }
.stat--level { min-width: 64px; }
.stat--throws { min-width: 64px; }

.stat__value.is-bump { animation: bump 0.32s cubic-bezier(.3, 1.8, .5, 1); }
@keyframes bump {
  0% { transform: scale(1); }
  40% { transform: scale(1.22); }
  100% { transform: scale(1); }
}

/* ---------- Arena ---------- */

.stage {
  grid-area: stage;
  position: relative;
  min-height: 0;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.arena {
  display: block;
  border: 4px solid var(--ink);
  border-radius: 20px;
  box-shadow: 6px 6px 0 var(--ink);
  background: #FDEBCB;
  touch-action: none;
  cursor: default;
  max-width: 100%;
  max-height: 100%;
}
.arena { cursor: crosshair; }
.arena.is-aiming,
.arena.is-panning { cursor: grabbing; }

.coach {
  position: absolute;
  left: 50%;
  top: 18px;
  max-width: min(640px, calc(100% - 24px));
  white-space: normal;
  text-align: center;
  z-index: 1;
  transform: translateX(-50%);
  margin: 0;
  padding: 8px 14px 8px 10px;
  background: var(--paper);
  border: var(--border) solid var(--ink);
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
  font-weight: 800;
  font-size: clamp(13px, 1.5vw, 16px);
  white-space: nowrap;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.coach__hand {
  display: inline-block;
  margin-right: 4px;
  animation: nudge 1.2s ease-in-out infinite;
}
.coach.is-hidden {
  opacity: 0;
  transform: translateX(-50%) translateY(-8px);
}
@keyframes nudge {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(-4px, 3px); }
}

.toast {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  background: var(--ink);
  color: var(--paper);
  font-weight: 700;
  font-size: 14px;
  padding: 8px 14px;
  border-radius: 999px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  white-space: nowrap;
  max-width: calc(100% - 32px);
  overflow: hidden;
  text-overflow: ellipsis;
}
.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---------- Inventar ---------- */

.inventory {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  padding: 6px;
  background: rgba(30, 27, 46, 0.82);
  border-radius: 16px;
  max-width: calc(100% - 24px);
  overflow-x: auto;
  scrollbar-width: none;
  z-index: 2;
}
.inventory::-webkit-scrollbar { display: none; }
.inventory[hidden] { display: none; }
.slot {
  position: relative;
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  border: 3px solid var(--ink);
  border-radius: 12px;
  background: var(--paper);
  cursor: pointer;
  padding: 0;
  display: grid;
  place-items: center;
  touch-action: manipulation;
  transition: transform 0.1s ease, background-color 0.15s ease;
}
.slot__icon { font-size: 24px; line-height: 1; font-family: system-ui, "Apple Color Emoji", "Segoe UI Emoji", sans-serif; }
.slot__key {
  position: absolute;
  right: 2px;
  bottom: 0;
  font-family: var(--font-display);
  font-size: 10px;
  color: var(--ink-soft);
}
.slot:hover { background: #FFF0CF; }
.slot.is-active {
  background: var(--sun);
  transform: translateY(-3px);
  box-shadow: 0 3px 0 var(--ink);
}
.slot.is-locked {
  background: #4A4560;
  color: var(--paper);
  cursor: not-allowed;
  border-style: dashed;
  border-color: #8C87A3;
}
.slot.is-locked .slot__icon { font-family: var(--font-display); font-size: 20px; color: #CFCBE0; }
.slot:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }

@media (max-width: 760px) {
  .slot { width: 40px; height: 40px; border-radius: 10px; }
  .slot__icon { font-size: 20px; }
}

/* ---------- Rundenende ---------- */

.roundover {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(30, 27, 46, 0.38);
  border-radius: 20px;
  z-index: 3;
}
.roundover[hidden] { display: none; }

.roundover__card {
  background: var(--paper);
  border: 4px solid var(--ink);
  border-radius: 22px;
  box-shadow: 8px 8px 0 var(--ink);
  padding: clamp(18px, 3vw, 30px) clamp(20px, 4vw, 40px);
  text-align: center;
  max-width: 440px;
  width: 100%;
  animation: pop-in 0.42s cubic-bezier(.3, 1.6, .5, 1);
}
.roundover__kicker {
  margin: 0;
  display: inline-block;
  font-family: var(--font-display);
  font-size: clamp(14px, 2vw, 18px);
  background: var(--tomato);
  color: var(--paper);
  padding: 6px 12px 4px;
  border: var(--border) solid var(--ink);
  border-radius: 10px;
  transform: rotate(-3deg);
}
.roundover__title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(30px, 6vw, 54px);
  line-height: 1;
  margin: 14px 0 6px;
}
.roundover__title span { color: var(--tomato); text-shadow: 3px 3px 0 var(--ink); }
.roundover__badge {
  display: inline-block;
  margin: 2px 0 6px;
  background: var(--sun);
  border: var(--border) solid var(--ink);
  border-radius: 999px;
  padding: 4px 12px;
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  animation: wiggle 1.4s ease-in-out infinite;
}
.roundover__badge[hidden] { display: none; }
.roundover__line {
  margin: 4px 0 18px;
  color: var(--ink-soft);
  font-weight: 700;
}
.roundover__actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

@keyframes pop-in {
  0% { transform: scale(0.7) rotate(-3deg); opacity: 0; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}
@keyframes wiggle {
  0%, 100% { transform: rotate(-3deg); }
  50% { transform: rotate(3deg); }
}

.scoreform { margin: 0 0 14px; text-align: left; }
.scoreform[hidden], .scores[hidden] { display: none; }
.scoreform label { display: block; font-weight: 800; font-size: 14px; margin-bottom: 6px; }
.scoreform__row { display: flex; gap: 8px; }
.scoreform input {
  flex: 1;
  min-width: 0;
  min-height: 46px;
  padding: 8px 12px;
  border: var(--border) solid var(--ink);
  border-radius: 12px;
  background: #FFFFFF;
  font-weight: 700;
  font-size: 16px;
}
.scoreform input:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
.scores { margin: 0 0 16px; text-align: left; }
.scores__title { margin: 0 0 6px; font-family: var(--font-display); font-size: 16px; }
.scores__list {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: rank;
  max-height: 34vh;
  overflow: auto;
  border: var(--border) solid var(--ink);
  border-radius: 12px;
  background: #FFFFFF;
}
.scores__list li {
  counter-increment: rank;
  display: flex;
  gap: 10px;
  align-items: baseline;
  padding: 6px 12px;
  font-weight: 700;
  border-bottom: 2px solid #F2E6CF;
}
.scores__list li:last-child { border-bottom: 0; }
.scores__list li::before { content: counter(rank) "."; font-family: var(--font-display); min-width: 28px; color: var(--tomato); }
.scores__list li .n { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scores__list li .s { font-family: var(--font-display); font-variant-numeric: tabular-nums; }
.scores__list li.is-new { background: var(--sun); }
.roundover__card { max-height: calc(100% - 16px); overflow: auto; }

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

.controls {
  grid-area: controls;
  display: flex;
  justify-content: center;
  gap: clamp(8px, 1.2vw, 14px);
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 10px 18px;
  background: var(--paper);
  border: var(--border) solid var(--ink);
  border-radius: 12px;
  box-shadow: var(--shadow);
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0.01em;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  transition: transform 0.08s ease, box-shadow 0.08s ease, background-color 0.15s ease;
}
.btn svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}
.btn:hover { background: #FFF0CF; }
.btn:active {
  transform: translate(3px, 3px);
  box-shadow: 1px 1px 0 var(--ink);
}
.btn:focus-visible,
.iconbtn:focus-visible,
.crop__canvas:focus-visible,
.drop:focus-within {
  outline: 3px solid var(--blue);
  outline-offset: 3px;
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: var(--shadow-sm);
}

.btn--primary { background: var(--sun); }
.btn--primary:hover { background: #FFD25E; }

.btn--ghost {
  background: transparent;
  box-shadow: none;
  border-color: transparent;
  text-decoration: underline;
  text-underline-offset: 3px;
  padding-inline: 8px;
}
.btn--ghost:hover { background: rgba(30, 27, 46, 0.06); }
.btn--ghost:active { transform: none; box-shadow: none; }

.btn--sound .icon-off { display: none; }
.btn--sound[aria-pressed="false"] .icon-on { display: none; }
.btn--sound[aria-pressed="false"] .icon-off { display: block; }
.btn--sound[aria-pressed="false"] { background: #EDE6D8; }

.iconbtn {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: var(--border) solid var(--ink);
  border-radius: 10px;
  background: var(--paper);
  cursor: pointer;
  padding: 0;
}
.iconbtn svg {
  width: 20px; height: 20px;
  fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round;
}

.footnote {
  grid-area: foot;
  margin: 0;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-soft);
}

.linkbtn {
  background: none;
  border: 0;
  padding: 2px 4px;
  font: inherit;
  font-weight: 800;
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.linkbtn:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; border-radius: 4px; }

/* ---------- Foto-Dialog ---------- */

.photo {
  border: 4px solid var(--ink);
  border-radius: 22px;
  box-shadow: 8px 8px 0 var(--ink);
  background: var(--paper);
  padding: 0;
  width: min(440px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  color: var(--ink);
  overflow: auto;
}
.photo::backdrop {
  background: rgba(30, 27, 46, 0.55);
}
.photo[open] { animation: pop-in 0.32s cubic-bezier(.3, 1.5, .5, 1); }

.photo__inner {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px;
}
.photo__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.photo__head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 22px;
  line-height: 1.1;
}

.drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 26px 16px;
  border: 3px dashed var(--ink);
  border-radius: 16px;
  background: #FFF0CF;
  cursor: pointer;
  text-align: center;
  transition: background-color 0.15s ease, transform 0.15s ease;
}
.drop:hover,
.drop.is-over { background: #FFE2A0; }
.drop.is-over { transform: scale(1.02); }
.drop__icon {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border: var(--border) solid var(--ink);
  border-radius: 50%;
  background: var(--sun);
  box-shadow: var(--shadow-sm);
}
.drop__icon svg {
  width: 28px; height: 28px;
  fill: none; stroke: var(--ink); stroke-width: 2.2; stroke-linejoin: round;
}
.drop__title { font-weight: 800; font-size: 17px; margin-top: 6px; }
.drop__hint { font-size: 13px; color: var(--ink-soft); }
.drop[hidden] { display: none; }

.crop {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.crop[hidden] { display: none; }
.crop__canvas {
  width: min(300px, 72vw);
  height: min(300px, 72vw);
  border: var(--border) solid var(--ink);
  border-radius: 16px;
  background: #2A2640;
  touch-action: none;
  cursor: grab;
}
.crop__canvas.is-dragging { cursor: grabbing; }
.crop__zoom {
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(300px, 72vw);
  font-weight: 800;
  font-size: 14px;
}
.crop__zoom input { flex: 1; accent-color: var(--tomato); min-height: 32px; }
.crop__hint { margin: 0; font-size: 13px; color: var(--ink-soft); font-weight: 700; }

.photo__error {
  margin: 0;
  padding: 10px 12px;
  background: #FFE1DB;
  border: var(--border) solid var(--tomato);
  border-radius: 12px;
  font-weight: 700;
  font-size: 14px;
}
.photo__error[hidden] { display: none; }

.photo__foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.photo__foot-right { display: flex; gap: 10px; margin-left: auto; }
.photo__foot-right .btn[hidden] { display: none; }
.photo__privacy {
  margin: 0;
  font-size: 12px;
  color: var(--ink-soft);
  font-weight: 700;
  text-align: center;
}

/* ---------- Responsiv ---------- */

@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; gap: 8px; }
  .logo { font-size: 24px; }
  .scoreboard { gap: 6px; }
  .stat { padding: 4px 9px 5px; min-width: 60px; border-radius: 10px; }
  .stat--score { min-width: 84px; }
  .stat__label { font-size: 9.5px; }
  .stat__value { font-size: 19px; }
  .arena { border-width: 3px; border-radius: 16px; box-shadow: 4px 4px 0 var(--ink); }
  .controls {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 7px;
  }
  .btn { min-height: 52px; padding: 6px 4px; flex-direction: column; gap: 3px; font-size: 12px; line-height: 1.1; border-radius: 12px; box-shadow: var(--shadow-sm); }
  .controls .btn span { white-space: normal; text-align: center; overflow-wrap: anywhere; }
  .coach { font-size: 12.5px; white-space: normal; text-align: center; padding: 6px 12px; }
  .roundover__actions .btn,
  .photo__foot .btn { flex-direction: row; font-size: 14px; padding: 8px 14px; min-height: 46px; }
}

@media (max-width: 380px) {
  .logo { font-size: 20px; }
  .stat--score { min-width: 72px; }
  .controls .btn { font-size: 11px; }
}

/* Kurze Querformat-Handys: Steuerung an die Seite */
@media (max-height: 520px) and (orientation: landscape) {
  .app {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto minmax(0, 1fr) auto;
    grid-template-areas: "top top" "stage controls" "foot foot";
    gap: 8px;
  }
  .logo { font-size: 20px; }
  .stat { padding: 3px 9px 4px; }
  .stat__value { font-size: 17px; }
  .controls {
    display: flex;
    flex-direction: column;
    justify-content: center;
    flex-wrap: nowrap;
    gap: 7px;
  }
  .controls .btn { min-height: 44px; padding: 4px 10px; font-size: 12px; flex-direction: row; justify-content: flex-start; }
  .footnote { font-size: 11px; }
}

/* Reduzierte Bewegung: dekorative Animationen aus */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .coach__hand,
  .roundover__badge { animation: none !important; }
}
