/* ============================================================================
   Für Lina – 16-Bit Arcade Skin
   Portrait-first, große Touch-Ziele, Pixel-Look, warme Retro-Palette.
   ========================================================================== */

:root {
  --amber:   #ffce33;
  --amber-d: #f39c12;
  --pink:    #ff5d7e;
  --cyan:    #59d0d0;
  --ink:     #0b0910;
  --ink-2:   #140f1e;
  --paper:   #fdf3d6;
  --arcade:  "Press Start 2P", monospace;
  --body:    "Fredoka", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%; width: 100%;
  overflow: hidden;
  background: #000;
  font-family: var(--body);
  color: #fff;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  touch-action: none;
  user-select: none; -webkit-user-select: none;
}

#screen { position: fixed; inset: 0; overflow: hidden; background: var(--ink); }

canvas#game {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  touch-action: none;
}

.hidden { display: none !important; }

/* ---- CRT-Scanlines über allem ---- */
#crt {
  position: absolute; inset: 0; z-index: 8; pointer-events: none;
  background: repeating-linear-gradient(
    0deg, rgba(0,0,0,0.16) 0px, rgba(0,0,0,0.16) 1px,
    transparent 2px, transparent 3px);
  mix-blend-mode: multiply;
  opacity: .5;
}
.scanlines {
  position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(
    0deg, rgba(0,0,0,0.22) 0px, rgba(0,0,0,0.22) 2px,
    transparent 3px, transparent 4px);
}

/* ---- Arcade-Typo ---- */
.arcade-title {
  font-family: var(--arcade);
  line-height: 1.25;
  letter-spacing: 1px;
  color: var(--amber);
  text-shadow: 3px 3px 0 #b5350f, 6px 6px 0 rgba(0,0,0,.45);
}
.arcade-title.small { font-size: 18px; }
.arcade-title { font-size: clamp(26px, 9vw, 46px); }
.hl { color: #fff; text-shadow: 3px 3px 0 var(--pink), 6px 6px 0 rgba(0,0,0,.45); }

.blink { animation: blink 1.1s steps(2, start) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* ---- HUD ---- */
#hud {
  position: absolute; z-index: 9;
  top: max(12px, env(safe-area-inset-top)); right: 12px;
  font-family: var(--arcade); font-size: 12px;
  color: var(--amber);
  display: flex; align-items: center; gap: 6px;
  text-shadow: 2px 2px 0 #000;
}
#hud .coin { color: var(--amber); animation: spin 1.4s linear infinite; display:inline-block; }
@keyframes spin { 50% { transform: scaleX(.2); } }

#muteBtn {
  position: absolute; z-index: 9;
  top: max(12px, env(safe-area-inset-top)); left: 12px;
  width: 38px; height: 38px;
  border: 2px solid rgba(255,255,255,.25);
  background: rgba(0,0,0,.35);
  color: #fff; font-size: 16px; cursor: pointer;
  font-family: var(--arcade);
  image-rendering: pixelated;
}

/* ---- Fortschritts-Leiste zur Torte ---- */
#progress {
  position: absolute; z-index: 9; top: max(14px, env(safe-area-inset-top)); left: 50%;
  transform: translateX(-50%);
  display: flex; align-items: center; gap: 6px;
  width: min(56vw, 220px);
}
#progressTrack {
  flex: 1; height: 8px;
  background: rgba(0,0,0,.45);
  border: 2px solid rgba(255,255,255,.25);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.4);
  image-rendering: pixelated;
}
#progressFill { height: 100%; width: 0%; background: var(--amber); box-shadow: 0 0 6px var(--amber); transition: width .15s linear; }
.goal-cake { width: 22px; height: 18px; margin: 0; filter: drop-shadow(1px 1px 0 rgba(0,0,0,.5)); }

