/* =============================================================
   SUPER MARIO DINOSAUR RUNNER - RETRO ARCADE STYLESHEET
   ============================================================= */

:root {
  --mario-red: #E52521;
  --mario-blue: #0038A8;
  --mario-yellow: #FCD828;
  --mario-green: #00A800;
  --bg-dark: #12151e;
  --panel-bg: #1e2433;
  --text-light: #f0f4f8;
  --text-muted: #9ba1b0;
  --border-color: #2e384d;
}

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

body {
  background-color: var(--bg-dark);
  color: var(--text-light);
  font-family: 'Press Start 2P', 'Courier New', monospace, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 18px 12px;
  overflow-x: hidden;
}

/* Master Container */
.game-container {
  width: 100%;
  max-width: 980px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Top Arcade HUD (Clean 4-column balanced layout) */
.arcade-hud {
  background: #000000;
  border: 4px solid #333333;
  border-radius: 8px;
  padding: 12px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.6);
  flex-wrap: wrap;
  gap: 12px;
}

.hud-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.hud-label {
  font-size: 10px;
  color: #ff5555;
  letter-spacing: 1px;
}

.hud-value {
  font-size: 16px;
  color: #ffffff;
  letter-spacing: 2px;
  transition: color 0.15s, transform 0.15s;
}

.hud-value.flash {
  color: #ffe600;
  transform: scale(1.15);
  text-shadow: 0 0 10px #ffe600;
}

.coin-box {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.hud-coin-canvas {
  width: 22px;
  height: 22px;
  image-rendering: -moz-crisp-edges;
  image-rendering: -webkit-crisp-edges;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  display: inline-block;
  vertical-align: middle;
  animation: coinBounce 1s infinite alternate ease-in-out;
}

@keyframes coinBounce {
  0% { transform: translateY(0); }
  100% { transform: translateY(-3px); }
}

.world-box {
  align-items: center;
}

.hud-subvalue {
  font-size: 11px;
  color: #00ffcc;
  letter-spacing: 0.5px;
}

.hi-score {
  align-items: flex-end;
}

.hi-val {
  color: #ffd700;
}

/* Star Timer Bar */
.star-timer-container {
  display: none;
  background: #111;
  border: 2px solid #ffd700;
  border-radius: 6px;
  padding: 6px 12px;
  text-align: center;
}

.star-label {
  font-size: 10px;
  color: #ffd700;
  margin-bottom: 4px;
  animation: rainbowText 1.5s infinite linear;
}

.star-bar-track {
  width: 100%;
  height: 10px;
  background: #222;
  border-radius: 5px;
  overflow: hidden;
}

.star-bar-fill {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #ff0055, #ffd700, #00ffcc, #0077ff, #ff0055);
  background-size: 200% 100%;
  animation: rainbowScroll 2s linear infinite;
  transition: width 0.1s linear;
}

@keyframes rainbowScroll {
  0% { background-position: 0% 50%; }
  100% { background-position: 200% 50%; }
}

@keyframes rainbowText {
  0% { color: #ffd700; text-shadow: 0 0 8px #ffd700; }
  33% { color: #00ffcc; text-shadow: 0 0 8px #00ffcc; }
  66% { color: #ff00aa; text-shadow: 0 0 8px #ff00aa; }
  100% { color: #ffd700; text-shadow: 0 0 8px #ffd700; }
}

/* Canvas Wrapper */
.canvas-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 960 / 380;
  background-color: #6b8cff;
  border: 4px solid #222;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7);
  touch-action: none;
}

#gameCanvas {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: -moz-crisp-edges;
  image-rendering: -webkit-crisp-edges;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  touch-action: none;
}

/* Overlay Screen (Start / Game Over) */
.overlay-screen {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  backdrop-filter: blur(2px);
}

.overlay-card {
  background: #191e2b;
  border: 4px solid var(--mario-yellow);
  border-radius: 12px;
  padding: 24px 30px;
  text-align: center;
  max-width: 600px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.8);
  cursor: pointer;
}

.pulse {
  animation: pulseCard 2s infinite ease-in-out;
}

@keyframes pulseCard {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.02); }
}

.game-title {
  color: var(--mario-yellow);
  font-size: 20px;
  margin-bottom: 8px;
  text-shadow: 3px 3px 0px #b80000;
  letter-spacing: 1px;
}

