:root {
  --ink: #f3f7ff;
  --paper: #fff7df;
  --stage-bg: #0a0d14;
  --charcoal: rgba(13, 14, 20, 0.88);
  --charcoal-strong: rgba(10, 11, 16, 0.95);
  --line: rgba(255, 255, 255, 0.18);
  --red: #ef3f55;
  --gold: #ffd05a;
  --green: #45d18d;
  --blue: #48a7ff;
  --player-accent: #00a7ff;
  --player-accent-dark: #dff6ff;
  --footer-ink: rgba(216, 226, 242, 0.5);
  --footer-link-ink: rgba(244, 250, 255, 0.9);
  --footer-bg: rgba(18, 24, 36, 0.78);
  --footer-shadow: 0 1px 0 rgba(0, 0, 0, 0.72), 0 0 10px rgba(0, 0, 0, 0.46);
  --dock-ink: #eef7ff;
  --dock-bg: rgba(14, 20, 31, 0.94);
  --dock-inner-line: rgba(255, 255, 255, 0.12);
  --dock-shadow: rgba(0, 167, 255, 0.16);
  --score-shadow:
    0 1px 0 rgba(0, 0, 0, 0.78),
    0 0 18px rgba(0, 167, 255, 0.34);
  --heat-track: rgba(238, 248, 255, 0.16);
  --heat-glint: rgba(255, 255, 255, 0.72);
  --target-ink: #042c44;
  --target-bg: rgba(248, 253, 255, 0.97);
  --target-line: rgba(119, 220, 255, 0.78);
  --moment-ink: #042c44;
  --moment-bg: rgba(248, 253, 255, 0.98);
  --moment-line: rgba(119, 220, 255, 0.84);
  --moment-shadow: rgba(0, 167, 255, 0.28);
  --logo-shadow: rgba(0, 167, 255, 0.18);
  --mode-bg: rgba(10, 16, 26, 0.58);
  --mode-line: rgba(216, 226, 242, 0.18);
  --mode-ink: rgba(238, 247, 255, 0.82);
  --mode-active-bg: linear-gradient(135deg, #ffd05a, #ff78d5 58%, #6be7ff);
  --mode-active-ink: #111826;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
  color-scheme: dark;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

* {
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
}

body {
  background: var(--stage-bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

button {
  border: 0;
  cursor: pointer;
  font: inherit;
  -webkit-tap-highlight-color: transparent;
}

canvas,
img,
svg {
  user-select: none;
  -webkit-user-drag: none;
}

button:disabled {
  cursor: wait;
  opacity: 0.7;
}

#flagCanvas {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 0;
  width: 100vw;
  height: 100vh;
  background: var(--stage-bg);
  pointer-events: none;
  transform: translateZ(0);
  will-change: contents;
  backface-visibility: hidden;
  contain: strict;
}

.game-shell {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  transform: translate3d(0, 0, 0);
  backface-visibility: hidden;
}

.playfield,
.site-title,
.site-about,
.site-credit,
.mute-button,
.score-mode {
  pointer-events: auto;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.ad-slot {
  position: absolute;
  top: calc(10px + env(safe-area-inset-top));
  left: 50%;
  display: grid;
  place-items: center;
  width: min(728px, calc(100vw - 24px));
  height: 90px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  color: rgba(255, 249, 234, 0.64);
  background: rgba(7, 8, 12, 0.56);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
  font-size: 0.72rem;
  text-transform: uppercase;
  transform: translateX(-50%);
}

[hidden].ad-slot {
  display: none;
}

.noscript-summary {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 20;
  width: min(420px, calc(100vw - 32px));
  padding: 18px;
  border: 1px solid rgba(237, 246, 255, 0.16);
  border-radius: 8px;
  color: #edf6ff;
  background: rgba(10, 16, 26, 0.9);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.34);
  text-align: center;
  transform: translate(-50%, -50%);
}

.noscript-summary h2 {
  margin: 0 0 8px;
  font-size: 1.8rem;
}

.noscript-summary p {
  margin: 8px 0 0;
  color: rgba(237, 246, 255, 0.76);
  line-height: 1.45;
}

.noscript-summary a {
  color: #79ddff;
  font-weight: 800;
  text-decoration: none;
}

.noscript-summary a:hover {
  text-decoration: underline;
}

.site-about {
  position: absolute;
  left: calc(10px + env(safe-area-inset-left));
  bottom: calc(10px + env(safe-area-inset-bottom));
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  width: max-content;
  max-width: min(420px, calc(100vw - 112px));
  padding: 0;
  color: var(--footer-ink);
  font-size: 0.62rem;
  text-shadow: var(--footer-shadow);
  transform: none;
  white-space: nowrap;
  contain: layout paint style;
}

.site-credit {
  position: absolute;
  right: calc(10px + env(safe-area-inset-right));
  bottom: calc(10px + env(safe-area-inset-bottom));
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  color: var(--footer-ink);
  font-size: 0.62rem;
  text-shadow: var(--footer-shadow);
  white-space: nowrap;
  contain: layout paint style;
}

.site-about a,
.site-credit a {
  padding: 0;
  border-radius: 0;
  color: var(--footer-link-ink);
  background: transparent;
  font-weight: 750;
  text-decoration: none;
}

.site-about a,
.site-credit a {
  flex: 0 0 auto;
}

.site-about a:hover,
.site-credit a:hover {
  text-decoration: underline;
}

.mute-button {
  position: absolute;
  top: calc(8px + env(safe-area-inset-top));
  right: calc(8px + env(safe-area-inset-right));
  z-index: 4;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  appearance: none;
  border: 1px solid rgba(216, 226, 242, 0.2);
  border-radius: 999px;
  color: rgba(244, 250, 255, 0.9);
  background: rgba(18, 24, 36, 0.58);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.18);
  transform: translateZ(0);
  contain: layout paint style;
}

.mute-button:active {
  transform: translateZ(0) scale(0.94);
}

.mute-button:focus-visible {
  outline: 2px solid rgba(0, 167, 255, 0.62);
  outline-offset: 3px;
}

.mute-icon {
  position: relative;
  display: block;
  width: 20px;
  height: 18px;
}

.mute-speaker::before,
.mute-speaker::after,
.mute-wave,
.mute-slash {
  position: absolute;
  content: "";
  display: block;
}

.mute-speaker::before {
  left: 1px;
  top: 6px;
  width: 6px;
  height: 6px;
  border-radius: 1px;
  background: currentColor;
}

.mute-speaker::after {
  left: 6px;
  top: 3px;
  width: 0;
  height: 0;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-right: 8px solid currentColor;
}

.mute-wave {
  top: 50%;
  right: 1px;
  border: 2px solid currentColor;
  border-left: 0;
  border-top-color: transparent;
  border-bottom-color: transparent;
  border-radius: 0 999px 999px 0;
  transform: translateY(-50%);
}

.mute-wave-one {
  width: 5px;
  height: 9px;
  opacity: 0.84;
}

.mute-wave-two {
  right: -3px;
  width: 9px;
  height: 15px;
  opacity: 0.58;
}

.mute-slash {
  left: 2px;
  top: 8px;
  width: 19px;
  height: 3px;
  border-radius: 999px;
  background: #ff55c7;
  opacity: 0;
  transform: rotate(-38deg);
  transform-origin: 50% 50%;
}

.mute-button.is-muted {
  color: rgba(244, 250, 255, 0.76);
  background: rgba(18, 24, 36, 0.72);
}

.mute-button.is-muted .mute-wave {
  opacity: 0;
}

.mute-button.is-muted .mute-slash {
  opacity: 1;
}

.score-mode {
  position: absolute;
  top: calc(12px + env(safe-area-inset-top));
  left: calc(10px + env(safe-area-inset-left));
  z-index: 4;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 4px;
  width: auto;
  max-width: none;
  padding: 4px;
  border: 1px solid var(--mode-line);
  border-radius: 16px;
  background: var(--mode-bg);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.18);
  transform: translateZ(0);
  contain: layout paint style;
}

.score-mode[hidden] {
  display: none;
}

.score-mode-button {
  min-width: 72px;
  height: 28px;
  padding: 0 10px;
  border-radius: 12px;
  color: var(--mode-ink);
  background: transparent;
  font-size: 0.72rem;
  font-weight: 850;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
}

.score-mode-button.is-active {
  color: var(--mode-active-ink);
  background: var(--mode-active-bg);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.42);
}

