:root {
  color-scheme: dark;
  --bg: #05070d;
  --panel: rgba(8, 13, 23, 0.84);
  --panel-strong: rgba(8, 13, 23, 0.96);
  --line: rgba(70, 215, 255, 0.36);
  --text: #f2f7ff;
  --muted: #8da2b8;
  --cyan: #46d7ff;
  --gold: #ffd24a;
  --green: #62f08e;
  --yellow: #ffe36a;
  --red: #ff5a64;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family:
    ui-monospace,
    SFMono-Regular,
    Menlo,
    Monaco,
    Consolas,
    "Liberation Mono",
    monospace;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  overscroll-behavior: none;
}

body {
  position: fixed;
  inset: 0;
}

body::after {
  position: fixed;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  content: "";
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(255, 255, 255, 0.08) 0,
      rgba(255, 255, 255, 0.02) 1px,
      transparent 2px,
      transparent 5px
    ),
    radial-gradient(circle at center, transparent 48%, rgba(0, 0, 0, 0.36) 100%);
  mix-blend-mode: screen;
  opacity: 0.42;
}

button {
  font: inherit;
}

#gameCanvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  display: block;
  cursor: crosshair;
  background: #05070d;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.profiler {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 8px);
  left: calc(env(safe-area-inset-left) + 8px);
  z-index: 6;
  width: min(330px, calc(100vw - env(safe-area-inset-left) - env(safe-area-inset-right) - 16px));
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5), 0 12px 28px rgba(0, 0, 0, 0.38);
  color: var(--text);
  font-size: 12px;
  line-height: 1.35;
  letter-spacing: 0;
  text-shadow: 0 1px 0 #000;
  backdrop-filter: blur(5px);
}

.profiler__row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  min-height: 16px;
}

.profiler__row span {
  color: var(--muted);
}

.profiler__row b {
  max-width: 220px;
  overflow: hidden;
  color: var(--cyan);
  font-weight: 700;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.profiler__row b.fps-good {
  color: var(--green);
}

.profiler__row b.fps-warn {
  color: var(--yellow);
}

.profiler__row b.fps-bad {
  color: var(--red);
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 8;
  display: grid;
  place-items: center;
  padding:
    calc(env(safe-area-inset-top) + 20px)
    calc(env(safe-area-inset-right) + 20px)
    calc(env(safe-area-inset-bottom) + 20px)
    calc(env(safe-area-inset-left) + 20px);
  background: rgba(2, 4, 8, 0.45);
}

.overlay--hidden {
  display: none;
}

.modal {
  width: min(390px, 100%);
  padding: 26px 24px 24px;
  border: 1px solid rgba(255, 210, 74, 0.42);
  border-radius: 8px;
  background: var(--panel-strong);
  box-shadow:
    0 0 0 2px rgba(0, 0, 0, 0.42),
    0 18px 42px rgba(0, 0, 0, 0.55),
    0 0 36px rgba(70, 215, 255, 0.12);
  text-align: center;
}

.modal__kicker {
  margin: 0 0 10px;
  color: var(--gold);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
}

.modal h1 {
  margin: 0 0 22px;
  color: var(--text);
  font-size: clamp(28px, 9vw, 42px);
  line-height: 1;
  letter-spacing: 0;
  text-shadow:
    3px 3px 0 #10263d,
    0 0 20px rgba(70, 215, 255, 0.25);
}

.final-stats {
  min-height: 72px;
  margin: -4px 0 18px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-line;
  font-variant-numeric: tabular-nums;
}

.action-button {
  min-width: 148px;
  min-height: 44px;
  padding: 11px 22px;
  border: 1px solid rgba(255, 210, 74, 0.86);
  border-radius: 6px;
  background: #101928;
  color: var(--gold);
  box-shadow:
    inset 0 -4px 0 rgba(0, 0, 0, 0.28),
    0 0 22px rgba(255, 210, 74, 0.12);
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.action-button:active {
  transform: translateY(2px);
  box-shadow:
    inset 0 -2px 0 rgba(0, 0, 0, 0.28),
    0 0 14px rgba(255, 210, 74, 0.1);
}

.action-button:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 3px;
}

@media (max-width: 520px) {
  .profiler {
    width: min(300px, calc(100vw - env(safe-area-inset-left) - env(safe-area-inset-right) - 16px));
    font-size: 11px;
  }

  .profiler__row b {
    max-width: 190px;
  }

  .modal {
    padding: 24px 18px 22px;
  }
}
