/* ========================================
   DUNDIE DASH — Retro Arcade Stylesheet
   ======================================== */

:root {
  --bg:        #0a0a12;
  --surface:   #12121f;
  --border:    #2a2a3d;
  --primary:   #f5c842;
  --accent:    #42f587;
  --danger:    #f54263;
  --text:      #e0e0e8;
  --muted:     #6a6a80;
  --font:      'Press Start 2P', monospace;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-top: 24px;
  overflow-x: hidden;
  image-rendering: pixelated;
}

/* Scanline overlay for retro CRT feel */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0,0,0,0.08) 2px,
    rgba(0,0,0,0.08) 4px
  );
  z-index: 9999;
}

#wrapper {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  margin: 0 auto;
  padding: 0 10px;
  box-sizing: border-box;
}

#wrapper > * {
  width: 100%;
  box-sizing: border-box;
}

/* ===== TITLE ===== */
#title {
  font-size: 18px;
  color: var(--primary);
  text-shadow: 0 0 12px rgba(245,200,66,0.5);
  letter-spacing: 2px;
  margin-bottom: 4px;
  animation: pulse-glow 2s ease-in-out infinite;
}
#subtitle {
  font-size: 8px;
  color: var(--muted);
  margin-bottom: 18px;
  letter-spacing: 3px;
  text-transform: uppercase;
}

@keyframes pulse-glow {
  0%, 100% { text-shadow: 0 0 12px rgba(245,200,66,0.4); }
  50%      { text-shadow: 0 0 24px rgba(245,200,66,0.8), 0 0 48px rgba(245,200,66,0.3); }
}

/* ===== FORM SCREEN ===== */
#form-screen {
  width: 100%;
}

#form-box, #leaderboard-box, #gameover-box, #cooldown-box {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 4px;
  padding: 20px;
  margin-bottom: 14px;
}

label {
  display: block;
  font-size: 8px;
  color: var(--muted);
  margin-bottom: 6px;
  margin-top: 12px;
}
label:first-of-type { margin-top: 0; }

input[type="text"] {
  width: 100%;
  padding: 10px;
  font-family: var(--font);
  font-size: 9px;
  background: var(--bg);
  color: var(--text);
  border: 2px solid var(--border);
  border-radius: 2px;
  outline: none;
  transition: border-color 0.2s;
}
input[type="text"]:focus {
  border-color: var(--primary);
}

#form-error {
  font-size: 7px;
  color: var(--danger);
  min-height: 14px;
  margin-top: 8px;
}

button {
  display: block;
  width: 100%;
  padding: 12px;
  font-family: var(--font);
  font-size: 10px;
  border: none;
  border-radius: 2px;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.2s;
  margin-top: 4px;
}
button:active { transform: scale(0.97); }

#play-btn {
  background: var(--primary);
  color: var(--bg);
  box-shadow: 0 4px 0 #c9a020;
}
#play-btn:hover { box-shadow: 0 2px 0 #c9a020; transform: translateY(2px); }

#back-btn, #cooldown-back-btn {
  background: var(--border);
  color: var(--text);
  box-shadow: 0 4px 0 #1a1a2d;
  margin-top: 14px;
}

/* ===== LEADERBOARD ===== */
#leaderboard-box h2 {
  font-size: 10px;
  color: var(--primary);
  margin-bottom: 12px;
  text-align: center;
}

#leaderboard-list {
  list-style: none;
  counter-reset: lb;
}
#leaderboard-list li {
  counter-increment: lb;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 8px;
  padding: 6px 4px;
  border-bottom: 1px solid var(--border);
}
#leaderboard-list li::before {
  content: counter(lb) ".";
  color: var(--muted);
  min-width: 28px;
}
#leaderboard-list li:nth-child(1)::before { color: #ffd700; }
#leaderboard-list li:nth-child(2)::before { color: #c0c0c0; }
#leaderboard-list li:nth-child(3)::before { color: #cd7f32; }

.lb-name  { flex: 1; color: var(--accent); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-score { color: var(--primary); margin-left: 8px; }

#leaderboard-list .empty-lb {
  color: var(--muted);
  text-align: center;
  display: block;
  padding: 12px;
}

/* ===== CANVAS ===== */
#game-canvas {
  border: 2px solid var(--border);
  border-radius: 2px;
  background: #0d1117;
}

/* ===== HUD ===== */
#hud {
  width: 400px;
  display: flex;
  justify-content: space-between;
  padding: 6px 2px;
  font-size: 9px;
}
#hud-score { color: var(--primary); }
#hud-user  { color: var(--muted); font-size: 7px; }

/* ===== GAME OVER ===== */
#gameover-screen, #cooldown-screen {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(10,10,18,0.88);
  z-index: 100;
}

#gameover-box h2, #cooldown-box h2 {
  font-size: 16px;
  color: var(--danger);
  margin-bottom: 14px;
  text-align: center;
}
#cooldown-box h2 { color: var(--primary); }

#final-score-text {
  font-size: 12px;
  color: var(--primary);
  text-align: center;
  margin-bottom: 8px;
}
#save-msg {
  font-size: 7px;
  color: var(--accent);
  text-align: center;
  margin-bottom: 8px;
}
.hint {
  font-size: 7px;
  color: var(--muted);
  text-align: center;
  line-height: 1.8;
}

#cooldown-timer {
  font-size: 11px;
  color: var(--accent);
  text-align: center;
  margin: 10px 0;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 440px) {
  #wrapper { width: 98vw; }
  #game-canvas { width: 100%; height: auto; }
  #hud { width: 100%; }
}