.score-mode-button:focus-visible {
  outline: 2px solid rgba(0, 167, 255, 0.62);
  outline-offset: 2px;
}

.next-target-slot {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
  pointer-events: none;
}

.moment-banner {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
  pointer-events: none;
}

.moment-banner[hidden] {
  display: none;
}

.site-title {
  position: absolute;
  top: calc(8px + env(safe-area-inset-top));
  left: 50%;
  z-index: 2;
  display: block;
  width: 114px;
  height: 114px;
  padding: 0;
  appearance: none;
  border: 0;
  border-radius: 20px;
  background: transparent;
  transform: translateX(-50%);
  cursor: pointer;
  contain: layout paint style;
  -webkit-tap-highlight-color: transparent;
}

.site-title:focus-visible {
  outline: 3px solid rgba(0, 167, 255, 0.42);
  outline-offset: 4px;
}

.site-title.needs-focus {
  filter:
    drop-shadow(0 0 0 rgba(0, 167, 255, 0.96))
    drop-shadow(0 0 14px rgba(0, 167, 255, 0.78))
    drop-shadow(0 8px 18px rgba(0, 76, 120, 0.24));
}

.site-title:active {
  transform: translateX(-50%) scale(0.98);
}

.site-logo-picture,
.site-logo-image {
  display: block;
  width: 100%;
  height: 100%;
}

