@font-face {
  font-family: Orbitron;
  src: url('./assets/Orbitron-Variable.woff2') format('woff2');
  font-weight: 400 900;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: dark;
  background: #080b10;
  --ship-color: #f5f6f8;
}

* {
  box-sizing: border-box;
}

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

body:not(.menu-open) {
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

button, input {
  font: inherit;
}

button {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible, input:focus-visible {
  outline: 2px solid #a4d9f1;
  outline-offset: 5px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  clip-path: inset(50%);
  overflow: hidden;
  white-space: nowrap;
}

[hidden] {
  display: none!important;
}

/* The canvas draws the world. The fixed HUD sits above it and passes pointer input through. */
#space {
  display: block;
  width: 100%;
  height: 100dvh;
  outline: none;
  touch-action: none;
  cursor: none;
}

#game-hud {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  color: #d4dfe8;
  font-family: Arial,Helvetica,sans-serif;
}

.leaderboard {
  position: absolute;
  right: max(24px,env(safe-area-inset-right));
  top: max(24px,env(safe-area-inset-top));
  width: 200px;
  padding: 14px 14px 10px;
  background: #0b141c80;
  border: 1px solid #c6deef16;
  border-radius: 6px;
  backdrop-filter: blur(3px);
}

.leaderboard h2 {
  font: 700 9px Orbitron,sans-serif;
  letter-spacing: 1.5px;
  margin: 0 0 11px;
  color: #b2c4d0;
}

.leaderboard ol {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.leaderboard li, .leaderboard-you {
  display: grid;
  grid-template-columns: 18px 1fr auto;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  line-height: 1.2;
  color: #91a3b1;
  font-variant-numeric: tabular-nums;
}

.leaderboard .rank {
  font-size: 10px;
  opacity: .65;
}

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

.leaderboard .pilot-score {
  font-size: 10px;
  opacity: .7;
}

.leaderboard-you {
  margin-top: 9px;
  padding-top: 9px;
  border-top: 1px solid #c6deef25;
  color: #e7eff7;
  font-weight: 700;
}

.leaderboard-you .rank, .leaderboard-you .pilot-score {
  opacity: .85;
}

#leaderboard-toggle {
  display: none;
}

.power-meter {
  --power-width: 220px;
  --power-inset: 24px;
  position: absolute;
  left: max(var(--power-inset),env(safe-area-inset-left));
  bottom: max(28px,env(safe-area-inset-bottom));
  width: var(--power-width);
  max-width: calc(100vw - max(var(--power-inset),env(safe-area-inset-left)) - max(var(--power-inset),env(safe-area-inset-right)));
}

.power-meter>span {
  display: block;
  font: 600 13px Orbitron,sans-serif;
  letter-spacing: 1.7px;
  margin-bottom: 10px;
  color: #94adbd;
}

.power-track {
  height: 9px;
  border-radius: 5px;
  background: #6b89942b;
  overflow: hidden;
  box-shadow: 0 0 0 1px #b9e9f00d;
}

/* Width and hue share the same ratio from the HUD. The track stays fixed. */
#power-fill {
  --power-hue: calc(120 * var(--power-ratio,1));
  width: 100%;
  height: 100%;
  background-color: hsl(var(--power-hue) 100% 58%);
  transform: scaleX(var(--power-ratio,1));
  transform-origin: left;
  transition: transform .12s linear,background-color .12s linear,box-shadow .12s linear;
  box-shadow: 0 0 10px hsl(var(--power-hue) 100% 58% / .4);
}

.player-score {
  position: absolute;
  left: 50%;
  bottom: max(41px,calc(env(safe-area-inset-bottom) + 12px));
  transform: translateX(-50%);
  font: 700 21px Orbitron,sans-serif;
  font-variant-numeric: tabular-nums;
  color: #e7eff7;
  text-shadow: 0 2px 6px #080b10,0 0 12px #080b10;
}

/* The menu overlays the same canvas used for flight. */
#menu {
  position: fixed;
  inset: 0;
  z-index: 2;
  background: rgba(11,10,20,.23);
  font-family: Arial,Helvetica,sans-serif;
  cursor: default;
}

