:root {
  --bg: #0f1419;
  --panel: #1a2332;
  --panel-2: #243044;
  --accent: #5eead4;
  --accent-2: #818cf8;
  --text: #e8eef7;
  --muted: #8b9cb3;
  --danger: #f87171;
  --ok: #4ade80;
  --radius: 12px;
  font-family: "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(1200px 600px at 10% -10%, #1e3a5f 0%, var(--bg) 55%);
  color: var(--text);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.layout { max-width: 1200px; margin: 0 auto; padding: 24px; }

.card {
  background: var(--panel);
  border: 1px solid #2d3a4f;
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

.btn {
  border: none;
  border-radius: 10px;
  padding: 10px 16px;
  font-weight: 600;
  cursor: pointer;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #0b1020;
}
.btn.secondary { background: var(--panel-2); color: var(--text); border: 1px solid #3d4f6a; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid #3d4f6a;
  background: #111827;
  color: var(--text);
}

label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 6px; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  background: #334155;
  color: var(--accent);
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 800px) { .grid-2 { grid-template-columns: 1fr; } }

.editor-shell {
  display: grid;
  grid-template-columns: 260px 1fr 300px;
  gap: 12px;
  height: calc(100vh - 100px);
}

.editor-panel {
  background: var(--panel);
  border: 1px solid #2d3a4f;
  border-radius: var(--radius);
  overflow: auto;
  padding: 12px;
}

.editor-canvas-wrap {
  position: relative;
  background: #0b1220;
  border: 1px solid #2d3a4f;
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 360px;
}

#editor-canvas, #play-canvas {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  display: block;
  z-index: 1;
}

.asset-item {
  padding: 8px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 0.9rem;
}
.asset-item:hover { background: var(--panel-2); }
.asset-item.locked { opacity: 0.45; }

.hidden { display: none !important; }

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  padding: 12px 16px;
  background: #14532d;
  border: 1px solid var(--ok);
  border-radius: 10px;
  z-index: 50;
}

.gs-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.gs-modal-inner {
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow: auto;
}

.rule-card {
  border: 1px solid #2d3a4f;
  border-radius: 8px;
  padding: 8px;
  margin-bottom: 8px;
  background: var(--panel-2);
}

.gs-hud {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
  z-index: 10;
}
.gs-hud-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.gs-hint { color: var(--muted); font-size: 0.85rem; }
.gs-inv {
  font-size: 0.85rem;
  background: rgba(26, 35, 50, 0.85);
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid #2d3a4f;
  max-width: 420px;
}

.gs-dialogue-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 80;
  padding: 20px;
}
.gs-dialogue { max-width: 520px; width: 100%; }
.gs-choices { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.gs-choices .btn { width: 100%; text-align: left; }

.editor-shell {
  height: calc(100vh - 160px);
}

.rule-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr auto;
  gap: 4px;
  margin-bottom: 6px;
  align-items: center;
}
.rule-row select,
.rule-row input { font-size: 0.78rem; padding: 6px 8px; }

#layer-toolbar:not(.hidden),
#cam3d-toolbar:not(.hidden) {
  display: flex;
}

.gs-notify {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  max-width: 520px;
  padding: 12px 16px;
  border-radius: 10px;
  z-index: 200;
  font-size: 0.92rem;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}
.gs-notify-error { background: #451a1a; border: 1px solid var(--danger); color: #fecaca; }
.gs-notify-ok { background: #14532d; border: 1px solid var(--ok); color: #bbf7d0; }
.gs-notify.hidden { display: none; }

.storage-bar {
  height: 8px;
  background: #1e293b;
  border-radius: 4px;
  overflow: hidden;
  margin-top: 6px;
}
.storage-bar > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}