:root {
  color-scheme: dark;
  --bg: #09090b;
  --surface: #15171b;
  --line: #3a414a;
  --text: #edf1f7;
  --muted: #aeb6c2;
  --accent: #ffcf66;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 18% 0%, rgba(255, 80, 121, 0.16), transparent 25rem),
    radial-gradient(circle at 82% 12%, rgba(78, 211, 255, 0.14), transparent 24rem),
    linear-gradient(180deg, #101012 0%, #070708 100%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-user-select: none;
  user-select: none;
}

.app-shell {
  width: min(100%, 1340px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 14px;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 12px;
}

.topbar {
  min-height: 52px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.status-text {
  margin: 0 auto 0 0;
  color: #ffe6a8;
  font-size: 0.98rem;
  font-weight: 780;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.text-button {
  appearance: none;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: rgba(21, 23, 27, 0.9);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}

.text-button:hover {
  border-color: #74808f;
}

.text-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.text-button[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #17120a;
  font-weight: 800;
}

.alley-stage {
  width: 100%;
  min-height: calc(100vh - 94px);
  display: grid;
  place-items: center;
  overflow: auto;
  overscroll-behavior: contain;
}

canvas {
  width: min(100%, 1280px);
  min-width: 860px;
  height: auto;
  border: 1px solid #303640;
  background: #050507;
  box-shadow: 0 22px 76px rgba(0, 0, 0, 0.48);
  touch-action: none;
}

.start-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(3, 4, 7, 0.74);
}

.start-overlay[hidden] {
  display: none;
}

.start-window {
  width: min(540px, 100%);
  border: 1px solid #46505d;
  border-radius: 8px;
  padding: 24px;
  background:
    linear-gradient(180deg, rgba(28, 30, 36, 0.98), rgba(12, 13, 17, 0.98));
  box-shadow: 0 26px 90px rgba(0, 0, 0, 0.68);
}

.start-kicker {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
}

.start-window h1 {
  margin: 0 0 12px;
  color: #ffe6a8;
  font-size: clamp(2rem, 8vw, 3.4rem);
  line-height: 0.95;
}

.start-copy,
.how-to-play p {
  margin: 0;
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.55;
}

.how-to-play {
  display: grid;
  gap: 8px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid #303640;
}

.start-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.start-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #17120a;
  font-weight: 850;
}

.test-controls {
  display: none;
}

body.is-test-mode .test-controls {
  position: fixed;
  left: 8px;
  bottom: 8px;
  z-index: 100;
  display: flex;
  gap: 6px;
  opacity: 0.04;
}

body.is-test-mode .test-controls:focus-within,
body.is-test-mode .test-controls:hover {
  opacity: 0.8;
}

.test-controls button {
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #15171b;
  color: var(--text);
  font: inherit;
  font-size: 12px;
}

@media (max-width: 920px) {
  .app-shell {
    padding: 10px;
  }

  .topbar {
    min-height: 86px;
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .top-actions {
    width: 100%;
    justify-content: space-between;
  }

  .text-button {
    min-height: 40px;
  }

  .alley-stage {
    min-height: calc(100vh - 112px);
    place-items: start center;
  }

  canvas {
    min-width: 720px;
  }
}
