/* ===========================================================================
   Space Shooter — styles
   ---------------------------------------------------------------------------
   Deliberately the same design language as the Snake game
   (games/snake-game/css/style.css): ink panels, parchment type, brass and
   jade accents, Fraunces / Inter / IBM Plex Mono, 12px radii, flat buttons.
   Every selector is scoped under #space-shooter (or .shooter-page for this
   standalone page), so nothing leaks into — or in from — a host page.
   =========================================================================== */

#space-shooter {

  /* palette — identical values to Snake's */
  --ss-ink: #0f1722;
  --ss-ink-deep: #0b121c;
  --ss-panel: rgba(14, 22, 33, 0.94);
  --ss-panel-soft: rgba(233, 226, 208, 0.05);
  --ss-parchment: #e9e2d0;
  --ss-parchment-dim: rgba(233, 226, 208, 0.62);
  --ss-parchment-faint: rgba(233, 226, 208, 0.38);
  --ss-brass: #c89b3c;
  --ss-jade: #63c79b;
  --ss-violet: #9a7bd1;
  --ss-oxblood: #c05252;
  --ss-line: rgba(233, 226, 208, 0.14);

  /* type */
  --ss-font-ui: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --ss-font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --ss-font-display: "Fraunces", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;

  /* metrics: a 3:4 stage that always fits the viewport with its HUD */
  /* 11rem = top bar + two-row HUD + gaps + page padding */
  --ss-stage-w: min(540px, calc(100vw - 1.5rem), calc((100vh - 11rem) * 0.75));
  --ss-stage-w: min(540px, calc(100vw - 1.5rem), calc((100dvh - 11rem) * 0.75));
  --ss-radius: 12px;
  --ss-gap: 0.6rem;

  display: block;
  width: var(--ss-stage-w);
  margin-inline: auto;
  font-family: var(--ss-font-ui);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ss-parchment);
  text-align: left;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

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

#space-shooter button,
#space-shooter input {
  font: inherit;
  color: inherit;
}

#space-shooter [hidden] {
  display: none !important;
}


/* ------------------------------- page shell ------------------------------- */

body.shooter-page {
  box-sizing: border-box; /* padding inside 100dvh — no stray scrollbars */
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(0.5rem, 2.5vw, 1.5rem) 0.75rem;
  background: radial-gradient(1200px 600px at 50% -10%, #16202e 0%, #0b121c 62%, #080d14 100%);
  color: #e9e2d0;
  overscroll-behavior: none;
}

.shooter-page__inner {
  width: 100%;
}

#space-shooter .shooter__topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.45rem;
  font-family: var(--ss-font-mono);
  font-size: 0.75rem;
}

#space-shooter .shooter__tools {
  display: flex;
  gap: 0.3rem;
}

#space-shooter .shooter__back {
  color: var(--ss-parchment-dim);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color 140ms ease, border-color 140ms ease;
}

#space-shooter .shooter__back:hover {
  color: var(--ss-brass);
  border-bottom-color: currentColor;
}

#space-shooter .shooter__crumb {
  color: var(--ss-parchment-faint);
}

#space-shooter .shooter__frame {
  display: flex;
  flex-direction: column;
  gap: var(--ss-gap);
}


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

/* Two compact rows: the numbers on top, the ship's state underneath. */
#space-shooter .shooter__hud {
  display: grid;
  row-gap: 0.3rem;
  padding: 0.4rem 0.7rem;
  background: var(--ss-panel-soft);
  border: 1px solid var(--ss-line);
  border-radius: var(--ss-radius);
}

#space-shooter .shooter-hud__row {
  display: flex;
  align-items: center;
  min-width: 0;
  min-height: 1.6rem;
}

#space-shooter .shooter-hud__item {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  padding: 0 0.6rem;
  min-width: 0;
}

#space-shooter .shooter-hud__item:first-child {
  padding-left: 0.1rem;
}

