:root {
  --game-black: #050706;
  --game-panel: #0b100e;
  --game-paper: #f3f3e8;
  --game-signal: #d7ff32;
  --game-cyan: #52f6d3;
  --game-red: #ff4f69;
  --game-orange: #ffad4d;
  --game-muted: #7b837b;
  --game-line: rgba(215, 255, 50, 0.22);
}

.signal-rogue-page {
  background: var(--game-black);
}

.game-page {
  min-height: 100vh;
  overflow: hidden;
  background:
    radial-gradient(circle at 78% 3%, rgba(82, 246, 211, 0.07), transparent 24rem),
    var(--game-black);
  color: var(--game-paper);
}

.game-project-intro,
.game-manual {
  width: min(100% - 2rem, 92rem);
  margin-inline: auto;
}

.game-project-intro {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(18rem, 0.8fr);
  gap: 3rem;
  align-items: end;
  padding: clamp(3rem, 7vw, 7rem) 0 clamp(2rem, 4vw, 3.5rem);
}

.game-project-kicker,
.overlay-code {
  margin: 0 0 0.8rem;
  color: var(--game-signal);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.23em;
  text-transform: uppercase;
}

.game-project-intro h1 {
  margin: 0;
  color: var(--game-paper);
  font-size: clamp(4rem, 11vw, 10rem);
  letter-spacing: -0.085em;
  line-height: 0.72;
}

.game-project-intro h1 span,
.start-card h2 span {
  color: var(--game-signal);
}

.game-project-intro > p {
  max-width: 34rem;
  margin: 0;
  color: #9fa79e;
  font-size: clamp(0.85rem, 1.4vw, 1rem);
  line-height: 1.8;
}

.game-shell {
  position: relative;
  width: min(100% - 2rem, 92rem);
  height: min(78svh, 54rem);
  min-height: 38rem;
  margin: 0 auto clamp(5rem, 9vw, 9rem);
  overflow: hidden;
  border: 1px solid rgba(215, 255, 50, 0.32);
  background: var(--game-black);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.7),
    0 30px 100px rgba(0, 0, 0, 0.55),
    0 0 60px rgba(82, 246, 211, 0.04);
  color: var(--game-paper);
  contain: layout paint;
  user-select: none;
  touch-action: none;
}

.game-shell:fullscreen {
  width: 100vw;
  height: 100vh;
  min-height: 100vh;
  border: 0;
}

#game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

.game-scanlines,
.game-vignette,
.damage-flash {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.game-scanlines {
  z-index: 3;
  opacity: 0.18;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 3px,
    rgba(255, 255, 255, 0.018) 4px
  );
  mix-blend-mode: screen;
}

.game-vignette {
  z-index: 4;
  box-shadow: inset 0 0 140px 24px rgba(0, 0, 0, 0.76);
}

.damage-flash {
  z-index: 14;
  background: radial-gradient(circle at center, transparent 20%, rgba(255, 79, 105, 0.45));
  opacity: 0;
  transition: opacity 0.09s;
}

.damage-flash.is-active {
  opacity: 1;
}

.game-topbar {
  position: absolute;
  z-index: 8;
  top: 1rem;
  left: 1rem;
  display: flex;
  gap: 0.35rem;
  pointer-events: none;
}

.hud-block {
  min-width: 6.4rem;
  padding: 0.55rem 0.7rem 0.5rem;
  border: 1px solid rgba(215, 255, 50, 0.18);
  background: rgba(5, 7, 6, 0.72);
  backdrop-filter: blur(8px);
}

.hud-block span,
.game-status-panel span,
.result-grid span,
.result-score span {
  display: block;
  color: var(--game-muted);
  font-size: 0.48rem;
  font-weight: 700;
  letter-spacing: 0.14em;
}

.hud-block strong {
  display: block;
  margin-top: 0.12rem;
  color: var(--game-paper);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
}

.hud-wave strong,
#hud-combo {
  color: var(--game-signal);
}

.game-status-panel {
  position: absolute;
  z-index: 8;
  left: 1rem;
  bottom: 1rem;
  width: min(24rem, calc(100% - 2rem));
  padding: 0.85rem;
  border: 1px solid rgba(215, 255, 50, 0.18);
  background: rgba(5, 7, 6, 0.78);
  backdrop-filter: blur(8px);
  pointer-events: none;
}

