html, body { margin: 0; width: 100%; height: 100%; overflow: hidden; background: #000; }
#game-container {
  position: fixed;
  inset: 0;
  display: none;
  margin: auto;
  width: min(100vw, 100dvh * 16 / 9);
  height: min(100dvh, 100vw * 9 / 16);
}

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

.space-adventure [hidden],
html:not(.online-game) .space-adventure .online-only,
.online-game .space-adventure .solo-only {
  display: none !important;
}

.space-adventure #control-panel {
  padding: 0;
  overflow: hidden;
}

.space-adventure #control-panel-options {
  width: 100%;
  height: 100dvh;
  min-height: 0;
  max-height: none;
  margin: 0;
  overflow: auto;
}

.space-adventure .game-menu-layout {
  grid-template-columns: minmax(300px, min(36vw, 500px)) minmax(0, 1fr);
  min-height: 100%;
  height: auto;
}

.space-adventure .game-menu-main {
  order: 0;
  justify-content: center;
  gap: clamp(.4rem, 1.4dvh, .85rem);
  padding: clamp(.75rem, 2dvh, 1.6rem) clamp(1rem, 2.4vw, 1.75rem);
  overflow: visible;
}

.space-adventure #options-title-bar,
.space-adventure #control-panel-instructions,
.space-adventure #button-container {
  margin: 0;
}

.space-adventure #multiplayer-toggle.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  min-height: 48px;
  font-size: 1.1875rem;
  line-height: 1.2;
  text-decoration: none;
  box-shadow: 0 5px 12px rgba(170, 52, 19, .28);
}

.space-adventure #multiplayer-toggle:focus-visible {
  outline: 3px solid #96330f;
  outline-offset: 3px;
}

.space-adventure #control-panel-instructions {
  padding: 0;
  font-size: clamp(.82rem, 1.75dvh, 1rem);
}

.space-adventure #control-panel-instructions p {
  margin: 0;
}

.space-adventure #options-inline-container {
  gap: .65rem;
  padding: .65rem 0;
}

.space-adventure .stop-action-mode-description {
  margin: 0;
}

.space-adventure #stop-action-mode-description {
  margin-top: .35rem;
  font-size: clamp(.8rem, 1.75dvh, .95rem);
}

.space-adventure .stop-action-mode-btn {
  min-height: 40px;
}

.space-adventure .game-mode-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin-top: .35rem;
  padding-inline: 1rem;
  border: 1px solid #709994;
  border-radius: .65rem;
  background: #fcffff;
  color: #173c39;
  font-weight: 700;
  text-decoration: none;
}

.space-adventure .game-mode-link:hover {
  background: #e1f5f3;
}

.space-adventure .game-mode-link:focus-visible {
  outline: 3px solid #04786c;
  outline-offset: 2px;
}

.space-adventure .game-menu-art {
  display: flex;
  order: 0;
  min-height: 0;
}

.space-adventure .ship-card {
  min-height: 0;
}

.space-adventure .ship-card img {
  height: clamp(106px, 35dvh, 290px);
}

@media (max-height: 700px) {
  .space-adventure .game-menu-layout {
    grid-template-columns: minmax(340px, min(51vw, 460px)) minmax(0, 1fr);
  }

  .space-adventure .game-menu-main {
    gap: .45rem;
    padding-block: .6rem;
  }

  html:not(.online-game) .space-adventure #control-panel-instructions,
  .online-game .space-adventure .game-menu-main:has(#room-info:not([hidden])) #control-panel-instructions {
    display: none;
  }

  .online-game .space-adventure #control-panel-instructions {
    max-width: 100%;
    line-height: 1.3;
  }

  .space-adventure #options-inline-container {
    gap: .45rem;
    padding-block: .5rem;
  }
}

@media (max-width: 700px), (max-aspect-ratio: 1/1) {
  .space-adventure .game-menu-layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto 1fr;
  }

  .space-adventure .game-menu-main {
    padding-top: clamp(2.25rem, 4dvh, 3rem);
  }

  .space-adventure .ship-select-panel {
    padding-block: .75rem;
  }

  .space-adventure .ship-card img {
    height: clamp(82px, 14dvh, 148px);
  }

  .space-adventure .ship-card-tag,
  .space-adventure .ship-card-stats {
    display: none;
  }

  .space-adventure .ship-select-title,
  .space-adventure .ship-card-name {
    font-size: clamp(9px, 2vw, 13px);
  }

  .space-adventure .ship-card-name,
  .space-adventure .asset-load-status {
    min-height: 0;
  }

  .space-adventure .ship-select-title,
  .space-adventure .asset-load-status {
    margin-bottom: .6rem;
  }
}

.hud {
  position: absolute;
  inset: 0;
  z-index: 30;
  color: #fff;
  font-family: 'Press Start 2P', cursive;
  font-size: clamp(9px, min(1.1vw, 1.95dvh), 14px);
  line-height: 1.7;
  display: none;
  text-align: right;
  pointer-events: none;
}

