@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;600;700;800;900&display=swap');

/* ============================================
   GAME CSS - Not a website, a GAME
   ============================================ */

:root {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --orange: #ff7a2f;
  --cyan: #30d6ff;
  --yellow: #ffe15d;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  position: fixed;
  background: #0a0f1c;
  font-family: 'Outfit', sans-serif;
}

/* ============================================
   FULL SCREEN GAME CANVAS
   ============================================ */
#game {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* ============================================
   MINIMAL IN-GAME HUD
   ============================================ */
.hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  padding: calc(8px + var(--safe-top)) calc(12px + var(--safe-right)) 0 calc(12px + var(--safe-left));
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: none;
  z-index: 10;
}

.hud.hidden {
  display: none;
}

.hud-score {
  font-size: clamp(1.5rem, 5vw, 2.5rem);
  font-weight: 900;
  color: #fff;
  text-shadow: 0 2px 8px rgba(0,0,0,0.5);
}

.hud-combo {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-size: clamp(1rem, 3vw, 1.5rem);
  font-weight: 800;
  color: var(--orange);
  text-shadow: 0 2px 8px rgba(0,0,0,0.5);
  opacity: 0;
  transition: opacity 0.2s;
}

.hud-combo.active {
  opacity: 1;
}

.hud-combo .combo-bar {
  position: absolute;
  bottom: -4px;
  left: 50%;
  transform: translateX(-50%);
  width: 50px;
  height: 3px;
  background: rgba(255,255,255,0.2);
  border-radius: 2px;
  overflow: hidden;
}

.hud-combo .combo-bar-fill {
  height: 100%;
  background: var(--orange);
  transition: width 0.1s linear;
}

.hud-level {
  font-size: clamp(1rem, 3vw, 1.5rem);
  font-weight: 700;
  color: var(--cyan);
  text-shadow: 0 2px 8px rgba(0,0,0,0.5);
}

.hud-level::before {
  content: 'LV ';
  font-size: 0.7em;
  opacity: 0.7;
}

.hud-lives {
  position: fixed;
  top: calc(50px + var(--safe-top));
  left: calc(12px + var(--safe-left));
  font-size: 1.2rem;
}

/* Level Progress Bar */
.level-progress-container {
  position: fixed;
  top: calc(50px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  width: min(300px, 50vw);
  height: 24px;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 12px;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.2);
}

.level-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--cyan), var(--orange));
  border-radius: 10px;
  transition: width 0.3s ease-out;
}

.level-progress-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  justify-content: space-between;
  width: 90%;
  font-size: 0.7rem;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
  pointer-events: none;
}

.hud-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.hud-btn {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 8px;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #fff;
  font-size: 1.1rem;
  cursor: pointer;
  pointer-events: auto;
  transition: transform 0.1s, opacity 0.1s;
}

.hud-btn:active {
  transform: scale(0.9);
}

.music-btn.muted {
  opacity: 0.4;
  text-decoration: line-through;
}

/* ============================================
   MENUS (Start, Pause, Game Over)
   ============================================ */
.menu {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 15, 28, 0.95);
  z-index: 100;
}

.menu.hidden {
  display: none;
}

.menu-content {
  text-align: center;
  padding: 20px;
}

/* Start Menu Title */
.game-title {
  font-size: clamp(4rem, 15vw, 8rem);
  font-weight: 900;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: -0.02em;
  line-height: 0.9;
  text-shadow: 
    0 0 40px rgba(255, 122, 47, 0.5),
    0 4px 20px rgba(0,0,0,0.5);
}

.game-subtitle {
  font-size: clamp(1rem, 4vw, 1.5rem);
  font-weight: 600;
  color: var(--orange);
  text-transform: uppercase;
  letter-spacing: 0.2em;
  margin-top: 8px;
  margin-bottom: 40px;
}

/* Menu Titles */
.menu-title {
  font-size: clamp(2rem, 8vw, 4rem);
  font-weight: 900;
  color: #fff;
  text-transform: uppercase;
  margin-bottom: 30px;
}

.level-title {
  color: var(--cyan);
}