.subtitle {
  color: #a0c4ff;
  font-size: 10px;
  margin-bottom: 20px;
  letter-spacing: 1px;
}

.start-instruction {
  font-size: 12px;
  color: #ffffff;
  background: #e52521;
  padding: 10px 16px;
  border-radius: 6px;
  margin-bottom: 16px;
  animation: blink 1.2s infinite;
  cursor: pointer;
}

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

.quick-controls {
  display: flex;
  gap: 16px;
  justify-content: center;
  font-size: 9px;
  color: #cfd8dc;
  flex-wrap: wrap;
}

kbd {
  background: #333d52;
  border: 2px solid #55627e;
  border-radius: 4px;
  padding: 2px 6px;
  font-family: inherit;
  font-size: 9px;
  color: #ffd700;
  box-shadow: 0 2px 0 #1b212c;
}

/* Game Over Modal */
.game-over-box {
  background: #181b24;
  border: 4px solid var(--mario-red);
  border-radius: 12px;
  padding: 28px 36px;
  text-align: center;
  width: 90%;
  max-width: 440px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.9);
  animation: popIn 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

@keyframes popIn {
  from { transform: scale(0.7); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.game-over-title {
  color: var(--mario-red);
  font-size: 22px;
  margin-bottom: 20px;
  text-shadow: 3px 3px 0 #000;
  letter-spacing: 2px;
}

.stats-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
  background: #0d1017;
  padding: 14px;
  border-radius: 6px;
  border: 2px solid #2a3449;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
}

.stat-val {
  color: #ffd700;
  font-size: 13px;
}

.arcade-btn {
  font-family: inherit;
  font-size: 12px;
  padding: 12px 20px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  letter-spacing: 1px;
  transition: transform 0.1s, filter 0.1s;
  touch-action: manipulation;
}

.restart-btn {
  background: var(--mario-green);
  color: #ffffff;
  box-shadow: 0 4px 0 #006b00;
}

.restart-btn:hover {
  filter: brightness(1.15);
  transform: translateY(-2px);
  box-shadow: 0 6px 0 #006b00;
}

.restart-btn:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #006b00;
}

/* Toolbar & Buttons */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  background: #191f2c;
  padding: 10px 16px;
  border-radius: 8px;
  border: 2px solid #2b3548;
}

.btn-group {
  display: flex;
  gap: 8px;
}

.tool-btn {
  background: #283347;
  color: #e0e6ed;
  border: 2px solid #3d4d6a;
  border-radius: 6px;
  padding: 8px 12px;
  font-family: inherit;
  font-size: 9px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  touch-action: manipulation;
}

.tool-btn:hover {
  background: #374661;
  border-color: #6179a6;
}

.tool-btn:active {
  transform: translateY(1px);
}

.legend-badge {
  font-size: 9px;
  color: #9eb1d4;
  letter-spacing: 0.5px;
}

/* Mobile Touch Controls */
.mobile-controls {
  display: none;
  justify-content: space-between;
  gap: 16px;
  margin-top: 6px;
}

.touch-btn {
  flex: 1;
  height: 68px;
  font-family: inherit;
  border: none;
  border-radius: 12px;
  color: #ffffff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.4);
  transition: transform 0.05s, box-shadow 0.05s;
  touch-action: none;
}

.duck-btn {
  background: #d84315;
  box-shadow: 0 6px 0 #8e2b0a;
}

.jump-btn {
  background: #2e7d32;
  box-shadow: 0 6px 0 #1b4d20;
}

.touch-btn:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.4);
}

.touch-icon {
  font-size: 16px;
}

.touch-text {
  font-size: 11px;
  letter-spacing: 1px;
}

/* Game Guide Cards */
.game-guide {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
  margin-top: 8px;
}