.hud-summary {
  position: absolute;
  right: var(--hud-right, 1.4%);
  bottom: 2.8%;
}

.ammo-meter {
  position: absolute;
  left: 1.56%;
  top: var(--ammo-top, 75%);
  width: 4.38%;
  height: 25%;
  display: none;
  z-index: 32;
}
.ammo-meter.right {
  left: auto;
  right: 1.56%;
}

.ammo-meter-track {
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  margin: 0 auto;
  border: 2px solid rgba(220, 255, 255, 0.85);
  border-radius: 16px;
  overflow: hidden;
  background:
    repeating-linear-gradient(
      to top,
      rgba(255,255,255,0.12) 0 10%,
      rgba(255,255,255,0.03) 10% 20%
    ),
    rgba(0, 0, 0, 0.45);
  position: relative;
}

.ammo-meter-track::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 14px rgba(0, 0, 0, 0.45);
}

.ammo-meter-fill {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 100%;
  width: 100%;
  background: hsl(120 85% 52%);
  box-shadow: 0 0 14px rgba(120, 255, 140, 0.6);
  transition: height 80ms linear, background 120ms linear, box-shadow 120ms linear;
}

#input-mode-segmented-control .stop-action-mode-btn,
#stop-action-mode-segmented-control .stop-action-mode-btn {
  font-size: clamp(11px, 1.55vw, 15px);
  padding-inline: clamp(8px, 1.2vw, 14px);
  min-width: 0;
}

@media (min-height: 1000px) {
  #input-mode-segmented-control .stop-action-mode-btn,
  #stop-action-mode-segmented-control .stop-action-mode-btn {
    font-size: clamp(12px, 1.7vw, 16px);
  }
}

@media (max-height: 720px) {
  #input-mode-segmented-control .stop-action-mode-btn,
  #stop-action-mode-segmented-control .stop-action-mode-btn {
    font-size: clamp(9px, 1.45vw, 12px);
  }
}

@media (max-width: 900px) {
  #input-mode-segmented-control .stop-action-mode-btn,
  #stop-action-mode-segmented-control .stop-action-mode-btn {
    font-size: clamp(10px, 2.5vw, 13px);
    letter-spacing: 0.01em;
  }
}

#game-over {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 35;
  background: rgba(0,0,0,0.5);
}

#game-over .results-panel {
  font-family: 'Press Start 2P', cursive;
  text-align: center;
  max-width: min(90vw, 680px);
}

#game-over-score {
  color: #fff;
  margin: 18px 0;
  font-size: 16px;
  line-height: 1.6;
}

.retry-hint {
  color: #fff;
  margin: 12px 0 6px;
  font-size: 12px;
  line-height: 1.5;
}

.retry-eyegaze-tiles {
  display: none;
  width: min(88vw, 680px);
  margin: 12px auto 0;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.retry-eyegaze-tile {
  width: min(42vw, 320px);
  aspect-ratio: 1 / 1;
  border: 4px solid rgba(255,255,255,0.75);
  border-radius: 20px;
  background: rgba(255,255,255,0.1);
  position: relative;
  overflow: hidden;
}

.retry-eyegaze-tile img {
  width: 82%;
  height: 82%;
  object-fit: contain;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 1;
}

.retry-eyegaze-fill {
  position: absolute;
  inset: 0;
  background: rgba(255, 52, 52, 0.42);
  transform: scale(0);
  transform-origin: center;
  pointer-events: none;
  z-index: 2;
}

.retry-eyegaze-label {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 12px;
  z-index: 3;
  text-align: center;
  color: #fff;
  font-family: 'Press Start 2P', cursive;
  font-size: 11px;
  line-height: 1.5;
  text-shadow: 0 0 8px rgba(0, 0, 0, 0.8);
  pointer-events: none;
}

.eyegaze-action-button-wrap {
  position: relative;
  width: min(100%, 180px);
  aspect-ratio: 1 / 1;
  margin-top: 4px;
}

.eyegaze-action-button-wrap .button {
  width: 100%;
  height: 100%;
  margin-top: 0;
  position: relative;
  z-index: 1;
  border-radius: 20px;
  white-space: normal;
  line-height: 1.3;
  padding: 12px;
}

.eyegaze-action-fill {
  position: absolute;
  inset: 0;
  border-radius: 20px;
  background: rgba(255, 52, 52, 0.42);
  transform: scale(0);
  transform-origin: center;
  pointer-events: none;
  z-index: 2;
}

#game-over.switch-score-screen .eyegaze-action-button-wrap {
  width: min(100%, 220px);
  aspect-ratio: auto;
  height: 56px;
}

#game-over.switch-score-screen .eyegaze-action-button-wrap .button {
  border-radius: 14px;
  padding: 8px 14px;
  font-size: 11px;
  line-height: 1.2;
}

#game-over.switch-score-screen .eyegaze-action-fill {
  border-radius: 16px;
}

#continue-button {
  width: min(100%, 280px);
  margin: 10px auto 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 1.2;
}