#menu.fade-in {
  animation: menu-fade-in .45s ease-out both;
}

@keyframes menu-fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.sponsorship-contact {
  position: absolute;
  top: max(18px,env(safe-area-inset-top));
  left: max(24px,env(safe-area-inset-left));
  isolation: isolate;
  margin: 0;
  padding: 14px 23px 18px;
  font: 700 14px/1.25 Arial,Helvetica,sans-serif;
  text-align: center;
  color: #241604;
  filter: drop-shadow(0 0 10px #ffcb5566);
}

.sponsorship-contact::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(150deg,#fff6b9,#ffda63 53%,#ffac20);
  clip-path: polygon(0 19%,9% 21%,11% 6%,21% 12%,28% 2%,38% 9%,49% 0,59% 9%,70% 2%,79% 12%,91% 6%,92% 20%,100% 17%,95% 36%,100% 51%,94% 65%,98% 80%,84% 79%,87% 100%,71% 86%,61% 92%,52% 85%,39% 94%,31% 85%,20% 92%,15% 81%,1% 84%,6% 67%,0 54%,5% 40%);
}

.sponsorship-contact strong {
  display: block;
}

.sponsorship-contact a {
  color: inherit;
  text-underline-offset: 3px;
  white-space: nowrap;
}

.sponsorship-contact a:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

.menu-controls, .settings-button, .settings-dialog, .daily-leaderboard {
  background: #0b141c80;
}

.menu-controls {
  position: absolute;
  right: max(24px,env(safe-area-inset-right));
  top: max(18px,env(safe-area-inset-top));
  max-width: calc(52vw - max(12px,env(safe-area-inset-right)));
  padding: 8px 10px;
  border: 1px solid #a4d9f12e;
  border-radius: 6px;
  color: #c2ced9;
  font: 12px/1.2 Arial,Helvetica,sans-serif;
}

.menu-controls dl {
  display: grid;
  grid-template-columns: minmax(0,1fr) auto;
  gap: 4px 10px;
  margin: 0;
}

.menu-controls dt {
  font-weight: 700;
  color: #e7eff7;
}

.menu-controls dd {
  margin: 0;
  text-align: right;
}

.menu-controls .touch-controls {
  display: none;
}

@media (hover: none) and (pointer: coarse) {
  .menu-controls .keyboard-controls {
    display: none;
  }
  .menu-controls .touch-controls {
    display: grid;
  }
}

@media (max-width: 600px), (max-height: 480px), (hover: none) and (pointer: coarse) {
  .sponsorship-contact {
    top: max(8px,env(safe-area-inset-top));
    left: max(8px,env(safe-area-inset-left));
    padding: 9px 16px 12px;
    font-size: 11px;
  }
  .menu-controls {
    top: max(8px,env(safe-area-inset-top));
    right: max(8px,env(safe-area-inset-right));
    padding: 5px 6px;
    font-size: 10px;
  }
  .menu-controls dl {
    gap: 3px 6px;
  }
}

.menu-version {
  position: absolute;
  right: 6%;
  bottom: 0;
  font: 600 12px/1 Orbitron,sans-serif;
  color: #aebac9;
}

.menu-center {
  position: absolute;
  left: 50%;
  top: 43%;
  transform: translate(-50%,-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  width: min(94vw,680px);
}

#menu-connection, #online-status {
  font: 14px Arial,Helvetica,sans-serif;
  color: #d4dfe8;
  text-align: center;
}

#menu-connection {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin: 14px 0 0;
}

#menu-connection a {
  color: #9edcf9;
  white-space: nowrap;
}

#online-status {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 14px;
  border-radius: 8px;
  background: #0b141cda;
}

#play:disabled {
  cursor: wait;
  opacity: .65;
}

.title-lockup {
  position: relative;
  width: min(760px,92vw);
  margin: 0 0 16px;
}

.game-title {
  margin: 0;
  user-select: none;
}

.game-title svg {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 5/1;
  overflow: visible;
  font-family: Orbitron,'Arial Black',sans-serif;
  font-weight: 900;
  font-size: 170px;
  letter-spacing: -.02em;
  stroke-linejoin: bevel;
  paint-order: stroke fill;
}

