:root {
  --bg-deep: #0b1120;
  --bg-panel: #111827;
  --bg-card: #1e293b;
  --border-subtle: #334155;
  --text-main: #f8fafc;
  --text-muted: #cbd5e1;
  --accent-sky: #38bdf8;
  --btn-blue: #0369a1;
  --btn-blue-hover: #0284c7;
  --btn-amber: #c2410c;
  --btn-emerald: #15803d;
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-deep);
  color: var(--text-main);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.38;
}

.app-shell {
  max-width: 1012px;
  margin: 0 auto;
  padding: 8px 12px 14px;
}

.top-header {
  margin-bottom: 8px;
}

.title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

h1 {
  margin: 0;
  font-size: 1.24rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #f8fafc;
}

.badge-pill {
  font-size: 0.74rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  background: #0f172a;
  color: #7dd3fc;
  border: 1px solid #0369a1;
}

.lede {
  margin: 4px 0 7px;
  font-size: 0.83rem;
  color: var(--text-muted);
}

.action-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

button {
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: 7px;
  padding: 5px 10px;
  cursor: pointer;
  border: 1px solid var(--border-subtle);
  background: var(--bg-card);
  color: var(--text-main);
  transition: background 0.14s ease, border-color 0.14s ease;
}

button:hover {
  border-color: var(--accent-sky);
}

button:focus-visible, input:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent-sky);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--btn-blue);
  color: #ffffff;
  border-color: #38bdf8;
}

.btn-amber {
  background: var(--btn-amber);
  color: #ffffff;
  border-color: #fb923c;
}

.btn-emerald {
  background: var(--btn-emerald);
  color: #ffffff;
  border-color: #4ade80;
}

.studio-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.56fr) minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  isolation: isolate;
}

.canvas-column, .controls-column {
  min-width: 0;
}

.canvas-frame {
  position: relative;
  width: 100%;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  background: #0f172a;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.42);
}

#grassCanvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 720 / 430;
  touch-action: none;
  cursor: grab;
}

#grassCanvas:active {
  cursor: grabbing;
}

.hud-pill {
  position: absolute;
  right: 8px;
  bottom: 8px;
  background: rgba(11, 17, 32, 0.86);
  color: #f8fafc;
  border: 1px solid rgba(125, 211, 252, 0.48);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 0.72rem;
  font-weight: 600;
  pointer-events: none;
  max-width: calc(100% - 16px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.telemetry-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin-top: 7px;
}

.stat-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 5px 8px;
  min-width: 0;
}

.stat-label {
  display: block;
  font-size: 0.63rem;
  letter-spacing: 0.04em;
  color: #94a3b8;
}

.stat-card strong {
  display: block;
  font-size: 0.76rem;
  color: #f8fafc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.controls-column {
  display: flex;
  flex-direction: column;
  gap: 7px;
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 8px 9px;
}

.control-group h2 {
  margin: 0 0 5px;
  font-size: 0.76rem;
  color: #7dd3fc;
  font-weight: 700;
}

.btn-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px;
}

.choice-btn {
  text-align: left;
  font-size: 0.72rem;
  padding: 5px 7px;
  background: #162033;
  color: #f1f5f9;
  border: 1px solid #334155;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.choice-btn.active {
  background: var(--btn-blue);
  color: #ffffff;
  border-color: #7dd3fc;
}

.full-width-btn {
  width: 100%;
  margin-top: 5px;
  text-align: center;
}

.slider-row {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) 54px;
  align-items: center;
  gap: 6px;
  font-size: 0.73rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.slider-row input[type="range"] {
  width: 100%;
  accent-color: #38bdf8;
}

.slider-row output {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: #f8fafc;
  font-size: 0.72rem;
}

kbd, code {
  background: #1e293b;
  border: 1px solid #475569;
  border-radius: 4px;
  padding: 0 4px;
  font-size: 0.72rem;
  color: #e2e8f0;
}

.studio-footer {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid #1e293b;
  font-size: 0.76rem;
  color: var(--text-muted);
}

.studio-footer p {
  margin: 0 0 5px;
}

.studio-footer a {
  color: #7dd3fc;
  text-decoration: underline;
}

@media (max-width: 760px) {
  .app-shell {
    padding: 5px 7px 12px;
  }
  h1 {
    font-size: 1.02rem;
  }
  .badge-pill {
    font-size: 0.64rem;
    padding: 2px 7px;
  }
  .lede {
    font-size: 0.71rem;
    margin: 3px 0 5px;
    line-height: 1.28;
  }
  .action-strip {
    gap: 4px;
  }
  .action-strip button {
    font-size: 0.65rem;
    padding: 3px 6px;
  }
  .studio-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
  }
  .telemetry-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .hud-pill {
    font-size: 0.63rem;
    padding: 2px 7px;
  }
}
