* {
  box-sizing: border-box;
}

:root {
  --bg: #09111f;
  --bg-soft: #0f1a2e;
  --panel: rgba(12, 21, 38, 0.86);
  --panel-2: rgba(16, 28, 48, 0.94);
  --panel-stroke: rgba(255, 255, 255, 0.08);
  --line: #79a6d8;
  --line-active: #9ed0ff;
  --text: #edf4ff;
  --muted: rgba(237, 244, 255, 0.66);
  --accent: #4da3ff;
  --accent-strong: #2f7fe0;
  --accent-soft: rgba(77, 163, 255, 0.14);
  --accent-2: #43c287;
  --button: rgba(255, 255, 255, 0.06);
  --button-hover: rgba(255, 255, 255, 0.11);
  --button-border: rgba(255, 255, 255, 0.10);
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.34);
  --shadow-soft: 0 14px 34px rgba(0, 0, 0, 0.24);
  --glow: 0 0 0 1px rgba(255, 255, 255, 0.03), 0 18px 50px rgba(77, 163, 255, 0.10);
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top, rgba(92, 157, 255, 0.18), transparent 24%),
    radial-gradient(circle at 20% 20%, rgba(67, 194, 135, 0.08), transparent 22%),
    linear-gradient(180deg, #08101d 0%, #0a1220 45%, #0c1626 100%);
  color: var(--text);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 18px;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.018) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.55), transparent 85%);
}

body.intro-mode {
  overflow: hidden;
}

.start-screen {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(circle at 50% 0%, rgba(77, 163, 255, 0.22), transparent 30%),
    radial-gradient(circle at 15% 30%, rgba(67, 194, 135, 0.10), transparent 22%),
    linear-gradient(180deg, rgba(8, 15, 27, 0.94) 0%, rgba(9, 17, 31, 0.97) 100%);
  z-index: 20;
}

.start-screen.visible {
  display: flex;
}

.start-card {
  position: relative;
  width: min(100%, 460px);
  padding: 36px 30px 30px;
  border-radius: 30px;
  background:
    linear-gradient(180deg, rgba(20, 32, 54, 0.92), rgba(12, 21, 38, 0.96));
  border: 1px solid rgba(255, 255, 255, 0.10);
  box-shadow: var(--shadow);
  text-align: centre;
  overflow: hidden;
}

.start-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at top right, rgba(77, 163, 255, 0.16), transparent 30%),
    radial-gradient(circle at bottom left, rgba(67, 194, 135, 0.08), transparent 26%);
  pointer-events: none;
}

.eyebrow {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(77, 163, 255, 0.12);
  border: 1px solid rgba(77, 163, 255, 0.18);
  color: #cfe6ff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.start-card h1 {
  position: relative;
  margin: 0 0 12px;
  font-size: 40px;
  line-height: 1.02;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: #ffffff;
  text-shadow: 0 6px 22px rgba(77, 163, 255, 0.16);
}

.start-card p {
  position: relative;
  margin: 0 0 24px;
  color: var(--muted);
  line-height: 1.65;
  font-size: 15px;
  max-width: 34ch;
  margin-inline: auto;
}

.start-cta {
  width: 100%;
}

.shell {
  width: min(100%, 520px);
  background:
    linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--panel-stroke);
  border-radius: 28px;
  padding: 16px;
  box-shadow: var(--shadow), var(--glow);
  backdrop-filter: blur(18px);
}

body.intro-mode .shell {
  display: none;
}

.topbar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 10px;
}

.stat {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.03));
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  padding: 11px 13px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin-bottom: 6px;
}

.value {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}

.subbar {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}

.budget {
  background:
    linear-gradient(180deg, rgba(77, 163, 255, 0.08), rgba(77, 163, 255, 0.04));
  border: 1px solid rgba(77, 163, 255, 0.14);
  border-radius: 18px;
  padding: 12px 13px;
}

.budget-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  color: #d7e8ff;
  font-weight: 600;
}

.playfield-wrap {
  position: relative;
  border-radius: 26px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.10);
  background:
    linear-gradient(180deg, rgba(245, 249, 255, 0.98), rgba(232, 239, 248, 0.98));
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.32),
    0 18px 40px rgba(0, 0, 0, 0.18);
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 10 / 16;
  max-height: 680px;
  touch-action: none;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(8, 14, 24, 0.42);
  backdrop-filter: blur(8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

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

.card {
  width: min(100%, 340px);
  border-radius: 22px;
  padding: 22px;
  background: linear-gradient(180deg, rgba(21, 32, 54, 0.98), rgba(13, 22, 38, 0.98));
  border: 1px solid rgba(255, 255, 255, 0.10);
  box-shadow: var(--shadow-soft);
  text-align: centre;
}

.card h2 {
  margin: 0 0 8px;
  font-size: 24px;
  font-weight: 750;
  color: #ffffff;
}

.card p {
  margin: 0 0 14px;
  color: var(--muted);
  line-height: 1.5;
  font-size: 14px;
}

.controls {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 12px;
}

button {
  border: 1px solid var(--button-border);
  background: var(--button);
  color: var(--text);
  border-radius: 14px;
  padding: 11px 14px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition:
    transform 120ms ease,
    background 120ms ease,
    border-color 120ms ease,
    opacity 120ms ease,
    box-shadow 120ms ease,
    filter 120ms ease;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.14);
  backdrop-filter: blur(10px);
}

button:hover {
  background: var(--button-hover);
  border-color: rgba(255, 255, 255, 0.18);
  box-shadow: 0 12px 22px rgba(0, 0, 0, 0.18);
}

button:active {
  transform: translateY(1px) scale(0.995);
}

button:disabled {
  opacity: 0.42;
  cursor: not-allowed;
  filter: grayscale(0.18);
}

.primary {
  background: linear-gradient(180deg, rgba(88, 173, 255, 1), rgba(47, 127, 224, 1));
  color: #ffffff;
  border-color: rgba(108, 183, 255, 0.55);
  box-shadow:
    0 14px 28px rgba(47, 127, 224, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.primary:hover {
  background: linear-gradient(180deg, rgba(102, 181, 255, 1), rgba(53, 135, 235, 1));
  border-color: rgba(147, 204, 255, 0.62);
}

.wide {
  grid-column: span 2;
}

@media (max-width: 560px) {
  .shell {
    padding: 14px;
    border-radius: 22px;
  }

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

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

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

  .wide {
    grid-column: span 1;
  }

  .start-card {
    padding: 32px 24px 24px;
    border-radius: 24px;
  }

  .start-card h1 {
    font-size: 34px;
  }
}