/* Shared glyph geometry keeps all five chrome/neon layers aligned. */
.title-depth {
  fill: #0b122f;
  stroke: #782887;
  stroke-width: 12;
}

.title-rim {
  fill: none;
  stroke: #bdffff;
  stroke-width: 12;
}

.title-neon {
  fill: none;
  stroke: #f72aef;
  stroke-width: 9;
  filter: drop-shadow(0 0 3px #f431df66);
}

.title-inset {
  fill: none;
  stroke: #091a36;
  stroke-width: 5;
}

.title-face {
  fill: url(#chrome);
  stroke: #d6ffff;
  stroke-width: 1.4;
}

/* The zero keeps the same polished highlight while using a red metal finish. */
.title-zero .title-depth {
  fill: #260b16;
  stroke: #76152a;
}

.title-zero .title-rim {
  stroke: #ffe3e3;
}

.title-zero .title-neon {
  stroke: #ff304a;
  filter: drop-shadow(0 0 3px #f4314966);
}

.title-zero .title-inset {
  stroke: #350b19;
}

.title-zero .title-face {
  fill: url(#chrome-red);
  stroke: #ffe2df;
}

#menu-form {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  width: 100%;
}

#player-name, .play-button {
  font-family: Orbitron,'Arial Black',sans-serif;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: .025em;
}

#player-name {
  width: min(300px,76vw);
  height: 49px;
  padding: 0 20px;
  border: 1px solid #555064;
  border-radius: 11px;
  background: #35313ee8;
  box-shadow: inset 0 2px 5px #08091144;
  color: #f3edf6;
  text-align: center;
  transition: border-color .15s,background .15s;
}

#player-name::placeholder {
  color: #bdb4c8;
  opacity: 1;
}

#player-name:hover {
  border-color: #70677f;
}

#player-name:focus {
  outline: none;
  border-color: #8a7b9c;
  background: #393441;
}

.play-button {
  width: 153px;
  height: 53px;
  border-radius: 27px;
  border: 1px solid #a2df70;
  background: linear-gradient(#9bd365,#76ac42);
  box-shadow: inset 0 1px 0 #c2ef9670,0 4px 0 #355321,0 8px 18px #0004;
  color: #f7ffe9;
  text-shadow: 0 2px 1px #47772e88;
  transition: filter .15s,transform .15s,box-shadow .15s;
}

.play-button:hover {
  filter: brightness(1.1);
}

.play-button:active {
  transform: translateY(3px);
  box-shadow: inset 0 1px 0 #c2ef9670,0 1px 0 #355321;
}

.settings-button, .settings-close {
  border: 1px solid #587487;
  border-radius: 8px;
  color: #d4e4ef;
  touch-action: manipulation;
}

.settings-button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-top: 14px;
  padding: 0;
}

.settings-button svg {
  width: 20px;
  height: 20px;
}

.settings-close {
  min-height: 38px;
  padding: 0 14px;
  background: #101b27;
  font: 600 12px/1.2 Orbitron,sans-serif;
}

.settings-button:hover, .settings-close:hover {
  background: #1a2b3b;
}

.settings-button:focus-visible, .settings-close:focus-visible {
  outline: 2px solid #a4d9f1;
  outline-offset: 3px;
}

.settings-dialog {
  width: min(380px,calc(100vw - 32px));
  padding: 24px;
  border: 1px solid #587487;
  border-radius: 12px;
  color: #d4e4ef;
  box-shadow: 0 10px 36px #0009;
}

.settings-dialog::backdrop {
  background: #080b10b3;
}

.settings-dialog h2 {
  margin: 0 0 20px;
  font: 700 18px/1.3 Orbitron,sans-serif;
}

.settings-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 44px;
  margin-bottom: 16px;
  font: 700 14px/1.4 Arial,Helvetica,sans-serif;
  cursor: pointer;
}

.settings-option input {
  appearance: none;
  flex: 0 0 auto;
  position: relative;
  width: 43px;
  height: 24px;
  margin: 0;
  border: 1px solid #7890a4;
  border-radius: 20px;
  background: #273649;
  cursor: pointer;
}