.site-logo-image {
  object-fit: contain;
  filter: drop-shadow(0 5px 12px var(--logo-shadow));
  pointer-events: none;
}

.playfield {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: min(224px, calc(100vw - 12px));
  transform: translateX(-50%);
  contain: layout style;
  z-index: 3;
}

.flag-button {
  position: relative;
  --heat-accent-a: #00a7ff;
  --heat-accent-b: #ff4fb8;
  --heat-accent-c: #ffd05a;
  --target-pressure: 0;
  display: grid;
  justify-items: center;
  gap: 0;
  width: 100%;
  min-height: 128px;
  padding: 5px 6px calc(7px + env(safe-area-inset-bottom));
  overflow: visible;
  border-radius: 10px 10px 0 0;
  color: var(--dock-ink);
  border: 1px solid rgba(0, 167, 255, 0.42);
  border-bottom: 0;
  background:
    linear-gradient(180deg, rgba(14, 20, 31, 0.7), rgba(14, 20, 31, 0.48));
  box-shadow:
    0 -1px 0 rgba(255, 255, 255, 0.07) inset,
    0 -5px 16px rgba(0, 167, 255, 0.08);
  transition: transform 75ms ease;
  transform-origin: 50% 100%;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  will-change: transform;
}

.flag-button::before,
.flag-button::after {
  position: absolute;
  content: "";
  pointer-events: none;
}

.flag-button::before {
  display: none;
}

.flag-button::after {
  display: none;
  left: 50%;
  top: 16px;
  width: 150px;
  height: 150px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.22);
  transform: translateX(-50%);
}

.flag-button.ready {
  transform: translateY(0);
}

.flag-button.pressed {
  transform: scale(0.985);
}

.flag-button.target-runway {
  border-color: rgba(67, 224, 119, calc(0.38 + var(--target-pressure) * 0.28));
  background:
    linear-gradient(180deg, rgba(67, 224, 119, calc(0.07 + var(--target-pressure) * 0.08)), rgba(14, 20, 31, 0) 42%),
    linear-gradient(180deg, rgba(14, 20, 31, 0.72), rgba(14, 20, 31, 0.5));
  box-shadow:
    0 -1px 0 rgba(255, 255, 255, 0.07) inset,
    0 -6px 18px rgba(67, 224, 119, calc(0.08 + var(--target-pressure) * 0.1)) inset,
    0 -5px 16px rgba(0, 167, 255, 0.08);
}

.flag-button.target-passing {
  border-color: rgba(67, 224, 119, 0.74);
  background:
    linear-gradient(180deg, rgba(67, 224, 119, 0.16), rgba(0, 220, 255, 0.06) 54%, rgba(14, 20, 31, 0) 100%),
    linear-gradient(180deg, rgba(14, 20, 31, 0.72), rgba(14, 20, 31, 0.5));
  box-shadow:
    0 -1px 0 rgba(255, 255, 255, 0.07) inset,
    0 -8px 22px rgba(67, 224, 119, 0.16) inset,
    0 -5px 16px rgba(0, 167, 255, 0.08);
}

.flag-orbit {
  display: none;
}

.flag-button-image {
  position: relative;
  z-index: 2;
  display: block;
  width: 132px;
  height: 99px;
  margin-top: 0;
  overflow: visible;
}

#heroFlagCanvas {
  display: block;
  width: 100%;
  height: 100%;
  contain: strict;
}

.flag-button-copy {
  position: relative;
  z-index: 2;
  display: grid;
  gap: 0;
  min-width: 0;
  justify-items: center;
  width: fit-content;
  max-width: 100%;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  text-align: center;
}

#selectedName {
  display: none;
  max-width: 100%;
  color: var(--player-accent-dark);
  font-size: 0.88rem;
  font-weight: 800;
  line-height: 1.15;
  overflow-wrap: anywhere;
  text-shadow:
    0 1px 0 rgba(255, 255, 255, 0.88),
    0 4px 14px rgba(255, 255, 255, 0.86);
}

