:root {
  color-scheme: dark;
  --bg: #06111f;
  --panel: rgba(8, 14, 28, 0.76);
  --panel-strong: rgba(10, 18, 34, 0.92);
  --line: rgba(154, 185, 255, 0.18);
  --text: rgba(246, 249, 255, 0.92);
  --muted: rgba(198, 211, 232, 0.68);
  --faint: rgba(198, 211, 232, 0.44);
  --arc: #9b7cff;
  --energy: #ffd166;
  --success: #55e6a5;
  --danger: #ff6b7c;
  --cyan: #62e8ff;
  --shadow: 0 28px 80px rgba(0, 0, 0, 0.42);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 18% 10%, rgba(155, 124, 255, 0.26), transparent 30%),
    radial-gradient(circle at 78% 12%, rgba(98, 232, 255, 0.18), transparent 32%),
    linear-gradient(145deg, #05101d 0%, #081827 54%, #0d1120 100%);
  color: var(--text);
  font-family: "Chakra Petch", "Avenir Next Condensed", "Trebuchet MS", system-ui, sans-serif;
}

body::before {
  position: fixed;
  inset: 0;
  pointer-events: none;
  content: "";
  opacity: 0.26;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: 36px 36px;
  mask-image: radial-gradient(circle at center, black 0%, transparent 76%);
}

button {
  font: inherit;
}

.game-shell {
  position: relative;
  width: 100vw;
  height: 100dvh;
  min-height: 620px;
  overflow: hidden;
}

.stage {
  position: absolute;
  inset: 0;
}

.stage canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.topbar,
.hud,
.toolbar,
.event-log,
.start-card,
.summary-card {
  position: absolute;
  z-index: 2;
}

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

.brand-lockup {
  max-width: min(620px, 66vw);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  color: var(--cyan);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.eyebrow::before {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  content: "";
  background: var(--success);
  box-shadow: 0 0 18px rgba(85, 230, 165, 0.8);
}

h1 {
  margin: 0;
  color: #fff;
  font-size: clamp(30px, 5vw, 70px);
  line-height: 0.92;
  letter-spacing: -0.055em;
  text-shadow: 0 12px 46px rgba(0, 0, 0, 0.56);
}

.subtitle {
  max-width: 560px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: clamp(14px, 1.2vw, 18px);
  line-height: 1.45;
}

.hud {
  top: 154px;
  left: 22px;
  display: grid;
  width: min(310px, calc(100vw - 44px));
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  pointer-events: none;
}

.hud-card,
.status-pill {
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
}

.hud-card {
  min-height: 74px;
  padding: 12px 13px;
  border-radius: 18px;
}

.hud-label {
  display: block;
  color: var(--faint);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.hud-value {
  display: block;
  margin-top: 6px;
  color: #fff;
  font-size: 24px;
  font-weight: 850;
  letter-spacing: -0.03em;
}

.hud-value.good {
  color: var(--success);
}

.hud-value.warn {
  color: var(--energy);
}

.hud-value.danger {
  color: var(--danger);
}

.status-pill {
  min-width: 260px;
  max-width: 360px;
  padding: 13px 15px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
  text-align: right;
}

.toolbar {
  right: 22px;
  bottom: 22px;
  left: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  pointer-events: none;
}

.tool-button,
.action-button {
  min-height: 46px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 16px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.03)),
    rgba(11, 18, 35, 0.82);
  color: var(--text);
  cursor: pointer;
  pointer-events: auto;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.32);
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    background 160ms ease,
    box-shadow 160ms ease;
}

.tool-button {
  min-width: 122px;
  padding: 9px 13px;
  text-align: left;
}

.action-button {
  padding: 0 17px;
  font-weight: 850;
}

.tool-button:hover,
.action-button:hover,
.tool-button:focus-visible,
.action-button:focus-visible {
  border-color: rgba(98, 232, 255, 0.58);
  outline: none;
  transform: translateY(-2px);
  box-shadow: 0 18px 48px rgba(98, 232, 255, 0.16);
}

.tool-button[aria-pressed="true"] {
  border-color: rgba(255, 209, 102, 0.78);
  background:
    linear-gradient(180deg, rgba(255, 209, 102, 0.22), rgba(155, 124, 255, 0.12)),
    rgba(15, 22, 38, 0.92);
}

.tool-kicker {
  display: block;
  color: var(--faint);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.tool-name {
  display: block;
  margin-top: 2px;
  color: #fff;
  font-size: 15px;
  font-weight: 820;
}

.event-log {
  right: 22px;
  bottom: 92px;
  display: grid;
  width: min(390px, calc(100vw - 44px));
  gap: 7px;
  pointer-events: none;
}

.log-line {
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  background: rgba(6, 12, 24, 0.68);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
  backdrop-filter: blur(14px);
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  padding: 28px;
  background: radial-gradient(circle at center, rgba(7, 11, 22, 0.1), rgba(2, 5, 12, 0.72));
}

.overlay[hidden] {
  display: none;
}

.start-card,
.summary-card {
  position: relative;
  width: min(560px, calc(100vw - 40px));
  padding: 28px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 28px;
  background:
    radial-gradient(circle at 20% 0%, rgba(98, 232, 255, 0.2), transparent 38%),
    linear-gradient(145deg, rgba(16, 23, 42, 0.94), rgba(7, 11, 23, 0.92));
  box-shadow: 0 28px 100px rgba(0, 0, 0, 0.62);
  text-align: left;
}

.start-card h2,
.summary-card h2 {
  margin: 0 0 10px;
  color: #fff;
  font-size: clamp(28px, 4vw, 46px);
  line-height: 0.98;
  letter-spacing: -0.045em;
}

.start-card p,
.summary-card p {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.55;
}

.start-card ul,
.summary-card ul {
  margin: 0 0 22px;
  padding-left: 19px;
  color: var(--muted);
  line-height: 1.55;
}

.primary-start {
  min-height: 50px;
  padding: 0 20px;
  border: 0;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--energy), #ff9d66 52%, var(--arc));
  color: #100d1d;
  cursor: pointer;
  font-weight: 900;
  letter-spacing: -0.015em;
  box-shadow: 0 18px 44px rgba(255, 209, 102, 0.22);
}

.primary-start:focus-visible {
  outline: 3px solid rgba(255, 255, 255, 0.72);
  outline-offset: 3px;
}

.fatal {
  position: absolute;
  inset: 22px;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 24px;
  border: 1px solid rgba(255, 107, 124, 0.5);
  border-radius: 28px;
  background: rgba(29, 8, 14, 0.92);
  color: #fff;
  text-align: center;
}

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

  .topbar {
    top: 14px;
    left: 14px;
    right: 14px;
    display: block;
  }

  .brand-lockup {
    max-width: 100%;
  }

  .status-pill {
    margin-top: 10px;
    max-width: 100%;
    text-align: left;
  }

  .hud {
    top: auto;
    bottom: 228px;
    left: 14px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    width: calc(100vw - 28px);
    gap: 7px;
  }

  .hud-card {
    min-height: 58px;
    padding: 8px;
    border-radius: 13px;
  }

  .hud-label {
    font-size: 8px;
  }

  .hud-value {
    font-size: 16px;
  }

  .toolbar {
    right: 14px;
    bottom: 14px;
    left: 14px;
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .tool-button {
    min-width: calc(50% - 6px);
    flex: 1 1 calc(50% - 6px);
  }

  .event-log {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
