/* ========== RESET & BASE ========== */
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@700;900&family=Poppins:wght@400;600;700&display=swap');

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

/* Brand Colors:
   Red:    #EC1E24
   Yellow: #F2EB18
   Orange: #FBAF39
   Black:  #000000
   White:  #FFFFFF
   Gray:   #545454
*/

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0a0a0a;
  font-family: 'Poppins', 'Segoe UI', Arial, sans-serif;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

/* ========== GAME CONTAINER ========== */
#game-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #0a0a0a;
}

#game-wrapper {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: #1a1a1a;
}

/* ========== UI OVERLAY ========== */
#ui-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.screen {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #fff;
  pointer-events: auto;
  width: 100%;
  max-width: 100%;
  padding: 20px;
}

.screen.active {
  display: flex;
}

/* ========== START SCREEN ========== */
.game-title {
  font-family: 'Montserrat', Arial, sans-serif;
  font-size: clamp(2.2rem, 9vw, 3.8rem);
  font-weight: 900;
  color: #EC1E24;
  text-shadow: 3px 3px 0 #8b0000, 0 0 25px rgba(236, 30, 36, 0.4);
  letter-spacing: 2px;
  line-height: 1.1;
  text-transform: uppercase;
}

.game-subtitle {
  font-family: 'Montserrat', Arial, sans-serif;
  font-size: clamp(0.9rem, 3.5vw, 1.4rem);
  font-weight: 700;
  color: #F2EB18;
  text-shadow: 2px 2px 0 #8a8500;
  margin-top: 4px;
  letter-spacing: 3px;
  text-transform: uppercase;
}

.tagline {
  font-size: clamp(0.8rem, 3vw, 1rem);
  color: #FBAF39;
  margin-top: 12px;
  font-style: italic;
  font-weight: 600;
}

.instructions {
  margin-top: 16px;
  font-size: clamp(0.7rem, 2.5vw, 0.85rem);
  color: #ccc;
  line-height: 1.8;
}

.best-score-display {
  margin-top: 16px;
  font-size: 1rem;
  font-weight: 700;
  color: #F2EB18;
}

/* ========== BUTTONS ========== */
.btn {
  border: none;
  border-radius: 50px;
  cursor: pointer;
  font-family: 'Montserrat', Arial, sans-serif;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  transition: transform 0.1s, box-shadow 0.1s;
  -webkit-tap-highlight-color: transparent;
}

.btn:active {
  transform: scale(0.95);
}

.btn-play {
  margin-top: 24px;
  padding: 16px 56px;
  font-size: clamp(1.2rem, 4vw, 1.5rem);
  background: linear-gradient(135deg, #EC1E24, #c41218);
  color: #fff;
  box-shadow: 0 6px 20px rgba(236, 30, 36, 0.5);
}

.btn-play:active {
  box-shadow: 0 2px 10px rgba(236, 30, 36, 0.3);
}

.btn-secondary {
  margin-top: 10px;
  padding: 10px 32px;
  font-size: clamp(0.8rem, 3vw, 1rem);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border: 2px solid rgba(255, 255, 255, 0.2);
}

.btn-small {
  padding: 8px 24px;
  font-size: 0.9rem;
  background: #EC1E24;
  color: #fff;
}

.btn-share {
  margin-top: 10px;
  padding: 12px 36px;
  font-size: clamp(0.85rem, 3vw, 1rem);
  background: linear-gradient(135deg, #FBAF39, #FF8C00);
  color: #fff;
  box-shadow: 0 4px 14px rgba(251, 175, 57, 0.4);
}

/* ========== HUD (canvas-rendered, minimal HTML) ========== */
#hud {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

#hud.active {
  display: block;
}

/* ========== PAUSE SCREEN ========== */
#pause-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.pause-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 30px 40px;
  background: rgba(10, 10, 20, 0.85);
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-radius: 16px;
}

.pause-title {
  font-family: 'Montserrat', Arial, sans-serif;
  font-size: clamp(1.6rem, 6vw, 2.2rem);
  font-weight: 900;
  color: #F2EB18;
  text-shadow: 2px 2px 0 #8a8500;
  margin-bottom: 8px;
}

