:root {
  font-family: "Trebuchet MS", system-ui, sans-serif;
  color: #edf0fa;
  background: #10172a;
  --muted: #a5b4c8;
  --lime: #d8f779;
  --mint: #86e3c5;
  --coral: #ffa98e;
}
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}
body {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) max(10px, env(safe-area-inset-right))
    env(safe-area-inset-bottom) max(10px, env(safe-area-inset-left));
}
button,
select,
a {
  font: inherit;
  -webkit-tap-highlight-color: transparent;
}
button {
  cursor: pointer;
  background: #24354b;
  color: #edf0fa;
  border: 1px solid #ffffff24;
  padding: 9px 13px;
  border-radius: 13px;
  min-height: 42px;
}
button:disabled {
  opacity: 0.35;
  cursor: default;
}
button:hover:not(:disabled) {
  background: #34475d;
}
button:focus-visible,
select:focus-visible,
canvas:focus-visible,
a:focus-visible {
  outline: 3px solid var(--lime);
  outline-offset: 2px;
}
[hidden] {
  display: none !important;
}
header,
main {
  width: min(1100px, 100%);
  margin: 0 auto;
}
header {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 4px;
  gap: 12px;
}
header > div {
  display: flex;
  gap: 6px;
}
.brand {
  font-size: 13px;
  font-weight: bold;
  text-decoration: none;
  color: var(--muted);
}
header button {
  font-size: 12px;
  padding: 7px 12px;
}
main {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 8px;
  padding-bottom: 8px;
}
.page-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 5px;
}
.category {
  font-size: 9px;
  letter-spacing: 1.5px;
  font-weight: bold;
  color: var(--mint);
}
h1 {
  font-size: 25px;
  letter-spacing: -0.7px;
  margin: 3px 0 2px;
}
.layout {
  min-height: 0;
  display: flex;
}
.game {
  width: 100%;
  min-height: 0;
  position: relative;
  background: #0a1023;
  border-radius: 24px;
  overflow: hidden;
  border: 2px solid #ffffff22;
  display: grid;
  grid-template-rows: 54px minmax(0, 1fr);
}
.hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 18px;
  background: #1c2c41;
  z-index: 1;
}
.hud > div {
  display: flex;
  flex-direction: column;
}
.hud span {
  font-size: 8px;
  letter-spacing: 1.2px;
  color: var(--muted);
}
.hud strong {
  font-size: 24px;
  line-height: 1.15;
}
.hud-order {
  text-align: center;
}
.hud-order strong {
  color: var(--lime);
}
.hud small {
  font-size: 13px;
}
.hud-shield {
  text-align: right;
}
.hud-shield strong {
  font-size: 16px;
  color: var(--mint);
  letter-spacing: 3px;
}
canvas {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  touch-action: none;
  background: #0a1023;
}
.overlay {
  position: absolute;
  inset: 54px 0 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #080f2388;
  backdrop-filter: blur(5px);
  z-index: 3;
  padding: 10px;
}
.start-panel {
  width: min(340px, 95%);
  text-align: center;
  padding: 18px;
  background: #1b2b40f5;
  border: 1px solid #b7c3ff30;
  border-radius: 20px;
  box-shadow: 0 15px 50px #0005;
}
.overlay-icon {
  display: none;
}
.start-panel h2 {
  font-size: 23px;
  margin: 0 0 7px;
}
.start-panel p {
  font-size: 12px;
  color: #c4cee0;
  line-height: 1.5;
  margin: 6px 0 12px;
}
.settings {
  display: flex;
  gap: 10px;
  text-align: left;
  margin-bottom: 12px;
}
.settings label {
  flex: 1;
}
.settings label span {
  display: block;
  font-size: 10px;
  color: var(--muted);
  margin-bottom: 4px;
}
select {
  width: 100%;
  background: #111f33;
  border: 1px solid #ffffff30;
  padding: 8px;
  color: #edf0fa;
  border-radius: 9px;
  font-size: 12px;
}
.primary {
  background: var(--lime);
  border: 0;
  color: #1c2820;
  font-weight: bold;
  width: 100%;
  padding: 10px;
}
.primary:hover:not(:disabled) {
  background: #e6ffa1;
}
.start-panel small {
  display: none;
}
.game-message {
  position: absolute;
  left: 12px;
  right: 12px;
  top: 65px;
  text-align: center;
  pointer-events: none;
  color: #eef8da;
  font-weight: bold;
  font-size: 12px;
  text-shadow: 0 2px 8px #000;
  z-index: 2;
}
.flight-summary {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #1c2b3f;
  border: 1px solid #ffffff12;
  border-radius: 15px;
  padding: 3px 12px;
  min-height: 40px;
}
.delivery-count {
  display: flex;
  align-items: baseline;
  gap: 5px;
  white-space: nowrap;
}
.delivery-count strong {
  font-size: 17px;
}
.delivery-count span {
  font-size: 10px;
  color: var(--muted);
}
.route {
  display: flex;
  gap: 5px;
  margin-left: auto;
}
.route i {
  width: 20px;
  height: 6px;
  background: #ffffff20;
  border-radius: 4px;
}
.route i.done {
  background: var(--lime);
}
.link {
  border: 0;
  background: none;
  padding: 5px;
  min-height: 32px;
  font-size: 11px;
  color: var(--muted);
}
footer {
  display: none;
}
.mobile-controls {
  display: none;
}
dialog {
  background: #1c2b40;
  color: #eef3ff;
  border: 1px solid #ffffff30;
  border-radius: 22px;
  padding: 26px;
  width: min(460px, 92vw);
  max-height: 85dvh;
  overflow: auto;
}
dialog::backdrop {
  background: #081322bb;
  backdrop-filter: blur(4px);
}
dialog h2 {
  font-size: 23px;
}
dialog p,
dialog li {
  font-size: 13px;
  line-height: 1.8;
  color: #c2cee0;
}
.close {
  float: right;
  font-size: 20px;
}
.instructions h2 {
  font-size: 17px;
}
.instructions ol {
  padding-left: 20px;
}
.legend {
  display: flex;
  gap: 12px;
  font-size: 11px;
}
.dot {
  width: 9px;
  height: 9px;
  display: inline-block;
  border-radius: 50%;
  margin-right: 5px;
}
.mint {
  background: var(--mint);
}
.coral {
  background: var(--coral);
}
.rock {
  background: #8592ac;
}
.record {
  font-size: 12px;
  margin: 15px 0;
  color: var(--muted);
}
.volume-control {
  display: flex;
  gap: 12px;
  align-items: center;
  font-size: 13px;
}
.volume-control input {
  flex: 1;
  accent-color: var(--lime);
}
.joystick {
  width: 80px;
  height: 80px;
  border: 1px solid #91a8cf60;
  border-radius: 50%;
  position: relative;
  flex-shrink: 0;
  background: radial-gradient(circle, #35456a77, #111c34);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.joystick-cross {
  position: absolute;
  background: #a4b9df25;
  pointer-events: none;
}
.joystick-cross.horizontal {
  height: 1px;
  left: 10px;
  right: 10px;
  top: 50%;
}
.joystick-cross.vertical {
  width: 1px;
  top: 10px;
  bottom: 10px;
  left: 50%;
}
.joystick-knob {
  position: absolute;
  left: calc(50% - 19px);
  top: calc(50% - 19px);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 28%, #d1d7f4, #7e8ebe);
  border: 2px solid #d4defa;
  box-shadow: 0 3px 10px #0005;
  display: grid;
  place-items: center;
  color: #324368;
  font-size: 20px;
  pointer-events: none;
}
.joystick.active {
  border-color: var(--lime);
}
.joystick.active .joystick-knob {
  border-color: var(--lime);
}
#brake {
  touch-action: none;
  user-select: none;
  font-size: 20px;
  min-width: 64px;
}
#brake span {
  font-size: 11px;
  display: block;
}
@media (any-pointer: coarse), (max-width: 700px) {
  .game {
    grid-template-rows: 50px minmax(0, 1fr) 94px;
  }
  .hud {
    padding: 6px 12px;
  }
  .hud strong {
    font-size: 22px;
  }
  .overlay {
    inset: 50px 0 94px;
  }
  .mobile-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 16px;
    background: #1b2b40;
    gap: 8px;
  }
  .mobile-controls > span {
    font-size: 10px;
    color: var(--muted);
    text-align: center;
    line-height: 1.6;
    white-space: pre-line;
  }
  .game-message {
    top: 59px;
    font-size: 11px;
  }
  .flight-summary > .category {
    display: none;
  }
  .route i {
    width: 15px;
  }
  .flight-summary {
    gap: 8px;
  }
  h1 {
    font-size: 22px;
  }
  .start-panel {
    padding: 13px;
  }
  .start-panel h2 {
    font-size: 21px;
  }
}
@media (max-height: 500px) {
  header {
    padding: 3px;
  }
  header button {
    min-height: 32px;
    padding: 5px 10px;
  }
  .page-title .category {
    display: none;
  }
  h1 {
    font-size: 20px;
  }
  .page-title button {
    min-height: 30px;
    padding: 4px 10px;
  }
  main {
    gap: 4px;
    padding-bottom: 4px;
  }
  .flight-summary {
    min-height: 32px;
  }
  .game {
    grid-template-rows: 40px minmax(0, 1fr);
  }
  .overlay {
    inset: 40px 0 0;
  }
  .hud strong {
    font-size: 20px;
  }
  .hud span {
    font-size: 7px;
  }
  .game-message {
    top: 44px;
  }
  .start-panel {
    padding: 10px;
  }
  .start-panel h2 {
    font-size: 18px;
    margin: 0 0 3px;
  }
  .start-panel p {
    font-size: 11px;
    margin: 4px 0;
  }
  .settings {
    margin-bottom: 6px;
  }
  .primary {
    min-height: 32px;
    padding: 6px;
  }
}
@media (max-height: 500px) and (any-pointer: coarse),
  (max-height: 500px) and (max-width: 700px) {
  .game {
    grid-template-columns: minmax(0, 1fr) 94px;
    grid-template-rows: 40px minmax(0, 1fr);
  }
  .hud {
    grid-column: 1/-1;
  }
  .mobile-controls {
    grid-column: 2;
    grid-row: 2;
    flex-direction: column;
    padding: 6px;
    gap: 4px;
  }
  .mobile-controls > span {
    display: none;
  }
  .joystick {
    width: 68px;
    height: 68px;
  }
  #brake {
    font-size: 15px;
    padding: 4px;
    min-height: 36px;
  }
  .overlay {
    inset: 40px 94px 0 0;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
  }
}