#space-shooter .shooter-hud__row--vitals .shooter-hud__item {
  align-items: center;
}

#space-shooter .shooter-hud__item + .shooter-hud__item {
  border-left: 1px solid var(--ss-line);
}

#space-shooter .shooter-hud__label {
  font-family: var(--ss-font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  color: var(--ss-parchment-faint);
}

#space-shooter .shooter-hud__value {
  font-family: var(--ss-font-mono);
  font-size: 1.05rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

#space-shooter .shooter-hud__item--hull {
  align-items: center;
}

#space-shooter .shooter-hull {
  position: relative;
  display: inline-block;
  flex: none;
  width: 3.4rem;
  height: 0.45rem;
  border: 1px solid var(--ss-line);
  border-radius: 2px;
  overflow: hidden;
}

#space-shooter .shooter-hull__fill {
  position: absolute;
  inset: 0;
  background: var(--ss-jade);
  transform-origin: left center;
  transition: transform 160ms ease-out;
}

#space-shooter .shooter-hull.is-mid .shooter-hull__fill { background: var(--ss-brass); }
#space-shooter .shooter-hull.is-low .shooter-hull__fill { background: var(--ss-oxblood); }

#space-shooter .shooter-hull.is-hit {
  animation: ss-hull-hit 260ms steps(2, end);
}

@keyframes ss-hull-hit {
  50% { border-color: var(--ss-oxblood); }
}

#space-shooter [data-lives].is-last {
  color: var(--ss-oxblood);
}

#space-shooter .shooter-hud__row--vitals {
  flex-wrap: wrap;
  row-gap: 0.25rem;
}

#space-shooter .shooter-hud__row--vitals .shooter-hud__item {
  flex: none;
}

#space-shooter .shooter-hud__effects {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  padding-left: 0.45rem;
}

#space-shooter .shooter-chip {
  display: inline-block;
  font-family: var(--ss-font-mono);
  font-size: 0.68rem;
  line-height: 1.5;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  border: 1px solid currentColor;
  white-space: nowrap;
}

#space-shooter .shooter-chip b {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

#space-shooter .shooter-chip--mult { color: var(--ss-brass); align-self: center; }
#space-shooter .shooter-chip--rapid { color: var(--ss-brass); }
#space-shooter .shooter-chip--spread { color: var(--ss-violet); }
#space-shooter .shooter-chip--shield { color: var(--ss-jade); }


/* --------------------------------- stage ---------------------------------- */

#space-shooter .shooter__stage {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  border-radius: var(--ss-radius);
  overflow: hidden;
  background: var(--ss-ink-deep);
  border: 1px solid var(--ss-line);
  user-select: none;
  -webkit-user-select: none;
}

#space-shooter .shooter__canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

#space-shooter.is-playing .shooter__stage {
  cursor: crosshair;
}

#space-shooter .shooter__sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

#space-shooter .shooter__noscript {
  padding: 1rem;
  text-align: center;
  color: var(--ss-parchment-dim);
}


/* -------------------------------- overlay --------------------------------- */

#space-shooter .shooter__overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.9rem;
  background: rgba(8, 13, 20, 0.55);
  touch-action: auto;
}

#space-shooter .shooter-screen {
  display: none;
  width: 100%;
  max-height: 100%;
  min-height: 0;
  justify-content: center;
}

#space-shooter .shooter-screen.is-active {
  display: flex;
}

#space-shooter .shooter-panel {
  width: min(100%, 22rem);
  max-height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  padding: 1.3rem 1.3rem 1.35rem;
  background: var(--ss-panel);
  border: 1px solid var(--ss-line);
  border-radius: var(--ss-radius);
  box-shadow: 0 18px 40px rgba(5, 9, 14, 0.55);
  animation: ss-panel-in 160ms ease-out;
  scrollbar-width: thin;
  scrollbar-color: var(--ss-brass) transparent;
}

