/* =============================================
   ULTRA DASH — Style Sheet
   ============================================= */

@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&family=Press+Start+2P&display=swap');

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

:root {
  --primary: #ff6a00;
  --secondary: #ee0979;
  --accent: #00f0ff;
  --dark: #0a0a1a;
  --dark2: #12122a;
  --text: #ffffff;
  --gold: #ffd700;
  --green: #00ff88;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--dark);
  color: var(--text);
  font-family: 'Orbitron', sans-serif;
}

/* ===== SCREENS ===== */
.screen {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  z-index: 10;
}
.screen.active { display: flex; }

/* ===== ANIMATED BG ===== */
.menu-bg-anim {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(255,106,0,.3) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 30%, rgba(0,240,255,.2) 0%, transparent 60%),
    linear-gradient(180deg, #0a0a1a 0%, #12122a 100%);
  z-index: 0;
  animation: bgPulse 4s ease-in-out infinite alternate;
}
@keyframes bgPulse {
  from { filter: brightness(1); }
  to   { filter: brightness(1.3); }
}

/* moving particles */
.menu-bg-anim::after {
  content:'';
  position:absolute; inset:0;
  background-image:
    radial-gradient(2px 2px at 15% 20%, rgba(255,255,255,.4) 0%, transparent 100%),
    radial-gradient(2px 2px at 70% 60%, rgba(0,240,255,.5) 0%, transparent 100%),
    radial-gradient(2px 2px at 40% 80%, rgba(255,106,0,.5) 0%, transparent 100%),
    radial-gradient(2px 2px at 85% 10%, rgba(255,255,255,.3) 0%, transparent 100%),
    radial-gradient(2px 2px at 50% 40%, rgba(238,9,121,.5) 0%, transparent 100%);
  animation: particleFloat 8s linear infinite;
}
@keyframes particleFloat {
  from { transform: translateY(0); }
  to   { transform: translateY(-30px); }
}

/* ===== MAIN MENU ===== */
.menu-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.game-title {
  font-family: 'Orbitron', sans-serif;
  font-size: clamp(3rem, 8vw, 7rem);
  font-weight: 900;
  background: linear-gradient(135deg, var(--primary), var(--secondary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: none;
  letter-spacing: 0.1em;
  animation: titleGlow 2s ease-in-out infinite alternate;
  filter: drop-shadow(0 0 30px rgba(255,106,0,.6));
}
@keyframes titleGlow {
  from { filter: drop-shadow(0 0 20px rgba(255,106,0,.6)); }
  to   { filter: drop-shadow(0 0 50px rgba(0,240,255,.8)); }
}

.menu-subtitle {
  font-size: 1rem;
  color: rgba(255,255,255,.5);
  letter-spacing: .3em;
  text-transform: uppercase;
}

/* ===== BUTTONS ===== */
.btn-primary, .btn-secondary, .btn-back {
  border: none;
  cursor: pointer;
  font-family: 'Orbitron', sans-serif;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  transition: all .2s;
  position: relative;
  overflow: hidden;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
  font-size: 1.1rem;
  padding: 14px 50px;
  border-radius: 4px;
  box-shadow: 0 4px 20px rgba(255,106,0,.4);
}
.btn-primary:hover {
  transform: scale(1.05) translateY(-2px);
  box-shadow: 0 8px 30px rgba(255,106,0,.7);
}
.btn-primary:active { transform: scale(.97); }

.btn-secondary {
  background: transparent;
  color: var(--accent);
  font-size: .9rem;
  padding: 10px 36px;
  border-radius: 4px;
  border: 2px solid var(--accent);
  box-shadow: 0 0 10px rgba(0,240,255,.2);
}
.btn-secondary:hover {
  background: rgba(0,240,255,.1);
  box-shadow: 0 0 20px rgba(0,240,255,.5);
  transform: translateY(-2px);
}

.btn-back {
  background: transparent;
  color: rgba(255,255,255,.6);
  font-size: .85rem;
  padding: 10px 24px;
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,.2);
  margin-top: 10px;
}
.btn-back:hover { color: white; border-color: white; }

.btn-guide {
  background: transparent;
  color: rgba(255,255,255,0.7);
  font-family: 'Orbitron', sans-serif;
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  padding: 9px 28px;
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,0.2);
  cursor: pointer;
  transition: all .2s;
  margin-top: 4px;
}
.btn-guide:hover { color: #00f0ff; border-color: #00f0ff; box-shadow: 0 0 12px rgba(0,240,255,.3); }

/* ===== GUIDE SCREEN ===== */
.btn-back-topleft {
  position: absolute;
  top: 18px;
  left: 18px;
  z-index: 20;
  background: rgba(0,0,0,0.55);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 8px;
  color: rgba(255,255,255,0.85);
  font-family: 'Orbitron', sans-serif;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .1em;
  padding: 8px 16px;
  cursor: pointer;
  transition: background .2s, border-color .2s, color .2s;
  backdrop-filter: blur(6px);
}
.btn-back-topleft:hover {
  background: rgba(0,240,255,0.12);
  border-color: #00f0ff;
  color: #00f0ff;
}

.guide-content {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 20px 24px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  overflow-y: auto;
  max-height: 100vh;
}

.guide-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  width: 100%;
}

