:root {
  --space-bg: #05040d;
  --space-panel: rgba(8, 6, 20, 0.96);
  --space-panel-soft: rgba(20, 14, 38, 0.88);
  --space-border: rgba(169, 85, 255, 0.48);
  --space-purple: #ad55ff;
  --space-cyan: #24f6d2;
  --space-yellow: #ffd424;
  --space-red: #ff536b;
  --space-text: #ffffff;
  --space-muted: #b8b3c5;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--space-bg);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--space-text);
  background-color: var(--space-bg);
  background-position: center;
  background-attachment: fixed;
  background-size: cover;
  font-family: Arial, Helvetica, sans-serif;
}

button,
a {
  font: inherit;
}

button {
  cursor: pointer;
}

.arcade-nav {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 78px;
  padding: 12px clamp(24px, 6vw, 130px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(5, 4, 13, 0.92);
  backdrop-filter: blur(14px);
}

.arcade-brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: #ffffff;
  text-decoration: none;
  font-size: clamp(17px, 1.4vw, 23px);
  font-weight: 900;
  letter-spacing: 0.03em;
}

.brand-code {
  color: var(--space-purple);
  font-size: 1.55em;
  line-height: 1;
}

.arcade-nav-links {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  background: rgba(12, 9, 24, 0.84);
}

.arcade-nav-links a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 15px;
  border-radius: 999px;
  color: #d8d4df;
  text-decoration: none;
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  transition: color 0.2s ease, background 0.2s ease;
}

.arcade-nav-links a:hover {
  color: #ffffff;
  background: rgba(173, 85, 255, 0.14);
}

.arcade-nav-links svg {
  width: 18px;
  height: 18px;
  fill: var(--space-purple);
}

.space-page {
  width: min(1400px, 94vw);
  margin: 0 auto;
  padding-bottom: 26px;
}

.game-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 56px;
  padding: 0 4px;
}

.toolbar-link {
  color: var(--space-purple);
  text-decoration: none;
  font-size: 13px;
  font-weight: 850;
  letter-spacing: 0.06em;
}

.toolbar-button {
  border: 0;
  background: none;
  cursor: pointer;
}

.toolbar-link:hover {
  color: #d69aff;
}

.arcade-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(330px, 0.9fr);
  width: 100%;
  min-height: min(760px, calc(100vh - 160px));
  overflow: hidden;
  border: 1px solid var(--space-border);
  border-radius: 28px;
  background: var(--space-panel);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.56);
}

.board-column {
  display: flex;
  min-width: 0;
  flex-direction: column;
  padding: clamp(22px, 3vh, 34px) clamp(22px, 2.5vw, 42px) 26px;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.space-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 17px;
  min-height: 52px;
  margin: 0 0 20px;
  color: var(--space-cyan);
  text-align: center;
  font-family: "Courier New", monospace;
  font-size: clamp(27px, 3vw, 46px);
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0.08em;
  text-shadow:
    0 0 5px rgba(36, 246, 210, 0.92),
    0 0 18px rgba(36, 246, 210, 0.45);
}

.space-logo-icon,
.ship-mark {
  width: 42px;
  height: 34px;
  color: var(--space-cyan);
  filter: drop-shadow(0 0 7px rgba(36, 246, 210, 0.75));
}

.game-stage {
  position: relative;
  flex: 1;
  min-height: 440px;
  overflow: hidden;
  border: 2px solid #1265ff;
  border-radius: 18px;
  background: #05070c;
  box-shadow:
    0 0 26px rgba(18, 101, 255, 0.22),
    inset 0 0 28px rgba(0, 0, 0, 0.8);
}

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

.game-overlay,
.overlay {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  padding: 24px;
  color: #ffffff;
  text-align: center;
  background: rgba(1, 3, 10, 0.58);
  backdrop-filter: blur(3px);
}

.game-overlay[hidden],
.overlay.hidden {
  display: none;
}

.overlay-card {
  max-width: 520px;
}

.overlay-card h2 {
  margin: 0 0 10px;
  color: var(--space-cyan);
  font-family: "Courier New", monospace;
  font-size: clamp(27px, 4vw, 48px);
  text-shadow: 0 0 14px rgba(36, 246, 210, 0.55);
}

.overlay-card p {
  margin: 0 0 20px;
  color: #ffffff;
  font-size: 15px;
  line-height: 1.55;
}

.overlay-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
}

.overlay-button,
.overlay-actions button {
  min-width: 140px;
  padding: 12px 18px;
  border: 1px solid var(--space-cyan);
  border-radius: 10px;
  color: var(--space-cyan);
  background: rgba(6, 30, 32, 0.9);
  font-weight: 900;
  text-transform: uppercase;
  box-shadow: 0 0 16px rgba(36, 246, 210, 0.24);
}

.game-help {
  display: flex;
  justify-content: center;
  gap: 22px;
  margin-top: 17px;
  color: var(--space-muted);
  font-size: 13px;
}

.game-help strong {
  color: var(--space-cyan);
}

