:root {
  color-scheme: dark;
  font-family: Inter, "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, system-ui, sans-serif;
  color: #edf2ef;
  background: #0c0e13;
  --ink: #edf2ef;
  --muted: #939da1;
  --deep: #0c0e13;
  --panel: #151820;
  --tile: #242a31;
  --cyan: #69d6d1;
  --red: #ff6b74;
  --yellow: #f4d35e;
  --line: rgba(237, 242, 239, 0.16);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-width: 320px; background: var(--deep); }
body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 78% 12%, rgba(105, 214, 209, 0.08), transparent 24rem),
    linear-gradient(180deg, #11151b 0, #0c0e13 70%);
}
button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; }
button:focus-visible, a:focus-visible { outline: 4px solid var(--yellow); outline-offset: 4px; }

.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;
}

.topbar, .game-shell, footer { width: min(1080px, calc(100% - 32px)); margin-inline: auto; }
.topbar {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid var(--line);
}
.topbar p {
  margin: 0;
  color: #7f898e;
  font: 800 0.64rem/1 ui-monospace, Consolas, monospace;
  letter-spacing: 0.14em;
}
.wordmark {
  display: flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  font-size: 0.73rem;
  font-weight: 900;
  letter-spacing: 0.18em;
  text-decoration: none;
}
.mark {
  width: 25px;
  height: 25px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  transform: rotate(-4deg);
}
.mark i { background: var(--cyan); }
.mark i:nth-child(2), .mark i:nth-child(3) { background: transparent; }

.game-shell { padding: clamp(48px, 7vw, 88px) 0 80px; }
.game-heading {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(300px, 1.1fr);
  align-items: end;
  gap: clamp(28px, 7vw, 88px);
  margin-bottom: 42px;
}
.eyebrow, .overlay-kicker {
  margin: 0 0 15px;
  color: #7e9294;
  font: 800 0.64rem/1.3 ui-monospace, Consolas, monospace;
  letter-spacing: 0.16em;
}
h1 {
  margin: 0;
  font-size: clamp(3.4rem, 8vw, 7rem);
  line-height: 0.82;
  letter-spacing: -0.08em;
}
h1 em { color: var(--red); font-style: normal; }
.lead {
  margin: 0 0 3px;
  padding-left: 20px;
  border-left: 4px solid var(--cyan);
  color: #aeb8b9;
  font-weight: 700;
  line-height: 1.9;
}

.play-area {
  border: 1px solid var(--line);
  background: rgba(21, 24, 32, 0.92);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.42);
}
.hud { display: grid; grid-template-columns: repeat(5, 1fr); border-bottom: 1px solid var(--line); }
.hud-item {
  min-height: 76px;
  padding: 15px 20px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
}
.hud-item + .hud-item { border-left: 1px solid var(--line); }
.hud-item > span {
  color: #778286;
  font: 800 0.56rem/1 ui-monospace, Consolas, monospace;
  letter-spacing: 0.14em;
}
.hud-item strong { font-size: clamp(1rem, 2.2vw, 1.35rem); line-height: 1; }
.hud-time { text-align: center; }
.hud-time strong { color: var(--yellow); font-size: clamp(1.7rem, 4vw, 2.4rem); font-variant-numeric: tabular-nums; }
.hud-time small { margin-left: 4px; color: #8e999c; font-size: 0.68rem; }
.hud-banished strong { color: var(--cyan); font-variant-numeric: tabular-nums; }
.hud-score strong { color: var(--yellow); font-variant-numeric: tabular-nums; }

.scene-frame {
  position: relative;
  overflow: hidden;
  background: #171b21;
  isolation: isolate;
}
#game-canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 8 / 5;
  background: #20262d;
  cursor: crosshair;
  touch-action: none;
}
.scene-frame.is-guiding #game-canvas { cursor: move; }
.scene-frame::after {
  position: absolute;
  inset: 14px;
  z-index: 4;
  border: 1px solid rgba(237, 242, 239, 0.22);
  border-radius: 3px;
  pointer-events: none;
  content: "";
}
.scene-frame.is-hit { animation: scene-hit 280ms ease-out; }
.screen-flash {
  position: absolute;
  z-index: 20;
  inset: 0;
  opacity: 0;
  pointer-events: none;
}
.screen-flash.is-slip { animation: slip-flash 360ms ease-out; }
.screen-flash.is-hit { animation: hit-flash 420ms ease-out; }
.screen-flash.is-clear { animation: clear-flash 520ms ease-out; }
.spawn-cue {
  position: absolute;
  z-index: 7;
  left: 50%;
  top: 9%;
  padding: 10px 19px;
  border: 1px solid rgba(255, 107, 116, 0.7);
  border-radius: 999px;
  color: #fff;
  background: rgba(94, 19, 29, 0.88);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.34);
  font-size: clamp(0.76rem, 2.4vw, 1rem);
  font-weight: 900;
  letter-spacing: 0.08em;
  transform: translateX(-50%);
  pointer-events: none;
  animation: cue-pop 900ms ease-out;
}
.spawn-cue.is-combo {
  border-color: rgba(244, 211, 94, 0.82);
  color: #12171a;
  background: rgba(244, 211, 94, 0.94);
  box-shadow: 0 8px 32px rgba(244, 211, 94, 0.22);
}