.settings-option input::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  left: 3px;
  top: 3px;
  border-radius: 50%;
  background: #e7eff7;
  transition: transform .15s;
}

.settings-option input:checked {
  background: #82c34d;
  border-color: #a2df70;
}

.settings-option input:checked::before {
  transform: translateX(19px);
  background: #152610;
}

.settings-dialog form {
  display: flex;
  justify-content: end;
}

.color-control {
  position: absolute;
  left: max(18px,env(safe-area-inset-left));
  bottom: max(18px,env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.color-preview {
  display: block;
  width: 69px;
  height: 69px;
  pointer-events: none;
}

.color-preview polygon {
  fill: #080b10;
  stroke: var(--ship-color);
  stroke-width: 1.5;
  stroke-linejoin: round;
}

.color-wheel {
  --wheel-diameter: 132px;
  position: relative;
  display: block;
  width: calc(var(--wheel-diameter) + 20px);
  height: calc(var(--wheel-diameter) + 20px);
  padding: 10px;
  border: 0;
  border-radius: 50%;
  background: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: crosshair;
}

#color-spectrum {
  display: block;
  width: var(--wheel-diameter);
  height: var(--wheel-diameter);
  border: 0;
  border-radius: 50%;
  pointer-events: none;
}

.color-wheel:active {
  cursor: grabbing;
}

.color-wheel:focus {
  outline: none;
}

.color-thumb {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 14px;
  height: 14px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--ship-color);
  box-shadow: 0 0 0 1.5px #0b1022b3,0 1px 5px #0008;
  transform: translate(-50%,-50%);
  pointer-events: none;
}

.color-wheel:focus-visible .color-thumb {
  outline: 2px solid #17283e;
  outline-offset: 1px;
}

.run-scores {
  position: absolute;
  left: 50%;
  bottom: max(28px,env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: auto auto;
  gap: 8px 12px;
  margin: 0;
  font: 600 22px Orbitron,sans-serif;
  color: #aebac9;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.run-scores dd {
  margin: 0;
  text-align: right;
  color: #e7eff7;
}

.daily-leaderboard {
  position: absolute;
  right: max(24px,env(safe-area-inset-right));
  bottom: max(28px,env(safe-area-inset-bottom));
  width: 220px;
  max-height: min(300px,43dvh);
  overflow-y: auto;
  padding: 12px;
  border: 1px solid #c6deef16;
  border-radius: 6px;
  color: #c6d0dc;
  scrollbar-width: thin;
}

.daily-leaderboard h2 {
  margin: 0 0 11px;
  font: 700 11px/1.3 Orbitron,sans-serif;
  letter-spacing: .45px;
}

.daily-leaderboard ol {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.daily-leaderboard li {
  display: grid;
  grid-template-columns: 17px minmax(0,1fr) auto;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.daily-leaderboard .rank {
  color: #7f93a6;
  font-size: .85em;
}

.daily-leaderboard .pilot-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.daily-leaderboard .pilot-score {
  color: #e7eff7;
  font-size: .9em;
}

#daily-leaderboard-status {
  margin: 9px 0 0;
  font-size: 11px;
  line-height: 1.35;
  color: #91a3b1;
}

@media (min-width: 601px) and (max-width: 900px) {
  .run-scores {
    font-size: 18px;
  }
  .color-control, .daily-leaderboard {
    bottom: max(88px,calc(env(safe-area-inset-bottom) + 76px));
  }
  .daily-leaderboard {
    width: 180px;
  }
}

@media (max-width: 600px) {
  .menu-center {
    top: 40%;
  }
  .title-lockup {
    margin-bottom: 15px;
  }
  .color-control {
    left: max(12px,env(safe-area-inset-left));
    bottom: max(68px,calc(env(safe-area-inset-bottom) + 56px));
  }
  .color-wheel {
    --wheel-diameter: 114px;
  }
  .run-scores {
    bottom: max(16px,calc(env(safe-area-inset-bottom) + 6px));
    gap: 5px 9px;
    font-size: 16px;
  }
  .daily-leaderboard {
    right: max(14px,env(safe-area-inset-right));
    bottom: max(68px,calc(env(safe-area-inset-bottom) + 56px));
    width: min(168px,43vw);
    max-height: 34dvh;
    padding: 8px;
  }
  .daily-leaderboard h2 {
    margin-bottom: 8px;
    font-size: 9px;
    letter-spacing: 0;
  }
  .daily-leaderboard ol {
    gap: 3px;
  }
  .daily-leaderboard li {
    grid-template-columns: 13px minmax(0,1fr) auto;
    gap: 3px;
    font-size: 10px;
  }
  #daily-leaderboard-status {
    font-size: 10px;
  }
  .player-score {
    font-size: 18px;
  }
}

@media (max-width: 380px) {
  .run-scores {
    font-size: 14px;
  }
}

@media (max-height: 480px) {
  .menu-center {
    top: 43%;
  }
  .title-lockup {
    width: min(525px,82vw);
    margin-bottom: 7px;
  }
  .settings-button {
    height: 40px;
    margin-top: 9px;
  }
  #menu-form {
    gap: 15px;
  }
  #player-name {
    height: 42px;
  }
  .play-button {
    height: 45px;
  }
  #player-name, .play-button {
    font-size: 14px;
  }
  .color-control {
    bottom: 8px;
    left: 10px;
  }
  .color-wheel {
    --wheel-diameter: 96px;
  }
  .daily-leaderboard {
    right: max(12px,env(safe-area-inset-right));
    bottom: max(12px,env(safe-area-inset-bottom));
    width: 150px;
    padding: 8px;
  }
  .daily-leaderboard h2 {
    font-size: 9px;
    margin-bottom: 6px;
  }
  .daily-leaderboard ol {
    gap: 2px;
  }
  .daily-leaderboard li {
    grid-template-columns: 12px minmax(0,1fr) auto;
    gap: 3px;
    font-size: 9px;
  }
  .run-scores {
    font-size: 15px;
    gap: 5px 8px;
  }
}

