:root {
  color-scheme: dark;
  --bg: #020608;
  --panel: rgba(2, 16, 16, 0.72);
  --aura: rgba(33, 255, 212, 0.12);
  --line: rgba(95, 255, 214, 0.48);
  --line-soft: rgba(95, 255, 214, 0.16);
  --text: #dbfff4;
  --muted: #7fcdbd;
  --good: #5dffc9;
  --warn: #ffc857;
  --bad: #ff5a66;
}

body[data-theme="blue"] {
  --panel: rgba(2, 13, 24, 0.74);
  --aura: rgba(54, 172, 255, 0.14);
  --line: rgba(109, 197, 255, 0.58);
  --line-soft: rgba(109, 197, 255, 0.2);
  --text: #e6f7ff;
  --muted: #98d7ff;
  --good: #65c7ff;
}

body[data-theme="yellow"] {
  --panel: rgba(24, 20, 2, 0.74);
  --aura: rgba(255, 215, 90, 0.13);
  --line: rgba(255, 215, 90, 0.58);
  --line-soft: rgba(255, 215, 90, 0.2);
  --text: #fff8da;
  --muted: #f1d47c;
  --good: #ffdd66;
}

body[data-theme="purple"] {
  --panel: rgba(16, 7, 24, 0.74);
  --aura: rgba(200, 150, 255, 0.14);
  --line: rgba(200, 150, 255, 0.58);
  --line-soft: rgba(200, 150, 255, 0.2);
  --text: #f8edff;
  --muted: #d9b8ff;
  --good: #c896ff;
}

body[data-theme="red"] {
  --panel: rgba(24, 5, 8, 0.74);
  --aura: rgba(255, 89, 110, 0.14);
  --line: rgba(255, 89, 110, 0.58);
  --line-soft: rgba(255, 89, 110, 0.2);
  --text: #ffe6ea;
  --muted: #ff9dac;
  --good: #ff6b7c;
}

body[data-theme="white"] {
  --panel: rgba(12, 16, 16, 0.76);
  --aura: rgba(255, 255, 255, 0.12);
  --line: rgba(244, 255, 248, 0.58);
  --line-soft: rgba(244, 255, 248, 0.2);
  --text: #ffffff;
  --muted: #dce8e2;
  --good: #f4fff8;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 48%, var(--aura), transparent 32rem),
    linear-gradient(180deg, #02100f 0%, var(--bg) 58%);
  color: var(--text);
  font-family:
    "Inter",
    "Segoe UI",
    system-ui,
    -apple-system,
    sans-serif;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  content: "";
  background:
    repeating-linear-gradient(
      180deg,
      rgba(255, 255, 255, 0.035) 0,
      rgba(255, 255, 255, 0.035) 1px,
      transparent 1px,
      transparent 4px
    );
  mix-blend-mode: screen;
  opacity: 0.38;
}

#game-shell {
  position: relative;
  width: 100vw;
  height: 100vh;
}

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

.rank-banner {
  position: relative;
  z-index: 5;
  display: grid;
  width: 100%;
  min-width: 0;
  margin: 0 0 0.85rem;
  padding: 0.8rem 1rem;
  border: 1px solid var(--good);
  background: rgba(2, 16, 16, 0.86);
  box-shadow:
    0 0 32px rgba(93, 255, 201, 0.28),
    inset 0 0 24px rgba(93, 255, 201, 0.12);
  color: var(--text);
  text-align: center;
  text-shadow: 0 0 12px rgba(93, 255, 201, 0.55);
  pointer-events: none;
}

.rank-banner[hidden] {
  display: none;
}

.rank-banner.show {
  animation: rank-banner-pop 3.2s ease both;
}

.rank-banner span {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 900;
}

.rank-banner strong {
  font-size: clamp(1rem, 2.5vw, 1.5rem);
  line-height: 1.15;
}

.hud {
  position: absolute;
  z-index: 3;
  display: flex;
  gap: 0.75rem;
  color: var(--text);
  text-shadow: 0 0 12px rgba(93, 255, 201, 0.45);
  pointer-events: none;
}

.hud-top {
  top: 1rem;
  left: 1rem;
  right: 1rem;
  align-items: center;
  justify-content: space-between;
}

.brand-lockup,
.pause-button,
.stat-group,
.ticker-shell,
#status-line,
.command-row button,
.review-window {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow:
    0 0 24px rgba(93, 255, 201, 0.08),
    inset 0 0 18px rgba(93, 255, 201, 0.06);
  backdrop-filter: blur(10px);
}

.brand-lockup {
  display: inline-flex;
  align-items: center;
  min-height: 2.5rem;
  padding: 0 0.8rem;
  gap: 0.55rem;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  white-space: nowrap;
}

