:root {
  color-scheme: dark;
  --ink: #05080d;
  --panel: rgba(7, 14, 21, 0.78);
  --panel-strong: rgba(12, 22, 31, 0.9);
  --line: rgba(210, 232, 230, 0.2);
  --text: #f4fbf7;
  --muted: #aac0bf;
  --cyan: #2bd6b8;
  --gold: #f3b24d;
  --rose: #f05d5e;
  --blue: #6aa9ff;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 18% 22%, rgba(43, 214, 184, 0.14), transparent 30%),
    radial-gradient(circle at 84% 70%, rgba(243, 178, 77, 0.14), transparent 28%),
    var(--ink);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  min-height: 44px;
  border: 1px solid rgba(244, 251, 247, 0.28);
  border-radius: 8px;
  padding: 0 18px;
  background: rgba(9, 18, 27, 0.82);
  color: var(--text);
  font: inherit;
  font-weight: 750;
  cursor: pointer;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
}

button:hover {
  transform: translateY(-1px);
  border-color: rgba(43, 214, 184, 0.75);
  background: rgba(19, 35, 47, 0.92);
}

button:focus-visible {
  outline: 3px solid rgba(43, 214, 184, 0.52);
  outline-offset: 3px;
}

.game-shell {
  width: 100vw;
  min-height: 100svh;
}

.stage {
  position: relative;
  width: 100vw;
  min-height: 100svh;
  overflow: hidden;
  isolation: isolate;
  touch-action: none;
}

#gameCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  background: #05080d;
  touch-action: none;
}

.topbar,
.bottombar,
.result-overlay {
  position: absolute;
  z-index: 2;
}

.topbar {
  top: 18px;
  left: 18px;
  right: 18px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  pointer-events: none;
}

.brief-panel,
.meter-panel,
.result-panel,
.mechanic {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(12px);
}

.brief-panel {
  max-width: 440px;
  padding: 16px 18px 17px;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--cyan);
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: 1.72rem;
  line-height: 1.05;
}

h2 {
  margin-bottom: 10px;
  font-size: 1.55rem;
  line-height: 1.08;
}

.brief-panel p:last-child,
.result-panel p:last-of-type {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.45;
}

.meter-panel {
  width: 260px;
  padding: 14px;
}

.meter-row,
.stats {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.meter-row span,
.stats {
  color: var(--muted);
  font-size: 0.92rem;
}

.meter-row strong {
  color: var(--gold);
  font-size: 1.32rem;
}

.meter-track {
  width: 100%;
  height: 12px;
  margin: 10px 0;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
}

.meter-track span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--cyan), var(--gold), var(--rose));
  box-shadow: 0 0 18px rgba(43, 214, 184, 0.45);
}

.foil-bars {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
  margin-top: 12px;
}

.foil-bars span {
  position: relative;
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
}

.foil-bars i {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--cyan);
}

.bottombar {
  left: 18px;
  right: 18px;
  bottom: 18px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
}

.mechanic {
  max-width: 560px;
  margin: 0;
  padding: 13px 16px;
  color: var(--muted);
  line-height: 1.42;
}

.mechanic strong {
  color: var(--text);
}

.controls {
  display: flex;
  gap: 10px;
}

#pulseBtn {
  border-color: rgba(43, 214, 184, 0.55);
  background: rgba(20, 74, 70, 0.82);
}

.result-overlay {
  inset: 0;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(2, 5, 8, 0.32);
  pointer-events: auto;
}

.result-overlay.is-hidden {
  display: none;
}

.result-panel {
  width: min(420px, 100%);
  padding: 22px;
  background: var(--panel-strong);
}

.result-panel button {
  margin-top: 18px;
}

@media (max-width: 760px) {
  body {
    overflow: hidden;
  }

  .topbar {
    top: 10px;
    left: 10px;
    right: 10px;
    display: grid;
    grid-template-columns: 1fr;
  }

  .brief-panel {
    max-width: none;
    padding: 13px 14px;
  }

  .brief-panel p:last-child {
    font-size: 0.92rem;
  }

  h1 {
    font-size: 1.38rem;
  }

  .meter-panel {
    width: 100%;
    padding: 12px;
  }

  .bottombar {
    left: 10px;
    right: 10px;
    bottom: 10px;
    display: grid;
    grid-template-columns: 1fr;
  }

  .mechanic {
    max-width: none;
    padding: 12px 13px;
    font-size: 0.92rem;
  }

  .controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
}
