:root {
  color-scheme: dark;
  --ink: #091116;
  --panel: rgba(9, 17, 22, 0.78);
  --panel-strong: rgba(18, 31, 38, 0.92);
  --text: #f4f7ef;
  --muted: #b6c2bd;
  --line: rgba(255, 255, 255, 0.18);
  --accent: #69d7b0;
  --amber: #f3b34f;
  --cyan: #4fd4df;
  --rose: #f06c8e;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--ink);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  min-height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  padding: 0 14px;
  background: var(--panel-strong);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

button:hover,
button:focus-visible {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px rgba(105, 215, 176, 0.22);
}

.shell {
  position: relative;
  width: 100vw;
  height: 100vh;
  min-height: 560px;
  isolation: isolate;
}

#gameCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  background:
    radial-gradient(circle at 18% 24%, rgba(79, 212, 223, 0.18), transparent 28%),
    radial-gradient(circle at 80% 18%, rgba(243, 179, 79, 0.16), transparent 30%),
    radial-gradient(circle at 72% 78%, rgba(240, 108, 142, 0.16), transparent 34%),
    linear-gradient(155deg, #0a1115 0%, #102129 46%, #17131a 100%);
}

.hud {
  position: absolute;
  left: clamp(14px, 3vw, 32px);
  right: clamp(14px, 3vw, 32px);
  top: clamp(14px, 3vw, 28px);
  display: grid;
  gap: 12px;
  max-width: 900px;
  padding: clamp(14px, 2.2vw, 22px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  backdrop-filter: blur(14px);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
  z-index: 2;
}

.topline {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

h1 {
  margin: 0;
  font-size: clamp(1.85rem, 3vw, 3rem);
  line-height: 1;
  letter-spacing: 0;
}

p {
  margin: 0;
}

#phaseText {
  margin-top: 7px;
  color: var(--muted);
  font-size: clamp(0.98rem, 1.4vw, 1.08rem);
  line-height: 1.35;
}

.objective {
  color: #eaf0e9;
  font-size: clamp(0.98rem, 1.35vw, 1.08rem);
  line-height: 1.45;
}

.meterRow {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.meterBlock {
  display: grid;
  grid-template-columns: auto minmax(64px, 1fr) 44px;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.meterLabel,
.meterValue,
.controls {
  font-size: 0.92rem;
}

.meterLabel {
  color: var(--muted);
  font-weight: 700;
}

.meterValue {
  text-align: right;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.meterTrack {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
}

.meterTrack span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  transition: width 140ms ease-out;
}

#meter0 {
  background: linear-gradient(90deg, #b97825, var(--amber));
}

#meter1 {
  background: linear-gradient(90deg, #287f9a, var(--cyan));
}

#meter2 {
  background: linear-gradient(90deg, #a93b6e, var(--rose));
}

.controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 16px;
  color: var(--muted);
}

.controls span {
  min-height: 24px;
  display: inline-flex;
  align-items: center;
}

@media (max-width: 760px) {
  .shell {
    min-height: 640px;
  }

  .hud {
    max-width: none;
  }

  .topline {
    align-items: stretch;
  }

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

@media (max-width: 520px) {
  .hud {
    padding: 12px;
  }

  .topline {
    flex-direction: column;
  }

  button {
    width: 100%;
  }

  .controls {
    align-items: stretch;
  }

  .controls span {
    width: 100%;
  }
}