.pause-button {
  min-height: 2.5rem;
  padding: 0 0.8rem;
  color: var(--text);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 900;
  cursor: pointer;
  pointer-events: auto;
}

.pause-button:hover {
  color: var(--bg);
  background: var(--good);
  text-shadow: none;
}

.scan-dot {
  width: 0.62rem;
  height: 0.62rem;
  border-radius: 50%;
  background: var(--good);
  box-shadow: 0 0 14px var(--good);
  animation: pulse 1.5s ease-in-out infinite;
}

.stat-group {
  display: grid;
  grid-template-columns: repeat(7, minmax(4.3rem, 1fr));
  min-height: 2.5rem;
}

.stat {
  display: grid;
  align-content: center;
  min-width: 0;
  padding: 0.34rem 0.72rem;
  border-left: 1px solid var(--line-soft);
}

.stat:first-child {
  border-left: 0;
}

.stat span {
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0;
}

.stat strong {
  font-size: 1rem;
  line-height: 1.05;
}

.hud-bottom {
  left: 1rem;
  right: 1rem;
  bottom: 1rem;
  flex-direction: column;
}

.command-row {
  display: flex;
  align-items: stretch;
  gap: 0.6rem;
}

#status-line {
  width: fit-content;
  max-width: min(42rem, calc(100vw - 2rem));
  min-height: 2.2rem;
  padding: 0.55rem 0.8rem;
  color: var(--good);
  font-size: 0.86rem;
  font-weight: 700;
}

.command-row button {
  min-height: 2.2rem;
  padding: 0 0.78rem;
  color: var(--text);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 900;
  cursor: pointer;
  pointer-events: auto;
}

.command-row button:disabled {
  cursor: default;
  opacity: 0.48;
}

.command-row button.locked {
  border-style: dashed;
  color: var(--muted);
}

.command-row button:not(:disabled):hover {
  color: var(--bg);
  background: var(--good);
  text-shadow: none;
}

.ticker-shell {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: stretch;
  min-height: 1.75rem;
  overflow: hidden;
}

.ticker-label {
  display: grid;
  place-items: center;
  min-width: 6.8rem;
  padding: 0 0.8rem;
  border-right: 1px solid var(--line);
  color: var(--bg);
  background: var(--good);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0;
}

.ticker-viewport {
  min-width: 0;
  overflow: hidden;
}

.ticker {
  display: inline-flex;
  align-items: center;
  gap: 1.2rem;
  min-width: max-content;
  height: 100%;
  padding: 0 0.72rem;
  overflow: hidden;
  white-space: nowrap;
  animation: tape-scroll 32s linear infinite;
}

.ticker-item {
  display: inline-flex;
  align-items: center;
  gap: 0.48rem;
  min-width: 0;
  max-width: 100%;
  color: #d9fff4;
  font-size: 0.78rem;
  line-height: 1;
  white-space: nowrap;
  text-transform: uppercase;
}

.ticker-item::before {
  display: inline-block;
  width: 0.42rem;
  height: 0.42rem;
  border-radius: 50%;
  content: "";
  background: var(--warn);
  box-shadow: 0 0 10px var(--warn);
}

.ticker-item.good::before {
  background: var(--good);
  box-shadow: 0 0 10px var(--good);
}

.ticker-item.bad::before {
  background: var(--bad);
  box-shadow: 0 0 10px var(--bad);
}

.review-panel {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: start center;
  padding: 1rem;
  overflow-y: auto;
  background: rgba(0, 8, 9, 0.58);
  pointer-events: auto;
}

.review-panel[hidden] {
  display: none;
}

.review-window {
  width: min(52rem, calc(100vw - 2rem));
  margin: 0 auto;
  padding: 1rem;
}

.review-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 1rem;
}

.review-kicker {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0;
}

.review-window h1 {
  margin: 0.3rem 0 0.7rem;
  font-size: clamp(1.35rem, 4vw, 2.4rem);
  line-height: 1;
  letter-spacing: 0;
}

.review-era {
  min-width: 12rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line-soft);
  color: var(--good);
  background: rgba(0, 0, 0, 0.18);
  font-size: 0.78rem;
  font-weight: 900;
  text-align: right;
}

.review-headline {
  margin: 0 0 0.85rem;
  padding: 0.68rem 0.75rem;
  border: 1px solid var(--line-soft);
  color: var(--text);
  background: rgba(0, 0, 0, 0.16);
  font-size: clamp(0.9rem, 2.2vw, 1.12rem);
  font-weight: 850;
  line-height: 1.25;
}

.grade-lockup {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.impact-log {
  display: grid;
  align-self: stretch;
  min-width: min(28rem, 52vw);
  margin-left: auto;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line-soft);
  background: rgba(0, 0, 0, 0.18);
  gap: 0.22rem;
}