.ship-select-panel {
  width: 100%;
  height: 100%;
  border-radius: 22px;
  position: relative;
  overflow: hidden;
  padding: 18px 18px 20px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: center;
  color: #fff;
  background: #000;
  border: 1px solid rgba(130, 185, 255, 0.1);
  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,0.02),
    0 16px 36px rgba(0,0,0,0.38);
}

#ship-select-stars {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
  background: #000;
}

.ship-select-panel::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 50% 0%, rgba(65,110,255,0.10), transparent 42%),
    radial-gradient(circle at 50% 100%, rgba(110,180,255,0.05), transparent 36%);
  pointer-events: none;
  z-index: 1;
}

.ship-select-title {
  position: relative;
  z-index: 2;
  font-family: 'Press Start 2P', cursive;
  font-size: 16px;
  line-height: 1.5;
  text-align: center;
  margin: 0 0 14px;
  color: #e9f3ff;
  text-shadow: 0 0 10px rgba(130, 190, 255, 0.2);
}

.asset-load-status {
  position: relative;
  z-index: 2;
  font-family: 'Press Start 2P', cursive;
  font-size: 9px;
  line-height: 1.8;
  text-align: center;
  color: #c7ddff;
  margin: -2px 0 16px;
  min-height: 28px;
  opacity: 0.95;
}

.ship-select-grid {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 0;
  align-items: start;
}

.ship-card {
  background: rgba(255,255,255,0.035);
  border: 1px solid rgba(175, 210, 255, 0.14);
  border-radius: 18px;
  padding: 8px 8px 12px;
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease, box-shadow 120ms ease, background 120ms ease;
  min-height: 460px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  position: relative;
  overflow: hidden;
}

.ship-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0));
  pointer-events: none;
}

.ship-card:hover {
  transform: translateY(-2px);
  border-color: rgba(200, 228, 255, 0.24);
  box-shadow: 0 10px 24px rgba(40, 90, 180, 0.12);
}

.ship-card.selected {
  background: rgba(120, 180, 255, 0.07);
  border-color: rgba(160, 220, 255, 0.34);
  box-shadow:
    0 0 0 1px rgba(160, 220, 255, 0.08),
    0 0 22px rgba(100, 180, 255, 0.12);
}

.ship-card img {
  width: 100%;
  max-width: 360px;
  height: 290px;
  object-fit: contain;
  image-rendering: auto;
  filter: drop-shadow(0 0 20px rgba(100,180,255,0.18));
  margin-top: -2px;
}

.ship-card-name {
  font-family: 'Press Start 2P', cursive;
  font-size: 12px;
  line-height: 1.45;
  text-align: center;
  color: #fff;
  min-height: 34px;
}

.ship-card-tag {
  font-family: 'Press Start 2P', cursive;
  font-size: 9px;
  line-height: 1.45;
  text-align: center;
  color: #b9d9ff;
  opacity: 0.95;
  min-height: 22px;
}

.ship-card-stats {
  margin-top: 4px;
  width: min(100%, 265px);
  padding: 10px 10px 8px;
  border-radius: 12px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(180, 215, 255, 0.1);
  box-shadow: inset 0 0 14px rgba(90, 140, 255, 0.035);
}

.ship-stat-row {
  display: grid;
  grid-template-columns: 76px 1fr;
  align-items: center;
  gap: 10px;
  margin-bottom: 11px;
}

.ship-stat-label {
  font-family: 'Press Start 2P', cursive;
  font-size: 9px;
  line-height: 1.35;
  color: #dcecff;
}

.ship-card-stat-label {
  font-size: 8px;
}

.ship-stat-bar {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 5px;
  height: 16px;
  align-items: stretch;
}

.ship-stat-segment {
  border-radius: 4px;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.05);
  box-shadow: inset 0 0 4px rgba(0,0,0,0.2);
  transition: background 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.ship-stat-segment.active {
  background: linear-gradient(180deg, rgba(205,235,255,0.95), rgba(110,185,255,0.82));
  border-color: rgba(190,230,255,0.2);
  box-shadow:
    0 0 8px rgba(120, 190, 255, 0.14),
    inset 0 0 3px rgba(255,255,255,0.15);
}

.ship-trait {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255,255,255,0.08);
  font-family: 'Press Start 2P', cursive;
  font-size: 9px;
  line-height: 1.8;
  color: #cfe5ff;
  text-align: center;
  min-height: 42px;
}

.ship-card-trait {
  margin-top: 8px;
  padding-top: 8px;
  min-height: 38px;
}

.ship-card:not(.selected) img {
  filter: grayscale(1) brightness(0.58) contrast(0.9);
  opacity: 0.72;
}

.ship-card:not(.selected) .ship-card-name,
.ship-card:not(.selected) .ship-card-tag,
.ship-card:not(.selected) .ship-card-stats,
.ship-card:not(.selected) .ship-card-trait {
  opacity: 0.45;
  color: #8fa0b6;
}

.ship-card:not(.selected) .ship-stat-segment.active {
  background: rgba(170, 176, 188, 0.38);
  border-color: rgba(200, 205, 215, 0.16);
  box-shadow: none;
}