/* Play Button */
.play-btn {
  display: inline-block;
  padding: 18px 60px;
  font-family: inherit;
  font-size: clamp(1.2rem, 4vw, 1.8rem);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #0a0f1c;
  background: linear-gradient(135deg, var(--orange), var(--yellow));
  border: none;
  border-radius: 60px;
  cursor: pointer;
  box-shadow: 
    0 8px 30px rgba(255, 122, 47, 0.4),
    inset 0 2px 0 rgba(255,255,255,0.3);
  transition: transform 0.15s, box-shadow 0.15s;
}

.play-btn:active {
  transform: scale(0.95);
  box-shadow: 0 4px 20px rgba(255, 122, 47, 0.3);
}

.menu-btn {
  display: block;
  width: 200px;
  margin: 12px auto;
  padding: 14px 0;
  font-family: inherit;
  font-size: 1.1rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #fff;
  background: rgba(255,255,255,0.1);
  border: 2px solid rgba(255,255,255,0.3);
  border-radius: 50px;
  cursor: pointer;
  transition: all 0.15s;
}

.menu-btn:active {
  background: rgba(255,255,255,0.2);
  transform: scale(0.95);
}

.menu-btn.secondary {
  background: transparent;
  border-color: rgba(255,255,255,0.2);
  color: rgba(255,255,255,0.7);
}

/* Score displays */
.high-score, .best-score {
  margin-top: 30px;
  font-size: 1rem;
  font-weight: 600;
  color: rgba(255,255,255,0.5);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* Mode Selector */
.mode-selector {
  margin: 30px 0;
  padding: 20px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.mode-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.7);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 15px;
}

.mode-buttons {
  display: flex;
  justify-content: center;
  gap: 15px;
  flex-wrap: wrap;
}

.mode-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 30px;
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 140px;
}

.mode-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.3);
  transform: translateY(-2px);
}

.mode-btn.active {
  background: rgba(48, 214, 255, 0.15);
  border-color: var(--cyan);
  box-shadow: 0 0 20px rgba(48, 214, 255, 0.2);
}

.mode-icon {
  font-size: 2rem;
  margin-bottom: 8px;
}

.mode-text {
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 4px;
}

.mode-desc {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.5);
}

/* Tutorial hints on start menu */
.tutorial-hints {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-top: 40px;
  flex-wrap: wrap;
}

.tutorial-hints.hidden {
  display: none;
}

.hint {
  font-size: 0.85rem;
  font-weight: 600;
  color: rgba(255,255,255,0.6);
  display: flex;
  align-items: center;
  gap: 8px;
}

.key {
  display: inline-block;
  padding: 4px 10px;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 6px;
  font-family: monospace;
  font-size: 0.9rem;
  color: var(--cyan);
}

.final-score {
  margin: 20px 0;
}

.score-label {
  display: block;
  font-size: 0.9rem;
  color: rgba(255,255,255,0.5);
  text-transform: uppercase;
  letter-spacing: 0.2em;
}

.score-value {
  display: block;
  font-size: clamp(3rem, 12vw, 6rem);
  font-weight: 900;
  color: var(--yellow);
  line-height: 1;
}

.level-score {
  font-size: 1.5rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 30px;
}

/* Menu images for victory/defeat */
.menu-image {
  width: 200px;
  height: 200px;
  object-fit: cover;
  border-radius: 20px;
  margin: 20px auto;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
  border: 4px solid rgba(255, 255, 255, 0.2);
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */
.toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 12px 28px;
  font-size: clamp(1.2rem, 4vw, 1.8rem);
  font-weight: 800;
  text-transform: uppercase;
  color: #0a0f1c;
  background: var(--yellow);
  border-radius: 8px;
  z-index: 200;
  animation: toastPop 0.3s ease-out;
}

.toast.hidden {
  display: none;
}

