:root {
  --paper: #f7f3e9;
  --muted: #77727f;
  --pink: #ff5da2;
  --orange: #ff9c5a;
  --yellow: #f5ef7b;
  --cyan: #68efff;
  --violet: #a47cff;
  --void: #07060b;
  --line: rgba(247, 243, 233, 0.14);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  color: var(--paper);
  background: var(--void);
  font-family: "Manrope", sans-serif;
}

button,
a { -webkit-tap-highlight-color: transparent; }
button:focus-visible,
a:focus-visible { outline: 2px solid var(--yellow); outline-offset: 4px; }

#game { position: fixed; inset: 0; width: 100%; height: 100%; touch-action: none; }

.grain {
  position: fixed;
  z-index: 50;
  inset: 0;
  pointer-events: none;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.92' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.damage-flash { position: fixed; z-index: 22; inset: 0; pointer-events: none; background: var(--pink); opacity: 0; }
.damage-flash.is-active { animation: flash 420ms ease-out; }
@keyframes flash { from { opacity: 0.25; } to { opacity: 0; } }

.topbar {
  position: fixed;
  z-index: 10;
  top: 0;
  right: 0;
  left: 0;
  height: 74px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 25px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(7, 6, 11, 0.86), rgba(7, 6, 11, 0.16));
  font-family: "DM Mono", monospace;
}

.logo { width: max-content; display: flex; align-items: center; gap: 12px; color: var(--paper); text-decoration: none; }
.logo-prism { width: 29px; height: 27px; display: block; clip-path: polygon(50% 0, 100% 100%, 0 100%); background: conic-gradient(from 150deg at 50% 75%, var(--pink), var(--yellow), var(--cyan), var(--violet), var(--pink)); }
.logo b,
.logo small { display: block; }
.logo b { font-size: 10px; letter-spacing: 0.14em; }
.logo small { margin-top: 5px; color: var(--muted); font-size: 6px; letter-spacing: 0.11em; }

.stage-readout { display: flex; align-items: center; gap: 13px; color: var(--muted); font-size: 7px; letter-spacing: 0.13em; }
.stage-readout strong { color: var(--paper); font-size: 10px; font-weight: 400; }

.sound-button { justify-self: end; display: flex; align-items: center; gap: 9px; padding: 10px 0; border: 0; color: var(--muted); background: transparent; font: 400 7px/1 "DM Mono", monospace; letter-spacing: 0.12em; cursor: pointer; }
.sound-button i { width: 7px; height: 7px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 12px var(--cyan); }
.sound-button.is-muted i { background: var(--muted); box-shadow: none; }