.meter-row {
  display: grid;
  grid-template-columns: 3.5rem 1fr 2.3rem;
  gap: 0.65rem;
  align-items: center;
  margin-bottom: 0.38rem;
}

.meter-row > b {
  color: var(--game-paper);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.62rem;
  text-align: right;
}

.meter {
  height: 0.3rem;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.12);
}

.meter i {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--game-red);
  box-shadow: 0 0 12px rgba(255, 79, 105, 0.7);
  transform-origin: left;
  transition: width 0.15s;
}

.meter-shield i {
  background: var(--game-cyan);
  box-shadow: 0 0 12px rgba(82, 246, 211, 0.7);
}

.meter-xp i {
  background: var(--game-signal);
  box-shadow: 0 0 12px rgba(215, 255, 50, 0.55);
}

.meter-row-xp {
  margin-bottom: 0.75rem;
}

.ability-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.35rem;
}

.ability-row > div {
  position: relative;
  min-width: 0;
  padding: 0.45rem 0.5rem 0.4rem;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.09);
}

.ability-row kbd {
  display: block;
  color: var(--game-paper);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.5rem;
  font-weight: 700;
}

.ability-row span {
  margin-top: 0.15rem;
  font-size: 0.42rem;
}

.ability-row i {
  position: absolute;
  inset: auto 0 0;
  height: 2px;
  background: var(--game-signal);
  transform-origin: left;
}

.boss-hud {
  position: absolute;
  z-index: 8;
  top: 1.15rem;
  left: 50%;
  width: min(30rem, 42vw);
  transform: translateX(-50%);
  pointer-events: none;
}

.boss-hud span {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--game-red);
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-align: center;
}

.boss-hud > div {
  height: 0.35rem;
  background: rgba(255, 255, 255, 0.11);
}

.boss-hud i {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--game-red);
  box-shadow: 0 0 16px rgba(255, 79, 105, 0.7);
}

.wave-clock {
  position: absolute;
  z-index: 8;
  top: 1rem;
  right: 1rem;
  width: 3.2rem;
  height: 3.2rem;
  pointer-events: none;
}

.wave-clock svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.wave-clock circle {
  fill: none;
  stroke: rgba(255, 255, 255, 0.1);
  stroke-width: 2;
}

.wave-clock #wave-ring {
  stroke: var(--game-signal);
  stroke-dasharray: 113.1;
  stroke-dashoffset: 0;
  stroke-linecap: square;
}

.wave-clock b {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--game-paper);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.68rem;
}

.game-toolbar {
  position: absolute;
  z-index: 12;
  right: 4.8rem;
  top: 1.35rem;
  display: flex;
  gap: 0.25rem;
}

.game-toolbar button {
  min-width: 2.25rem;
  height: 1.85rem;
  padding: 0 0.55rem;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(5, 7, 6, 0.72);
  color: #858d85;
  cursor: pointer;
  font-size: 0.43rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.game-toolbar button:hover,
.game-toolbar button.is-active {
  border-color: var(--game-signal);
  color: var(--game-signal);
}

.game-overlay {
  position: absolute;
  z-index: 20;
  inset: 0;
  display: grid;
  place-items: center;
  overflow-y: auto;
  padding: 1.5rem;
  background: rgba(3, 5, 4, 0.84);
  backdrop-filter: blur(12px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}

.game-overlay[hidden] {
  display: none;
}

.game-overlay.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.start-card,
.upgrade-card,
.pause-card,
.result-card {
  width: min(100%, 58rem);
  padding: clamp(1.5rem, 4vw, 3rem);
  border: 1px solid rgba(215, 255, 50, 0.3);
  background:
    linear-gradient(135deg, rgba(215, 255, 50, 0.035), transparent 45%),
    rgba(6, 9, 8, 0.94);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.5);
}

.start-card {
  position: relative;
  max-width: 52rem;
}

.start-mark {
  position: absolute;
  top: 2rem;
  right: 2rem;
  display: flex;
  gap: 0.25rem;
}

.start-mark i {
  width: 0.45rem;
  height: 0.45rem;
  background: var(--game-signal);
  animation: mark-pulse 1.6s infinite alternate;
}

.start-mark i:nth-child(2) { animation-delay: 0.25s; }
.start-mark i:nth-child(3) { animation-delay: 0.5s; }

@keyframes mark-pulse {
  to { opacity: 0.18; transform: translateY(0.2rem); }
}

.start-card h2,
.pause-card h2,
.result-card h2,
.upgrade-card h2 {
  margin: 0;
  color: var(--game-paper);
  font-size: clamp(2.5rem, 8vw, 6.4rem);
  letter-spacing: -0.075em;
  line-height: 0.85;
}

.upgrade-card h2 {
  font-size: clamp(2.2rem, 5vw, 4.5rem);
}

.start-copy,
.upgrade-card > p:not(.overlay-code) {
  max-width: 42rem;
  margin: 1.4rem 0 0;
  color: #9ca49c;
  font-size: 0.8rem;
  line-height: 1.8;
}

.control-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  margin-top: 1.6rem;
  background: rgba(255, 255, 255, 0.1);
}