#space-shooter .shooter-panel::-webkit-scrollbar { width: 6px; }
#space-shooter .shooter-panel::-webkit-scrollbar-track { background: transparent; }
#space-shooter .shooter-panel::-webkit-scrollbar-thumb { background: var(--ss-brass); border-radius: 999px; }

#space-shooter .shooter-panel--menu {
  text-align: center;
  padding-block: 1.8rem 1.5rem;
}

#space-shooter .shooter-panel--compact {
  text-align: center;
}

#space-shooter .shooter-panel--wide {
  width: min(100%, 26rem);
}

@keyframes ss-panel-in {
  from { opacity: 0; transform: translateY(6px) scale(0.985); }
  to { opacity: 1; transform: none; }
}


/* --------------------------------- titles --------------------------------- */

#space-shooter .shooter-title {
  font-family: var(--ss-font-display);
  font-weight: 600;
  font-size: clamp(1.7rem, 8vw, 2.4rem);
  line-height: 1.08;
  letter-spacing: 0.26em;
  text-indent: 0.26em;
  text-transform: uppercase;
  color: var(--ss-parchment);
}

#space-shooter .shooter-subtitle {
  margin-top: 0.7rem;
  font-family: var(--ss-font-mono);
  font-size: 0.78rem;
  color: var(--ss-parchment-dim);
}

#space-shooter .shooter-screen__title {
  font-family: var(--ss-font-display);
  font-weight: 600;
  font-size: 1.5rem;
  letter-spacing: 0.02em;
  margin-bottom: 0.6rem;
}

#space-shooter .shooter-screen__note {
  font-family: var(--ss-font-mono);
  font-size: 0.75rem;
  color: var(--ss-parchment-dim);
  margin-bottom: 0.9rem;
}

#space-shooter .shooter-section {
  margin: 1rem 0 0.5rem;
  font-family: var(--ss-font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ss-brass);
}

#space-shooter .shooter-screen__foot {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1rem;
}


/* -------------------------------- buttons --------------------------------- */

#space-shooter .shooter-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.62em 1.1em;
  font-family: var(--ss-font-ui);
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--ss-parchment);
  background: var(--ss-panel-soft);
  border: 1px solid var(--ss-line);
  border-radius: 9px;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease, transform 90ms ease;
}

#space-shooter .shooter-button:hover {
  background: rgba(233, 226, 208, 0.11);
  border-color: rgba(200, 155, 60, 0.45);
}

#space-shooter .shooter-button:active {
  transform: translateY(1px);
}

#space-shooter .shooter-button:disabled {
  opacity: 0.5;
  cursor: default;
  transform: none;
}

#space-shooter :is(.shooter-button, .shooter-input, .shooter__back, input[type="range"], input[type="checkbox"]):focus-visible {
  outline: 2px solid var(--ss-brass);
  outline-offset: 2px;
}

/* Focus moved by a game controller: the same brass ring keyboard users get. */
#space-shooter.is-pad :is(.shooter-button, .shooter-input, input[type="range"], input[type="checkbox"], a):focus {
  outline: 2px solid var(--ss-brass);
  outline-offset: 2px;
}

#space-shooter .shooter-button--primary {
  background: var(--ss-jade);
  border-color: transparent;
  color: #08121b;
  font-weight: 600;
}

#space-shooter .shooter-button--primary:hover {
  background: #7fd8a8;
  border-color: transparent;
}

#space-shooter .shooter-button--ghost {
  background: transparent;
  font-size: 0.82rem;
  padding: 0.5em 0.9em;
}

#space-shooter .shooter-button--icon {
  width: 1.9rem;
  height: 1.9rem;
  padding: 0;
  border-radius: 8px;
  background: transparent;
}

#space-shooter .shooter-button--icon svg {
  width: 1rem;
  height: 1rem;
  fill: currentColor;
  stroke: currentColor;
}

#space-shooter .shooter-button--icon rect,
#space-shooter .shooter-button--icon path:not([fill="none"]) {
  stroke: none;
}