.impact-log-title {
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 950;
}

.impact-row {
  display: flex;
  justify-content: space-between;
  gap: 0.7rem;
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.18;
}

.impact-row span {
  overflow-wrap: anywhere;
}

.impact-row strong {
  color: var(--bad);
  white-space: nowrap;
}

.impact-row.empty,
.impact-row.more {
  color: var(--muted);
}

#grade-readout {
  display: grid;
  place-items: center;
  width: 4.5rem;
  height: 4.5rem;
  border: 1px solid var(--line);
  color: var(--bg);
  background: var(--good);
  box-shadow: 0 0 24px var(--line);
  font-size: 3rem;
  font-weight: 950;
  line-height: 1;
}

#score-readout {
  color: var(--text);
  font-size: 1.2rem;
}

.review-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
}

.review-grid div {
  min-height: 4rem;
  padding: 0.65rem;
  border: 1px solid var(--line-soft);
  background: rgba(0, 0, 0, 0.16);
}

.review-grid span {
  display: block;
  margin-bottom: 0.28rem;
  color: var(--muted);
  font-size: 0.64rem;
  font-weight: 850;
}

.review-grid strong {
  color: var(--text);
  font-size: clamp(1rem, 2.2vw, 1.35rem);
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.review-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 0.9rem;
}

.perk-shop {
  margin-top: 0.9rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line-soft);
}

.shop-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.55rem;
}

.shop-head span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
}

.shop-head strong {
  color: var(--good);
  font-size: 0.95rem;
}

.perk-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.5rem;
}

.perk-grid button {
  display: grid;
  gap: 0.22rem;
  min-height: 3.2rem;
  border: 1px solid var(--line-soft);
  background: rgba(0, 0, 0, 0.18);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.perk-grid button:hover:not(:disabled) {
  border-color: var(--good);
  background: rgba(93, 255, 201, 0.12);
}

.perk-grid button:disabled {
  cursor: default;
  opacity: 0.48;
}

.perk-grid button.purchased {
  border-color: var(--good);
  background: rgba(93, 255, 201, 0.1);
  opacity: 1;
}

.perk-grid button.upgraded {
  animation: perk-upgrade-flash 0.95s ease both;
}

.perk-grid span {
  padding: 0.55rem 0.55rem 0;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 850;
}

.perk-grid strong {
  padding: 0 0.55rem 0.55rem;
  font-size: 0.95rem;
}

.review-actions button {
  min-height: 2.7rem;
  min-width: 11rem;
  border: 1px solid var(--line);
  background: rgba(2, 16, 16, 0.82);
  color: var(--text);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  pointer-events: auto;
}

.review-actions button:hover {
  border-color: var(--good);
  color: var(--bg);
  background: var(--good);
  text-shadow: none;
}

@keyframes pulse {
  50% {
    opacity: 0.5;
    transform: scale(0.7);
  }
}

@keyframes tape-scroll {
  0% {
    transform: translateX(0);
  }

  100% {
    transform: translateX(-50%);
  }
}

@keyframes perk-upgrade-flash {
  0% {
    box-shadow: 0 0 0 rgba(93, 255, 201, 0);
    transform: scale(1);
  }

  36% {
    border-color: var(--good);
    background: rgba(93, 255, 201, 0.22);
    box-shadow: 0 0 22px rgba(93, 255, 201, 0.5);
    transform: scale(1.035);
  }

  100% {
    transform: scale(1);
  }
}

@keyframes rank-banner-pop {
  0% {
    opacity: 0;
    transform: translateY(-0.5rem) scale(0.98);
  }

  14%,
  78% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }

  100% {
    opacity: 0;
    transform: translateY(-0.35rem) scale(0.99);
  }
}

@media (max-width: 720px) {
  .hud-top {
    align-items: stretch;
    flex-direction: column;
  }

  .brand-lockup {
    width: fit-content;
  }

  .stat-group {
    width: 100%;
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .stat {
    padding-inline: 0.5rem;
  }

  .ticker-shell {
    grid-template-columns: 1fr;
    min-height: 3.1rem;
  }

  .ticker-label {
    justify-content: start;
    min-height: 1.55rem;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .ticker {
    align-items: flex-start;
    height: 1.55rem;
  }

  .command-row {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  #status-line {
    width: 100%;
    grid-column: 1 / -1;
  }

  .review-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .review-head,
  .grade-lockup {
    align-items: stretch;
    flex-direction: column;
  }

  .review-era,
  .impact-log {
    width: 100%;
    min-width: 0;
    text-align: left;
  }

  .perk-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 460px) {
  .review-grid {
    grid-template-columns: 1fr;
  }

  .perk-grid {
    grid-template-columns: 1fr;
  }
}
