﻿:root {
  color-scheme: dark;
  --panel: rgba(8, 13, 26, 0.78);
  --panel-border: rgba(198, 221, 255, 0.24);
  --text: #f6f8ff;
  --muted: #b7c0d8;
  --accent: #58d3ff;
  --accent-strong: #84f4c8;
  --danger: #ff665f;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  color: var(--text);
  background: #03050b;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  border: 0;
  color: inherit;
  font: inherit;
}

.game-shell {
  position: relative;
  width: 100vw;
  height: 100svh;
  min-height: 420px;
  overflow: hidden;
  background: #03050b;
}

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

.menu-panel {
  position: absolute;
  left: 50%;
  top: clamp(22px, 7vh, 72px);
  display: grid;
  width: min(680px, calc(100vw - 32px));
  gap: 18px;
  padding: 22px;
  transform: translateX(-50%);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

body[data-phase="playing"] .menu-panel,
body[data-phase="paused"] .menu-panel {
  opacity: 0;
  pointer-events: none;
}

body[data-phase="landed"] .menu-panel,
body[data-phase="crashed"] .menu-panel {
  top: max(2px, env(safe-area-inset-top));
  gap: 14px;
  padding-block: 18px;
}

.mission-title {
  display: grid;
  gap: 6px;
}

.base-switch {
  display: inline-grid;
  grid-auto-flow: column;
  justify-self: start;
  overflow: hidden;
  border: 1px solid rgba(132, 244, 200, 0.34);
  border-radius: 6px;
  background: rgba(4, 8, 16, 0.62);
}

.base-button {
  min-height: 30px;
  padding: 0 12px;
  color: var(--accent-strong);
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  -webkit-tap-highlight-color: transparent;
}

.base-button + .base-button {
  border-left: 1px solid rgba(132, 244, 200, 0.22);
}

.base-button.is-active {
  color: #061019;
  background: linear-gradient(135deg, var(--accent-strong), var(--accent));
}

.base-button:disabled {
  cursor: default;
  opacity: 0.64;
}

.base-button:focus-visible {
  outline: 2px solid rgba(132, 244, 200, 0.86);
  outline-offset: -2px;
}

.version-badge,
.copyright-badge {
  position: absolute;
  color: rgba(246, 248, 255, 0.68);
  font-size: 0.82rem;
  font-weight: 700;
  text-decoration: none;
}

.version-badge {
  top: 18px;
  right: 20px;
}

.copyright-badge {
  right: 20px;
  bottom: 14px;
}

.copyright-badge:hover {
  color: #ffffff;
  text-decoration: underline;
}

h1 {
  margin: 0;
  font-size: clamp(2.4rem, 6vw, 4.8rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.menu-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.language-switch {
  display: inline-grid;
  grid-auto-flow: column;
  justify-self: end;
  margin: -6px 0 -8px;
  overflow: hidden;
  border: 1px solid rgba(132, 244, 200, 0.34);
  border-radius: 6px;
  background: rgba(4, 8, 16, 0.62);
}

.language-button {
  min-width: 48px;
  min-height: 38px;
  padding: 0 12px;
  cursor: pointer;
  color: rgba(246, 248, 255, 0.74);
  background: rgba(255, 255, 255, 0.06);
  font-weight: 900;
  -webkit-tap-highlight-color: transparent;
}

.language-button + .language-button {
  border-left: 1px solid rgba(132, 244, 200, 0.22);
}

.language-button.is-active {
  color: #061019;
  background: linear-gradient(135deg, var(--accent-strong), var(--accent));
}

.language-button:focus-visible {
  outline: 2px solid rgba(132, 244, 200, 0.86);
  outline-offset: -2px;
}

.primary-action,
.secondary-action {
  min-height: 44px;
  min-width: 116px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 800;
}

.primary-action {
  padding: 0 22px;
  color: #051018;
  background: linear-gradient(135deg, var(--accent-strong), var(--accent));
}

.secondary-action {
  padding: 0 18px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.reset-game-button {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  z-index: 3;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(246, 248, 255, 0.26);
  border-radius: 50%;
  background: rgba(5, 10, 20, 0.72);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.32);
  color: rgba(246, 248, 255, 0.86);
  cursor: pointer;
  font-size: 1rem;
  font-weight: 900;
  line-height: 1;
}

.reset-game-button:hover {
  border-color: rgba(132, 244, 200, 0.62);
  color: #ffffff;
}

body[data-phase="title"] .reset-game-button {
  display: none;
}

body[data-phase="title"] #repeat-button,
body[data-phase="title"] #new-button,
body[data-phase="landed"] #repeat-button,
body[data-phase="crashed"] #repeat-button {
  display: none;
}

.instructions-panel {
  display: grid;
  gap: 8px;
  max-height: min(32vh, 220px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 12px 14px;
  border: 1px solid rgba(132, 244, 200, 0.24);
  border-radius: 6px;
  background: rgba(3, 6, 14, 0.54);
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.35;
  scrollbar-color: rgba(132, 244, 200, 0.72) rgba(255, 255, 255, 0.12);
  scrollbar-width: thin;
}

.instructions-panel[hidden] {
  display: none;
}

.instructions-panel::-webkit-scrollbar {
  width: 8px;
}

.instructions-panel::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.1);
}

.instructions-panel::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(132, 244, 200, 0.72);
}