.guide-card {
  background: rgba(0,0,0,0.45);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  backdrop-filter: blur(6px);
  transition: border-color .2s;
}
.guide-card:hover { border-color: rgba(0,240,255,0.35); }

.guide-card-wide {
  grid-column: 1 / -1;
}

.guide-card-icon {
  font-size: 1.8rem;
  line-height: 1;
}

.guide-card h3 {
  font-family: 'Orbitron', sans-serif;
  font-size: .75rem;
  font-weight: 900;
  letter-spacing: .15em;
  color: var(--accent);
  margin: 0;
}

.guide-desc {
  font-size: .82rem;
  color: rgba(255,255,255,0.7);
  margin: 0;
  line-height: 1.5;
}

.guide-card ul {
  list-style: none;
  padding: 0; margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.guide-card ul li {
  font-size: .82rem;
  color: rgba(255,255,255,0.8);
  display: flex;
  align-items: center;
  gap: 6px;
}

.key {
  display: inline-block;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 4px;
  padding: 1px 7px;
  font-family: monospace;
  font-size: .8rem;
  color: white;
}

.mode-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.mode-item {
  font-size: .82rem;
  color: rgba(255,255,255,0.8);
  display: flex;
  align-items: center;
  gap: 8px;
}
.mode-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 6px currentColor;
}

.obstacle-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.obs-item {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: .82rem;
  color: rgba(255,255,255,0.8);
  line-height: 1.4;
}
.obs-preview {
  border-radius: 4px;
  background: rgba(255,255,255,0.05);
  flex-shrink: 0;
}

.event-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.event-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: .82rem;
  color: rgba(255,255,255,0.8);
  line-height: 1.4;
}
.event-tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 4px;
  font-family: 'Orbitron', sans-serif;
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .08em;
  color: white;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ===== SCREEN TITLE ===== */
.screen-title {
  font-size: clamp(1.5rem, 4vw, 2.5rem);
  font-weight: 900;
  text-align: center;
  background: linear-gradient(90deg, var(--accent), var(--primary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 30px;
}

/* ===== LEVEL SELECT ===== */
.level-select-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 90%;
  max-width: 900px;
}

.level-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 16px;
  width: 100%;
  margin-bottom: 20px;
}

.level-card {
  background: rgba(255,255,255,.05);
  border: 2px solid rgba(255,255,255,.1);
  border-radius: 8px;
  padding: 20px 10px;
  text-align: center;
  cursor: pointer;
  transition: all .2s;
  position: relative;
}
.level-card:hover:not(.locked) {
  border-color: var(--accent);
  background: rgba(0,240,255,.08);
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(0,240,255,.2);
}
.level-card.locked {
  opacity: .4;
  cursor: not-allowed;
}
.level-card.completed {
  border-color: var(--green);
}
.level-card .lvl-num {
  font-size: 1.5rem;
  font-weight: 900;
  color: white;
}
.level-card .lvl-name {
  font-size: .55rem;
  color: rgba(255,255,255,.5);
  margin-top: 4px;
}
.level-card .lock-icon {
  font-size: 1.5rem;
  margin-bottom: 4px;
}
.level-card.final-level {
  border-color: var(--secondary);
  background: rgba(238,9,121,.1);
}

/* ===== GAME CANVAS ===== */
#gameScreen {
  display: none;
  position: fixed;
  inset: 0;
  background: #0a0a0a;
  z-index: 5;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
#gameScreen.active {
  display: flex;
}

#gameCanvas {
  display: block;
  border: 2px solid rgba(255,255,255,0.15);
  border-radius: 6px;
  box-shadow: 0 0 40px rgba(0,0,0,0.8), 0 0 80px rgba(0,200,255,0.08);
  image-rendering: pixelated;
  max-width: 100%;
}