#space-shooter .shooter-icon-off,
#space-shooter .is-muted .shooter-icon-on {
  display: none;
}

#space-shooter .is-muted .shooter-icon-off {
  display: inline;
}

#space-shooter .shooter-button.is-muted {
  color: var(--ss-oxblood);
}


/* ---------------------------------- menu ---------------------------------- */

#space-shooter .shooter-menu {
  display: grid;
  gap: 0.5rem;
  margin-top: 1.3rem;
}

#space-shooter .shooter-menu--row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 1rem;
}

#space-shooter .shooter-menu__status {
  margin-top: 1rem;
  font-family: var(--ss-font-mono);
  font-size: 0.72rem;
  color: var(--ss-parchment-faint);
}

#space-shooter kbd {
  display: inline-block;
  min-width: 1.5em;
  margin: 0 0.1em;
  padding: 0 0.35em;
  font-family: var(--ss-font-mono);
  font-size: 0.72em;
  line-height: 1.6;
  text-align: center;
  color: var(--ss-parchment);
  border: 1px solid var(--ss-line);
  border-bottom-width: 2px;
  border-radius: 4px;
}


/* ------------------------------ how to play ------------------------------- */

#space-shooter .shooter-keys {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.35rem 0.9rem;
  font-size: 0.84rem;
}

#space-shooter .shooter-keys dt {
  font-family: var(--ss-font-mono);
  font-size: 0.75rem;
  color: var(--ss-parchment-faint);
  padding-top: 0.1rem;
}

#space-shooter .shooter-legend {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem 0.8rem;
  list-style: none;
  font-size: 0.8rem;
  color: var(--ss-parchment-dim);
}

#space-shooter .shooter-legend li {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

#space-shooter .shooter-legend canvas {
  flex: none;
  width: 27px;
  height: 27px;
  object-fit: contain;
  image-rendering: pixelated;
}

#space-shooter .shooter-legend strong {
  color: var(--ss-parchment);
  font-weight: 500;
}


/* ------------------------------- leaderboard ------------------------------ */

#space-shooter .shooter-board {
  list-style: none;
  font-family: var(--ss-font-mono);
  font-size: 0.82rem;
}

#space-shooter .shooter-board li {
  display: grid;
  grid-template-columns: 1.7rem minmax(0, 1fr) auto auto;
  align-items: baseline;
  gap: 0.6rem;
  padding: 0.38rem 0.2rem;
  border-bottom: 1px solid var(--ss-line);
}

#space-shooter .shooter-board li:last-child {
  border-bottom: 0;
}

#space-shooter .shooter-board__rank {
  color: var(--ss-parchment-faint);
  font-variant-numeric: tabular-nums;
}

#space-shooter .shooter-board li:first-child .shooter-board__rank {
  color: var(--ss-brass);
}

#space-shooter .shooter-board__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--ss-font-ui);
}

#space-shooter .shooter-board__score {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

#space-shooter .shooter-board__date {
  font-size: 0.68rem;
  color: var(--ss-parchment-faint);
  text-align: right;
}

#space-shooter .shooter-board li.is-you {
  background: rgba(99, 199, 155, 0.08);
  border-radius: 6px;
}

#space-shooter .shooter-board li.is-you .shooter-board__name {
  color: var(--ss-jade);
}

#space-shooter .shooter-board__status {
  margin-top: 0.6rem;
  font-family: var(--ss-font-mono);
  font-size: 0.75rem;
  color: var(--ss-parchment-dim);
}

#space-shooter .shooter-board__status:empty {
  display: none;
}

#space-shooter .shooter-board__status.is-error {
  color: var(--ss-oxblood);
}

#space-shooter .shooter-board__you {
  margin-top: 0.6rem;
  font-family: var(--ss-font-mono);
  font-size: 0.75rem;
  color: var(--ss-jade);
}


/* ------------------------------- settings --------------------------------- */

