/* ══════════════════════════════════════
   Rosalinde's Rescue Run – Styles
   ══════════════════════════════════════ */

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

body {
  background: #1a1a2e;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  font-family: 'Courier New', Courier, monospace;
  color: #fff;
}

/* ── Canvas ── */
#gameCanvas {
  display: block;
  image-rendering: pixelated;
  cursor: default;
}

/* ── Overlay screens ── */
.screen {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(3px);
}
.screen.active { display: flex; }

.screen-box {
  background: #16213e;
  border: 3px solid #e94560;
  border-radius: 16px;
  padding: 40px 56px;
  text-align: center;
  max-width: 520px;
  width: 90%;
  box-shadow: 0 0 40px rgba(233,69,96,0.4);
}

h1 {
  font-size: 2.8rem;
  color: #e94560;
  line-height: 1.2;
  margin-bottom: 12px;
  text-shadow: 0 0 20px rgba(233,69,96,0.6);
}
h2 { font-size: 2rem; color: #f5a623; margin-bottom: 16px; }

.subtitle {
  color: #a8b2d8;
  margin-bottom: 24px;
  font-size: 1rem;
  font-style: italic;
}

.controls-hint {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  justify-content: center;
  font-size: 0.8rem;
  color: #8892b0;
  margin-bottom: 32px;
  background: rgba(255,255,255,0.04);
  border-radius: 8px;
  padding: 12px;
}

.btn-primary {
  background: #e94560;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-size: 1.2rem;
  font-weight: bold;
  letter-spacing: 2px;
  padding: 14px 40px;
  cursor: pointer;
  transition: transform .1s, box-shadow .1s;
  box-shadow: 0 4px 20px rgba(233,69,96,0.5);
}
.btn-primary:hover  { transform: scale(1.05); }
.btn-primary:active { transform: scale(0.97); }

/* Wave clear banner */
.wave-box {
  animation: wavePop .35s cubic-bezier(.36,.07,.19,.97);
}
@keyframes wavePop {
  0%   { transform: scale(0.7); opacity: 0; }
  60%  { transform: scale(1.08); }
  100% { transform: scale(1);    opacity: 1; }
}

/* ── HUD ── */
#hud {
  position: fixed;
  top: 0; left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  padding: 10px 20px;
  background: rgba(0,0,0,0.45);
  font-size: 1rem;
  z-index: 5;
  pointer-events: none;
}
#hud.hidden { display: none; }