#localClicks {
  display: block;
  color: var(--player-accent-dark);
  font-size: 2.16rem;
  line-height: 0.92;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  text-shadow: var(--score-shadow);
  transform-origin: 50% 70%;
  will-change: transform, filter;
}

#localClicks.score-pop {
  animation: scorePop 145ms cubic-bezier(.2, .9, .2, 1);
}

@keyframes scorePop {
  0% {
    filter: brightness(1.22);
    transform: scale(1.16);
  }

  72% {
    filter: brightness(1.04);
    transform: scale(0.985);
  }

  100% {
    filter: brightness(1);
    transform: scale(1);
  }
}

.heat-meter {
  position: relative;
  isolation: isolate;
  display: block;
  width: min(164px, 100%);
  height: 5px;
  margin-top: 5px;
  overflow: hidden;
  border-radius: 999px;
  background-clip: padding-box;
  background: var(--heat-track);
  opacity: 0;
  transform: translateZ(0);
  -webkit-mask-image: -webkit-radial-gradient(white, black);
  contain: strict;
}

.heat-meter-fill {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 0;
  background:
    linear-gradient(180deg, var(--heat-glint), rgba(255, 255, 255, 0)),
    linear-gradient(90deg, var(--heat-accent-a), var(--heat-accent-b) 52%, var(--heat-accent-c));
  transform: scaleX(0);
  transform-origin: 0 50%;
  will-change: transform;
}

.next-target {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.next-target[hidden] {
  display: none;
}

@media (max-width: 760px) {
  .ad-slot {
    top: calc(8px + env(safe-area-inset-top));
    width: 320px;
    max-width: calc(100vw - 20px);
    height: 50px;
  }

  .site-about {
    top: auto;
    right: auto;
    bottom: calc(8px + env(safe-area-inset-bottom));
    left: calc(4px + env(safe-area-inset-left));
    align-items: flex-start;
    max-width: calc(100vw - 132px);
    padding: 0;
    font-size: 0.5rem;
    gap: 5px;
  }

  .site-credit {
    right: calc(4px + env(safe-area-inset-right));
    bottom: calc(8px + env(safe-area-inset-bottom));
    font-size: 0.5rem;
  }

  .mute-button {
    top: calc(7px + env(safe-area-inset-top));
    right: calc(5px + env(safe-area-inset-right));
    width: 34px;
    height: 34px;
  }

  .score-mode {
    top: calc(7px + env(safe-area-inset-top));
    left: calc(5px + env(safe-area-inset-left));
    max-width: none;
    padding: 3px;
    border-radius: 14px;
    gap: 3px;
  }

  .score-mode-button {
    min-width: 58px;
    height: 25px;
    padding: 0 6px;
    border-radius: 11px;
    font-size: 0.62rem;
  }

  .site-title {
    top: calc(2px + env(safe-area-inset-top));
    width: 93px;
    height: 93px;
    border-radius: 22px;
  }

  .playfield {
    bottom: 0;
    width: min(142px, calc(100vw - 10px));
  }

  .flag-button {
    min-height: 74px;
    padding: 3px 4px calc(5px + env(safe-area-inset-bottom));
    border-radius: 8px 8px 0 0;
  }

  .flag-button::after {
    width: 130px;
    height: 130px;
  }

  .flag-orbit {
    width: 124px;
    height: 124px;
  }

  .flag-button-image {
    width: 76px;
    height: 57px;
    margin-top: 0;
  }

  #localClicks {
    font-size: 1.28rem;
  }

  .heat-meter {
    width: min(98px, 100%);
    height: 4px;
    margin-top: 3px;
  }

}

@media (max-height: 700px) and (orientation: landscape) {
  .ad-slot {
    display: none;
  }

  .playfield {
    right: 16px;
    left: auto;
    bottom: 16px;
    width: 280px;
    transform: none;
  }

  .flag-button {
    min-height: 152px;
  }
}

@media (max-height: 700px) and (orientation: landscape) and (pointer: coarse) {
  .playfield {
    right: 10px;
    bottom: 0;
    width: min(142px, calc(100vw - 10px));
  }

  .flag-button {
    min-height: 74px;
    padding: 3px 4px calc(5px + env(safe-area-inset-bottom));
    border-radius: 8px 8px 0 0;
  }

  .flag-button-image {
    width: 76px;
    height: 57px;
  }

  #localClicks {
    font-size: 1.28rem;
  }
}
