:root {
  color-scheme: dark;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  background: #0a0d0b;
  color: #ecf2e8;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overscroll-behavior: none;
}

body {
  min-height: 100dvh;
  background:
    radial-gradient(circle at 50% 20%, rgba(93, 122, 77, 0.2), transparent 38%),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.018) 0 1px, transparent 1px 4px),
    #0a0d0b;
}

button {
  font: inherit;
}

.controller {
  width: min(100%, 720px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  gap: 18px;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.eyebrow {
  margin: 0 0 4px;
  color: #e35c3f;
  font-weight: 800;
  letter-spacing: 0.24em;
}

h1 {
  margin: 0;
  font: 700 clamp(18px, 5vw, 28px) / 1.1 system-ui, sans-serif;
}

.status {
  max-width: 48%;
  padding: 9px 12px;
  border: 1px solid #677064;
  border-radius: 999px;
  color: #c3ccc0;
  font-size: 12px;
  text-align: center;
}

.status[data-state="connected"] {
  border-color: #72b35c;
  color: #a9e68f;
}

.status[data-state="error"] {
  border-color: #bd5945;
  color: #ff9a82;
}

.controls {
  flex: 1;
  min-height: 300px;
  display: grid;
  grid-template-columns: 1fr 0.72fr;
  align-items: center;
  gap: clamp(20px, 8vw, 74px);
}

.joystick {
  position: relative;
  width: min(58vw, 280px);
  aspect-ratio: 1;
  justify-self: center;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 2px solid #596457;
  background: rgba(29, 37, 30, 0.72);
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.8), 0 18px 50px rgba(0, 0, 0, 0.35);
  touch-action: none;
}

.joystick-ring {
  position: absolute;
  inset: 28%;
  border: 1px dashed #768274;
  border-radius: 50%;
}

.joystick-knob {
  position: absolute;
  width: 34%;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 2px solid #9bad91;
  background: linear-gradient(145deg, #66755f, #303b2f);
  box-shadow: 0 9px 18px rgba(0, 0, 0, 0.45);
  will-change: transform;
}

.joystick > span {
  position: absolute;
  bottom: 12%;
  color: #8c9789;
  font-size: 12px;
  letter-spacing: 0.2em;
}

.fire {
  width: min(34vw, 170px);
  aspect-ratio: 1;
  justify-self: center;
  border: 3px solid #ff8167;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 32%, #c94e38, #742519 72%);
  color: white;
  box-shadow: 0 10px 0 #45150f, 0 18px 35px rgba(0, 0, 0, 0.45);
  font-weight: 900;
  font-size: clamp(18px, 5vw, 28px);
  letter-spacing: 0.12em;
  touch-action: none;
}

.fire.pressed {
  transform: translateY(7px);
  box-shadow: 0 3px 0 #45150f, 0 9px 20px rgba(0, 0, 0, 0.45);
}

.dossier-toggle {
  width: 100%;
  padding: 13px 16px;
  border: 1px solid #566052;
  border-radius: 6px;
  background: #171d18;
  color: #d7dfd3;
}

.dossier {
  padding: 14px 16px;
  border-left: 3px solid #d2a04d;
  background: rgba(34, 31, 21, 0.8);
  color: #e8d4a8;
  user-select: text;
  -webkit-user-select: text;
}

.dossier h2,
.dossier p,
.hint {
  margin: 0;
}

.dossier h2 {
  margin-bottom: 6px;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.dossier p,
.hint {
  font: 13px / 1.5 system-ui, sans-serif;
}

.hint {
  color: #8c9589;
  text-align: center;
}

.disabled .controls {
  opacity: 0.38;
  pointer-events: none;
}

@media (orientation: portrait) and (max-width: 520px) {
  .controls {
    grid-template-columns: 1fr 0.62fr;
    gap: 12px;
  }

  .joystick {
    width: min(61vw, 260px);
  }

  .fire {
    width: min(31vw, 150px);
  }
}

@media (max-height: 540px) and (orientation: landscape) {
  .controller {
    display: grid;
    grid-template-columns: 1fr minmax(220px, 0.45fr);
    grid-template-rows: auto 1fr auto;
  }

  header,
  .controls {
    grid-column: 1;
  }

  .controls {
    min-height: 220px;
  }

  .joystick {
    width: min(42vh, 230px);
  }

  .fire {
    width: min(28vh, 145px);
  }

  .dossier-toggle,
  .dossier,
  .hint {
    grid-column: 2;
  }
}
