:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #05080d;
  color: #eaf6ff;
}

* {
  box-sizing: border-box;
}

html,
body,
#game {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

#scene {
  display: block;
  width: 100%;
  height: 100%;
  background: #7eb9e8;
}

.loading-screen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  background: #05080d;
  color: #eaf6ff;
  font-size: 18px;
  font-weight: 800;
}

body:not(.is-loading) .loading-screen {
  display: none;
}

body.is-loading #hud,
body.is-loading #startOverlay {
  visibility: hidden;
  pointer-events: none;
}

#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  user-select: none;
  overflow: hidden;
}

.hud-row.top {
  position: absolute;
  top: 16px;
  left: 50%;
  display: grid;
  grid-template-columns: repeat(4, minmax(86px, 1fr));
  gap: 8px;
  width: min(540px, calc(100vw - 32px));
  transform: translateX(-50%);
}

.readout,
#lockBox,
#missionPanel,
#controls {
  border: 1px solid rgba(142, 210, 255, 0.28);
  background: rgba(6, 14, 22, 0.66);
  box-shadow: 0 0 18px rgba(0, 190, 255, 0.08) inset;
  backdrop-filter: blur(6px);
}

.readout {
  min-width: 0;
  padding: 7px 10px;
}

.readout span,
#lockBox span,
#missionPanel span,
#controls span {
  display: block;
  color: rgba(190, 230, 255, 0.72);
  font-size: 11px;
  line-height: 1.25;
  letter-spacing: 0;
}

.readout strong {
  display: block;
  margin-top: 2px;
  color: #f7fbff;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 24px;
  line-height: 1;
}

#reticle {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 92px;
  height: 92px;
  transform: translate(-50%, -50%);
}

.reticle-ring {
  position: absolute;
  inset: 14px;
  border: 2px solid rgba(134, 255, 210, 0.74);
  border-radius: 50%;
  box-shadow: 0 0 20px rgba(65, 255, 180, 0.16);
}

.reticle-ring::before,
.reticle-ring::after {
  content: "";
  position: absolute;
  background: rgba(134, 255, 210, 0.8);
}

.reticle-ring::before {
  left: 50%;
  top: -18px;
  bottom: -18px;
  width: 2px;
  transform: translateX(-50%);
}

.reticle-ring::after {
  top: 50%;
  left: -18px;
  right: -18px;
  height: 2px;
  transform: translateY(-50%);
}

.reticle-dot {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #dfffee;
  transform: translate(-50%, -50%);
}

#lockBox {
  position: absolute;
  right: 18px;
  top: 16px;
  width: 130px;
  padding: 10px;
}

#lockBox strong {
  display: block;
  margin: 4px 0;
  color: #ffdd76;
  font-size: 17px;
  line-height: 1.1;
}

#missionPanel {
  position: absolute;
  left: 18px;
  top: 16px;
  width: min(130px, calc(100vw - 36px));
  height: 56px;
  padding: 7px 10px;
}

#missionPanel strong {
  display: block;
  color: #9effdc;
  font-size: 13px;
  line-height: 1.2;
}

#missionText {
  margin-top: 4px;
  font-size: 14px;
  color: #eef9ff;
}

#radar {
  position: absolute;
  right: 18px;
  bottom: 18px;
  width: 184px;
  height: 184px;
  border: 1px solid rgba(142, 210, 255, 0.28);
  background: rgba(6, 14, 22, 0.66);
}

#controls {
  position: absolute;
  left: 18px;
  bottom: 18px;
  display: none;
  grid-template-columns: repeat(2, minmax(96px, 1fr));
  gap: 4px 14px;
  width: min(390px, calc(100vw - 230px));
  min-width: 250px;
  padding: 10px 12px;
}

#message {
  position: absolute;
  left: 50%;
  top: 118px;
  max-width: min(520px, calc(100vw - 32px));
  padding: 9px 13px;
  color: #fff;
  font-size: 18px;
  line-height: 1.25;
  text-align: center;
  text-shadow: 0 2px 8px #00121e;
  transform: translateX(-50%);
  opacity: 0;
  transition: opacity 180ms ease;
}

#message.visible {
  opacity: 1;
}

#damageOverlay {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle, rgba(255, 0, 0, 0) 42%, rgba(255, 0, 0, 0.38) 100%);
  opacity: 0;
  transition: opacity 120ms ease;
}

.start-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 18px;
  background: rgba(4, 10, 16, 0.42);
  pointer-events: auto;
  transition: opacity 160ms ease, visibility 160ms ease;
  -webkit-overflow-scrolling: touch;
}

.start-overlay.hidden {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.start-panel {
  width: min(420px, calc(100vw - 36px));
  max-height: calc(100vh - 36px);
  max-height: calc(100svh - 36px);
  max-height: calc(100dvh - 36px);
  overflow-y: auto;
  box-sizing: border-box;
  border: 1px solid rgba(142, 210, 255, 0.34);
  background: rgba(6, 14, 22, 0.78);
  box-shadow: 0 0 26px rgba(0, 190, 255, 0.1) inset;
  padding: 18px;
  backdrop-filter: blur(8px);
  -webkit-overflow-scrolling: touch;
}

.start-kicker {
  display: block;
  color: rgba(190, 230, 255, 0.72);
  font-size: 11px;
  line-height: 1.2;
  letter-spacing: 0;
}

.start-panel h1,
.start-panel strong {
  display: block;
  margin: 0;
  max-width: 100%;
  overflow: hidden;
  color: #f7fbff;
  font-size: clamp(32px, 7vw, 54px);
  line-height: 1.1;
  white-space: nowrap;
}

.start-panel p {
  margin: 10px 0 14px;
  color: rgba(220, 238, 255, 0.82);
  line-height: 1.45;
}

.start-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
}

.start-controls div {
  padding: 7px 9px;
  border: 1px solid rgba(142, 210, 255, 0.16);
  background: rgba(255, 255, 255, 0.05);
}

.start-controls dt {
  color: #9effdc;
  font-size: 11px;
  font-weight: 800;
}

.start-controls dd {
  margin: 3px 0 0;
  color: #eaf6ff;
  font-size: 12px;
}

.mode-buttons {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.mode-buttons button {
  min-height: 48px;
  border: 1px solid rgba(134, 255, 210, 0.48);
  background: rgba(16, 49, 68, 0.88);
  color: #eaf6ff;
  font: inherit;
  font-weight: 700;
  line-height: 1.1;
  cursor: pointer;
}

.mode-buttons button:focus-visible,
.mode-buttons button:hover {
  border-color: #9effdc;
  background: rgba(24, 77, 96, 0.94);
  outline: none;
}

.mode-buttons button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.start-panel .gameblocks-credit {
  margin: 18px 0 0;
  color: rgba(220, 238, 255, 0.66);
  font-size: 12px;
  line-height: 1.2;
  text-align: center;
}

.gameblocks-credit a {
  color: inherit;
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 2px;
}

@media (max-width: 860px) {
  #missionPanel,
  #lockBox {
    top: 88px;
  }
}

@media (max-width: 700px) {
  .hud-row.top {
    grid-template-columns: repeat(2, minmax(86px, 1fr));
    top: 10px;
  }

  #missionPanel {
    top: 142px;
    left: 12px;
    right: 12px;
    width: auto;
  }

  #lockBox {
    top: 222px;
    right: 12px;
    width: 132px;
  }

  #radar {
    width: 142px;
    height: 142px;
    right: 12px;
    bottom: 12px;
  }

  #message {
    top: 318px;
    font-size: 15px;
  }

  .mode-buttons {
    grid-template-columns: 1fr;
  }
}