/* ---- Zurufe des Begleiters ---- */
#shoutLayer { position: absolute; inset: 0; z-index: 6; pointer-events: none; }
.shout {
  position: absolute;
  transform: translate(-50%, -100%);
  font-family: var(--arcade); font-size: 11px; white-space: nowrap;
  color: #fff;
  text-shadow: 2px 2px 0 rgba(0,0,0,.6), 0 0 6px rgba(0,0,0,.5);
  opacity: 0;
  animation: shoutPop 1.5s ease forwards;
}
.shout.val { color: var(--amber); font-size: 13px; text-shadow: 2px 2px 0 #b5350f, 0 0 8px var(--amber); }
@keyframes shoutPop {
  0%   { opacity: 0; transform: translate(-50%, -70%) scale(.6); }
  18%  { opacity: 1; transform: translate(-50%, -100%) scale(1.05); }
  30%  { transform: translate(-50%, -100%) scale(1); }
  75%  { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -230%) scale(1); }
}

/* ---- Overlays ---- */
.overlay {
  position: absolute; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  text-align: center; padding: 26px;
  padding-bottom: max(26px, env(safe-area-inset-bottom));
}
#lockScreen  { background: radial-gradient(130% 90% at 50% 15%, #251a3e 0%, #150f24 55%, #0b0910 100%); }
#startScreen { background: radial-gradient(130% 90% at 50% 12%, #33204d 0%, #1a1030 55%, #0b0910 100%); }

.pix-cake { image-rendering: pixelated; width: 96px; height: 78px; margin: 0 auto 6px; display: block; filter: drop-shadow(3px 4px 0 rgba(0,0,0,.5)); }

.lock-inner, .start-inner { position: relative; z-index: 1; max-width: 460px; animation: rise .5s ease both; }

.lock-kicker, .start-kicker {
  font-family: var(--arcade); font-size: 9px; letter-spacing: 1px;
  color: var(--pink); margin-bottom: 16px;
}
.lock-sub, .start-sub { margin-top: 16px; font-size: 16px; line-height: 1.55; opacity: .82; }
#lockPhrase { color: var(--amber); font-weight: 600; }