.hud-left, .hud-right {
  display: flex;
  gap: 24px;
  align-items: center;
}
.hud-left span { color: #cdd6f4; }
.hud-right span { color: #f5c2e7; }

/* ── Ammo warning ── */
#ammo-warning {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: #e94560;
  color: #fff;
  padding: 8px 24px;
  border-radius: 20px;
  font-weight: bold;
  font-size: 1.1rem;
  z-index: 20;
  animation: blink .4s infinite alternate;
}
#ammo-warning.hidden { display: none; }
@keyframes blink { to { opacity: 0.3; } }

/* ── Difficulty selection ── */
.diff-label {
  color: #8892b0;
  font-size: 0.85rem;
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.diff-buttons {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}
.btn-diff {
  border: 2px solid currentColor;
  border-radius: 8px;
  background: transparent;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: bold;
  padding: 12px 20px;
  cursor: pointer;
  transition: transform .1s, background .15s, box-shadow .15s;
  letter-spacing: 0.5px;
}
.btn-diff:hover  { transform: scale(1.06); }
.btn-diff:active { transform: scale(0.96); }

.btn-junior { color: #4ade80; }
.btn-junior:hover { background: rgba(74,222,128,0.15); box-shadow: 0 0 18px rgba(74,222,128,0.3); }

.btn-pro    { color: #facc15; }
.btn-pro:hover    { background: rgba(250,204,21,0.15); box-shadow: 0 0 18px rgba(250,204,21,0.3); }

.btn-senior { color: #f87171; }
.btn-senior:hover { background: rgba(248,113,113,0.15); box-shadow: 0 0 18px rgba(248,113,113,0.3); }

/* ── Victory screen ── */
.victory-box {
  border-color: #4ade80;
  box-shadow: 0 0 60px rgba(74,222,128,0.5);
  animation: victoryPop .5s cubic-bezier(.36,.07,.19,.97);
}
@keyframes victoryPop {
  0%   { transform: scale(0.5) rotate(-4deg); opacity: 0; }
  70%  { transform: scale(1.06) rotate(1deg); }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}
.victory-emoji {
  font-size: 3rem;
  margin-bottom: 8px;
  animation: bounce 1s ease infinite alternate;
}
@keyframes bounce { to { transform: translateY(-10px); } }

.victory-title {
  color: #4ade80;
  text-shadow: 0 0 30px rgba(74,222,128,0.7);
  font-size: 3.5rem;
}
.victory-sub {
  color: #a7f3d0;
  margin-bottom: 20px;
  font-size: 1rem;
  line-height: 1.6;
}
.btn-green {
  background: #16a34a;
  box-shadow: 0 4px 20px rgba(74,222,128,0.4);
}

/* ── URL Overlay (top right, always during gameplay) ── */
#url-overlay {
  position: fixed;
  top: 52px;       /* below HUD bar */
  right: 16px;
  text-align: right;
  z-index: 6;
  pointer-events: auto;
  line-height: 1.5;
}
#url-overlay.hidden { display: none; }

#url-overlay a {
  display: block;
  color: #ffffff;
  font-family: 'Courier New', Courier, monospace;
  font-size: 15px;
  font-weight: bold;
  text-decoration: none;
  text-shadow:
    -1px -1px 0 #000, 1px -1px 0 #000,
    -1px  1px 0 #000, 1px  1px 0 #000,
     0    0   6px rgba(0,0,0,0.7);
  transition: opacity .15s;
}
#url-overlay a:hover { opacity: 0.75; text-decoration: underline; }

#url-overlay hr {
  border: none;
  border-top: 1px solid rgba(255,255,255,0.6);
  margin: 4px 0;
  box-shadow: 0 0 4px rgba(0,0,0,0.5);
}

/* ── Victory CTA ── */
.victory-cta {
  margin: 16px 0 20px;
  padding: 14px 20px;
  background: rgba(74,222,128,0.08);
  border: 1px solid rgba(74,222,128,0.3);
  border-radius: 8px;
  font-size: 0.9rem;
  line-height: 1.8;
  color: #a7f3d0;
}
.victory-cta a {
  color: #4ade80;
  font-weight: bold;
  font-size: 1.05rem;
  text-decoration: none;
  display: block;
}
.victory-cta a:hover { text-decoration: underline; }
.victory-cta p { margin: 0; color: #cbd5e1; font-size: 0.85rem; }

/* Responsive: if window is very wide, canvas is centred by body flex */

/* ── Canvas: Touch-Scroll & Pinch-Zoom deaktivieren ── */
#gameCanvas { touch-action: none; }

/* ── Mobile Touch Controls ── */
#mobile-controls {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  justify-content: space-between;
  align-items: flex-end;
  padding: 8px 16px 20px;
  z-index: 15;
  pointer-events: none;
}
body.touch-device #mobile-controls { display: flex; }

#mc-dpad, #mc-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  pointer-events: auto;
}

.mc-btn {
  width: 64px; height: 64px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.35);
  background: rgba(0,0,0,0.60);
  color: #fff;
  font-size: 1.3rem;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  cursor: pointer;
  user-select: none; -webkit-user-select: none;
  touch-action: manipulation;
  line-height: 1.1;
  transition: background 0.08s, transform 0.08s;
}
.mc-btn:active { background: rgba(233,69,96,0.5); transform: scale(0.90); }

.mc-throw {
  width: 76px; height: 76px;
  border-color: #e94560;
  background: rgba(233,69,96,0.35);
  font-size: 1.5rem;
}
.mc-berta {
  border-color: #4ade80;
  background: rgba(74,222,128,0.20);
  transition: border-color 0.3s, background 0.3s, opacity 0.3s;
}
.mc-berta.mc-berta-used {
  border-color: #e94560;
  background: rgba(233,69,96,0.20);
  opacity: 0.55;
}

.mc-fullscreen {
  width: 48px; height: 48px;
  font-size: 1.1rem;
  border-color: rgba(255,255,255,0.4);
}