/* ========== GAME OVER ========== */
.gameover-title {
  font-family: 'Montserrat', Arial, sans-serif;
  font-size: clamp(1.8rem, 7vw, 2.8rem);
  font-weight: 900;
  color: #EC1E24;
  text-shadow: 2px 2px 0 #8b0000;
}

.gameover-stats {
  display: flex;
  gap: 24px;
  margin-top: 20px;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stat-label {
  font-size: 0.75rem;
  color: #aaa;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.stat-value {
  font-family: 'Montserrat', Arial, sans-serif;
  font-size: clamp(1.6rem, 6vw, 2.4rem);
  font-weight: 900;
  color: #F2EB18;
  margin-top: 4px;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}

.gameover-buttons {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

/* ========== INITIAL ENTRY ========== */
#initial-entry {
  margin-top: 16px;
}

#initial-entry p {
  font-size: 0.9rem;
  color: #ccc;
  margin-bottom: 8px;
}

#initials-input {
  width: 80px;
  padding: 8px;
  font-family: 'Montserrat', Arial, sans-serif;
  font-size: 1.4rem;
  font-weight: 700;
  text-align: center;
  text-transform: uppercase;
  background: rgba(255,255,255,0.1);
  border: 2px solid #EC1E24;
  border-radius: 8px;
  color: #fff;
  outline: none;
}

#initials-input:focus {
  border-color: #F2EB18;
  box-shadow: 0 0 10px rgba(242, 235, 24, 0.3);
}

/* ========== LEADERBOARD ========== */
.lb-title {
  font-family: 'Montserrat', Arial, sans-serif;
  font-size: clamp(1.4rem, 5vw, 2rem);
  font-weight: 900;
  color: #EC1E24;
  text-shadow: 2px 2px 0 #8b0000;
  margin-bottom: 16px;
}

.lb-list {
  width: 100%;
  max-width: 90%;
}

.lb-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  font-size: 0.95rem;
}