.hud-panel { position: fixed; z-index: 10; top: 105px; font-family: "DM Mono", monospace; }
.hud-panel > span,
.combo-panel > span,
.power-panel > span { display: block; margin-bottom: 8px; color: var(--muted); font: 300 7px/1 "DM Mono", monospace; letter-spacing: 0.14em; }
.score-panel { left: 25px; }
.score-panel > strong { display: block; font-size: 23px; font-weight: 300; letter-spacing: 0.04em; }
.high-score { display: flex; gap: 9px; margin-top: 7px; color: #57525e; font-size: 7px; }
.high-score b { font-weight: 400; }
.lives-panel { right: 25px; text-align: right; }
.lives { display: flex; gap: 7px; }
.lives i { width: 22px; height: 8px; transform: skewX(-22deg); background: var(--cyan); box-shadow: 0 0 10px rgba(104, 239, 255, 0.35); }
.lives i.is-lost { background: #29252e; box-shadow: none; }

.combo-panel { position: fixed; z-index: 10; top: 192px; left: 25px; opacity: 0.4; transition: opacity 180ms ease, transform 180ms ease; }
.combo-panel strong { color: var(--pink); font: 300 26px/1 "DM Mono", monospace; text-shadow: 0 0 18px rgba(255, 93, 162, 0.3); }
.combo-panel.is-hot { opacity: 1; transform: translateX(4px); }

.power-panel { position: fixed; z-index: 10; top: 192px; right: 25px; width: 95px; text-align: right; opacity: 0.45; }
.power-panel > div { width: 100%; height: 2px; background: #29252e; }
.power-panel i { display: block; width: 0; height: 100%; background: var(--yellow); box-shadow: 0 0 9px var(--yellow); transform-origin: right; }

.overlay {
  position: fixed;
  z-index: 30;
  inset: 0;
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  align-items: center;
  gap: 7vw;
  padding: 10vh 10vw;
  visibility: hidden;
  opacity: 0;
  background:
    linear-gradient(115deg, rgba(255, 93, 162, 0.08), transparent 35%),
    radial-gradient(circle at 80% 30%, rgba(104, 239, 255, 0.08), transparent 30%),
    rgba(7, 6, 11, 0.95);
  backdrop-filter: blur(13px);
  transition: opacity 480ms ease, visibility 480ms;
}
.overlay.is-visible { visibility: visible; opacity: 1; }

.poster { position: relative; }
.poster-index { color: var(--pink); font: 400 8px/1 "DM Mono", monospace; letter-spacing: 0.2em; }
h1,
h2 { margin: 24px 0; font-weight: 600; line-height: 0.72; letter-spacing: -0.09em; }
h1 { font-size: clamp(84px, 11vw, 168px); }
h1 span { color: transparent; -webkit-text-stroke: 1px rgba(247, 243, 233, 0.75); }
.poster p { margin: 30px 0 18px; color: var(--muted); font: 300 8px/1 "DM Mono", monospace; letter-spacing: 0.24em; }
.spectrum { width: min(430px, 100%); height: 5px; display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.spectrum i:nth-child(1) { background: var(--pink); }
.spectrum i:nth-child(2) { background: var(--orange); }
.spectrum i:nth-child(3) { background: var(--yellow); }
.spectrum i:nth-child(4) { background: var(--cyan); }
.spectrum i:nth-child(5) { background: var(--violet); }

.briefing { position: relative; max-width: 410px; padding: 34px; border: 1px solid var(--line); background: rgba(12, 10, 17, 0.72); box-shadow: 0 26px 80px rgba(0, 0, 0, 0.34); }
.briefing::after { content: ""; position: absolute; top: -1px; right: 32px; width: 70px; height: 2px; background: var(--cyan); box-shadow: 0 0 14px var(--cyan); }
.briefing-label { margin-bottom: 24px; color: var(--cyan); font: 400 7px/1 "DM Mono", monospace; letter-spacing: 0.18em; }
.briefing p { margin: 0 0 28px; color: #96909d; font-size: 13px; line-height: 1.7; }
.control-list { display: grid; gap: 9px; margin-bottom: 28px; }
.control-list div { display: flex; align-items: center; justify-content: space-between; padding-bottom: 9px; border-bottom: 1px solid rgba(255,255,255,0.07); color: var(--muted); font: 300 7px/1 "DM Mono", monospace; letter-spacing: 0.11em; }
kbd { color: var(--paper); background: none; font: 400 8px/1 "DM Mono", monospace; }
.primary-button { width: 100%; height: 56px; display: flex; align-items: center; justify-content: space-between; padding: 0 19px; border: 1px solid var(--paper); color: var(--void); background: var(--paper); font: 500 9px/1 "DM Mono", monospace; letter-spacing: 0.16em; cursor: pointer; transition: background 160ms ease, border-color 160ms ease; }
.primary-button:hover { border-color: var(--yellow); background: var(--yellow); }
.primary-button span { font-size: 17px; }
.briefing small { display: block; margin-top: 12px; color: #4f4b55; text-align: center; font: 300 6px/1 "DM Mono", monospace; letter-spacing: 0.12em; }

.result-overlay { grid-template-columns: 1fr; place-items: center; text-align: center; }
.result-copy { width: min(560px, 90vw); }
.result-kicker { color: var(--pink); font: 400 8px/1 "DM Mono", monospace; letter-spacing: 0.2em; }
h2 { font-size: clamp(76px, 10vw, 138px); }
.result-score { display: flex; align-items: center; justify-content: space-between; margin: 35px 0 24px; padding-block: 18px; border-block: 1px solid var(--line); font-family: "DM Mono", monospace; }
.result-score span { color: var(--muted); font-size: 7px; letter-spacing: 0.14em; }
.result-score strong { color: var(--yellow); font-size: 24px; font-weight: 300; }

.pause-card,
.stage-card { position: fixed; z-index: 24; top: 50%; left: 50%; width: min(330px, 86vw); display: grid; gap: 11px; padding: 28px; transform: translate(-50%, -50%) scale(0.94); visibility: hidden; opacity: 0; border: 1px solid var(--line); background: rgba(7, 6, 11, 0.9); text-align: center; backdrop-filter: blur(11px); transition: 180ms ease; }
.pause-card.is-visible,
.stage-card.is-visible { visibility: visible; opacity: 1; transform: translate(-50%, -50%) scale(1); }
.pause-card span,
.pause-card small,
.stage-card span,
.stage-card small { color: var(--muted); font: 300 7px/1 "DM Mono", monospace; letter-spacing: 0.15em; }
.pause-card b,
.stage-card b { font-size: 30px; letter-spacing: -0.04em; }
.stage-card span { color: var(--cyan); }

.launch-hint { position: fixed; z-index: 10; left: 50%; bottom: 36px; transform: translateX(-50%); visibility: hidden; opacity: 0; color: var(--yellow); font: 400 7px/1 "DM Mono", monospace; letter-spacing: 0.16em; transition: opacity 180ms ease; }
.launch-hint.is-visible { visibility: visible; opacity: 1; animation: blink 1.2s ease-in-out infinite; }
@keyframes blink { 50% { opacity: 0.38; } }

footer { position: fixed; z-index: 10; right: 0; bottom: 0; left: 0; height: 20px; display: flex; align-items: center; justify-content: space-between; padding: 0 13px; border-top: 1px solid rgba(247, 243, 233, 0.08); color: #48434d; font: 300 6px/1 "DM Mono", monospace; letter-spacing: 0.12em; }

@media (max-width: 740px) {
  .topbar { height: 60px; padding: 0 15px; }
  .logo small { display: none; }
  .stage-readout > span { display: none; }
  .sound-button span { display: none; }
  .hud-panel { top: 78px; }
  .score-panel { left: 15px; }
  .lives-panel { right: 15px; }
  .combo-panel { top: 150px; left: 15px; }
  .power-panel { top: 150px; right: 15px; }
  .overlay { grid-template-columns: 1fr; align-content: center; gap: 35px; padding: 7vh 7vw; overflow-y: auto; }
  h1 { margin-block: 18px; font-size: clamp(72px, 22vw, 112px); }
  .poster p { margin-top: 22px; }
  .briefing { max-width: none; padding: 24px; }
  .briefing p { display: none; }
  .control-list { grid-template-columns: repeat(3, 1fr); }
  .control-list div { display: grid; justify-content: center; gap: 7px; text-align: center; border: 0; }
  footer span:nth-child(2) { display: none; }
}

@media (max-height: 680px) and (min-width: 741px) {
  .overlay { padding-block: 7vh; }
  h1 { font-size: min(20vh, 130px); }
  .briefing p { margin-bottom: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  .overlay,
  .pause-card,
  .stage-card { transition: none; }
  .launch-hint.is-visible { animation: none; }
}