/* iOS Vollbild Hinweis Toast */
#ios-fullscreen-hint {
  position: fixed;
  bottom: 110px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(22,33,62,0.97);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 12px;
  padding: 12px 20px;
  z-index: 50;
  max-width: 88vw;
  text-align: center;
  font-size: 0.82rem;
  line-height: 1.5;
  color: #cdd6f4;
  box-shadow: 0 4px 24px rgba(0,0,0,0.6);
  white-space: nowrap;
}
#ios-fullscreen-hint.hidden { display: none; }
.mc-btn small { font-size: 0.55rem; letter-spacing: 0.5px; margin-top: 2px; }

/* ── Dreh-Hinweis (Standalone-Modus, Hochformat) ── */
#screen-rotate { z-index: 200; }

/* ── iOS Onboarding-Hinweis ── */
#screen-ios-hint { z-index: 100; }
.ios-hint-box { max-width: 440px; }
.ios-hint-icon { font-size: 2.4rem; margin-bottom: 8px; }

.ios-steps {
  text-align: left;
  margin: 18px 0 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.ios-step {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-size: 0.95rem;
  color: #cdd6f4;
  line-height: 1.4;
}
.ios-step-num {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: #e94560;
  color: #fff;
  font-weight: bold;
  font-size: 0.85rem;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}
.ios-step-divider {
  text-align: center;
  color: #8892b0;
  font-size: 0.82rem;
  font-style: italic;
}
.ios-safari-note {
  font-size: 0.78rem;
  color: #8892b0;
  margin: -8px 0 20px;
  line-height: 1.4;
  text-align: center;
}

/* ── Credits ── */
.credits {
  margin-top: 20px;
  font-size: 0.72rem;
  color: #4a5568;
  text-align: center;
  letter-spacing: 0.3px;
}
.credits a {
  color: #4a5568;
  text-decoration: none;
}
.credits a:hover { text-decoration: underline; }

/* ── Mobile Controls auf Menu-Screens ausblenden ── */
/* Sibling-Selektor: Controls werden unsichtbar, wenn Start/Gameover/Victory/Hint aktiv */
#screen-start.active    ~ #mobile-controls,
#screen-gameover.active ~ #mobile-controls,
#screen-victory.active  ~ #mobile-controls,
#screen-ios-hint.active ~ #mobile-controls {
  display: none;
}

/* ── Querformat auf kleinen Geräten: Screen scrollbar machen ── */
@media (max-height: 520px) {
  .screen {
    align-items: flex-start;
    overflow-y: auto;
    padding: 6px 0 12px;
  }
  .screen-box {
    padding: 16px 24px;
    width: 92%;
  }
  h1 { font-size: 1.7rem; margin-bottom: 6px; }
  h2 { font-size: 1.4rem; margin-bottom: 10px; }
  .subtitle { margin-bottom: 12px; font-size: 0.88rem; }
  .controls-hint { margin-bottom: 14px; padding: 8px; font-size: 0.75rem; }
  .diff-label { margin-bottom: 6px; }
  .btn-diff { padding: 8px 14px; font-size: 0.85rem; }
  .btn-primary { padding: 10px 28px; font-size: 1rem; }
}

/* ── HUD auf kleinen Bildschirmen ── */
@media (max-width: 640px) {
  #hud { font-size: 0.68rem; padding: 5px 8px; }
  .hud-left, .hud-right { gap: 8px; }
}

/* ── Desktop Fullscreen Button ── */
#btn-fullscreen {
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 15;
  background: rgba(0,0,0,0.55);
  color: #fff;
  border: 2px solid rgba(255,255,255,0.35);
  border-radius: 8px;
  font-size: 1.25rem;
  padding: 7px 12px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, transform 0.1s;
}
#btn-fullscreen:hover  { background: rgba(255,255,255,0.12); transform: scale(1.06); }
#btn-fullscreen:active { transform: scale(0.94); }
#btn-fullscreen.hidden { display: none; }

/* Hide desktop fullscreen on touch devices */
body.touch-device #btn-fullscreen { display: none !important; }

/* ── Berta Badge ── */
#berta-badge {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.52);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 20px;
  padding: 5px 18px;
  color: #ffffff;
  font-size: 0.76rem;
  font-family: 'Courier New', Courier, monospace;
  z-index: 6;
  pointer-events: none;
  white-space: nowrap;
}
#berta-badge.hidden { display: none; }