.control-grid div {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem;
  background: #090d0b;
}

.control-grid kbd {
  color: var(--game-signal);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.55rem;
  font-weight: 700;
}

.control-grid span {
  color: #737b73;
  font-size: 0.55rem;
}

.difficulty-picker {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin: 1.5rem 0 0.75rem;
}

.difficulty {
  padding: 0.8rem;
  border: 1px solid rgba(255, 255, 255, 0.13);
  background: transparent;
  color: var(--game-paper);
  cursor: pointer;
  text-align: left;
}

.difficulty b,
.difficulty span {
  display: block;
}

.difficulty b {
  font-size: 0.62rem;
  letter-spacing: 0.12em;
}

.difficulty span {
  margin-top: 0.2rem;
  color: var(--game-muted);
  font-size: 0.52rem;
}

.difficulty:hover,
.difficulty.is-selected {
  border-color: var(--game-signal);
  background: rgba(215, 255, 50, 0.06);
}

.primary-action,
.ghost-action {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.6rem;
  padding: 0.95rem 1rem;
  border: 1px solid var(--game-signal);
  background: var(--game-signal);
  color: var(--game-black);
  cursor: pointer;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.13em;
}

.primary-action:hover {
  filter: brightness(1.12);
}

.ghost-action {
  border-color: rgba(255, 255, 255, 0.17);
  background: transparent;
  color: var(--game-muted);
}

.ghost-action:hover {
  border-color: var(--game-paper);
  color: var(--game-paper);
}

.start-note {
  margin: 0.8rem 0 0;
  color: #626962;
  font-size: 0.5rem;
  text-align: center;
}

.upgrade-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin-top: 2rem;
}

.upgrade-option {
  position: relative;
  min-height: 14rem;
  padding: 1.2rem;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.018);
  color: var(--game-paper);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.16s, background 0.16s, transform 0.16s;
}

.upgrade-option::after {
  position: absolute;
  right: -1.8rem;
  bottom: -2.2rem;
  width: 7rem;
  height: 7rem;
  border: 1px solid currentColor;
  border-radius: 50%;
  content: '';
  opacity: 0.12;
}

.upgrade-option:hover,
.upgrade-option:focus-visible {
  border-color: var(--game-signal);
  background: rgba(215, 255, 50, 0.05);
  transform: translateY(-0.25rem);
}

.upgrade-option small {
  display: block;
  color: var(--game-signal);
  font-size: 0.48rem;
  font-weight: 700;
  letter-spacing: 0.15em;
}

.upgrade-option b {
  display: block;
  margin-top: 2rem;
  color: var(--game-paper);
  font-size: 1.35rem;
  letter-spacing: -0.03em;
}

.upgrade-option p {
  margin: 0.75rem 0 0;
  color: #899189;
  font-size: 0.67rem;
  line-height: 1.6;
}

.upgrade-option em {
  position: absolute;
  bottom: 1rem;
  left: 1.2rem;
  color: #596059;
  font-size: 0.48rem;
  font-style: normal;
  letter-spacing: 0.1em;
}

.pause-card,
.result-card {
  max-width: 28rem;
  text-align: center;
}