@keyframes toastPop {
  0% { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
  50% { transform: translate(-50%, -50%) scale(1.1); }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

/* ============================================
   MOBILE TOUCH CONTROLS
   ============================================ */
.touch-controls {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
}

.touch-controls.hidden {
  display: none;
}

.touch-btn {
  position: fixed;
  pointer-events: auto;
  border: none;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.1s;
}

.touch-btn:active {
  transform: scale(0.85);
  opacity: 0.7;
}

/* Jump - Bottom left, large */
.jump-btn {
  left: calc(16px + var(--safe-left));
  bottom: calc(24px + var(--safe-bottom));
  width: clamp(70px, 18vw, 100px);
  height: clamp(70px, 18vw, 100px);
  border-radius: 50%;
  background: linear-gradient(135deg, var(--orange), var(--yellow));
  box-shadow: 0 4px 20px rgba(255, 122, 47, 0.5);
}

.jump-btn::after {
  content: '▲';
  font-size: clamp(1.5rem, 5vw, 2rem);
  color: #0a0f1c;
}

/* Punch - Bottom right, large */
.punch-btn {
  right: calc(16px + var(--safe-right));
  bottom: calc(24px + var(--safe-bottom));
  width: clamp(70px, 18vw, 100px);
  height: clamp(70px, 18vw, 100px);
  border-radius: 50%;
  background: linear-gradient(135deg, var(--cyan), #1e78ff);
  box-shadow: 0 4px 20px rgba(48, 214, 255, 0.5);
}

.punch-btn::after {
  content: '✊';
  font-size: clamp(1.5rem, 5vw, 2rem);
}

/* Pause - Top right, small */
.pause-btn {
  right: calc(12px + var(--safe-right));
  top: calc(12px + var(--safe-top));
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.pause-btn::after {
  content: '❚❚';
  font-size: 0.8rem;
  color: rgba(255,255,255,0.8);
  letter-spacing: -2px;
}

/* ============================================
   LANDSCAPE MODE ADJUSTMENTS
   ============================================ */
@media (orientation: landscape) and (max-height: 500px) {
  .jump-btn, .punch-btn {
    width: clamp(55px, 12vh, 80px);
    height: clamp(55px, 12vh, 80px);
    bottom: calc(16px + var(--safe-bottom));
  }
  
  .jump-btn::after, .punch-btn::after {
    font-size: 1.2rem;
  }
  
  .hud {
    padding-top: calc(6px + var(--safe-top));
  }
  
  .hud-score {
    font-size: 1.5rem;
  }
  
  .game-title {
    font-size: clamp(2.5rem, 12vh, 5rem);
  }
  
  .play-btn {
    padding: 14px 50px;
    font-size: 1.2rem;
  }
}

/* ============================================
   PORTRAIT MODE - Extra tall phones
   ============================================ */
@media (orientation: portrait) and (min-height: 700px) {
  .jump-btn, .punch-btn {
    bottom: calc(40px + var(--safe-bottom));
  }
}

/* ============================================
   PC CONTROLS - Visible on desktop
   ============================================ */
.pc-controls {
  position: fixed;
  bottom: calc(20px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 30px;
  z-index: 50;
  padding: 15px 25px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(10px);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.pc-controls.hidden {
  display: none;
}

.pc-control-hint {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}

.pc-key {
  display: inline-block;
  padding: 8px 16px;
  background: linear-gradient(135deg, #2a2a3a, #1a1a2a);
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  border-bottom: 4px solid rgba(255, 255, 255, 0.1);
  font-family: 'Outfit', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  color: var(--cyan);
  text-shadow: 0 0 10px rgba(48, 214, 255, 0.3);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.pc-action {
  font-size: 0.75rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.7);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ============================================
   DESKTOP - Hide touch controls, show PC controls by default
   ============================================ */
@media (hover: hover) and (pointer: fine) {
  .play-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 12px 40px rgba(255, 122, 47, 0.5);
  }
  
  .menu-btn:hover {
    background: rgba(255,255,255,0.15);
    border-color: rgba(255,255,255,0.4);
  }
}

/* ============================================
   MODE-SPECIFIC CONTROLS
   ============================================ */
/* PC Mode - show PC controls, hide mobile */
body[data-mode="pc"] .pc-controls {
  display: flex !important;
}

body[data-mode="pc"] .touch-controls {
  display: none !important;
}

/* Mobile Mode - show mobile controls, hide PC */
body[data-mode="mobile"] .pc-controls {
  display: none !important;
}

body[data-mode="mobile"] .touch-controls {
  display: flex !important;
}

/* ============================================
   REDUCED MOTION
   ============================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}