/* ===== MOBILE FIXES ===== */
#legal-links {
  text-align: center;
  padding: 16px 0;
  font-family: var(--font);
  font-size: 6px;
}
#legal-links a {
  color: var(--muted);
  text-decoration: none;
  margin: 0 10px;
}
#legal-links a:hover {
  color: var(--primary);
}


#title {
  text-align: center;
  width: 100%;
}

#subtitle {
  text-align: center;
  width: 100%;
}

@media (max-width: 440px) {
  body {
    padding-top: 12px;
  }
  #title {
    font-size: 14px;
  }
  #game-canvas {
    width: 100%;
    height: auto;
  }
}

/* ===== INSTRUCTIONS ===== */
#instructions {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 4px;
  padding: 20px;
  margin-top: 14px;
  width: 100%;
}
#instructions h2 {
  font-size: 10px;
  color: var(--primary);
  text-align: center;
  margin-bottom: 16px;
}
.inst-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.inst-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.inst-icon {
  font-size: 16px;
  flex-shrink: 0;
  line-height: 1;
}
.inst-item p {
  font-size: 7px;
  color: var(--muted);
  line-height: 1.8;
}
@media (max-width: 440px) {
  .inst-grid {
    grid-template-columns: 1fr;
  }
}

/* ===== INSTRUCTIONS ===== */
#instructions {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 4px;
  padding: 20px;
  margin-top: 14px;
  width: 100%;
}
#instructions h2 {
  font-size: 10px;
  color: var(--primary);
  text-align: center;
  margin-bottom: 16px;
}
.inst-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.inst-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.inst-icon {
  font-size: 16px;
  flex-shrink: 0;
  line-height: 1;
}
.inst-item p {
  font-size: 7px;
  color: var(--muted);
  line-height: 1.8;
}
@media (max-width: 440px) {
  .inst-grid {
    grid-template-columns: 1fr;
  }
}

/* ===== PRIZE POOL ===== */
#prize-pool {
  background: var(--surface);
  border: 2px solid #f5c842;
  border-radius: 4px;
  padding: 20px;
  margin-top: 14px;
  width: 100%;
}
#prize-pool h2 {
  font-size: 10px;
  color: var(--primary);
  text-align: center;
  margin-bottom: 14px;
}
.prize-item {
  font-size: 8px;
  color: var(--accent);
  text-align: center;
  padding: 8px;
  background: rgba(66, 245, 135, 0.05);
  border: 1px solid rgba(66, 245, 135, 0.15);
  border-radius: 4px;
  margin-bottom: 6px;
}
.prize-note {
  font-size: 6px;
  color: var(--muted);
  text-align: center;
  margin-top: 10px;
  line-height: 1.8;
}

/* ===== HALL OF FAME ===== */
#hall-of-fame {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 4px;
  padding: 20px;
  margin-top: 14px;
  width: 100%;
}
#hall-of-fame h2 {
  font-size: 10px;
  color: var(--primary);
  text-align: center;
  margin-bottom: 14px;
}
.winner-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px;
  border-bottom: 1px solid var(--border);
  font-size: 7px;
}
.winner-card:last-child {
  border-bottom: none;
}
.winner-name {
  color: var(--accent);
  flex: 1;
}
.winner-score {
  color: var(--primary);
  margin: 0 10px;
}
.winner-week {
  color: var(--muted);
  font-size: 6px;
}
.winner-prize {
  color: var(--accent);
  font-size: 6px;
  margin-left: 8px;
}
.winner-sent {
  color: var(--accent);
}
.winner-pending {
  color: var(--danger);
  font-size: 6px;
}
.empty-winners {
  color: var(--muted);
  text-align: center;
  font-size: 7px;
  padding: 10px;
}

/* ===== RETRO ARCADE EXTRAS ===== */

#insert-coin {
  font-size: 8px;
  color: var(--primary);
  text-align: center;
  letter-spacing: 2px;
  animation: blink-text 1s steps(2) infinite;
  margin-bottom: 14px;
}

@keyframes blink-text {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* ALL TIME HIGH SCORES */
#alltime-box {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 4px;
  padding: 20px;
  margin-top: 14px;
}

#alltime-box h2 {
  font-size: 10px;
  color: var(--primary);
  margin-bottom: 12px;
  text-align: center;
}

#alltime-list {
  list-style: none;
  counter-reset: at;
}

#alltime-list li {
  counter-increment: at;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 8px;
  padding: 6px 4px;
  border-bottom: 1px solid var(--border);
}

#alltime-list li::before {
  content: counter(at) ".";
  color: var(--muted);
  min-width: 28px;
}

#alltime-list li:nth-child(1)::before { color: #ffd700; }
#alltime-list li:nth-child(2)::before { color: #c0c0c0; }
#alltime-list li:nth-child(3)::before { color: #cd7f32; }

.at-name {
  flex: 1;
  color: #ff6b9d;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.at-score {
  color: var(--primary);
  margin-left: 8px;
}

#alltime-list .empty-at {
  color: var(--muted);
  text-align: center;
  display: block;
  padding: 12px;
}

/* NEW HIGH SCORE FLASH */
#new-highscore {
  font-size: 10px;
  color: #ffd700;
  text-align: center;
  animation: highscore-flash 0.5s ease-in-out infinite alternate;
  margin-bottom: 8px;
}

@keyframes highscore-flash {
  0% { color: #ffd700; text-shadow: 0 0 10px rgba(255,215,0,0.8); }
  100% { color: #ff6b9d; text-shadow: 0 0 20px rgba(255,107,157,0.8); }
}

/* Leaderboard box separator */
#leaderboard-box {
  border-bottom: none;
}