.control-column {
  display: flex;
  min-width: 0;
  flex-direction: column;
  padding: 24px 28px 22px;
}

.desktop-stats,
.mobile-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.mobile-stats,
.mobile-hud {
  display: none;
}

.mobile-hud span {
  padding: 11px 14px;
  border-radius: 12px;
  color: #1c1724;
  background: #f4f2f5;
  font-size: 15px;
  font-weight: 700;
}

.stat-card {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-width: 0;
  padding: 12px 9px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.035);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.04);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.stat-icon {
  flex: 0 0 auto;
  color: var(--space-yellow);
  font-size: 22px;
}

.stat-icon.red {
  color: var(--space-red);
}

.stat-card span:last-child {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 2px;
}

.stat-card b {
  color: var(--space-yellow);
  font-size: 19px;
  line-height: 1;
}

.controls-block {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) 190px;
  align-items: center;
  gap: 24px;
  margin: 34px 0 28px;
}

.keyboard-help h2,
.score-preview h2 {
  margin: 0 0 17px;
  color: var(--space-purple);
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 0.05em;
}

.keyboard-help p {
  margin: 10px 0;
  color: var(--space-muted);
  font-size: 13px;
}

.keyboard-help strong {
  color: var(--space-cyan);
}

.control-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 22px;
}

.mini-dpad,
.dpad-preview {
  display: grid;
  grid-template-columns: repeat(3, 48px);
  grid-template-rows: repeat(3, 48px);
  gap: 6px;
}

.mini-key,
.dpad-preview span {
  display: grid;
  place-items: center;
  border: 1px solid rgba(173, 85, 255, 0.45);
  border-radius: 13px;
  color: var(--space-purple);
  background: #1a122d;
  font-size: 19px;
}

.mini-key.up,
.dpad-preview .up {
  grid-column: 2;
}

.mini-key.left,
.dpad-preview .left {
  grid-column: 1;
  grid-row: 2;
}

.mini-key.center,
.dpad-preview .center {
  grid-column: 2;
  grid-row: 2;
  color: #090710;
  background: var(--space-yellow);
}

.mini-key.right,
.dpad-preview .right {
  grid-column: 3;
  grid-row: 2;
}

.mini-key.down,
.dpad-preview .down {
  grid-column: 2;
  grid-row: 3;
}

.mini-fire {
  display: grid;
  width: 68px;
  height: 68px;
  place-items: center;
  border: 1px solid rgba(36, 246, 210, 0.55);
  border-radius: 50%;
  color: var(--space-cyan);
  background: rgba(6, 30, 32, 0.85);
  font-size: 27px;
  box-shadow: 0 0 18px rgba(36, 246, 210, 0.18);
}

.action-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.arcade-action {
  min-height: 48px;
  padding: 10px 13px;
  border: 1px solid rgba(173, 85, 255, 0.65);
  border-radius: 12px;
  color: var(--space-purple);
  background: rgba(27, 17, 47, 0.85);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.arcade-action:hover {
  border-color: var(--space-purple);
  color: #ffffff;
}

.score-preview {
  margin-top: 25px;
}

.ranking-preview {
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.025);
  list-style: none;
}

.ranking-preview li {
  display: grid;
  grid-template-columns: 30px 1fr auto;
  gap: 8px;
  padding: 11px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 13px;
}

.ranking-preview li:last-child {
  border-bottom: 0;
}

.rank-position {
  color: var(--space-purple);
  font-weight: 900;
}

.ranking-preview li:first-child .rank-position {
  color: var(--space-yellow);
}

.rank-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-score {
  color: var(--space-yellow);
  font-weight: 900;
}

.ranking-loading,
.ranking-empty {
  display: block !important;
  color: var(--space-muted);
  text-align: center;
}

.btn-start,
.btn-start-space {
  width: 100%;
  min-height: 58px;
  margin-top: auto;
  padding: 12px 20px;
  border: 2px solid var(--space-cyan);
  border-radius: 12px;
  color: var(--space-cyan);
  background: rgba(5, 27, 29, 0.92);
  font-family: "Courier New", monospace;
  font-size: 19px;
  font-weight: 900;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  box-shadow:
    0 0 18px rgba(36, 246, 210, 0.28),
    inset 0 0 16px rgba(36, 246, 210, 0.08);
}

.btn-start:hover,
.btn-start-space:hover {
  color: #07110f;
  background: var(--space-cyan);
}

.btn-start-space svg {
  width: 20px;
  height: 22px;
  margin-right: 9px;
  fill: currentColor;
  vertical-align: middle;
}

.mobile-controls {
  display: none;
}

@media (max-width: 1120px) {
  .arcade-shell {
    grid-template-columns: minmax(0, 1.5fr) minmax(310px, 0.8fr);
  }

  .board-column {
    padding-right: 24px;
    padding-left: 24px;
  }

  .control-column {
    padding-right: 22px;
    padding-left: 22px;
  }

  .controls-block {
    grid-template-columns: 1fr;
  }

  .keyboard-help {
    text-align: center;
  }
}

