:root {
  --ink: #07111f;
  --muted: #5d6878;
  --panel: rgba(255, 255, 255, 0.88);
  --line: rgba(22, 49, 85, 0.16);
  --blue: #1263ee;
  --blue-dark: #073a97;
  --gold: #ffc928;
  --green: #24b86e;
  --red: #ec4b42;
  --shadow: 0 24px 80px rgba(7, 17, 31, 0.22);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 22% 14%, rgba(255, 255, 255, 0.95), transparent 25%),
    linear-gradient(135deg, #c9edff 0%, #eef8ff 34%, #eaf7ec 100%);
}

button {
  font: inherit;
}

[hidden] {
  display: none !important;
}

.runner-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.game-shell {
  width: min(1120px, 100%);
}

.game-topbar {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 12px 4px 18px;
}

.brand-link {
  color: var(--blue-dark);
  font-size: 14px;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-decoration: none;
}

.stat-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.stat {
  min-width: 112px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 10px 32px rgba(7, 17, 31, 0.08);
  backdrop-filter: blur(16px);
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.stat strong {
  display: block;
  margin-top: 3px;
  color: var(--ink);
  font-size: 25px;
  line-height: 1;
}

.game-frame {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: 8px;
  background: #8ed9ff;
  box-shadow: var(--shadow);
  aspect-ratio: 3 / 2;
  min-height: 360px;
  touch-action: none;
}

.game-canvas,
.game-canvas canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.screen-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 22px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.1), rgba(7, 17, 31, 0.18)),
    rgba(7, 17, 31, 0.05);
  transition: opacity 0.18s ease, visibility 0.18s ease;
}

.screen-overlay.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.overlay-panel {
  width: min(460px, 100%);
  padding: 32px;
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 24px 70px rgba(7, 17, 31, 0.25);
  text-align: center;
  backdrop-filter: blur(18px);
}

.eyeline {
  margin: 0 0 10px;
  color: var(--blue-dark);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.overlay-panel h1 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(42px, 7vw, 72px);
  line-height: 0.94;
  letter-spacing: 0;
}

.overlay-panel p {
  margin: 18px auto 0;
  max-width: 360px;
  color: #334155;
  font-size: 16px;
}

.result-line {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 18px;
}

.result-line span {
  min-width: 118px;
  padding: 10px 12px;
  border: 1px solid rgba(7, 17, 31, 0.12);
  border-radius: 8px;
  background: #f7fbff;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.result-line strong {
  color: var(--ink);
}

.button-row {
  display: flex;
  justify-content: center;
  margin-top: 26px;
}

.primary-button {
  min-width: 150px;
  min-height: 48px;
  padding: 0 22px;
  border: 1px solid rgba(7, 17, 31, 0.1);
  border-radius: 8px;
  background: linear-gradient(180deg, #1977ff, var(--blue));
  color: #fff;
  font-size: 15px;
  font-weight: 850;
  letter-spacing: 0;
  cursor: pointer;
  box-shadow: 0 14px 28px rgba(18, 99, 238, 0.32);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.primary-button:hover,
.primary-button:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 18px 34px rgba(18, 99, 238, 0.38);
}

.primary-button:focus-visible {
  outline: 3px solid rgba(255, 201, 40, 0.7);
  outline-offset: 3px;
}

.mobile-controls {
  display: none;
}

.lane-button {
  min-height: 58px;
  border: 1px solid rgba(7, 17, 31, 0.12);
  border-radius: 999px;
  background: linear-gradient(180deg, #ffffff, #eaf3ff);
  color: var(--blue-dark);
  font-size: 26px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 12px 28px rgba(7, 17, 31, 0.12);
  touch-action: manipulation;
}

.lane-button:active {
  transform: translateY(1px);
}

.lane-button:focus-visible {
  outline: 3px solid rgba(18, 99, 238, 0.32);
  outline-offset: 3px;
}

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

@media (max-width: 760px) {
  body {
    overflow-x: hidden;
  }

  .runner-page {
    min-height: 100dvh;
    padding: 10px 12px calc(12px + env(safe-area-inset-bottom));
    align-items: start;
    place-items: stretch;
  }

  .game-shell {
    width: 100%;
    min-height: calc(100dvh - 22px);
    display: flex;
    flex-direction: column;
  }

  .game-topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
    min-height: 0;
    padding-bottom: 12px;
  }

  .brand-link {
    font-size: 12px;
  }

  .stat-row {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .stat {
    min-width: 0;
    padding: 9px 10px;
  }

  .stat strong {
    font-size: 21px;
  }

  .game-frame {
    flex: 1 1 auto;
    min-height: 0;
    aspect-ratio: auto;
    height: clamp(430px, 62dvh, 560px);
  }

  .mobile-controls {
    display: grid;
    grid-template-columns: 78px minmax(0, 1fr) 78px;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
  }

  .mobile-controls p {
    margin: 0;
    color: var(--muted);
    font-size: 12px;
    font-weight: 750;
    line-height: 1.25;
    text-align: center;
  }

  .overlay-panel {
    padding: 18px 16px;
  }

  .eyeline {
    margin-bottom: 7px;
    font-size: 10px;
  }

  .overlay-panel h1 {
    font-size: clamp(34px, 11vw, 46px);
  }

  .overlay-panel p {
    margin-top: 10px;
    font-size: 13px;
    line-height: 1.4;
  }

  .button-row {
    margin-top: 14px;
  }

  .primary-button {
    min-height: 42px;
    font-size: 14px;
  }

  .result-line {
    flex-direction: column;
    gap: 8px;
  }
}
