@font-face {
  font-family: "Nothing";
  src: url("../assets/nothing-font.otf/nothing-font.otf") format("opentype");
  font-weight: normal;
  font-style: normal;
}

:root {
  --bg: #000;
  --bg-maze: #0a0a0a;
  --wall: #1a1a1a;
  --wall-border: #333;
  --text: #fff;
  --text-muted: #888;
  --accent: #fff;
  --accent-bg: #000;
  --link: #fff;
  --danger: #fff;
}

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

html {
  touch-action: manipulation;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  position: relative;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", system-ui, sans-serif;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  touch-action: manipulation;
}

#bg-video {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  min-width: 100%;
  min-height: 100%;
  object-fit: cover;
  z-index: 0;
  transition: opacity 0.6s ease-in-out;
}

#bg-video.video-loop-fade {
  opacity: 0.2;
}

#bg-decorations {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

#bg-decorations img {
  position: absolute;
  opacity: 0.85;
  object-fit: contain;
}

#main-layout {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  width: 100%;
  max-width: 100vw;
  padding: 0 12px;
  padding-bottom: calc(120px + env(safe-area-inset-bottom, 0px));
  box-sizing: border-box;
}

#game-container {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  overflow: visible;
  padding: 12px 0;
  min-height: 0;
}

#game.hidden {
  display: none !important;
}

#game:not(.hidden) {
  animation: fog-in-game 0.6s ease-out forwards;
}

#game {
  display: block;
  border-radius: 8px;
  border: 3px solid rgba(255, 255, 255, 0.35);
  box-shadow: 0 0 40px rgba(255, 255, 255, 0.08), inset 0 0 0 1px rgba(255, 255, 255, 0.1);
  max-width: min(100%, 448px);
  max-height: min(calc(100vh - 100px), 480px);
  max-height: min(calc(100dvh - 100px), 480px);
  width: auto;
  height: auto;
  aspect-ratio: 448 / 480;
  object-fit: contain;
  background: var(--bg-maze);
}

.overlay {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  z-index: 10;
  text-align: center;
  padding: 32px 40px;
  background: rgba(0, 0, 0, 0.95);
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-radius: 20px;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.6);
  max-width: min(90vw, 400px);
}

#menu-overlay {
  max-width: min(94vw, 520px);
  padding: 48px 56px;
  gap: 24px;
}

#gameover-overlay {
  width: calc(100vw - 24px);
  max-width: none;
  padding: 40px 24px;
  gap: 20px;
  box-sizing: border-box;
}

#victory-overlay {
  max-width: min(94vw, 480px);
  padding: 40px 48px;
  gap: 20px;
}

#menu-overlay h1 {
  font-size: clamp(32px, 9vw, 48px);
}

#menu-overlay .slogan,
#menu-overlay .cta-text {
  font-size: clamp(14px, 3.5vw, 16px);
}

#menu-overlay button {
  font-size: clamp(16px, 4vw, 20px);
  padding: 16px 40px;
}

#menu-overlay #cta-link {
  font-size: clamp(15px, 3.5vw, 18px);
}

.overlay:not(.hidden) {
  animation: fog-in 0.6s ease-out forwards;
}

.overlay.overlay-hiding {
  animation: fog-out 0.5s ease-in forwards;
}

.overlay.overlay-hiding {
  animation: fog-out 0.5s ease-in forwards;
  pointer-events: none;
}

.overlay.hidden {
  display: none !important;
}

@keyframes fog-in-game {
  from {
    opacity: 0;
    transform: scale(0.92);
    filter: blur(14px);
  }
  to {
    opacity: 1;
    transform: scale(1);
    filter: blur(0);
  }
}

@keyframes fog-in {
  from {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.92);
    filter: blur(12px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
    filter: blur(0);
  }
}

@keyframes fog-out {
  from {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
    filter: blur(0);
  }
  to {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.92);
    filter: blur(12px);
  }
}

.overlay h1 {
  font-family: "Nothing", cursive;
  font-size: clamp(28px, 8vw, 42px);
  font-weight: 700;
  color: var(--text);
}

.overlay h2 {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", system-ui, sans-serif;
  font-size: clamp(20px, 5vw, 28px);
  font-weight: 600;
  color: var(--text);
}

.overlay h2.danger {
  color: var(--danger);
}

.slogan, .cta-text, .share-text {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", system-ui, sans-serif;
  font-size: clamp(12px, 3vw, 14px);
  color: var(--text-muted);
}

.score-display {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", system-ui, sans-serif;
  font-size: clamp(16px, 4vw, 20px);
  color: var(--text);
}

button {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", system-ui, sans-serif;
  font-size: clamp(14px, 3.5vw, 18px);
  font-weight: 600;
  color: var(--accent-bg);
  background: var(--accent);
  border: 2px solid var(--text);
  padding: 14px 32px;
  cursor: pointer;
  border-radius: 8px;
  transition: opacity 0.2s;
}

button:hover {
  opacity: 0.9;
}

button.secondary {
  background: transparent;
  color: var(--text-muted);
  font-size: clamp(12px, 2.5vw, 14px);
  border-color: var(--text-muted);
}

button.secondary:hover {
  color: var(--text);
  border-color: var(--text);
}

#cta-link {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", system-ui, sans-serif;
  font-size: clamp(14px, 3vw, 16px);
  color: var(--link);
  text-decoration: underline;
  cursor: pointer;
}

#cta-link:hover {
  opacity: 0.8;
}

.share-links {
  display: flex;
  gap: 16px;
}

.share-links a {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", system-ui, sans-serif;
  font-size: clamp(12px, 2.5vw, 14px);
  color: var(--link);
  text-decoration: underline;
}

.share-links a:hover {
  opacity: 0.8;
}

