@font-face { font-family: 'Bangers'; src: url('/fonts/bangers.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: 'Fredoka'; src: url('/fonts/fredoka.woff2') format('woff2'); font-weight: 300 700; font-display: swap; }

:root {
  --ink: #1a1020;
  --yellow: #ffd93d;
  --green: #58d13c;
  --red: #ff3b4e;
  --cream: #fff8e1;
  --blue: #35a6ff;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; background: #9edcff; color: var(--ink); font-family: 'Fredoka', system-ui, sans-serif; }
canvas#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
canvas#blood { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 20; }
[hidden] { display: none !important; }

/* ---- HUD ---- */
#hud { position: fixed; top: 16px; left: 16px; right: 16px; display: flex; gap: 14px; justify-content: space-between; pointer-events: none; z-index: 10; }
.panel {
  background: var(--cream); border: 4px solid var(--ink); border-radius: 16px; padding: 6px 18px;
  font-size: 1.4rem; font-weight: 600; box-shadow: 5px 5px 0 var(--ink); transform: rotate(-1.2deg);
  display: flex; align-items: center; gap: 8px;
}
.panel:nth-child(2) { transform: rotate(1deg); }
.panel:nth-child(3) { transform: rotate(-0.6deg); min-width: 130px; justify-content: center; }
.panel b { font-family: 'Bangers', cursive; font-size: 2rem; font-weight: 400; letter-spacing: 1px; color: #e0182d; }
.lives svg { width: 34px; height: 34px; filter: drop-shadow(2px 2px 0 var(--ink)); }
.lives svg.pop { animation: pop 0.5s; }

/* ---- Bildschirme ---- */
.screen { position: fixed; inset: 0; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 18px; z-index: 30; padding: 16px; }
.screen.active { display: flex; }
.screen.dim { background: rgba(26, 16, 32, 0.45); backdrop-filter: blur(3px); }
#loading { background: #9edcff; }

.menu-box { display: flex; flex-direction: column; align-items: flex-start; gap: 16px; margin-right: auto; margin-left: clamp(16px, 7vw, 120px); max-width: 560px; }
.title { margin: 0; font-family: 'Bangers', cursive; font-weight: 400; font-size: clamp(4rem, 12vw, 9rem); line-height: 0.85; letter-spacing: 3px; color: var(--yellow); transform: rotate(-4deg); display: flex; flex-direction: column;
  -webkit-text-stroke: 0.07em var(--ink); paint-order: stroke fill; text-shadow: 0.05em 0.06em 0 var(--ink); }
.title span:nth-child(2) { color: var(--green); margin-left: 0.5em; }
.title.small { font-size: 4rem; flex-direction: row; gap: 0.3em; }
.title.small span:nth-child(2) { margin: 0; }
.tagline { margin: 0; font-size: 1.35rem; font-weight: 600; background: var(--cream); border: 4px solid var(--ink); border-radius: 14px; padding: 10px 16px; box-shadow: 5px 5px 0 var(--ink); }
.hint { margin: 4px 0 0; font-size: 1rem; font-weight: 500; background: rgba(255, 255, 255, 0.85); border-radius: 10px; padding: 6px 12px; }
kbd { background: #fff; border: 2px solid var(--ink); border-bottom-width: 4px; border-radius: 6px; padding: 0 6px; margin: 0 2px; font-family: inherit; font-weight: 600; }

.card {
  background: var(--cream); border: 5px solid var(--ink); border-radius: 22px; padding: 26px 34px; box-shadow: 9px 9px 0 var(--ink);
  display: flex; flex-direction: column; align-items: center; gap: 16px; min-width: min(420px, 92vw); max-width: 94vw;
  max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y;
}
.card.wide { min-width: min(820px, 94vw); overflow: hidden; }
/* Bei den Slots scrollt nur die Liste; Titel und Zurück-Button bleiben immer sichtbar */
.card.wide .slot-grid { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; padding: 2px 6px 8px 2px; }
.card.wide > * { flex-shrink: 0; }
.card.wide > .slot-grid { flex-shrink: 1; }
.card h2 { margin: 0; text-align: center; font-family: 'Bangers', cursive; font-weight: 400; font-size: 3.6rem; letter-spacing: 2px; color: var(--green); -webkit-text-stroke: 0.06em var(--ink); paint-order: stroke fill; text-shadow: 0.05em 0.06em 0 var(--ink); transform: rotate(-2deg); }
.card h2.bloody { color: var(--red); }
.note { margin: 0; min-height: 1.4em; font-size: 1.15rem; font-weight: 500; text-align: center; }

.btn {
  font-family: 'Bangers', cursive; font-size: 1.6rem; letter-spacing: 1.5px; color: var(--ink); background: var(--yellow);
  border: 4px solid var(--ink); border-radius: 14px; padding: 8px 26px; cursor: pointer; box-shadow: 5px 5px 0 var(--ink);
  transition: transform 0.08s, box-shadow 0.08s; user-select: none;
}
.btn.big { font-size: 2.2rem; padding: 10px 36px; min-width: 300px; }
.btn.alt { background: var(--blue); color: #fff; text-shadow: 2px 2px 0 var(--ink); }
.btn:hover { transform: translate(-2px, -3px) rotate(-1deg); box-shadow: 8px 9px 0 var(--ink); }
.btn:active { transform: translate(4px, 4px); box-shadow: 1px 1px 0 var(--ink); }
.btn:focus-visible { outline: 4px dashed var(--red); outline-offset: 3px; }

.stats { list-style: none; margin: 0; padding: 0; width: 100%; display: flex; flex-direction: column; gap: 6px; font-size: 1.4rem; font-weight: 600; }
.stats li { display: flex; justify-content: space-between; gap: 40px; border-bottom: 3px dotted var(--ink); padding-bottom: 4px; }
.stats b { font-family: 'Bangers', cursive; font-weight: 400; color: #e0182d; font-size: 1.8rem; }

/* ---- Speicherslots ---- */
.slot-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px 16px; width: 100%; }
.slot {
  font: inherit; text-align: left; background: #fff; border: 4px solid var(--ink); border-radius: 14px; padding: 8px 14px; cursor: pointer;
  box-shadow: 4px 4px 0 var(--ink); display: grid; grid-template-columns: auto 1fr; gap: 0 12px; align-items: center; transition: transform 0.08s;
}
.slot .no { grid-row: span 2; font-family: 'Bangers', cursive; font-size: 2.4rem; color: var(--blue); -webkit-text-stroke: 0.05em var(--ink); paint-order: stroke fill; }
.slot .l1 { font-weight: 700; font-size: 1.15rem; }
.slot .l2 { font-size: 0.95rem; font-weight: 500; opacity: 0.75; }
.slot.empty .l1 { opacity: 0.5; }
.slot:hover:not(:disabled) { transform: translate(-2px, -2px) rotate(-0.6deg); }
.slot:disabled { cursor: not-allowed; background: #e9e4d2; box-shadow: 2px 2px 0 var(--ink); }
.slot.armed { background: var(--red); color: #fff; animation: shake 0.3s; }
.slot.armed .no { color: #fff; }

/* ---- Comic-Pop-ups ---- */
#popups { position: fixed; inset: 0; pointer-events: none; z-index: 25; display: flex; align-items: center; justify-content: center; }
.pop {
  position: absolute; font-family: 'Bangers', cursive; font-size: clamp(5rem, 18vmin, 13rem); letter-spacing: 4px; color: var(--red);
  -webkit-text-stroke: 0.09em var(--ink); paint-order: stroke fill; text-shadow: 0.06em 0.07em 0 var(--ink);
  animation: comic 2.2s cubic-bezier(.2, 1.4, .4, 1) forwards; white-space: nowrap;
}
.pop.water { color: #7fd6ff; }

@keyframes pop { 0% { transform: scale(0.2); } 60% { transform: scale(1.4); } 100% { transform: scale(1); } }
@keyframes comic {
  0% { transform: scale(0.1) rotate(var(--r)); opacity: 0; }
  12% { transform: scale(1.35) rotate(var(--r)); opacity: 1; }
  22% { transform: scale(1) rotate(var(--r)); }
  75% { transform: scale(1.05) rotate(var(--r)); opacity: 1; }
  100% { transform: scale(1.25) rotate(var(--r)) translateY(-8vh); opacity: 0; }
}
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

.bar { width: min(420px, 70vw); height: 26px; border: 4px solid var(--ink); border-radius: 14px; background: #fff; overflow: hidden; box-shadow: 4px 4px 0 var(--ink); }
#loading-fill { width: 0; height: 100%; background: var(--green); transition: width 0.15s; }

@media (max-width: 700px) {
  .slot-grid { grid-template-columns: 1fr; }
  .btn.big { min-width: 0; width: 100%; }
  .panel { font-size: 1rem; padding: 4px 10px; }
  .menu-box { margin: 0 auto; align-items: center; text-align: center; }
}

/* ---- Ton, Pause und Touch-Steuerung ---- */
.round {
  position: fixed; bottom: 16px; width: 54px; height: 54px; border-radius: 50%; border: 4px solid var(--ink); background: var(--cream);
  font-size: 1.5rem; line-height: 1; cursor: pointer; box-shadow: 4px 4px 0 var(--ink); z-index: 40; padding: 0;
}
.round:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); }
#btn-mute { left: 16px; }
#btn-pause { left: 84px; display: none; }
body.playing #btn-pause { display: block; }

#dpad { opacity: 0.88; position: fixed; right: 18px; bottom: 18px; z-index: 15; display: none; grid-template-columns: repeat(3, 68px); grid-template-rows: repeat(3, 68px); gap: 6px; }
#dpad button {
  border: 4px solid var(--ink); border-radius: 18px; background: var(--yellow); color: var(--ink); font-size: 1.8rem; box-shadow: 4px 4px 0 var(--ink);
  touch-action: none; cursor: pointer; padding: 0;
}
#dpad button:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); background: var(--green); }
#dpad [data-dir=up] { grid-area: 1 / 2; }
#dpad [data-dir=left] { grid-area: 2 / 1; }
#dpad [data-dir=right] { grid-area: 2 / 3; }
#dpad [data-dir=down] { grid-area: 3 / 2; }
@media (pointer: coarse) { body.playing #dpad { display: grid; } }
@media (pointer: coarse) and (max-height: 500px) { #dpad { grid-template-columns: repeat(3, 56px); grid-template-rows: repeat(3, 56px); } }

/* ---- Niedrige Fenster (Handy im Querformat) ---- */
@media (max-height: 560px) {
  .screen { gap: 10px; padding: 8px; }
  .card { padding: 12px 22px; gap: 10px; border-width: 4px; box-shadow: 6px 6px 0 var(--ink); }
  .card h2 { font-size: 2.3rem; }
  .btn { font-size: 1.3rem; padding: 4px 20px; }
  .btn.big { font-size: 1.6rem; padding: 5px 26px; min-width: 0; }
  .note { font-size: 1rem; }
  .stats { font-size: 1.1rem; gap: 3px; }
  .stats b { font-size: 1.4rem; }
  .slot-grid { gap: 8px 12px; }
  .slot { padding: 3px 10px; border-width: 3px; box-shadow: 3px 3px 0 var(--ink); }
  .slot .no { font-size: 1.7rem; }
  .slot .l1 { font-size: 1rem; }
  .slot .l2 { font-size: 0.8rem; }
  #slots-note { display: none; }
  .title { font-size: clamp(3rem, 15vh, 6rem); }
  .menu-box { gap: 8px; margin-left: 84px; }
  .tagline { font-size: 1rem; padding: 6px 12px; }
  .hint { font-size: 0.85rem; padding: 4px 10px; }
  #hud { top: 8px; }
  .panel { font-size: 1.1rem; padding: 2px 12px; }
  .panel b { font-size: 1.5rem; }
}
body.hide-round .round { display: none !important; }