/* ===== HUD ===== */
#hud {
  position: fixed;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: linear-gradient(180deg, rgba(0,0,0,.7) 0%, transparent 100%);
  z-index: 20;
  pointer-events: none;
}
#hudLeft, #hudRight {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
#hudLeft span, #hudRight span {
  font-size: .7rem;
  color: rgba(255,255,255,.8);
  letter-spacing: .1em;
}
#hudLevel { color: var(--accent) !important; font-weight: 700; font-size: .9rem !important; }
#hudMode  { color: var(--primary) !important; }

#hudCenter { flex: 1; margin: 0 20px; }

#progressBarBg {
  position: relative;
  height: 8px;
  background: rgba(255,255,255,.15);
  border-radius: 4px;
  overflow: visible;
}
#progressBarFill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 4px;
  transition: width .1s;
  box-shadow: 0 0 8px rgba(0,240,255,.5);
}
#progressText {
  position: absolute;
  right: 0;
  top: -18px;
  font-size: .65rem;
  color: var(--accent);
}

#btnPause {
  position: fixed;
  top: 8px;
  right: 16px;
  background: transparent;
  border: 1px solid rgba(255,255,255,.3);
  color: white;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 1rem;
  cursor: pointer;
  z-index: 25;
  transition: all .2s;
}
#btnPause:hover { background: rgba(255,255,255,.1); }

/* ===== OVERLAYS ===== */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.overlay.hidden { display: none; }

.overlay-box {
  background: linear-gradient(135deg, var(--dark), var(--dark2));
  border: 2px solid rgba(255,255,255,.15);
  border-radius: 12px;
  padding: 40px 50px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 320px;
  box-shadow: 0 20px 60px rgba(0,0,0,.8);
  animation: overlayIn .3s ease-out;
}
@keyframes overlayIn {
  from { opacity:0; transform: scale(.8) translateY(20px); }
  to   { opacity:1; transform: scale(1) translateY(0); }
}

.overlay-box h2 {
  font-size: 2rem;
  font-weight: 900;
}
.overlay-box p {
  font-size: .8rem;
  color: rgba(255,255,255,.6);
}

.death-box h2 { color: #ff4444; }
.complete-box h2 { color: var(--gold); }

#completeStars {
  font-size: 2rem;
  letter-spacing: .3em;
}

/* ===== FAKE FINISH ===== */
#fakeFinish {
  background: rgba(0,0,0,0);
  z-index: 80;
  pointer-events: none;
  animation: fakeFlash .8s ease-out forwards;
}
.fake-finish-text {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(1.5rem, 5vw, 3rem);
  color: var(--gold);
  text-shadow: 0 0 30px rgba(255,215,0,.8);
  animation: fakeTextPulse .5s ease-out;
}
@keyframes fakeFlash {
  0%   { background: rgba(255,255,255,.8); }
  30%  { background: rgba(255,215,0,.3); }
  100% { background: rgba(0,0,0,0); }
}
@keyframes fakeTextPulse {
  from { transform: scale(1.5); opacity:0; }
  to   { transform: scale(1); opacity:1; }
}

/* ===== FINAL SCREEN ===== */
#finalScreen {
  background: black;
  z-index: 100;
  flex-direction: column;
}
.final-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}
.final-text {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(1rem, 3vw, 2rem);
  color: var(--accent);
  text-align: center;
  letter-spacing: .1em;
  animation: finalGlow 2s ease-in-out infinite alternate;
}
@keyframes finalGlow {
  from { text-shadow: 0 0 20px rgba(0,240,255,.5); }
  to   { text-shadow: 0 0 60px rgba(0,240,255,1), 0 0 100px rgba(0,240,255,.5); }
}
#finalStats {
  font-size: .75rem;
  color: rgba(255,255,255,.5);
  text-align: center;
  line-height: 2;
}

/* ===== GLITCH OVERLAY ===== */
.glitch-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  pointer-events: none;
  animation: glitchAnim .15s steps(1) infinite;
}
.glitch-overlay.hidden { display: none; }

@keyframes glitchAnim {
  0%   { background: transparent; transform: translate(0,0); }
  20%  { background: rgba(255,0,0,.07); transform: translate(-4px, 2px); clip-path: inset(20% 0 40% 0); }
  40%  { background: rgba(0,0,255,.07); transform: translate(4px, -2px); clip-path: inset(60% 0 10% 0); }
  60%  { background: transparent; transform: translate(0,0); clip-path: none; }
  80%  { background: rgba(0,255,0,.05); transform: translate(-2px, 0px); clip-path: inset(80% 0 5% 0); }
  100% { background: transparent; transform: translate(0,0); clip-path: none; }
}