.pause-card .overlay-code,
.result-card .overlay-code {
  text-align: left;
}

.result-score {
  margin: 2rem 0 1rem;
  padding: 1.25rem;
  border-block: 1px solid rgba(255, 255, 255, 0.12);
}

.result-score b {
  display: block;
  margin-top: 0.25rem;
  color: var(--game-signal);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 2.8rem;
  line-height: 1;
}

.result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  margin-bottom: 1rem;
  background: rgba(255, 255, 255, 0.1);
}

.result-grid > div {
  padding: 0.85rem;
  background: #080c0a;
}

.result-grid b {
  display: block;
  margin-top: 0.2rem;
  color: var(--game-paper);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85rem;
}

.result-record {
  margin: 0 0 1rem;
  color: var(--game-signal);
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.18em;
}

.announcement {
  position: absolute;
  z-index: 16;
  top: 50%;
  left: 50%;
  display: none;
  width: min(34rem, calc(100% - 3rem));
  padding: 1.1rem 1.4rem;
  border-block: 1px solid var(--game-signal);
  background: rgba(5, 7, 6, 0.82);
  transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: none;
}

.announcement.is-active {
  display: block;
  animation: announce 1.8s both;
}

.announcement small,
.announcement strong {
  display: block;
}

.announcement small {
  color: var(--game-signal);
  font-size: 0.52rem;
  font-weight: 700;
  letter-spacing: 0.18em;
}

.announcement strong {
  margin-top: 0.25rem;
  color: var(--game-paper);
  font-size: clamp(1.6rem, 5vw, 3.3rem);
  letter-spacing: -0.04em;
}

@keyframes announce {
  0% { opacity: 0; transform: translate(-50%, -50%) scaleX(0.2); }
  14%, 78% { opacity: 1; transform: translate(-50%, -50%) scaleX(1); }
  100% { opacity: 0; transform: translate(-50%, -50%) scaleX(1.25); }
}

.touch-controls {
  position: absolute;
  z-index: 10;
  inset: auto 0 0;
  display: none;
  height: 42%;
  align-items: end;
  justify-content: space-between;
  padding: 0 1rem 1rem;
  pointer-events: none;
}

.touch-stick {
  position: relative;
  width: 7.2rem;
  height: 7.2rem;
  border: 1px solid rgba(215, 255, 50, 0.24);
  border-radius: 50%;
  background: rgba(5, 7, 6, 0.32);
  pointer-events: auto;
}

.touch-stick i {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 2.8rem;
  height: 2.8rem;
  border: 1px solid rgba(215, 255, 50, 0.48);
  border-radius: 50%;
  background: rgba(215, 255, 50, 0.1);
  transform: translate(-50%, -50%);
}

.touch-stick span {
  position: absolute;
  bottom: -0.85rem;
  left: 50%;
  color: rgba(215, 255, 50, 0.45);
  font-size: 0.42rem;
  font-weight: 700;
  letter-spacing: 0.13em;
  transform: translateX(-50%);
  white-space: nowrap;
}

.touch-actions {
  display: flex;
  gap: 0.5rem;
  align-items: end;
  padding-bottom: 0.5rem;
  pointer-events: auto;
}

.touch-actions button {
  width: 3.7rem;
  height: 3.7rem;
  border: 1px solid rgba(215, 255, 50, 0.42);
  border-radius: 50%;
  background: rgba(5, 7, 6, 0.58);
  color: var(--game-signal);
  font-size: 0.48rem;
  font-weight: 700;
}

.game-manual {
  padding-bottom: clamp(5rem, 10vw, 10rem);
}

.game-manual > div:first-child {
  display: grid;
  grid-template-columns: 0.6fr 1.4fr;
  gap: 2rem;
  align-items: end;
  padding-bottom: 2rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.13);
}

.game-manual h2 {
  margin: 0;
  color: var(--game-paper);
  font-size: clamp(2.6rem, 7vw, 6.5rem);
  letter-spacing: -0.065em;
  line-height: 0.82;
}

.manual-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
}

.manual-grid article {
  min-height: 18rem;
  padding: 2rem 2rem 2rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.13);
}

.manual-grid article + article {
  padding-left: 2rem;
  border-left: 1px solid rgba(255, 255, 255, 0.13);
}

