@font-face {
  font-family: 'Madou Futo Maru Gothic';
  src: url('../assets/MadouFutoMaruGothic.ttf') format('truetype');
  font-display: swap;
}

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

body {
  background: #1a1a2e;
  overflow: hidden;
  font-family: 'Madou Futo Maru Gothic', monospace;
  color: #e0e0e0;
  image-rendering: pixelated;
}

canvas { display: block; }

#game-container {
  position: relative;
  width: 100vw;
  height: 100vh;
}

#ui-overlay {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
}

#ui-overlay > * { pointer-events: auto; }

#indicators-stack {
  position: absolute;
  bottom: 15px;
  right: 15px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  z-index: 5;
  width: 80px;
}

/* Pixel Button */
.pixel-btn {
  font-family: 'Madou Futo Maru Gothic', monospace;
  font-size: 22px;
  padding: 10px 20px;
  background: #2a2a4a;
  color: #e0e0e0;
  border: 3px solid #7B61FF;
  cursor: pointer;
  text-transform: uppercase;
  image-rendering: pixelated;
  transition: background 0.1s;
}
.pixel-btn:hover { background: #3a3a6a; }
.pixel-btn:active { background: #1a1a3a; border-style: inset; }

/* Menu Screen */
#menu-screen {
  display: none;
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  background: rgba(26, 26, 46, 0.9);
  z-index: 10;
}

.title-wrapper {
  position: relative;
  display: inline-block;
}

.game-title {
  font-size: 96px;
  color: #7B61FF;
  text-align: center;
  text-shadow: 4px 4px 0 white, 2px 2px 0 #3a2a8a, 0 0 20px #7B61FF44;
  line-height: 1.6;
  perspective: 600px;
  transform-style: preserve-3d;
  animation: title3d 6s ease-in-out infinite;
}

@keyframes title3d {
  0%   { transform: perspective(600px) rotateY(-8deg) rotateX(4deg) translateZ(0px); }
  25%  { transform: perspective(600px) rotateY(6deg) rotateX(-3deg) translateZ(30px); }
  50%  { transform: perspective(600px) rotateY(8deg) rotateX(4deg) translateZ(0px); }
  75%  { transform: perspective(600px) rotateY(-6deg) rotateX(-3deg) translateZ(30px); }
  100% { transform: perspective(600px) rotateY(-8deg) rotateX(4deg) translateZ(0px); }
}

.menu-ghost {
  animation: bob 2s ease-in-out infinite;
  position: relative;
}
.menu-ghost-img {
  width: 96px;
  height: 96px;
  filter: drop-shadow(0 0 8px #7B61FF) drop-shadow(0 0 20px #7B61FF55);
  cursor: pointer;
  transition: all 0.3s ease;
}
.menu-ghost:hover .menu-ghost-img {
  image-rendering: pixelated;
  width: 192px;
  height: 192px;
}

.menu-ghost::after {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  width: 150px; height: 150px;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, #7B61FF66 0%, #7B61FF22 40%, transparent 70%);
  border-radius: 50%;
  animation: heartbeat-glow 0.8s ease-in-out infinite;
  pointer-events: none;
  z-index: -1;
}

@keyframes heartbeat-glow {
  0% { opacity: 0.3; transform: translate(-50%, -50%) scale(1); }
  15% { opacity: 1; transform: translate(-50%, -50%) scale(1.4); }
  30% { opacity: 0.5; transform: translate(-50%, -50%) scale(1.1); }
  45% { opacity: 0.9; transform: translate(-50%, -50%) scale(1.25); }
  60% { opacity: 0.3; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0.3; transform: translate(-50%, -50%) scale(1); }
}

@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}



.menu-buttons { display: flex; flex-direction: column; gap: 12px; }

.how-to-play-modal {
  background: #2a2a4a;
  border: 3px solid #7B61FF;
  padding: 20px;
  font-size: 22px;
  line-height: 2;
  max-width: 400px;
}
.how-to-play-modal h3 { color: #7B61FF; margin-bottom: 10px; }

/* Level Select */
#level-select-screen {
  display: none;
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: rgba(26, 26, 46, 0.95);
  z-index: 10;
  overflow-y: auto;
  padding: 20px;
}

#level-select-screen h2 { color: #7B61FF; font-size: 22px; }

.level-grid {
  display: grid;
  grid-template-columns: repeat(5, 80px);
  gap: 8px;
}

.level-tile {
  width: 80px; height: 80px;
  background: #2a2a4a;
  border: 2px solid #444;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 22px;
  cursor: default;
}
.level-tile.unlocked { border-color: #7B61FF; cursor: pointer; }
.level-tile.unlocked:hover { background: #3a3a6a; }
.level-tile.solved { border-color: #4CAF50; }
.level-tile.locked { opacity: 0.4; }
.level-num { font-size: 22px; }
.level-stars { color: #FFD700; font-size: 22px; }
.level-best { color: #888; font-size: 22px; }
.level-nav { display: flex; gap: 12px; align-items: center; }
.page-label { font-size: 22px; }

/* Game Panels */
.game-panel {
  display: none;
  position: absolute;
  flex-direction: column;
  gap: 6px;
  font-size: 22px;
  background: rgba(0,0,0,0.5);
  padding: 10px;
  border: 2px solid #7B61FF;
  z-index: 5;
}
#hud { top: 10px; left: 10px; }
#controls-list { top: 10px; right: 10px; }
.hud-row, .controls-row { display: flex; gap: 8px; }
.hud-label, .controls-title, .controls-key { color: #7B61FF; }
.hud-toggle { color: #4CAF50; cursor: pointer; }

/* Pause Menu */
#pause-menu {
  display: none;
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: rgba(0, 0, 0, 0.7);
  z-index: 20;
}
#pause-menu h2 { color: #7B61FF; font-size: 22px; }
.pause-buttons { display: flex; flex-direction: column; gap: 10px; }

/* Level Complete */
#level-complete {
  display: none;
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: rgba(0, 0, 0, 0.8);
  z-index: 20;
}
#level-complete h2 { color: #4CAF50; font-size: 22px; }
.stars { font-size: 22px; color: #FFD700; }
.stats { font-size: 22px; line-height: 2.5; text-align: center; }
.complete-buttons { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

/* Confetti */
.confetti-container {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  overflow: hidden;
}
.confetti {
  position: absolute;
  top: -10px;
  width: 8px; height: 8px;
  animation: fall 3s linear infinite;
}
@keyframes fall {
  to { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

/* Zoom Indicator */
/* Slider Indicators */
.slider-indicator { text-align: center; }
.slider-label { font-size: 22px; color: #aaa; margin-bottom: 4px; }
.slider-track {
  width: 100%; height: 6px;
  background: #2a2a4a;
  border: 1px solid #444;
  position: relative;
}
.slider-fill {
  position: absolute;
  top: 0; height: 100%;
  background: #7B61FF;
  width: 0;
}

/* Compass */
#compass {
  width: 80px;
  height: 80px;
  z-index: 5;
  perspective: 120px;
}
.compass-ring {
  width: 100%; height: 100%;
  border: 1px solid #444;
  background: #2a2a4a;
  border-radius: 50%;
  position: relative;
  transition: transform 0.3s ease;
  transform-style: preserve-3d;
}
.compass-label {
  position: absolute;
  font-size: 22px;
  color: #fff;
}
.compass-N { top: 4px; left: 50%; transform: translateX(-50%); color: #7B61FF; font-weight: bold; }
.compass-S { bottom: 4px; left: 50%; transform: translateX(-50%); }
.compass-E { right: 6px; top: 50%; transform: translateY(-50%); }
.compass-W { left: 6px; top: 50%; transform: translateY(-50%); }
.compass-arrow {
  position: absolute;
  top: 14px; left: 50%;
  width: 2px; height: 20px;
  background: #7B61FF;
  transform: translateX(-50%);
}