.guide-card {
  background: #171d29;
  border: 2px solid #283347;
  border-radius: 8px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.guide-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.guide-badge {
  font-size: 8px;
  padding: 3px 6px;
  border-radius: 4px;
  font-weight: bold;
}

.guide-badge.red { background: var(--mario-red); color: #fff; }
.guide-badge.green { background: var(--mario-green); color: #fff; }
.guide-badge.yellow { background: #e09900; color: #fff; }
.guide-badge.gold { background: #d49500; color: #fff; }

.guide-card h3 {
  font-size: 10px;
  color: #f0f4f8;
  letter-spacing: 0.5px;
}

.guide-card p {
  font-family: 'Fredoka', 'Segoe UI', sans-serif;
  font-size: 13px;
  line-height: 1.45;
  color: #a4b3c9;
}

.guide-card strong {
  color: #ffdd57;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  body {
    padding: 10px 8px;
  }

  .mobile-controls {
    display: flex;
  }

  .hud-value {
    font-size: 13px;
  }

  .hud-label, .hud-subvalue {
    font-size: 8px;
  }

  .game-title {
    font-size: 16px;
  }

  .start-instruction {
    font-size: 10px;
  }

  .legend-badge {
    display: none;
  }
}

/* High Score Sheet & Leaderboard */
.leaderboard-card {
  max-width: 680px;
  width: 90%;
  max-height: 90%;
  display: flex;
  flex-direction: column;
  background: #111827;
  border: 4px solid #ffd700;
  box-shadow: 0 0 25px rgba(255, 215, 0, 0.4), inset 0 0 15px rgba(0, 0, 0, 0.8);
  padding: 20px 24px;
}

.leaderboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  border-bottom: 2px dashed #ffd700;
  padding-bottom: 10px;
}

.leaderboard-title {
  color: #ffd700;
  font-size: 14px;
  margin: 0;
  letter-spacing: 1px;
  text-shadow: 2px 2px 0 #b00;
}

.mode-badge {
  font-size: 9px;
  background: #0088cc;
  color: #ffffff;
  padding: 4px 8px;
  border-radius: 4px;
  letter-spacing: 0.5px;
}

.mode-badge.local {
  background: #7755aa;
}

.leaderboard-table-container {
  overflow-y: auto;
  max-height: 220px;
  margin-bottom: 12px;
}

.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 10px;
  text-align: left;
}

.leaderboard-table th {
  color: #a0c4ff;
  padding: 6px 8px;
  border-bottom: 2px solid #374151;
  letter-spacing: 1px;
}

.leaderboard-table td {
  padding: 8px;
  border-bottom: 1px solid #1f2937;
  color: #f3f4f6;
}

.leaderboard-table tr:hover {
  background: rgba(255, 215, 0, 0.08);
}

.leaderboard-table .rank-1 { color: #ffd700; font-weight: bold; }
.leaderboard-table .rank-2 { color: #e5e7eb; font-weight: bold; }
.leaderboard-table .rank-3 { color: #d97706; font-weight: bold; }

.firebase-notice {
  font-family: 'Fredoka', sans-serif;
  font-size: 11px;
  color: #9ca3af;
  background: rgba(255, 255, 255, 0.05);
  border-left: 3px solid #ffd700;
  padding: 6px 10px;
  margin-bottom: 14px;
  text-align: left;
  line-height: 1.4;
}

.firebase-notice code {
  color: #facc15;
  background: rgba(0, 0, 0, 0.4);
  padding: 2px 4px;
  border-radius: 3px;
}

.leaderboard-actions {
  display: flex;
  justify-content: center;
}

.arcade-btn.close-btn {
  background: #374151;
  border-color: #6b7280;
  font-size: 11px;
  padding: 8px 24px;
}

.arcade-btn.close-btn:hover {
  background: #4b5563;
}

/* Initials Input on Game Over */
.new-high-score-section {
  background: rgba(255, 215, 0, 0.12);
  border: 2px dashed #ffd700;
  border-radius: 8px;
  padding: 10px 14px;
  margin: 12px 0 16px;
  animation: pulseCard 1.8s infinite;
}

.new-hi-title {
  color: #ffd700;
  font-size: 11px;
  margin-bottom: 8px;
  letter-spacing: 1px;
}

.initials-input-box {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
}

.initials-input-box input {
  font-family: 'Press Start 2P', monospace;
  font-size: 14px;
  width: 90px;
  text-align: center;
  text-transform: uppercase;
  background: #000;
  color: #00ffcc;
  border: 2px solid #ffd700;
  border-radius: 4px;
  padding: 6px 4px;
  outline: none;
  letter-spacing: 2px;
}

.initials-input-box input:focus {
  border-color: #00ffcc;
  box-shadow: 0 0 8px #00ffcc;
}

.arcade-btn.small-btn {
  padding: 6px 12px;
  font-size: 10px;
}

.game-over-buttons {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.arcade-btn.scores-btn {
  background: #d49500;
  border-color: #ffe600;
}

.arcade-btn.scores-btn:hover {
  background: #f8b800;
}