.overlay {
  position: absolute;
  z-index: 10;
  inset: 0;
  padding: clamp(14px, 4vw, 36px);
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, rgba(5, 7, 10, 0.36), rgba(5, 7, 10, 0.82));
}
.overlay-card {
  width: min(590px, 100%);
  padding: clamp(22px, 5vw, 42px);
  border: 1px solid rgba(237, 242, 239, 0.28);
  border-radius: 18px;
  background: rgba(20, 24, 31, 0.96);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.52);
  text-align: center;
  backdrop-filter: blur(8px);
}
.overlay-card h2 { margin: 0; font-size: clamp(2rem, 6vw, 3.7rem); line-height: 1; letter-spacing: -0.055em; }
.steps { margin: 26px 0 20px; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); list-style: none; }
.steps li { padding: 9px 12px; display: flex; flex-direction: column; gap: 5px; }
.steps li + li { border-left: 1px solid var(--line); }
.steps b { color: var(--yellow); font: 900 0.85rem/1 ui-monospace, Consolas, monospace; }
.steps span { color: #aab4b5; font-size: 0.76rem; font-weight: 750; line-height: 1.45; }
.silent-note { margin: 17px 0 0; color: #849092; font-size: 0.72rem; font-weight: 700; }
.primary-button {
  min-height: 54px;
  padding: 0 26px;
  border: 0;
  border-radius: 999px;
  color: #0b1215;
  background: var(--cyan);
  box-shadow: 0 7px 0 #2c7774;
  font-weight: 950;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease;
}
.primary-button:hover { transform: translateY(-2px); box-shadow: 0 9px 0 #2c7774; }
.primary-button:active { transform: translateY(5px); box-shadow: 0 2px 0 #2c7774; }
.result-card { width: min(440px, 100%); }
.result-time { margin: 22px 0 10px; color: var(--yellow); }
.result-time strong { font-size: clamp(4rem, 13vw, 7rem); line-height: 0.8; letter-spacing: -0.08em; }
.result-time span { margin-left: 8px; color: var(--ink); font-weight: 900; }
.result-detail { min-height: 2.8em; margin: 0 0 22px; color: #a9b5b6; font-weight: 750; line-height: 1.55; }

.controls {
  min-height: 112px;
  padding: 20px clamp(18px, 4vw, 34px);
  display: grid;
  grid-template-columns: minmax(210px, 320px) 1fr;
  align-items: center;
  gap: 28px;
  border-top: 1px solid var(--line);
}
.controls p { margin: 0; color: #a4afb0; font-weight: 700; line-height: 1.7; }
.control-card {
  min-height: 66px;
  padding: 0 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
  border: 2px solid #5c696c;
  border-radius: 10px;
  color: var(--ink);
  background: #1e252c;
  box-shadow: 0 7px 0 #0d1015;
}
.control-card > span:last-child { display: flex; flex-direction: column; gap: 4px; }
.control-card b { font: 900 0.74rem/1 ui-monospace, Consolas, monospace; letter-spacing: 0.08em; }
.control-card small { color: #8d999a; font-size: 0.72rem; font-weight: 800; }
.target-icon { position: relative; width: 34px; height: 34px; border: 2px dashed var(--cyan); border-radius: 50%; }
.target-icon::before,
.target-icon::after { position: absolute; left: 50%; top: 50%; background: var(--cyan); content: ""; transform: translate(-50%, -50%); }
.target-icon::before { width: 22px; height: 2px; }
.target-icon::after { width: 2px; height: 22px; }
.target-icon i { position: absolute; left: 50%; top: 50%; width: 8px; height: 8px; z-index: 1; border-radius: 50%; background: #1e252c; box-shadow: 0 0 0 3px var(--cyan); transform: translate(-50%, -50%); }

footer {
  min-height: 78px;
  padding: 20px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  border-top: 1px solid var(--line);
  color: #747f82;
  font: 750 0.62rem/1.5 ui-monospace, Consolas, monospace;
  letter-spacing: 0.08em;
}

@keyframes cue-pop {
  0% { opacity: 0; transform: translate(-50%, -10px) scale(0.92); }
  22% { opacity: 1; transform: translate(-50%, 0) scale(1.03); }
  100% { opacity: 1; transform: translate(-50%, 0) scale(1); }
}
@keyframes slip-flash {
  0% { opacity: 0; background: var(--yellow); }
  18% { opacity: 0.34; }
  100% { opacity: 0; }
}
@keyframes hit-flash {
  0% { opacity: 0; background: var(--red); }
  24% { opacity: 0.62; }
  100% { opacity: 0; }
}
@keyframes clear-flash {
  0% { opacity: 0; background: var(--cyan); }
  25% { opacity: 0.46; }
  100% { opacity: 0; }
}
@keyframes scene-hit {
  0%, 100% { transform: translateX(0); }
  22% { transform: translateX(-8px); }
  48% { transform: translateX(7px); }
  74% { transform: translateX(-3px); }
}

@media (max-width: 700px) {
  .topbar, .game-shell, footer { width: min(100% - 22px, 1080px); }
  .topbar p { display: none; }
  .game-shell { padding-top: 42px; }
  .game-heading { grid-template-columns: 1fr; gap: 24px; }
  h1 { font-size: clamp(3.5rem, 19vw, 6rem); }
  .lead { font-size: 0.9rem; }
  .hud-item { min-height: 65px; padding: 11px 9px; }
  .hud-item strong { font-size: 0.86rem; }
  .hud-time strong { font-size: 1.48rem; }
  .scene-frame::after { inset: 8px; }
  .overlay { padding: 10px; }
  .overlay-card { padding: 19px 16px 20px; border-radius: 12px; }
  .overlay-card h2 { font-size: clamp(1.8rem, 8vw, 2.7rem); }
  .steps { margin: 16px 0 13px; }
  .steps li { padding: 5px 6px; }
  .steps b { font-size: 0.68rem; }
  .steps span { font-size: 0.63rem; }
  .silent-note { margin-top: 12px; font-size: 0.62rem; }
  .primary-button { min-height: 48px; }
  .result-time { margin: 13px 0 7px; }
  .result-detail { margin-bottom: 14px; font-size: 0.78rem; }
  .controls { min-height: 0; padding: 17px 14px 20px; grid-template-columns: 1fr; gap: 16px; }
  .control-card { min-height: 61px; }
  .controls p { min-height: 2.8em; font-size: 0.8rem; text-align: center; }
  footer { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 420px) {
  .game-heading { margin-bottom: 28px; }
  .hud-item { padding-inline: 4px; }
  .hud-item > span { font-size: 0.48rem; letter-spacing: 0.08em; }
  .hud-item strong { font-size: 0.76rem; }
  .hud-time strong { font-size: 1.2rem; }
  .hud-item:first-child strong { font-size: 0.72rem; }
  .scene-frame { min-height: 219px; }
  #game-canvas { min-height: 219px; object-fit: cover; }
  .spawn-cue { top: 6%; padding: 7px 13px; font-size: 0.66rem; }
  .intro-overlay { padding: 6px; }
  .intro-overlay .overlay-card { padding: 12px 10px 13px; }
  .intro-overlay .overlay-kicker { margin-bottom: 6px; font-size: 0.5rem; }
  .intro-overlay h2 { font-size: 1.55rem; }
  .intro-overlay .steps { margin: 9px 0 7px; }
  .intro-overlay .steps span { font-size: 0.56rem; line-height: 1.25; }
  .intro-overlay .primary-button { min-height: 44px; padding-inline: 18px; font-size: 0.76rem; }
  .intro-overlay .silent-note { margin-top: 7px; font-size: 0.54rem; }
  .result-overlay { padding: 6px; }
  .result-overlay .overlay-card { padding: 10px 11px 12px; }
  .result-card .overlay-kicker { margin-bottom: 3px; font-size: 0.48rem; }
  .result-card h2 { font-size: 1.55rem; }
  .result-card .result-time { margin: 5px 0 3px; }
  .result-card .result-time strong { font-size: 3rem; }
  .result-card .result-time span { font-size: 0.66rem; }
  .result-card .result-detail { min-height: 0; margin-bottom: 7px; font-size: 0.68rem; line-height: 1.25; }
  .result-card .primary-button { min-height: 44px; padding-inline: 14px; font-size: 0.72rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
