/* ============================================================
   SPACE BATTLE — styles
   Retro space arcade · fully responsive · portrait-first
============================================================ */

:root {
  --bg: #05060a;
  --bg-2: #0a0e1a;
  --accent: #38e8ff;
  --accent-2: #b66bff;
  --danger: #ff4d6d;
  --text: #eaf2ff;
  --muted: #8a98b8;
  --hud: clamp(0.85rem, 3.4vw, 1.15rem);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
}

/* Game shell — fills the viewport, never scrolls */
.game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  background: radial-gradient(120% 100% at 50% 0%, var(--bg-2) 0%, var(--bg) 60%);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

/* Canvases stack and fill the shell */
.stars,
.board {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.stars {
  z-index: 1;
}

.board {
  z-index: 2;
}

/* ----------------------------------------------------------
   HUD
---------------------------------------------------------- */
.hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.5rem;
  padding: calc(env(safe-area-inset-top, 0px) + 0.7rem) clamp(0.8rem, 4vw, 1.6rem) 0.7rem;
  pointer-events: none;
}

.hud__item {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.hud__item--center {
  align-items: center;
}

.hud__item--right {
  align-items: flex-end;
}

.hud__label {
  font-size: clamp(0.6rem, 2.4vw, 0.72rem);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

.hud__value {
  font-size: var(--hud);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  text-shadow: 0 0 12px rgba(56, 232, 255, 0.6);
}

.hud__lives {
  color: var(--danger);
  text-shadow: 0 0 12px rgba(255, 77, 109, 0.6);
  letter-spacing: 0.08em;
}

/* ----------------------------------------------------------
   TOUCH CONTROLS
---------------------------------------------------------- */
.controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: clamp(0.6rem, 3vw, 1.4rem);
  padding: 0.6rem clamp(0.8rem, 4vw, 1.8rem)
    calc(env(safe-area-inset-bottom, 0px) + 0.8rem);
}

.ctrl {
  font-family: inherit;
  color: var(--text);
  background: rgba(20, 26, 44, 0.55);
  border: 1.5px solid rgba(56, 232, 255, 0.35);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border-radius: 18px;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease, box-shadow 0.15s ease;
  touch-action: none;
}

.ctrl--move {
  width: clamp(64px, 20vw, 96px);
  height: clamp(64px, 20vw, 96px);
  font-size: clamp(2rem, 9vw, 3rem);
  font-weight: 700;
  line-height: 1;
}

.ctrl--fire {
  flex: 1;
  max-width: 230px;
  height: clamp(56px, 16vw, 78px);
  font-size: clamp(1rem, 4.4vw, 1.4rem);
  font-weight: 800;
  letter-spacing: 0.14em;
  color: #05060a;
  background: linear-gradient(180deg, var(--accent), #1ab9d6);
  border-color: transparent;
  box-shadow: 0 0 22px rgba(56, 232, 255, 0.45);
}

.ctrl:active,
.ctrl.is-down {
  transform: translateY(2px) scale(0.96);
  background: rgba(56, 232, 255, 0.22);
  box-shadow: 0 0 26px rgba(56, 232, 255, 0.55);
}

.ctrl--fire:active,
.ctrl--fire.is-down {
  background: linear-gradient(180deg, #7af2ff, var(--accent));
}

/* Hide touch controls when a fine pointer (mouse) is the primary input */
@media (hover: hover) and (pointer: fine) {
  .controls {
    opacity: 0.32;
    transition: opacity 0.25s ease;
  }

  .controls:hover {
    opacity: 1;
  }
}

/* ----------------------------------------------------------
   OVERLAYS (start / game over)
---------------------------------------------------------- */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 1.4rem;
  background: radial-gradient(80% 70% at 50% 40%, rgba(10, 14, 26, 0.82), rgba(5, 6, 10, 0.95));
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: fade 0.35s ease;
}

.overlay--hidden {
  display: none;
}

@keyframes fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.panel {
  width: min(420px, 100%);
  text-align: center;
  padding: clamp(1.6rem, 6vw, 2.6rem) clamp(1.2rem, 5vw, 2rem);
  border: 1px solid rgba(56, 232, 255, 0.22);
  border-radius: 22px;
  background: rgba(10, 14, 26, 0.7);
  box-shadow: 0 0 60px rgba(56, 232, 255, 0.12);
}

.panel__title {
  font-size: clamp(2.1rem, 11vw, 3.4rem);
  font-weight: 900;
  letter-spacing: 0.04em;
  line-height: 1;
  text-shadow: 0 0 24px rgba(56, 232, 255, 0.5);
}

.panel__title .accent {
  display: block;
  color: var(--accent);
}

.panel__title--over .accent {
  color: var(--danger);
  text-shadow: 0 0 24px rgba(255, 77, 109, 0.5);
}

.panel__sub {
  margin-top: 0.8rem;
  color: var(--muted);
  font-size: clamp(0.85rem, 3.6vw, 1rem);
}

.panel__score,
.panel__best {
  margin-top: 1rem;
  font-size: clamp(1rem, 4.4vw, 1.25rem);
  color: var(--muted);
  letter-spacing: 0.1em;
}

.panel__score span,
.panel__best span {
  display: inline-block;
  margin-left: 0.4em;
  font-weight: 900;
  font-size: 1.4em;
  color: var(--accent);
}

.panel__best span {
  color: var(--accent-2);
}

.panel__btn {
  margin-top: 1.6rem;
  width: 100%;
  padding: 0.95rem 1.4rem;
  font-family: inherit;
  font-size: clamp(1rem, 4.4vw, 1.2rem);
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #05060a;
  background: linear-gradient(180deg, var(--accent), #16a9c7);
  border: none;
  border-radius: 14px;
  cursor: pointer;
  box-shadow: 0 0 30px rgba(56, 232, 255, 0.45);
  transition: transform 0.1s ease, box-shadow 0.2s ease;
}

.panel__btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 40px rgba(56, 232, 255, 0.65);
}

.panel__btn:active {
  transform: translateY(0);
}

.panel__hint {
  margin-top: 1.4rem;
  list-style: none;
  color: var(--muted);
  font-size: clamp(0.72rem, 3vw, 0.85rem);
  line-height: 1.7;
}

.panel__hint strong {
  color: var(--text);
}

.panel__back {
  display: inline-block;
  margin-top: 1.2rem;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.85rem;
  transition: color 0.2s ease;
}

.panel__back:hover {
  color: var(--accent);
}

/* ----------------------------------------------------------
   LANDSCAPE TWEAKS
---------------------------------------------------------- */
@media (orientation: landscape) and (max-height: 520px) {
  .ctrl--move {
    width: clamp(54px, 12vh, 80px);
    height: clamp(54px, 12vh, 80px);
  }

  .ctrl--fire {
    height: clamp(48px, 11vh, 70px);
  }

  .panel {
    padding: 1.2rem 1.6rem;
  }

  .panel__hint {
    margin-top: 0.9rem;
  }
}
