/* -------------------- RESET & BASE -------------------- */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Poppins', Arial, sans-serif;
  background: linear-gradient(180deg, #001f3f, #00274d);
  color: #fff;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

/* visibility helper */
.hidden { display: none !important; }

/* -------------------- START SCREEN -------------------- */
#startScreen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 18px;
  z-index: 2000;
  text-align: center;
}

#startScreen h1 {
  font-size: 3rem;
  color: #ffcc00;
  text-shadow: 0 4px 18px rgba(0,0,0,0.6);
}

#startBtn {
  appearance: none;
  border: none;
  background: linear-gradient(90deg,#ff6b6b,#ff3b3b);
  color: white;
  padding: 14px 32px;
  border-radius: 10px;
  font-size: 1.2rem;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0,0,0,0.45);
}
#startBtn:active { transform: translateY(1px); }

.intro-watermark {
  margin-top: 30px;
  font-size: 1.1rem;
  color: rgba(255,255,255,0.7);
  letter-spacing: 0.6px;
}

/* -------------------- GAME CONTAINER -------------------- */
#gameContainer {
  position: relative;
  width: 100%;
  height: 100%;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  overflow: hidden;
  padding-top: 10px; /* space for HUD */
}

/* ----------- HUD ----------- */

/* Scoreboard container */
#scoreboard {
  display: flex;
  justify-content: center;
  margin: 10px auto;
  padding: 10px 20px;
  border: 2px solid #bfb065;
  border-radius: 12px;
  background: rgba(0, 8, 34, 0.85);
  box-shadow: 0 4px 10px rgba(0,0,0,0.4);
  width: 100%;
  max-width: 900px;   /* same as max desktop canvas width */
  box-sizing: border-box;
}

/* HUD inside the scoreboard */
#hud {
  display: flex;
  flex-direction: column;
  align-items: center;
  color: white;
  font-size: 16px;
  font-family: 'Poppins', sans-serif;
  gap: 5px;
  width: 100%;
}

/* Top row (Score, Time, Coins) */
.hud-top {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px; /* reduced gap to prevent wrapping */
  width: 100%;
}

/* Bottom row (Total Coins) */
.hud-bottom {
  display: flex;
  color: #bfb065;
  justify-content: center;
  width: 100%;
}

.hud-item {
  min-width: 100px;
  text-align: center;
}

/* Desktop: merge into one line */
@media (min-width: 768px) {
  #hud {
    flex-direction: row;
    justify-content: center;
    flex-wrap: nowrap;
    gap: 16px; /* reduced gap to fit in single line */
  }

  .hud-top,
  .hud-bottom {
    display: contents;
  }
}

/* Canvas styling */
#gameCanvas {
  display: block;
  background: #000822;
  border: 3px solid rgba(255,255,255,0.25);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.6);
  image-rendering: auto;

  /* Make canvas width follow container and height auto */
  max-width: 900px;
  max-height: calc(100% - 120px); /* leave space for HUD + padding */
  height: auto;
  width: 100%;
}

/* -------------------- GAME OVER OVERLAY -------------------- */
#gameOverScreen {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  pointer-events: none;
  z-index: 1500;
}

#gameOverScreen .overlay {
  pointer-events: all;
  background: rgba(17,17,17,0.98);
  padding: 36px 60px;
  border-radius: 14px;
  text-align: center;
  box-shadow: 0 12px 40px rgba(0,0,0,0.7);
  min-width: 320px;
  max-width: 92%;
}

#gameOverScreen h2 {
  color: #ff6b6b;
  font-size: 2.6rem;
  margin-bottom: 12px;
}

#gameOverScreen p {
  color: #fff;
  font-size: 1.25rem;
  margin-bottom: 18px;
}

#gameOverScreen button {
  background: linear-gradient(90deg,#ff6b6b,#ff3b3b);
  color: white;
  border: none;
  padding: 12px 26px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
}

/* -------------------- RESPONSIVE -------------------- */
@media (max-width: 480px) {
  #hud { gap: 6px; padding: 8px 12px; }
  #startScreen h1 { font-size: 2.4rem; }
  #startBtn { font-size: 1rem; padding: 12px 24px; }
  #gameOverScreen .overlay { padding: 24px 36px; }
}

/* -------------------- SCREEN SAFE AREA -------------------- */
body {
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}