.overlay .btn-primary {
  display: inline-block;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", system-ui, sans-serif;
  font-size: clamp(14px, 3.5vw, 18px);
  font-weight: 600;
  color: var(--accent-bg);
  background: var(--accent);
  border: 2px solid var(--text);
  padding: 14px 32px;
  border-radius: 8px;
  text-decoration: none;
  cursor: pointer;
  transition: opacity 0.2s;
}

.overlay .btn-primary:hover {
  opacity: 0.9;
}

#game-ui {
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  z-index: 5;
  pointer-events: none;
}

#game-ui.hidden {
  display: none;
}

#turbo-banner {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 15;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
  pointer-events: none;
  animation: fog-in-banner 0.6s ease-out forwards;
}

#turbo-banner.hidden {
  display: none !important;
}

@keyframes fog-in-banner {
  from {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.9);
    filter: blur(14px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
    filter: blur(0);
  }
}

.turbo-text {
  font-family: "Nothing", cursive;
  font-size: clamp(24px, 6vw, 36px);
  font-weight: 800;
  color: #ffd700;
  text-shadow: 0 0 20px rgba(255, 215, 0, 0.9), 0 0 40px rgba(255, 215, 0, 0.6), 0 0 60px rgba(255, 255, 100, 0.4);
  animation: turbo-pulse 0.4s ease-in-out infinite alternate;
}

.turbo-hedgehog {
  width: 80px;
  height: 80px;
  filter: brightness(1.8) sepia(0.5) hue-rotate(35deg) saturate(2.5) drop-shadow(0 0 20px rgba(255, 220, 0, 0.9)) drop-shadow(0 0 40px rgba(255, 200, 0, 0.6));
  animation: turbo-shake 0.15s ease-in-out infinite;
}

@keyframes turbo-shake {
  0%, 100% { transform: translateX(0) translateY(0); }
  25% { transform: translateX(-3px) translateY(-2px); }
  50% { transform: translateX(3px) translateY(2px); }
  75% { transform: translateX(-2px) translateY(1px); }
}

/* Game popup (cop catch / bonus) */
.popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 32px 40px;
  min-width: 280px;
  background: rgba(0, 0, 0, 0.95);
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 20px;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.7);
  cursor: pointer;
  animation: fog-in-popup 0.5s ease-out forwards;
}

.popup.popup-hiding {
  animation: fog-out-popup 0.45s ease-in forwards;
}

.popup.hidden {
  display: none !important;
}

@keyframes fog-in-popup {
  from {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.88);
    filter: blur(16px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
    filter: blur(0);
  }
}

@keyframes fog-out-popup {
  from {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
    filter: blur(0);
  }
  to {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.88);
    filter: blur(16px);
  }
}

.popup img {
  width: 96px;
  height: 96px;
  object-fit: contain;
}

.popup span {
  font-family: "Nothing", cursive;
  font-size: clamp(18px, 4.5vw, 24px);
  font-weight: 400;
  text-align: center;
  line-height: 1.3;
  width: 100%;
  align-self: stretch;
  display: block;
}

.popup.popup-danger span {
  color: #e53935;
  font-weight: 700;
}


@keyframes turbo-pulse {
  from { opacity: 1; transform: scale(1); }
  to { opacity: 0.95; transform: scale(1.05); }
}

.game-ui-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 16px;
  background: rgba(0, 0, 0, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 12px;
  min-width: 72px;
}

.game-ui-badge-center {
  flex: 1;
  margin: 0 8px;
}

.game-ui-label {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", system-ui, sans-serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.game-ui-badge span:last-child {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", system-ui, sans-serif;
  font-size: clamp(18px, 4vw, 22px);
  font-weight: 700;
  color: var(--text);
}

#score-text { }
#level-text { }
#lives-text { }

/* Victory overlay */
.victory-buttons {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  max-width: 280px;
  margin-top: 8px;
}

.victory-buttons .btn-primary {
  display: inline-block;
  text-align: center;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", system-ui, sans-serif;
  font-size: clamp(14px, 3.5vw, 16px);
  font-weight: 600;
  color: var(--accent-bg);
  background: var(--accent);
  border: 2px solid var(--text);
  padding: 14px 24px;
  border-radius: 8px;
  text-decoration: none;
  cursor: pointer;
  transition: opacity 0.2s;
}

.victory-buttons .btn-primary:hover {
  opacity: 0.9;
}

.victory-buttons button {
  width: 100%;
}

#dpad {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 8px;
  justify-items: center;
  align-items: center;
  z-index: 5;
  pointer-events: auto;
  padding: 16px 12px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  margin: 0 auto 24px;
  margin-bottom: max(24px, env(safe-area-inset-bottom, 0px));
  width: 100%;
  max-width: 448px;
  box-sizing: border-box;
  background: rgba(0, 0, 0, 0.9);
  border-radius: 24px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

#dpad.hidden {
  display: none;
}

#dpad .dpad-btn {
  min-width: 56px;
  min-height: 56px;
  width: clamp(56px, 18vw, 80px);
  height: clamp(56px, 18vw, 80px);
  background: rgba(255, 255, 255, 0.15);
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-radius: 12px;
  color: var(--text);
  font-size: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

#dpad .dpad-btn:active {
  background: rgba(255, 255, 255, 0.3);
}

#dpad .dpad-btn.empty {
  background: transparent;
  border: none;
  pointer-events: none;
}

@media (max-width: 480px) {
  #game-container {
    padding: 8px 0;
  }
  #main-layout {
    padding-bottom: calc(150px + env(safe-area-inset-bottom, 0px));
  }
  #dpad {
    margin-bottom: max(16px, env(safe-area-inset-bottom, 0px));
  }
}