#space-shooter .shooter-field {
  display: grid;
  grid-template-columns: auto 1fr 2.2rem;
  align-items: center;
  gap: 0.7rem;
  margin: 0.4rem 0 0.9rem;
  font-size: 0.88rem;
}

#space-shooter .shooter-field output {
  font-family: var(--ss-font-mono);
  font-size: 0.8rem;
  text-align: right;
  color: var(--ss-parchment-dim);
}

#space-shooter input[type="range"] {
  width: 100%;
  accent-color: var(--ss-brass);
}

#space-shooter .shooter-toggle {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.35rem 0;
  font-size: 0.88rem;
  cursor: pointer;
}

#space-shooter .shooter-toggle input {
  width: 1rem;
  height: 1rem;
  accent-color: var(--ss-jade);
}


/* -------------------------------- game over ------------------------------- */

#space-shooter .shooter-final {
  font-family: var(--ss-font-mono);
  font-size: 2.2rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

#space-shooter .shooter-chip--record {
  margin-top: 0.3rem;
  color: var(--ss-brass);
}

#space-shooter .shooter-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin: 0.9rem 0 0.2rem;
  border: 1px solid var(--ss-line);
  border-radius: 9px;
}

#space-shooter .shooter-stats div {
  padding: 0.4rem 0.2rem;
}

#space-shooter .shooter-stats div + div {
  border-left: 1px solid var(--ss-line);
}

#space-shooter .shooter-stats dt {
  font-family: var(--ss-font-mono);
  font-size: 0.64rem;
  color: var(--ss-parchment-faint);
}

#space-shooter .shooter-stats dd {
  font-family: var(--ss-font-mono);
  font-size: 0.92rem;
  font-weight: 600;
}

#space-shooter .shooter-submit {
  margin-top: 1rem;
  text-align: left;
}

#space-shooter .shooter-submit__label {
  display: block;
  margin-bottom: 0.35rem;
  font-family: var(--ss-font-mono);
  font-size: 0.7rem;
  color: var(--ss-parchment-dim);
}

#space-shooter .shooter-submit__row {
  display: flex;
  gap: 0.45rem;
}

#space-shooter .shooter-input {
  flex: 1;
  min-width: 0;
  padding: 0.55em 0.75em;
  font-size: 0.92rem;
  background: var(--ss-panel-soft);
  border: 1px solid var(--ss-line);
  border-radius: 9px;
}

#space-shooter .shooter-input::placeholder {
  color: var(--ss-parchment-faint);
}

#space-shooter .shooter-submit__status {
  min-height: 1.2em;
  margin-top: 0.45rem;
  font-family: var(--ss-font-mono);
  font-size: 0.72rem;
  color: var(--ss-parchment-dim);
}

#space-shooter .shooter-submit__status.is-ok { color: var(--ss-jade); }
#space-shooter .shooter-submit__status.is-error { color: var(--ss-oxblood); }

#space-shooter .shooter-submit.is-done .shooter-submit__row {
  display: none;
}


/* ------------------------------ small screens ----------------------------- */

@media (max-width: 480px) {
  #space-shooter .shooter-hud__item {
    padding: 0 0.45rem;
  }

  #space-shooter .shooter-hud__value {
    font-size: 0.95rem;
  }

  #space-shooter .shooter-legend {
    grid-template-columns: 1fr;
  }

  #space-shooter .shooter-stats {
    grid-template-columns: repeat(2, 1fr);
  }

  #space-shooter .shooter-stats div:nth-child(3) {
    border-left: 0;
  }

  #space-shooter .shooter-stats div:nth-child(n + 3) {
    border-top: 1px solid var(--ss-line);
  }

  #space-shooter .shooter-board__date {
    display: none;
  }

  #space-shooter .shooter-board li {
    grid-template-columns: 1.5rem minmax(0, 1fr) auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  #space-shooter *,
  #space-shooter *::before,
  #space-shooter *::after {
    animation: none !important;
    transition: none !important;
  }
}