/* Keep a short portrait menu above the two lower corner controls. */
@media (max-width: 600px) and (max-height: 600px) and (orientation: portrait) {
  .menu-center {
    top: 36%;
  }
  #menu-form {
    gap: 12px;
  }
  .color-control, .daily-leaderboard {
    bottom: max(64px,calc(env(safe-area-inset-bottom) + 52px));
  }
  .daily-leaderboard {
    max-height: 31dvh;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none!important;
  }
  #menu.fade-in {
    animation: none;
  }
}

@media (max-width: 600px), (hover: none) and (pointer: coarse) {
  .daily-leaderboard {
    display: none;
  }
  .leaderboard {
    right: max(8px,env(safe-area-inset-right));
    top: max(8px,env(safe-area-inset-top));
    width: 118px;
    padding: 6px 6px 3px;
  }
  .leaderboard ol {
    gap: 2px;
  }
  .leaderboard li, .leaderboard-you {
    font-size: 9px;
    grid-template-columns: 12px minmax(0,1fr) auto;
    gap: 3px;
  }
  .leaderboard h2 {
    margin-bottom: 5px;
    font-size: 8px;
    letter-spacing: .55px;
  }
  .leaderboard .rank, .leaderboard .pilot-score {
    font-size: 8px;
  }
  .leaderboard-you {
    margin-top: 5px;
    padding-top: 5px;
  }
  #leaderboard-toggle {
    display: block;
    width: 100%;
    min-height: 28px;
    margin-top: 4px;
    border: 1px solid #c6deef25;
    border-radius: 4px;
    background: #192b38;
    color: #e7eff7;
    font-size: 17px;
    pointer-events: auto;
    touch-action: manipulation;
  }
  #leaderboard-toggle:focus-visible {
    outline-offset: 1px;
  }
  .leaderboard.is-minimized {
    padding: 3px;
  }
  .leaderboard.is-minimized #leaderboard-content {
    display: none;
  }
  .leaderboard.is-minimized #leaderboard-toggle {
    margin-top: 0;
  }
}

@media (max-width: 600px) {
  .power-meter {
    --power-width: min(176px,50vw);
    --power-inset: 20px;
    bottom: max(23px,env(safe-area-inset-bottom));
  }
}