.lb-row:nth-child(1) .lb-rank { color: #F2EB18; }
.lb-row:nth-child(2) .lb-rank { color: #c0c0c0; }
.lb-row:nth-child(3) .lb-rank { color: #FBAF39; }

.lb-rank {
  width: 30px;
  text-align: left;
  font-family: 'Montserrat', Arial, sans-serif;
  font-weight: 700;
}

.lb-name {
  flex: 1;
  text-align: left;
  color: #ddd;
  letter-spacing: 2px;
}

.lb-score-val {
  text-align: right;
  color: #F2EB18;
  font-family: 'Montserrat', Arial, sans-serif;
  font-weight: 700;
}

/* ========== HEAT BADGE & ALMOST MSG ========== */
.heat-badge {
  margin-top: 8px;
  padding: 8px 24px;
  border-radius: 24px;
  font-family: 'Montserrat', Arial, sans-serif;
  font-weight: 900;
  font-size: clamp(0.9rem, 3.5vw, 1.2rem);
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 2px;
  text-shadow: 1px 1px 3px rgba(0,0,0,0.5);
  border: 2px solid rgba(255,255,255,0.2);
  box-shadow: 0 2px 12px rgba(0,0,0,0.3);
}

.score-breakdown {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 14px;
  font-family: 'Poppins', Arial, sans-serif;
  font-size: clamp(0.72rem, 2.5vw, 0.85rem);
  font-weight: 600;
}

.breakdown-item {
  color: #ccc;
}

.breakdown-item span {
  font-weight: 700;
}

.almost-msg {
  margin-top: 8px;
  font-size: clamp(0.75rem, 2.5vw, 0.9rem);
  font-weight: 600;
  color: #F2EB18;
  animation: pulse-glow 1s ease-in-out infinite alternate;
}

@keyframes pulse-glow {
  from { opacity: 0.7; }
  to { opacity: 1; text-shadow: 0 0 8px rgba(242, 235, 24, 0.5); }
}

/* ========== START SCREEN ========== */
.start-hero-spacer {
  height: 100px;
}

.start-buttons {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  width: 100%;
  max-width: 90%;
  justify-content: center;
}

.start-buttons .btn-play {
  margin-top: 0;
  flex: 1;
  padding: 14px 12px;
  font-size: clamp(1rem, 3.5vw, 1.2rem);
}

.btn-play-alt {
  background: linear-gradient(135deg, #FBAF39, #e09520) !important;
  box-shadow: 0 6px 20px rgba(251, 175, 57, 0.4) !important;
}

/* ========== RULES / HOW TO PLAY ========== */
#rules-screen {
  overflow-y: auto;
  max-height: 100%;
  padding: 16px 20px;
}

.rules-title {
  font-family: 'Montserrat', Arial, sans-serif;
  font-size: clamp(1.4rem, 5vw, 2rem);
  font-weight: 900;
  color: #EC1E24;
  text-shadow: 2px 2px 0 #8b0000;
  margin-bottom: 12px;
}

.rules-content {
  text-align: left;
  width: 100%;
  max-width: 90%;
}

.rule-section {
  margin-bottom: 14px;
}

.rule-section h3 {
  font-family: 'Montserrat', Arial, sans-serif;
  font-size: clamp(0.85rem, 3vw, 1rem);
  font-weight: 700;
  color: #F2EB18;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.rule-section p {
  font-size: clamp(0.72rem, 2.5vw, 0.85rem);
  color: #ccc;
  line-height: 1.6;
  margin: 2px 0;
}

.rule-section strong {
  color: #fff;
}

.heat-list {
  color: #FBAF39 !important;
  font-weight: 600;
}

/* ========== GAME OVER LOOT ROW ========== */
.gameover-loot {
  display: flex;
  gap: 18px;
  margin-top: 12px;
  font-size: clamp(0.85rem, 3vw, 1.05rem);
  font-weight: 600;
}

.loot-item {
  color: #FBAF39;
}

/* ========== COMBO INDICATOR (canvas helper) ========== */
.combo-badge {
  font-family: 'Montserrat', Arial, sans-serif;
  font-weight: 900;
  color: #F2EB18;
}

/* ========== LEADERBOARD BUTTONS ========== */
.lb-buttons {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hidden {
  display: none !important;
}

/* ========== TABLET & DESKTOP ========== */
@media (min-width: 600px) {
  .screen {
    padding: 28px;
    max-width: 90%;
  }

  .game-title {
    font-size: clamp(2.8rem, 7vw, 4.2rem);
  }

  .game-subtitle {
    font-size: clamp(1.2rem, 3.5vw, 2rem);
  }

  .tagline {
    font-size: clamp(1rem, 3vw, 1.4rem);
  }

  .start-buttons {
    gap: 16px;
  }

  .start-buttons .btn-play {
    padding: 20px 24px;
    font-size: clamp(1.2rem, 3vw, 1.6rem);
  }

  .btn-secondary {
    padding: 16px 48px;
    font-size: clamp(1rem, 2.5vw, 1.3rem);
  }

  .gameover-title {
    font-size: clamp(2.5rem, 6vw, 4rem);
  }

  .stat-value {
    font-size: clamp(2.2rem, 5vw, 3.2rem);
  }

  .lb-list {
    max-width: 500px;
  }

  .lb-row {
    padding: 12px 18px;
    font-size: 1.15rem;
  }

  #start-best-score {
    font-size: 1.2rem;
  }
}

/* ========== LANDSCAPE WARNING ========== */
#rotate-msg {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #0a0a0a;
  color: #F2EB18;
  font-family: 'Montserrat', Arial, sans-serif;
  font-weight: 700;
  font-size: 1.4rem;
  z-index: 9999;
  align-items: center;
  justify-content: center;
  text-align: center;
  flex-direction: column;
  gap: 16px;
}

#rotate-msg .rotate-icon {
  font-size: 3rem;
}

@media (max-height: 480px) and (orientation: landscape) {
  #rotate-msg {
    display: flex !important;
  }
  #game-container {
    display: none !important;
  }
}