/* ===== FLASH OVERLAY ===== */
.flash-overlay {
  position: fixed;
  inset: 0;
  z-index: 85;
  pointer-events: none;
  background: white;
}
.flash-overlay.hidden { display: none; }

/* ===== WARNING TEXT ===== */
.warning-text {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 88;
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(.7rem, 2vw, 1.2rem);
  color: #ff4444;
  text-align: center;
  text-shadow: 0 0 20px rgba(255,68,68,.8);
  animation: warningPulse .5s ease-in-out infinite;
  pointer-events: none;
}
.warning-text.hidden { display: none; }
@keyframes warningPulse {
  from { opacity: 1; }
  to   { opacity: .3; }
}

/* ===== ICON MENU ===== */
.icon-menu-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 90%;
  max-width: 800px;
  gap: 16px;
}

#iconPreview {
  width: 100px;
  height: 100px;
  border: 3px solid var(--accent);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,.4);
  margin-bottom: 10px;
}
#iconPreview canvas { width: 80px; height: 80px; }

.icon-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
  gap: 10px;
  width: 100%;
  max-height: 250px;
  overflow-y: auto;
  padding: 10px;
  background: rgba(0,0,0,.3);
  border-radius: 8px;
}
#iconGrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); gap:10px; width:100%; max-height:240px; overflow-y:auto; padding:8px; background:rgba(0,0,0,.3); border-radius:8px; }

.icon-item {
  width: 70px;
  height: 70px;
  border: 2px solid rgba(255,255,255,.15);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all .2s;
  background: rgba(255,255,255,.05);
  position: relative;
}
.icon-item:hover:not(.locked-icon) {
  border-color: var(--accent);
  transform: scale(1.05);
}
.icon-item.selected { border-color: var(--gold); box-shadow: 0 0 12px rgba(255,215,0,.5); }
.icon-item.locked-icon { opacity: .3; cursor: not-allowed; }
.icon-item .lock-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}
.icon-item canvas { width: 50px; height: 50px; }

.color-pick-group { display: flex; flex-direction: column; gap: 8px; align-items: center; }
.color-pick-group label { font-size: .7rem; color: rgba(255,255,255,.5); }
.color-row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.color-swatch {
  width: 32px; height: 32px;
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid transparent;
  transition: all .2s;
}
.color-swatch:hover { transform: scale(1.2); }
.color-swatch.selected { border-color: white; transform: scale(1.15); }

/* ===== LEADERBOARD ===== */
.leaderboard-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 90%;
  max-width: 600px;
}

#leaderboardList {
  width: 100%;
  max-height: 60vh;
  overflow-y: auto;
  background: rgba(0,0,0,.3);
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 16px;
}
.lb-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(255,255,255,.07);
  font-size: .75rem;
}
.lb-row:last-child { border-bottom: none; }
.lb-rank { width: 30px; text-align: center; font-weight: 900; color: var(--accent); }
.lb-rank.gold { color: var(--gold); }
.lb-rank.silver { color: #c0c0c0; }
.lb-rank.bronze { color: #cd7f32; }
.lb-name { flex: 1; color: white; }
.lb-level { color: rgba(255,255,255,.5); font-size: .7rem; }
.lb-time { color: var(--green); font-size: .7rem; }
.lb-empty { text-align: center; color: rgba(255,255,255,.3); padding: 20px; font-size: .8rem; }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: rgba(255,255,255,.05); }
::-webkit-scrollbar-thumb { background: rgba(0,240,255,.3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0,240,255,.5); }

/* ===== SCREEN SHAKE (JS adds/removes class) ===== */
.shake {
  animation: shakeAnim .15s ease-in-out !important;
}
@keyframes shakeAnim {
  0%,100% { transform: translate(0,0); }
  20%  { transform: translate(-6px, 3px); }
  40%  { transform: translate(6px, -3px); }
  60%  { transform: translate(-4px, -3px); }
  80%  { transform: translate(4px, 2px); }
}

/* ===== AURA EFFECT (canvas drawn but glow here) ===== */
.aura-active #gameCanvas {
  filter: drop-shadow(0 0 15px rgba(0,240,255,.6));
}