@media (max-width: 820px) {
  .arcade-nav {
    min-height: 68px;
    padding: 10px 16px;
  }

  .arcade-nav-links a {
    padding: 10px;
  }

  .arcade-nav-links a span {
    display: none;
  }

  .space-page {
    min-height: calc(100vh - 68px);
    padding: 18px 14px 24px;
  }

  .arcade-shell {
    display: block;
    min-height: 0;
    overflow: visible;
    border-radius: 24px;
  }

  .board-column {
    padding: 24px 18px 18px;
    border-right: 0;
  }

  .control-column {
    display: none;
  }

  .space-logo {
    margin-bottom: 18px;
    font-size: clamp(24px, 7vw, 36px);
  }

  .space-logo-icon,
  .ship-mark {
    width: 31px;
    height: 26px;
  }

  .mobile-stats,
  .mobile-hud {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
  }

  .mobile-hud span:last-child {
    text-align: right;
  }

  .mobile-stats .stat-card {
    padding: 12px 14px;
  }

  .mobile-stats .stat-card b {
    font-size: 22px;
  }

  .game-stage {
    height: min(60vh, 620px);
    min-height: 430px;
    flex: none;
    border-radius: 14px;
  }

  .game-help {
    display: none;
  }

  .mobile-controls {
    display: grid;
    grid-template-columns: 1fr 104px;
    align-items: center;
    gap: 28px;
    margin-top: 14px;
    padding: 12px 14px;
    border-radius: 15px;
    background: rgba(255, 255, 255, 0.07);
  }

  .touch-dpad,
  .dpad {
    display: grid;
    grid-template-columns: repeat(3, 55px);
    grid-template-rows: repeat(3, 55px);
    justify-content: center;
    gap: 0;
  }

  .touch-button,
  .dpad-btn {
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 11px;
    color: #ffffff;
    background: #2a2a2a;
    font-size: 23px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.28);
    touch-action: none;
    user-select: none;
  }

  .touch-button.up,
  .dpad-btn.up {
    grid-column: 2;
  }

  .touch-button.left,
  .dpad-btn.left {
    grid-column: 1;
    grid-row: 2;
  }

  .touch-dpad-center,
  .dpad::after {
    grid-column: 2;
    grid-row: 2;
    background: #ffffff;
  }

  .dpad::after {
    display: block;
    content: "";
  }

  .touch-button.right,
  .dpad-btn.right {
    grid-column: 3;
    grid-row: 2;
  }

  .touch-button.down,
  .dpad-btn.down {
    grid-column: 2;
    grid-row: 3;
  }

  .touch-fire {
    display: grid;
    width: 84px;
    height: 84px;
    place-items: center;
    justify-self: center;
    border: 0;
    border-radius: 50%;
    color: #ffffff;
    background: #222222;
    font-size: 37px;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.3);
    touch-action: none;
    user-select: none;
  }
}

@media (max-width: 480px) {
  .arcade-brand span:last-child {
    font-size: 14px;
  }

  .arcade-nav-links {
    gap: 2px;
    padding: 4px;
  }

  .arcade-nav-links a {
    padding: 8px;
  }

  .game-toolbar {
    margin-bottom: 13px;
  }

  .toolbar-link {
    font-size: 12px;
  }

  .board-column {
    padding: 20px 14px 14px;
  }

  .space-logo {
    gap: 8px;
    font-size: clamp(19px, 6.2vw, 27px);
    letter-spacing: 0.03em;
  }

  .space-logo-icon {
    width: 25px;
  }

  .mobile-stats {
    gap: 10px;
  }

  .mobile-stats .stat-card {
    gap: 8px;
    padding: 10px;
  }

  .mobile-stats .stat-icon {
    font-size: 20px;
  }

  .mobile-stats .stat-card > span:last-child {
    font-size: 10px;
  }

  .game-stage {
    height: 60vh;
    min-height: 430px;
  }

  .game-overlay {
    padding: 16px;
  }

  .overlay-card p {
    font-size: 13px;
  }

  .mobile-controls {
    grid-template-columns: minmax(180px, 1fr) 88px;
    gap: 12px;
    padding: 12px 8px;
  }

  .touch-dpad,
  .dpad {
    grid-template-columns: repeat(3, 50px);
    grid-template-rows: repeat(3, 50px);
  }

  .touch-fire {
    width: 76px;
    height: 76px;
  }
}

@media (max-width: 370px) {
  .arcade-brand span:last-child {
    display: none;
  }

  .space-page {
    padding-right: 8px;
    padding-left: 8px;
  }

  .board-column {
    padding-right: 10px;
    padding-left: 10px;
  }

  .touch-dpad,
  .dpad {
    grid-template-columns: repeat(3, 46px);
    grid-template-rows: repeat(3, 46px);
  }
}
#game,
.game-stage,
.mobile-controls,
.dpad-btn,
.touch-fire {
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  overscroll-behavior: contain;
}