/* ============================================================
   Star Catcher – Game Stylesheet
   Layout: HUD (top) | Canvas (flex-fill) | D-Pad (bottom)
   Overlays sit absolutely on top of everything.
   ============================================================ */

/* ── Reset & Base ── */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0f0c29;
  font-family: 'Comic Sans MS', 'Chalkboard SE', 'Segoe UI', cursive, sans-serif;
  color: #fff;
}

/* ── App Shell: fixed 3-row layout ── */
#app {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── HUD ── */
#hud {
  flex-shrink: 0;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: rgba(0, 0, 0, 0.45);
  border-bottom: 2px solid rgba(255, 255, 255, 0.08);
  z-index: 10;
}

#level-display {
  font-size: 17px;
  font-weight: bold;
  color: #90EE90;
  min-width: 80px;
}

#score-display {
  font-size: 20px;
  font-weight: bold;
  color: #FFD700;
  text-shadow: 0 0 8px rgba(255, 215, 0, 0.6);
}

#pause-btn {
  width: 40px;
  height: 40px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  transition: background 0.15s;
}
#pause-btn:hover,
#pause-btn:active {
  background: rgba(255, 255, 255, 0.28);
}

/* ── Canvas ── */
#gameCanvas {
  display: block;
  flex: 1 1 auto;     /* fill all remaining vertical space */
  width: 100%;
  touch-action: none; /* prevent browser scroll on touch */
}

/* ── Mobile D-Pad ── */
#mobile-controls {
  flex-shrink: 0;
  height: 148px;
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(0, 0, 0, 0.35);
  border-top: 2px solid rgba(255, 255, 255, 0.06);
  z-index: 10;
  padding-bottom: env(safe-area-inset-bottom, 0px); /* iOS home bar */
}

/* Wrapper that sits D-pad on the left and fire button on the right */
.controls-layout {
  display: flex;
  align-items: center;
  gap: 32px;
}

.dpad {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.dpad-middle {
  display: flex;
  align-items: center;
  gap: 6px;
}

.dpad-center {
  width: 52px;
  height: 52px;
}

.dpad-btn {
  width: 58px;
  height: 58px;
  border-radius: 14px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.13);
  color: #fff;
  font-size: 22px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  transition: background 0.1s, border-color 0.1s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dpad-btn.active,
.dpad-btn:active {
  background: rgba(255, 215, 0, 0.45);
  border-color: #FFD700;
}

/* ══════════ OVERLAY SCREENS ══════════ */

.overlay {
  position: absolute;
  inset: 0;               /* top/right/bottom/left: 0 */
  background: rgba(15, 12, 41, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  animation: fadeIn 0.25s ease;
}

.overlay.hidden {
  display: none;
}

@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.97); }
  to   { opacity: 1; transform: scale(1); }
}

.overlay-content {
  text-align: center;
  padding: 40px 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  max-width: 420px;
  width: 100%;
}

.game-title {
  font-size: clamp(2.4rem, 8vw, 3.6rem);
  font-weight: bold;
  color: #FFD700;
  text-shadow: 0 0 24px rgba(255, 215, 0, 0.55);
  line-height: 1.1;
}

.subtitle {
  font-size: clamp(1rem, 3.5vw, 1.3rem);
  color: #ccc;
}

.instructions {
  font-size: clamp(0.85rem, 2.8vw, 1rem);
  color: #aaa;
  background: rgba(255,255,255,0.06);
  border-radius: 10px;
  padding: 10px 18px;
}

.overlay-icon {
  font-size: 56px;
  line-height: 1;
}

.overlay-title {
  font-size: clamp(2rem, 7vw, 3rem);
  font-weight: bold;
  color: #FFD700;
  text-shadow: 0 0 18px rgba(255, 215, 0, 0.5);
}

.final-score-text {
  font-size: clamp(1.4rem, 5vw, 2rem);
  color: #90EE90;
  font-weight: bold;
}

.thanks-msg {
  font-size: clamp(1.1rem, 4vw, 1.5rem);
  color: #B0C4DE;
}

/* ── Buttons ── */
.btn-primary {
  padding: 14px 44px;
  font-size: clamp(1.1rem, 4vw, 1.4rem);
  font-family: inherit;
  font-weight: bold;
  color: #0f0c29;
  background: linear-gradient(135deg, #FFD700 0%, #FF8C00 100%);
  border: none;
  border-radius: 32px;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(255, 215, 0, 0.4);
  transition: transform 0.1s, box-shadow 0.1s;
  width: 200px;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(255, 215, 0, 0.55);
}

.btn-primary:active {
  transform: scale(0.96);
}

.btn-secondary {
  padding: 11px 36px;
  font-size: clamp(0.95rem, 3.2vw, 1.15rem);
  font-family: inherit;
  font-weight: bold;
  color: #ccc;
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-radius: 28px;
  cursor: pointer;
  transition: background 0.15s;
  width: 200px;
}

.btn-secondary:hover,
.btn-secondary:active {
  background: rgba(255, 255, 255, 0.2);
}

/* ── Fire button ── */
.fire-btn {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  border: 3px solid rgba(255, 100, 0, 0.6);
  background: rgba(255, 80, 0, 0.2);
  color: white;
  font-size: 32px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  transition: background 0.1s, transform 0.08s;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 14px rgba(255, 100, 0, 0.35);
}

.fire-btn.active,
.fire-btn:active {
  background: rgba(255, 140, 0, 0.55);
  border-color: #FF8C00;
  transform: scale(0.92);
}

/* ── Desktop hint: shrink controls slightly ── */
@media (pointer: fine) {
  #mobile-controls {
    height: 110px;
  }
  .dpad-btn {
    width: 46px;
    height: 46px;
    font-size: 18px;
  }
  .dpad-center {
    width: 42px;
    height: 42px;
  }
  .fire-btn {
    width: 62px;
    height: 62px;
    font-size: 26px;
  }
}
