:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #080a12;
}

* {
  box-sizing: border-box;
}

html,
body,
#game-shell {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  background: #080a12;
  touch-action: none;
}

#game-shell {
  position: relative;
  display: grid;
  place-items: center;
}

#stage {
  position: relative;
  width: min(100%, calc(100vh * 16 / 9));
  max-height: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: #0d111d;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
  cursor: pointer;
}

#game-canvas:focus-visible {
  outline: 3px solid #ffcf54;
  outline-offset: -3px;
}

#hud {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.game-mark {
  position: absolute;
  top: 1.2rem;
  left: 1.35rem;
  margin: 0;
  color: #54f3c2;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: clamp(0.58rem, 1.45vw, 0.82rem);
  font-weight: 800;
}

.metrics {
  position: absolute;
  top: 1rem;
  right: 1.35rem;
  display: flex;
  gap: clamp(0.7rem, 2.4vw, 1.6rem);
}

.metrics p {
  display: grid;
  gap: 0.1rem;
  min-width: 3.5rem;
  margin: 0;
  text-align: right;
}

.metrics span {
  color: #929ab4;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: clamp(0.48rem, 1.1vw, 0.66rem);
  font-weight: 700;
}

.metrics strong {
  color: #f7f8fc;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: clamp(0.72rem, 1.8vw, 1rem);
}

.progress {
  position: absolute;
  top: 4.1rem;
  right: 1.35rem;
  left: 1.35rem;
  height: 3px;
  overflow: hidden;
  background: rgba(146, 154, 180, 0.22);
}

#progress-fill {
  display: block;
  width: 0;
  height: 100%;
  background: #54f3c2;
  transform-origin: left;
}

.panel {
  position: absolute;
  inset: 50% auto auto 50%;
  z-index: 5;
  width: min(31rem, calc(100% - 2rem));
  transform: translate(-50%, -50%);
  padding: clamp(1rem, 3vw, 1.6rem);
  border: 1px solid rgba(84, 243, 194, 0.55);
  border-radius: 8px;
  background: rgba(8, 10, 18, 0.95);
  box-shadow: 0 18px 64px rgba(0, 0, 0, 0.58);
  text-align: center;
}

.panel[hidden] {
  display: none;
}

.panel h1,
.panel h2 {
  margin: 0.35rem 0 0.7rem;
  color: #f7f8fc;
  font-size: clamp(1.75rem, 6vw, 3rem);
  letter-spacing: 0;
  line-height: 1;
}

.panel p {
  max-width: 27rem;
  margin: 0.55rem auto;
  color: #c7cbda;
  font-size: clamp(0.72rem, 2vw, 0.94rem);
  line-height: 1.45;
}

.panel .eyebrow {
  color: #54f3c2;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: clamp(0.55rem, 1.5vw, 0.7rem);
  font-weight: 800;
}

.panel .hint,
.panel .best {
  color: #929ab4;
  font-size: clamp(0.62rem, 1.7vw, 0.78rem);
}

.panel button {
  min-width: 9.5rem;
  min-height: 44px;
  margin-top: 0.65rem;
  padding: 0.68rem 1.15rem;
  border: 0;
  border-radius: 6px;
  background: #54f3c2;
  color: #07120f;
  font: inherit;
  font-weight: 850;
  cursor: pointer;
}

.panel button:hover {
  background: #76f7d3;
}

.panel button:focus-visible {
  outline: 3px solid #ffcf54;
  outline-offset: 3px;
}

#notice {
  position: absolute;
  top: 24%;
  left: 50%;
  z-index: 3;
  min-width: 10rem;
  margin: 0;
  transform: translateX(-50%);
  color: #ffcf54;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: clamp(0.68rem, 2vw, 0.95rem);
  font-weight: 900;
  text-align: center;
  opacity: 0;
  transition: opacity 160ms ease;
  pointer-events: none;
}

#notice.visible {
  opacity: 1;
}

#tap-hint {
  position: absolute;
  right: 1.35rem;
  bottom: 1.1rem;
  z-index: 2;
  margin: 0;
  color: rgba(247, 248, 252, 0.58);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: clamp(0.56rem, 1.4vw, 0.72rem);
  font-weight: 800;
  pointer-events: none;
}

@media (max-width: 640px), (max-height: 420px) {
  .game-mark {
    top: 0.7rem;
    left: 0.8rem;
  }

  .metrics {
    top: 0.55rem;
    right: 0.8rem;
  }

  .progress {
    top: 2.9rem;
    right: 0.8rem;
    left: 0.8rem;
  }

  #tap-hint {
    right: 0.8rem;
    bottom: 0.65rem;
  }

  .panel {
    width: calc(100% - 1rem);
    padding: 0.48rem 0.7rem;
  }

  .panel h1,
  .panel h2 {
    margin: 0.15rem 0 0.35rem;
    font-size: clamp(1.45rem, 6vw, 2rem);
  }

  .panel p {
    margin: 0.28rem auto;
    line-height: 1.3;
  }

  .panel button {
    margin-top: 0.3rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  #notice {
    transition: none;
  }
}
