@font-face {
  font-family: 'Orbitron';
  font-weight: 400;
  font-display: swap;
  src: url('../vendor/fonts/orbitron-latin-400-normal.woff2') format('woff2');
}

@font-face {
  font-family: 'Orbitron';
  font-weight: 700;
  font-display: swap;
  src: url('../vendor/fonts/orbitron-latin-700-normal.woff2') format('woff2');
}

@font-face {
  font-family: 'Audiowide';
  font-weight: 400;
  font-display: swap;
  src: url('../vendor/fonts/audiowide-latin-400-normal.woff2') format('woff2');
}

:root {
  --cyan: #5ec4f2;
  --blue: #2f6bff;
  --orange: #ff4500;
  --red: #ff1a1a;
  --controls: 0px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  /* No double-tap zoom or pull to refresh; the menu panel still scrolls. */
  touch-action: manipulation;
  overscroll-behavior: none;
}

body {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
  font-family: 'Orbitron', sans-serif;
  font-weight: 700;
  text-align: center;
  color: #fff;
  background: #000;
  -webkit-tap-highlight-color: transparent;
}

h1,
h2,
p {
  margin: 0;
}

.c-blue {
  color: var(--blue);
}

.c-orange {
  color: var(--orange);
}

/* ---------- Header ---------- */

.top {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60px;
  padding: max(8px, env(safe-area-inset-top)) 64px 4px;
  position: relative;
}

.tron-logo {
  font: 400 clamp(30px, 6vw, 52px) / 1 'Audiowide', sans-serif;
  letter-spacing: 0.18em;
  padding-left: 0.18em;
  color: #e9f8ff;
  text-shadow: 0 0 6px var(--cyan), 0 0 18px var(--cyan), 0 0 36px rgba(94, 196, 242, 0.6);
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #000;
  color: #fff;
  font: 700 16px/1 'Orbitron', sans-serif;
  cursor: pointer;
}

.icon-btn:hover,
.icon-btn:focus-visible {
  border-color: var(--cyan);
  color: var(--cyan);
}

.top-actions {
  position: absolute;
  right: max(10px, env(safe-area-inset-right));
  top: max(8px, env(safe-area-inset-top));
  display: flex;
  gap: 8px;
}

.icon-btn[hidden] {
  display: none;
}

#mute-btn {
  font-size: 20px;
}

#mute-btn[aria-pressed='true'] {
  opacity: 0.6;
  background: linear-gradient(to top right, transparent 47%, #fff 47% 53%, transparent 53%) #000;
}

/* ---------- HUD ---------- */

.hud {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  width: min(100%, 820px);
  margin: 0 auto;
  padding: 0 12px 6px;
  font-size: 14px;
}

.hud[hidden] {
  display: none;
}

.hud-side {
  display: grid;
  grid-template-columns: auto auto;
  align-items: center;
  gap: 2px 10px;
}

.hud-side.blue {
  justify-content: end;
}

.hud-side.orange {
  justify-content: start;
}

.hud-name {
  font-family: 'Audiowide', sans-serif;
  font-weight: 400;
}

.blue .hud-name,
.blue .hud-score {
  color: var(--blue);
}

.orange .hud-name,
.orange .hud-score {
  color: var(--orange);
}

.hud-score {
  font-size: 24px;
}

.meter {
  grid-column: 1 / -1;
  height: 6px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 3px;
  overflow: hidden;
}

.meter span {
  display: block;
  height: 100%;
  width: 100%;
  transform-origin: left;
}

.blue .meter span {
  background: var(--blue);
}

.orange .meter span {
  background: var(--orange);
}

.hud-mid {
  font-family: 'Audiowide', sans-serif;
  font-weight: 400;
  font-size: 13px;
  color: var(--cyan);
  white-space: nowrap;
}

#pause-btn {
  font-size: 13px;
}

/* ---------- Stage ---------- */

.stage {
  position: relative;
  flex: 1;
  display: grid;
  place-items: center;
  min-height: 0;
  padding: 4px 10px calc(10px + var(--controls));
}

.arena {
  display: block;
  border: 3px solid var(--cyan);
  box-shadow: 0 0 18px rgba(94, 196, 242, 0.35);
  touch-action: none;
}

.panel {
  position: absolute;
  inset: 4px 10px calc(10px + var(--controls));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin: auto;
  width: min(100% - 20px, 640px);
  height: fit-content;
  max-height: calc(100% - 14px - var(--controls));
  overflow-y: auto;
  padding: 20px 16px;
  border: 3px solid var(--cyan);
  background: rgba(0, 0, 0, 0.88);
  box-shadow: 0 0 24px rgba(94, 196, 242, 0.3);
}

.panel[hidden] {
  display: none;
}

.panel h2 {
  font: 400 28px/1.1 'Audiowide', sans-serif;
  text-decoration: underline;
}

.lead {
  font-family: 'Audiowide', sans-serif;
  font-weight: 400;
  font-size: 17px;
  line-height: 1.35;
  max-width: 34em;
}

.opt {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 6px;
}

.opt-label {
  width: 100%;
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--cyan);
}