.instructions-panel p {
  margin: 0;
}

.menu-status {
  min-height: 1.35rem;
  margin: 0;
  padding-right: 170px;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.35;
}

.touch-controls {
  position: absolute;
  left: max(18px, env(safe-area-inset-left));
  right: max(18px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: 58px 58px minmax(28px, 1fr) 58px minmax(28px, 1fr) 72px;
  grid-template-rows: 58px;
  gap: 8px;
  pointer-events: none;
}

.touch-button {
  display: grid;
  place-items: center;
  grid-row: 1;
  align-self: end;
  justify-self: start;
  width: 58px;
  height: 58px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(6, 12, 24, 0.72);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.32);
  color: #ffffff;
  cursor: pointer;
  font-size: 1.75rem;
  font-weight: 900;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  appearance: none;
  touch-action: none;
  user-select: none;
  pointer-events: auto;
}

.touch-button span {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  line-height: 1;
  pointer-events: none;
  -webkit-user-select: none;
  user-select: none;
}

.touch-button[data-thrust="left"] {
  grid-column: 1;
}

.touch-button[data-thrust="right"] {
  grid-column: 2;
}

.touch-button-pause {
  grid-column: 4;
  justify-self: center;
  color: #84f4c8;
  background: rgba(6, 12, 24, 0.82);
}

.touch-button-main {
  grid-column: 6;
  justify-self: end;
  width: 72px;
  color: #061019;
  background: linear-gradient(135deg, #f9d66a, #ff8a4b);
}

.touch-button:active,
.touch-button.is-active {
  transform: translateY(1px);
  filter: brightness(1.18);
}

@media (hover: hover) and (pointer: fine) {
  .touch-controls {
    display: none;
  }
}

@media (max-width: 720px) {
  .game-shell {
    min-height: 100svh;
  }

  .menu-panel {
    top: max(14px, env(safe-area-inset-top));
    padding: 16px;
  }

  .version-badge {
    top: 12px;
    right: 14px;
  }

  .copyright-badge {
    right: 14px;
    bottom: 10px;
  }

  .menu-status {
    padding-right: 0;
    padding-bottom: 22px;
  }

  h1 {
    font-size: 2.4rem;
  }

  .touch-controls {
    left: max(12px, env(safe-area-inset-left));
    right: max(12px, env(safe-area-inset-right));
    grid-template-columns: 62px 62px minmax(16px, 1fr) 64px minmax(16px, 1fr) 78px;
    grid-template-rows: 64px;
    gap: 6px;
  }

  .touch-button {
    width: 64px;
    height: 64px;
  }

  .touch-button-main {
    width: 78px;
  }
}

.mission-controls {
  display: grid;
  grid-template-columns: 0.85fr repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.field-label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
}

.field-label select,
.field-label input {
  width: 100%;
  min-height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 6px;
  padding: 0 10px;
  color: var(--text);
  background: rgba(5, 10, 20, 0.72);
  font: 700 0.95rem Inter, ui-sans-serif, system-ui, sans-serif;
  outline: none;
}

.field-label select:focus,
.field-label input:focus {
  border-color: rgba(132, 244, 200, 0.72);
  box-shadow: 0 0 0 3px rgba(132, 244, 200, 0.14);
}

.compact-action {
  min-width: 138px;
}

@media (max-width: 720px) {
  .mission-controls {
    grid-template-columns: 1fr;
  }

  .menu-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .language-switch {
    justify-self: stretch;
    margin: -2px 0 -4px;
  }

  .language-button {
    min-width: 0;
    width: 100%;
  }

  .primary-action,
  .secondary-action {
    min-width: 0;
    width: 100%;
  }
}