.manual-grid span {
  color: var(--game-signal);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.6rem;
}

.manual-grid h3 {
  margin: 4rem 0 0.75rem;
  color: var(--game-paper);
  font-size: 1.4rem;
  letter-spacing: -0.03em;
}

.manual-grid p {
  margin: 0;
  color: #8d958d;
  font-size: 0.75rem;
  line-height: 1.8;
}

@media (pointer: coarse), (max-width: 760px) {
  #game-canvas { cursor: default; }
  .touch-controls { display: flex; }
  .game-status-panel { bottom: auto; top: 4.8rem; width: 15rem; }
  .ability-row { display: none; }
  .meter-row { grid-template-columns: 3rem 1fr 2rem; }
  .game-toolbar { right: 4.3rem; }
  .game-toolbar #motion-button { display: none; }
}

@media (max-width: 900px) {
  .game-project-intro { grid-template-columns: 1fr; gap: 1.5rem; }
  .game-project-intro h1 { font-size: clamp(4rem, 18vw, 8rem); }
  .game-shell { height: 76svh; min-height: 34rem; }
  .hud-high { display: none; }
  .boss-hud { top: 4.9rem; width: min(24rem, 60vw); }
  .game-manual > div:first-child { grid-template-columns: 1fr; }
  .manual-grid { grid-template-columns: 1fr; }
  .manual-grid article { min-height: auto; padding: 2rem 0; }
  .manual-grid article + article { padding-left: 0; border-left: 0; }
  .manual-grid h3 { margin-top: 2rem; }
}

@media (max-width: 620px) {
  .game-project-intro,
  .game-manual,
  .game-shell { width: calc(100% - 1rem); }
  .game-project-intro { padding-top: 2.5rem; }
  .game-project-intro h1 { font-size: 20vw; }
  .game-shell { height: 78svh; min-height: 35rem; margin-bottom: 4rem; }
  .game-topbar { top: 0.55rem; left: 0.55rem; }
  .hud-block { min-width: 4.7rem; padding: 0.45rem; }
  .hud-block span { font-size: 0.4rem; }
  .hud-block strong { font-size: 0.62rem; }
  .game-toolbar { top: 0.75rem; right: 3.9rem; }
  .game-toolbar #mute-button,
  .game-toolbar #fullscreen-button { display: none; }
  .wave-clock { top: 0.55rem; right: 0.55rem; width: 2.9rem; height: 2.9rem; }
  .game-status-panel { top: 3.9rem; left: 0.55rem; width: 13.5rem; padding: 0.55rem; }
  .boss-hud { top: 7.5rem; width: 78vw; }
  .control-grid { grid-template-columns: 1fr 1fr; }
  .difficulty-picker { grid-template-columns: 1fr; }
  .start-card, .upgrade-card, .pause-card, .result-card { padding: 1.2rem; }
  .start-mark { display: none; }
  .start-card h2 { font-size: clamp(2.5rem, 14vw, 4.5rem); }
  .start-copy { font-size: 0.66rem; }
  .upgrade-grid { grid-template-columns: 1fr; }
  .upgrade-option { min-height: 8rem; }
  .upgrade-option b { margin-top: 0.8rem; }
  .upgrade-option em { position: static; display: block; margin-top: 0.8rem; }
  .touch-stick { width: 6.3rem; height: 6.3rem; }
  .touch-actions { flex-direction: column; }
  .touch-actions button { width: 3.2rem; height: 3.2rem; }
}

@media (max-height: 680px) and (orientation: landscape) {
  .game-shell { min-height: 30rem; height: calc(100svh - 4rem); }
  .start-card, .upgrade-card { padding: 1.2rem 1.5rem; }
  .start-card h2 { font-size: 3.5rem; }
  .start-copy { margin-top: 0.75rem; }
  .control-grid { margin-top: 0.8rem; }
  .difficulty-picker { margin-top: 0.8rem; }
  .upgrade-option { min-height: 10rem; }
  .touch-controls { height: 55%; }
}

@media (prefers-reduced-motion: reduce) {
  .start-mark i,
  .announcement.is-active { animation: none; }
  .announcement.is-active { opacity: 1; }
}
