:root {
  color-scheme: dark;
  font-family: Inter, "Helvetica Neue", "Hiragino Sans", "Yu Gothic", sans-serif;
  background: #09090b;
  color: #f6f5f1;
  --acid: #d8ff3e;
  --muted: #92928d;
  --line: #2a2a2d;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    #09090b;
  background-size: 32px 32px;
}

header,
main {
  width: min(92vw, 1100px);
  margin-inline: auto;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--line);
}

header p,
.back-link {
  margin: 0;
  color: var(--muted);
  font: 700 0.8rem/1 monospace;
  letter-spacing: 0.08em;
}

.back-link {
  color: #f6f5f1;
  text-decoration: none;
}

.back-link:hover {
  color: var(--acid);
}

.back-link:focus-visible,
button:focus-visible {
  outline: 3px solid var(--acid);
  outline-offset: 4px;
}

main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 230px;
  gap: 1.5rem;
  padding: clamp(2rem, 6vw, 5rem) 0 3rem;
}

.game {
  min-width: 0;
}

.title-row {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 2rem;
  margin-bottom: 2.5rem;
}

.eyebrow {
  margin: 0 0 0.75rem;
  color: var(--acid);
  font: 700 0.82rem/1 monospace;
  letter-spacing: 0.14em;
}

h1 {
  margin: 0;
  font-size: clamp(3.4rem, 9vw, 7.5rem);
  line-height: 0.82;
  letter-spacing: -0.07em;
}

h1 span {
  color: var(--acid);
}

.target {
  padding-left: 1.25rem;
  border-left: 1px solid var(--line);
}

.target span,
.record span {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--muted);
  font: 700 0.75rem/1 monospace;
  letter-spacing: 0.12em;
}

.target strong {
  font: 700 clamp(1.8rem, 4vw, 3rem)/1 monospace;
}

.stage {
  position: relative;
  overflow: hidden;
  display: grid;
  place-items: center;
  min-height: 430px;
  padding: 3rem 1.5rem;
  border: 1px solid var(--line);
  border-radius: 1.25rem;
  background: rgba(17, 17, 19, 0.92);
  text-align: center;
}

.stage::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 45%, rgba(216, 255, 62, 0.12), transparent 42%);
  opacity: 0;
  transition: opacity 220ms ease;
  pointer-events: none;
}

.stage[data-state="running"]::before,
.stage[data-state="result"]::before {
  opacity: 1;
}

.timer-wrap,
.mode-switch,
.result,
.main-button,
.key-hint {
  position: relative;
  z-index: 1;
}

.mode-switch {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0 0 2rem;
  padding: 0.3rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #0e0e10;
}

.mode-switch legend {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.mode-switch label {
  cursor: pointer;
}

.mode-switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.mode-switch span {
  display: block;
  min-width: 5.5rem;
  padding: 0.65rem 1rem;
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
  transition: color 120ms ease, background 120ms ease;
}

.mode-switch input:checked + span {
  background: var(--acid);
  color: #09090b;
}

.mode-switch input:focus-visible + span {
  outline: 3px solid var(--acid);
  outline-offset: 3px;
}

.mode-switch input:disabled + span {
  cursor: not-allowed;
  opacity: 0.55;
}

.timer-label,
.unit {
  margin: 0;
  color: var(--muted);
  font: 700 0.75rem/1 monospace;
  letter-spacing: 0.15em;
}

.timer {
  display: block;
  margin: 0.7rem 0;
  font: 700 clamp(4.4rem, 13vw, 8.5rem)/0.95 monospace;
  letter-spacing: -0.09em;
  font-variant-numeric: tabular-nums;
}

.stage[data-state="running"] .timer {
  color: var(--acid);
}

.stage[data-state="running"][data-mode="hidden"] .timer,
.stage[data-state="running"][data-mode="hidden"] .unit {
  visibility: hidden;
}

.result {
  min-height: 1.7em;
  margin: 1.4rem 0 1.8rem;
  color: #cacac5;
  font-size: 1rem;
  font-weight: 600;
}

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

.main-button {
  width: min(100%, 360px);
  min-height: 64px;
  border: 0;
  border-radius: 999px;
  background: var(--acid);
  color: #09090b;
  cursor: pointer;
  font: 800 1.05rem/1 sans-serif;
  transition: transform 120ms ease, background 120ms ease;
}

.main-button:hover {
  background: #e4ff76;
  transform: scale(1.02);
}

.main-button:active {
  transform: scale(0.98);
}

.stage[data-state="running"] .main-button {
  background: #f6f5f1;
}

.key-hint {
  margin: 1rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

kbd {
  padding: 0.16rem 0.42rem;
  border: 1px solid #444448;
  border-bottom-width: 2px;
  border-radius: 0.3rem;
  font-family: monospace;
}

.record {
  align-self: end;
  display: grid;
  gap: 1.2rem;
  padding: 1.5rem;
  border-top: 3px solid var(--acid);
  background: #17171a;
}

.record strong {
  display: block;
  font: 700 2rem/1.1 monospace;
  font-variant-numeric: tabular-nums;
}

.record button {
  justify-self: start;
  padding: 0;
  border: 0;
  border-bottom: 1px solid #5b5b5f;
  background: none;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
}

.record button:hover {
  color: #f6f5f1;
}

@media (max-width: 760px) {
  main {
    grid-template-columns: 1fr;
  }

  .record {
    grid-template-columns: 1fr auto;
    align-items: end;
  }
}

@media (max-width: 520px) {
  header p {
    display: none;
  }

  .title-row {
    align-items: start;
  }

  .target {
    padding-left: 0.8rem;
  }

  .stage {
    min-height: 400px;
  }

  .timer {
    font-size: clamp(3.8rem, 20vw, 6rem);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}

.share-x {
  display: block;
  width: min(100%, 280px);
  min-height: 48px;
  margin: .7rem auto 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #17171a;
  color: var(--acid);
  font-weight: 800;
  cursor: pointer;
}
.share-x[hidden] { display: none !important; }
