:root {
  --bg-0: #091409;
  --bg-1: #0f2612;
  --bg-2: #1f4725;
  --card: rgba(12, 23, 14, 0.78);
  --card-strong: rgba(13, 27, 16, 0.92);
  --line: rgba(184, 255, 163, 0.22);
  --line-strong: rgba(184, 255, 163, 0.38);
  --text: #efffe8;
  --muted: rgba(239, 255, 232, 0.72);
  --accent: #9cff7e;
  --accent-deep: #5fc15c;
  --warning: #ffd36b;
  --danger: #ff7868;
  --shadow: 0 28px 90px rgba(0, 0, 0, 0.5);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
}

body {
  font-family: 'Space Grotesk', 'Segoe UI', sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 12% 8%, rgba(126, 255, 173, 0.18), transparent 40%),
    radial-gradient(circle at 88% 78%, rgba(203, 255, 118, 0.14), transparent 38%),
    linear-gradient(145deg, var(--bg-0), var(--bg-1) 46%, var(--bg-2));
}

.shell {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: min(1500px, 100%);
  margin: 0 auto;
  padding: 18px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(120deg, rgba(14, 28, 17, 0.88), rgba(16, 39, 22, 0.74));
  box-shadow: var(--shadow);
}

.brand-block h1 {
  margin: 4px 0;
  font-family: 'Chakra Petch', sans-serif;
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1;
  letter-spacing: 0.02em;
}

.eyebrow {
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

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

.badge {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 12px;
  background: rgba(21, 44, 25, 0.72);
}

.badge.muted {
  color: var(--muted);
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 14px;
  min-height: 74vh;
}

.playfield-panel {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  background: radial-gradient(circle at 50% -20%, rgba(176, 255, 124, 0.2), rgba(16, 38, 20, 0.92) 55%);
  box-shadow: var(--shadow);
}

.game-root {
  width: 100%;
  height: clamp(420px, 72vh, 900px);
}

.game-root canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.starter-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 22px;
  backdrop-filter: blur(6px);
  background: rgba(5, 10, 6, 0.55);
}

.starter-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.overlay-card {
  width: min(980px, 100%);
  max-height: 100%;
  overflow: auto;
  border-radius: 18px;
  border: 1px solid var(--line-strong);
  background: var(--card-strong);
  padding: 18px;
}

.overlay-card h2 {
  margin: 8px 0 0;
  font-family: 'Chakra Petch', sans-serif;
  font-size: clamp(22px, 4vw, 32px);
}

.overlay-copy {
  margin: 6px 0 14px;
  color: var(--muted);
  max-width: 72ch;
}

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

.starter-card {
  border-radius: 14px;
  border: 1px solid var(--line);
  background: linear-gradient(165deg, rgba(22, 45, 28, 0.92), rgba(14, 27, 17, 0.96));
  padding: 12px;
  display: grid;
  gap: 10px;
}

.starter-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.starter-title {
  font-family: 'Chakra Petch', sans-serif;
  font-size: 18px;
}

.starter-type {
  color: var(--muted);
  font-size: 12px;
}

.starter-preview {
  display: grid;
  gap: 5px;
  justify-items: center;
  text-align: center;
}

.starter-preview img {
  width: 88px;
  height: 88px;
  object-fit: contain;
  filter: drop-shadow(0 5px 16px rgba(0, 0, 0, 0.5));
}

.starter-preview span {
  font-size: 11px;
  color: var(--muted);
}

.floating-controls {
  position: absolute;
  left: 14px;
  bottom: 14px;
  display: grid;
  gap: 8px;
}

.mode-switch {
  display: inline-flex;
  gap: 6px;
  padding: 6px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(10, 21, 13, 0.9);
}

.mode-hint {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  background: rgba(9, 17, 11, 0.72);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 10px;
}

.side-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.panel-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  padding: 12px;
}

.panel-card h3 {
  margin: 0 0 10px;
  font-size: 15px;
  font-family: 'Chakra Petch', sans-serif;
  letter-spacing: 0.04em;
}

.selected-card {
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
  min-height: 138px;
  display: grid;
  align-content: center;
  justify-items: center;
  padding: 10px;
  text-align: center;
  background: rgba(10, 19, 13, 0.7);
}

.selected-card.empty {
  color: var(--muted);
}

.selected-card img {
  width: 110px;
  height: 110px;
  object-fit: contain;
  filter: drop-shadow(0 8px 20px rgba(0, 0, 0, 0.45));
}

.readout-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 7px;
}

.readout-list li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
}

.readout-list span {
  color: var(--muted);
}

.readout-list strong {
  font-family: 'Chakra Petch', sans-serif;
  font-weight: 600;
}

.hint {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.admin-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.editor-palette {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 8px 0 10px;
}

.brush-btn {
  border-color: rgba(189, 250, 171, 0.35);
  background: rgba(19, 38, 23, 0.78);
}

.brush-btn.active {
  border-color: rgba(189, 250, 171, 0.82);
  background: linear-gradient(135deg, rgba(168, 255, 135, 0.34), rgba(79, 178, 89, 0.28));
}

.toast-region {
  display: grid;
  gap: 8px;
}

.toast {
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 10px;
  padding: 9px 10px;
  background: rgba(10, 24, 13, 0.9);
  font-size: 12px;
}

.toast.warn {
  border-left-color: var(--warning);
}

.toast.error {
  border-left-color: var(--danger);
}

.btn {
  border: 1px solid rgba(179, 255, 152, 0.42);
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(149, 255, 125, 0.26), rgba(66, 163, 74, 0.2));
  color: var(--text);
  padding: 8px 12px;
  font-weight: 600;
  font-family: 'Space Grotesk', sans-serif;
  cursor: pointer;
  transition: transform 140ms ease, border-color 160ms ease, background 160ms ease;
}

.btn:hover {
  transform: translateY(-1px);
  border-color: rgba(187, 255, 160, 0.78);
}

.btn.active {
  background: linear-gradient(135deg, rgba(170, 255, 139, 0.38), rgba(76, 177, 84, 0.35));
}

.btn.ghost {
  background: rgba(14, 25, 17, 0.75);
  border-color: var(--line);
}

.btn.small {
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 9px;
}

code {
  font-family: 'Chakra Petch', monospace;
  font-size: 11px;
  background: rgba(0, 0, 0, 0.26);
  padding: 1px 4px;
  border-radius: 5px;
}

@media (max-width: 1180px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .game-root {
    height: clamp(420px, 66vh, 760px);
  }

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

  .toast-region {
    grid-column: 1 / -1;
  }
}

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

  .topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .top-actions {
    justify-content: flex-start;
  }

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

  .starter-preview img {
    width: 74px;
    height: 74px;
  }

  .game-root {
    height: clamp(380px, 58vh, 620px);
  }

  .side-panel {
    grid-template-columns: 1fr;
  }
}
