:root {
  color-scheme: light;
  font-family: Arial, Helvetica, sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

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

body {
  background: #f8f4ea;
  user-select: none;
}

.game {
  position: relative;
  touch-action: none;
  cursor: crosshair;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.prompt,
.score,
.best-score,
.mobile-note {
  font-family: "Courier New", monospace;
  font-size: clamp(8px, 1.4vw, 12px);
  font-weight: 800;
  letter-spacing: 0.13em;
}

.best-score {
  display: flex;
  align-items: baseline;
  gap: 5px;
  color: #777168;
  font-size: clamp(7px, 1vw, 10px);
}

.best-score strong {
  color: #181816;
  font-size: 1.15em;
  font-variant-numeric: tabular-nums;
}

.prompt {
  position: absolute;
  left: 22px;
  bottom: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: opacity 240ms ease;
}

.prompt.hidden {
  opacity: 0;
}

.prompt-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #ff5c35;
  animation: blink 900ms steps(2, end) infinite;
}

.score {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.score span {
  color: #777168;
  font-size: 0.72em;
}

.score strong {
  min-width: 3ch;
  font-size: clamp(18px, 3.3vw, 30px);
  letter-spacing: -0.04em;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.score-cluster {
  position: absolute;
  top: 18px;
  left: 20px;
  display: flex;
  align-items: baseline;
  gap: clamp(14px, 3vw, 28px);
}

.mobile-note {
  display: none;
  position: absolute;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  color: #777168;
  pointer-events: none;
}

.joystick {
  display: none;
  position: absolute;
  left: 50%;
  bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  z-index: 2;
  width: 116px;
  height: 116px;
  border: 2px solid rgba(24, 24, 22, 0.58);
  border-radius: 50%;
  background: rgba(248, 244, 234, 0.86);
  box-shadow: 0 8px 28px rgba(24, 24, 22, 0.12), inset 0 0 0 10px rgba(24, 24, 22, 0.035);
  transform: translateX(-50%);
  touch-action: none;
  transition: opacity 160ms ease, visibility 160ms ease;
}

.joystick::before,
.joystick::after {
  position: absolute;
  content: "";
  background: rgba(24, 24, 22, 0.12);
  pointer-events: none;
}

.joystick::before {
  top: 50%;
  left: 13px;
  right: 13px;
  height: 1px;
}

.joystick::after {
  top: 13px;
  bottom: 13px;
  left: 50%;
  width: 1px;
}

.joystick.hidden {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.joystick-knob {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 48px;
  height: 48px;
  border: 2px solid #181816;
  border-radius: 50%;
  background: #ff5c35;
  box-shadow: 0 5px 12px rgba(24, 24, 22, 0.2);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.respawn,
.pause-overlay {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-content: center;
  justify-items: center;
  padding: 24px;
  background: rgba(248, 244, 234, 0.9);
  backdrop-filter: blur(6px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 180ms ease, visibility 180ms ease;
}

.respawn.active,
.pause-overlay.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.respawn span,
.respawn h1,
.respawn p,
.respawn button,
.pause-overlay span,
.pause-overlay h1,
.pause-overlay p,
.pause-overlay button {
  font-family: "Courier New", monospace;
}

.respawn span,
.pause-overlay span {
  color: #2563eb;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.2em;
}

.respawn h1,
.pause-overlay h1 {
  margin: 8px 0 4px;
  font-size: clamp(34px, 8vw, 68px);
  letter-spacing: -0.08em;
}

.respawn p,
.pause-overlay p {
  margin: 0 0 22px;
  color: #777168;
  font-size: 12px;
}

.run-summary,
.rewarded-button,
.ad-status,
.restart-label {
  display: none;
}

.respawn.run-over .run-summary {
  display: grid;
}

.respawn.run-over .rewarded-button,
.respawn.run-over .restart-label {
  display: block;
}

.respawn.run-over .ad-status:not(:empty) {
  display: block;
}

.run-summary {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: min(360px, 100%);
  margin-bottom: 14px;
  border: 1px solid rgba(24, 24, 22, 0.18);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.38);
  overflow: hidden;
}

.run-summary > div {
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 12px 18px;
}

.run-summary > div + div {
  border-left: 1px solid rgba(24, 24, 22, 0.14);
}

.run-summary span {
  color: #777168;
  font-size: 8px;
  letter-spacing: 0.12em;
}

.run-summary strong {
  color: #181816;
  font-family: "Courier New", monospace;
  font-size: 24px;
  font-variant-numeric: tabular-nums;
}

.respawn .rewarded-button {
  width: min(360px, 100%);
  min-height: 58px;
  margin-bottom: 10px;
  background: #2563eb;
}

.respawn .rewarded-button:hover,
.respawn .rewarded-button:focus-visible {
  background: #173d99;
}

.respawn .rewarded-button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.ad-status {
  margin: -2px 0 10px !important;
  color: #b33b21 !important;
  font-size: 9px !important;
  font-weight: 700;
}

.restart-label {
  margin: 4px 0 8px;
  color: #777168 !important;
  font-size: 8px !important;
}

.mode-buttons {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  width: min(540px, 100%);
}

.respawn button {
  min-width: 0;
  min-height: 70px;
  padding: 12px 14px;
  border: 0;
  border-radius: 14px;
  background: #181816;
  color: white;
  font-weight: 800;
  cursor: pointer;
}

.respawn button b,
.respawn button small,
.respawn button em {
  display: block;
  font-family: inherit;
}

.respawn button b {
  font-size: 12px;
  letter-spacing: 0.13em;
}

.respawn button small {
  margin-top: 5px;
  color: rgba(255, 255, 255, 0.58);
  font-size: 8px;
  letter-spacing: 0.08em;
}

.respawn button em {
  margin-top: 8px;
  color: #60a5fa;
  font-size: 8px;
  font-style: normal;
  letter-spacing: 0.08em;
}

.respawn button:hover,
.respawn button:focus-visible {
  background: #2563eb;
  outline: none;
}

.pause-overlay button {
  min-width: 160px;
  min-height: 52px;
  padding: 12px 24px;
  border: 0;
  border-radius: 14px;
  background: #181816;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.13em;
  cursor: pointer;
}

.pause-overlay button:hover,
.pause-overlay button:focus-visible {
  background: #2563eb;
  outline: none;
}

@media (max-width: 520px) {
  .mode-buttons {
    grid-template-columns: 1fr;
    width: min(220px, 100%);
  }

  .respawn button {
    min-height: 58px;
  }

  .respawn.run-over h1 {
    font-size: 32px;
  }

  .respawn.run-over p {
    margin-bottom: 12px;
  }

  .respawn.run-over .mode-buttons {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: min(360px, 100%);
  }

  .respawn.run-over .mode-buttons button {
    min-height: 54px;
    padding: 8px 6px;
  }

  .respawn.run-over .mode-buttons em {
    display: none;
  }
}

@keyframes blink {
  50% { opacity: 0.2; }
}

.joystick-mode .game { cursor: default; }
.joystick-mode .prompt { display: none; }
.joystick-mode .mobile-note {
  display: block;
  bottom: calc(38px + env(safe-area-inset-bottom, 0px));
}
.joystick-mode .joystick { display: block; }
