:root {
  color-scheme: dark;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #0f172a;
  color: #f8fafc;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  /* home-screen wallpaper: deep navy into violet with a soft top glow */
  background:
    radial-gradient(1200px 500px at 50% -10%, rgba(124, 58, 237, 0.35), transparent 70%),
    linear-gradient(160deg, #0f172a 0%, #1e1b4b 60%, #312e81 130%);
  background-attachment: fixed;
  /* mobile: no rubber-band scroll, no pinch/double-tap zoom, no text select */
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}
button, input, select { font: inherit; }

#app { min-height: 100vh; }

.shell {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px;
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 24px;
}

.hero h1 { margin: 0 0 8px; font-size: 2rem; }
.hero p { margin: 0; color: #cbd5e1; max-width: 720px; }

.panel {
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 20px;
  padding: 20px;
  backdrop-filter: blur(16px);
}

/* ---- home screen: app-style icon grid ---- */
.home { max-width: 860px; }
.home-head { text-align: center; margin: 14px 0 30px; }
.home-head h1 {
  margin: 0;
  font-size: clamp(1.5rem, 4vw, 2.1rem);
  letter-spacing: 0.5px;
  text-shadow: 0 2px 18px rgba(124, 58, 237, 0.55);
}

.library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(128px, 152px));
  gap: 30px 22px;
  justify-items: center;
  justify-content: center;
}

.card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 0;
  background: none;
  border: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.card:focus-visible { outline: none; }
.card:focus-visible .icon-art, .card:focus-visible .icon-fallback {
  outline: 3px solid #a78bfa;
  outline-offset: 3px;
}
.icon-art, .icon-fallback {
  width: clamp(96px, 15vw, 140px);
  aspect-ratio: 1;
  border-radius: 24%;
  object-fit: cover;
  background: #ffffff;
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.45), 0 2px 6px rgba(0, 0, 0, 0.35);
  transition: transform 160ms ease, box-shadow 160ms ease;
}
.icon-art.missing { visibility: hidden; }
.icon-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  font-weight: 800;
  color: #4c1d95;
  background: linear-gradient(160deg, #f5f3ff, #ddd6fe);
}
.card:hover .icon-art, .card:hover .icon-fallback {
  transform: translateY(-5px) scale(1.05);
  box-shadow: 0 20px 36px rgba(0, 0, 0, 0.5), 0 0 24px rgba(124, 58, 237, 0.35);
}
.card:active .icon-art, .card:active .icon-fallback { transform: scale(0.93); }
.card h3 {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: #f8fafc;
  text-align: center;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
  line-height: 1.25;
  max-width: 15ch;
}

.editor-grid {
  display: grid;
  grid-template-columns: minmax(240px, 340px) minmax(300px, 1fr);
  gap: 16px;
}

.form-row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.form-row input, .form-row select { padding: 8px 10px; border-radius: 10px; border: 1px solid #334155; background: #020617; color: #f8fafc; }

.play-shell { display: grid; gap: 16px; }
.canvas-wrap { overflow: auto; padding: 8px; background: rgba(2, 6, 23, 0.7); border-radius: 20px; }
canvas { display: block; border-radius: 14px; background: #111827; width: 100%; max-width: 720px; margin: 0 auto; }

.controls { display: flex; flex-wrap: wrap; gap: 8px; }
button {
  border: none;
  border-radius: 999px;
  padding: 10px 14px;
  background: linear-gradient(135deg, #38bdf8, #2563eb);
  color: white;
  cursor: pointer;
}
button.secondary { background: #334155; }

.empty { color: #cbd5e1; }

@media (max-width: 820px) {
  .editor-grid { grid-template-columns: 1fr; }
  .hero { flex-direction: column; align-items: flex-start; }
}