.opt button,
.link-btn {
  min-height: 44px;
  padding: 6px 14px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-radius: 8px;
  background: #000;
  color: #fff;
  font: 400 15px 'Audiowide', sans-serif;
  cursor: pointer;
}

.opt button[aria-pressed='true'] {
  border-color: var(--red);
  color: var(--red);
}

.opt[aria-disabled='true'] {
  opacity: 0.35;
  pointer-events: none;
}

.big-btn {
  margin-top: 6px;
  min-height: 52px;
  padding: 6px 34px;
  border: 4px solid var(--red);
  border-radius: 10px;
  background: #000;
  color: #fff;
  font: 400 26px 'Audiowide', sans-serif;
  cursor: pointer;
}

.big-btn:hover,
.big-btn:focus-visible,
.opt button:hover,
.opt button:focus-visible,
.link-btn:hover,
.link-btn:focus-visible {
  box-shadow: 0 0 14px rgba(255, 26, 26, 0.6);
  outline: none;
}

.link-btn {
  border-color: transparent;
  text-decoration: underline;
}

.help {
  font-size: 12px;
  font-weight: 400;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.75);
}

.touch-help,
.gk-has-touch .keys-help {
  display: none;
}

.gk-has-touch .touch-help {
  display: block;
}

.record {
  color: var(--cyan);
}

body.live .stage {
  touch-action: none;
}

/* START stays in reach while the settings scroll on short screens. */
#menu .big-btn {
  position: sticky;
  bottom: 0;
  z-index: 1;
  flex: none;
  box-shadow: 0 0 0 6px rgba(0, 0, 0, 0.92);
}

/* Room for the on-screen pad while a round is running: below the arena in
   portrait, beside it in landscape. The kit pad is 3 x 56px plus its gaps and
   sits max(16px, safe area) from the edge. */
.gk-has-touch body.live {
  --controls: calc(180px + max(16px, env(safe-area-inset-bottom)));
}

@media (orientation: landscape) and (max-height: 560px) {
  .gk-has-touch body.live {
    --controls: 0px;
  }

  /* D-pad on the left, Boost on the right, the arena in between. */
  .gk-has-touch body.live .stage {
    padding-left: calc(186px + max(16px, env(safe-area-inset-left)));
    padding-right: calc(96px + max(16px, env(safe-area-inset-right)));
  }

  .top {
    min-height: 52px;
    padding-block: 4px;
  }

  .top-actions {
    top: max(4px, env(safe-area-inset-top));
  }

  .tron-logo {
    font-size: 26px;
  }

  /* While playing, the logo gives its row to the arena; the HUD moves up between
     the corner buttons. */
  body.live .top {
    min-height: 0;
    padding: 0;
  }

  body.live .tron-logo {
    display: none;
  }

  body.live .hud {
    width: min(100% - 240px, 520px);
    padding-top: max(6px, env(safe-area-inset-top));
  }

  /* Settings in two columns so START fits on the screen. */
  #menu:not([hidden]) {
    display: grid;
    grid-template-columns: repeat(2, auto);
    justify-content: center;
    align-content: start;
    gap: 8px 16px;
    padding: 10px 8px;
    width: min(100% - 20px, 720px);
  }

  #menu > :not(.opt, .big-btn) {
    grid-column: 1 / -1;
    justify-self: center;
  }

  /* START sits beside the last option row. */
  #menu .big-btn {
    position: static;
    align-self: end;
    justify-self: center;
    margin: 0;
    font-size: 22px;
  }

  #menu h2 {
    font-size: 22px;
  }

  #menu .lead {
    font-size: 13px;
  }

  /* Each setting: its label over one row of buttons. */
  #menu .opt {
    display: grid;
    grid-auto-flow: column;
    justify-content: center;
  }

  #menu .opt-label {
    grid-row: 1;
    grid-column: 1 / -1;
  }

  #menu .opt button {
    grid-row: 2;
  }

  #menu .opt-label {
    line-height: 1;
  }
}

/* Very short landscape screens keep just the settings, START and the tips. */
@media (orientation: landscape) and (max-height: 360px) {
  #menu h2,
  #menu .lead {
    display: none;
  }
}

/* Short screens: tighter menus. */
@media (max-height: 740px), (max-width: 380px) {
  .panel {
    gap: 6px;
    padding: 12px 10px;
  }

  .opt {
    gap: 4px 6px;
  }

  .opt-label {
    line-height: 1.1;
  }

  .opt button {
    padding: 6px 10px;
    font-size: 13px;
  }

  .panel h2 {
    font-size: 22px;
  }

  .lead {
    font-size: 14px;
  }
}

@media (max-width: 520px) {
  .top {
    min-height: 56px;
  }

  /* Pause on the left, sound on the right, so neither covers the logo. */
  .top-actions {
    left: max(10px, env(safe-area-inset-left));
    justify-content: space-between;
    pointer-events: none;
  }

  .top-actions > * {
    pointer-events: auto;
  }

  #mute-btn {
    margin-left: auto;
  }

  .hud {
    gap: 6px;
    font-size: 12px;
  }

  .hud-score {
    font-size: 20px;
  }

  .panel {
    gap: 10px;
    padding: 16px 10px;
  }

  .panel h2 {
    font-size: 24px;
  }

  .lead {
    font-size: 15px;
  }
}