.countdown { margin: 22px auto 10px; display: flex; gap: 8px; justify-content: center; }
.cd-box {
  background: var(--ink-2); border: 2px solid rgba(255,255,255,.14);
  padding: 12px 6px 8px; min-width: 60px;
  display: flex; flex-direction: column; align-items: center;
  box-shadow: 4px 4px 0 rgba(0,0,0,.4);
}
.cd-box b { font-family: var(--arcade); font-size: 20px; color: #fff; }
.cd-box i { margin-top: 8px; font-family: var(--arcade); font-size: 7px; letter-spacing: 1px; color: var(--amber); font-style: normal; }
.lock-foot { margin-top: 22px; font-family: var(--arcade); font-size: 9px; color: rgba(255,255,255,.7); }

.start-hint, .lock-kicker { opacity: .9; }
.start-sub { text-transform: lowercase; }
.start-hint { margin-top: 16px; font-family: var(--arcade); font-size: 8px; color: rgba(255,255,255,.5); }

/* ---- Pixel-Buttons ---- */
.pix-btn {
  margin-top: 26px;
  font-family: var(--arcade); font-size: 15px;
  color: var(--ink); background: var(--amber);
  border: none; padding: 16px 22px; cursor: pointer;
  box-shadow: 5px 5px 0 #a35a00, 5px 5px 0 0 #000;
  box-shadow: 0 5px 0 #a35a00, 5px 5px 0 rgba(0,0,0,.4);
  transition: transform .07s steps(2), box-shadow .07s steps(2);
}
.pix-btn:active { transform: translate(0, 4px); box-shadow: 0 1px 0 #a35a00, 2px 2px 0 rgba(0,0,0,.4); }
.pix-btn.ghost { background: #241c10; color: var(--amber); box-shadow: 0 5px 0 #000; border: 2px solid var(--amber); }

/* ---- Finale ---- */
#finaleScreen {
  flex-direction: column;
  background: radial-gradient(130% 90% at 50% 55%, #3a2560 0%, #180f30 55%, #0a0713 100%);
  overflow: hidden;
}
.finale-words { position: absolute; inset: 0; pointer-events: none; }
.float-word {
  position: absolute; left: 50%; bottom: 24%;
  transform: translateX(-50%);
  font-family: var(--arcade); font-size: 13px; white-space: nowrap;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  animation: floatUp 3.6s ease-out forwards;
  text-shadow: 2px 2px 0 rgba(0,0,0,.5);
}
.float-word .g { font-size: 22px; image-rendering: pixelated; }

.finale-big { position: relative; z-index: 5; max-width: 540px; padding: 16px; animation: rise .7s ease both; }
.finale-title { font-size: clamp(20px, 7vw, 34px); }
.finale-name {
  font-family: var(--arcade); font-size: clamp(40px, 15vw, 78px);
  color: var(--amber); margin-top: 6px;
  text-shadow: 4px 4px 0 var(--pink), 8px 8px 0 rgba(0,0,0,.4);
  animation: popBig .6s steps(4) both;
}
.finale-line {
  margin-top: 22px; font-size: 18px; line-height: 1.6; color: #f3ecff;
  opacity: 0; animation: fadeIn 1.6s ease .5s forwards;
}
#replayBtn { margin-top: 24px; animation: fadeIn 1s ease both; }
#confetti { position: absolute; inset: 0; z-index: 1; pointer-events: none; }

/* ---- Touch-Steuerung ---- */
#controls {
  position: absolute; z-index: 10; inset: auto 0 0 0;
  display: flex; justify-content: space-between; align-items: flex-end;
  padding: 0 18px max(18px, env(safe-area-inset-bottom));
  pointer-events: none;
}
.pad-left { display: flex; gap: 12px; pointer-events: auto; }
.pad-right { pointer-events: auto; }
.ctrl {
  touch-action: none; -webkit-user-select: none; user-select: none;
  width: 66px; height: 66px;
  font-family: var(--arcade); font-size: 20px; color: #fff;
  background: rgba(20,15,30,.55);
  border: 3px solid rgba(255,255,255,.22);
  box-shadow: 0 4px 0 rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center;
  image-rendering: pixelated;
}
.ctrl:active, .ctrl.pressed {
  transform: translateY(3px); box-shadow: 0 1px 0 rgba(0,0,0,.5);
  background: var(--amber); color: var(--ink); border-color: var(--amber-d);
}
.ctrl-jump {
  width: 92px; height: 92px; flex-direction: column; gap: 2px;
  font-size: 26px;
  background: rgba(255,206,51,.22); border-color: rgba(255,206,51,.55);
}
.ctrl-jump small { font-family: var(--arcade); font-size: 8px; letter-spacing: 1px; }

/* ---- Rotate-Hinweis ---- */
#rotateHint {
  display: none; position: fixed; inset: 0; z-index: 90;
  background: var(--ink); flex-direction: column; align-items: center;
  justify-content: center; gap: 16px; text-align: center; padding: 24px;
}
.pix-arrow { font-size: 46px; animation: spin 1.6s steps(8) infinite; }
#rotateHint p { font-family: var(--arcade); font-size: 12px; line-height: 1.6; opacity: .85; }
@media (orientation: landscape) and (max-height: 500px) { #rotateHint { display: flex; } }

/* ---- Keyframes ---- */
@keyframes rise   { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { to { opacity: 1; } }
@keyframes popBig { 0% { opacity: 0; transform: scale(.4); } 100% { opacity: 1; transform: scale(1); } }
@keyframes floatUp {
  0%   { opacity: 0; transform: translateX(-50%) translateY(24px) scale(.5); }
  16%  { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
  82%  { opacity: 1; }
  100% { opacity: 0; transform: translateX(-50%) translateY(-46vh) scale(1); }
}
@media (prefers-reduced-motion: reduce) { * { animation-duration: .001ms !important; } }
