:root {
  --bg: #ffe066;
  --panel: rgba(255, 250, 236, 0.96);
  --panel-border: #232323;
  --ink: #1f1a17;
  --muted: #6a5850;
  --accent: #ff6b6b;
  --accent-strong: #e84e4e;
  --accent-alt: #4ecdc4;
  --shadow: 0 18px 0 rgba(35, 35, 35, 0.15), 0 28px 55px rgba(73, 49, 20, 0.2);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Trebuchet MS", "Comic Sans MS", "Marker Felt", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 18%, rgba(255, 255, 255, 0.75), transparent 16%),
    radial-gradient(circle at 85% 22%, rgba(255, 105, 105, 0.32), transparent 18%),
    radial-gradient(circle at 20% 85%, rgba(78, 205, 196, 0.34), transparent 18%),
    radial-gradient(circle at 82% 80%, rgba(255, 255, 255, 0.5), transparent 15%),
    linear-gradient(140deg, #fff1a6 0%, #ffd166 38%, #ffb86b 100%);
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(320px, 420px) 1fr;
  gap: 24px;
  padding: 24px;
}

.panel {
  background: var(--panel);
  border: 3px solid var(--panel-border);
  border-radius: 30px;
  box-shadow: var(--shadow);
}

.controls {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.preview-panel {
  padding: 20px;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 48px);
}

.panel-header h1,
.preview-header h2 {
  margin: 4px 0 10px;
  font-size: clamp(1.9rem, 1.8vw, 2.5rem);
  line-height: 0.95;
  letter-spacing: -0.03em;
}

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.78rem;
  color: var(--accent-strong);
  font-weight: 800;
}

.artist-credit {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
}

.intro,
.help-text,
.status-text {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.control-group-full {
  grid-column: 1 / -1;
}

[hidden] {
  display: none;
}

.group-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

label {
  font-size: 0.92rem;
  font-weight: 800;
}

input[type="file"],
input[type="number"],
input[type="color"],
select,
button {
  border-radius: 18px;
  border: 3px solid rgba(35, 35, 35, 0.9);
  background: rgba(255, 255, 255, 0.96);
  color: var(--ink);
  font: inherit;
}

input[type="file"],
input[type="number"],
select {
  width: 100%;
  padding: 12px 14px;
}

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

input[type="color"] {
  width: 100%;
  min-height: 48px;
  padding: 6px;
}

input[type="range"] {
  width: 100%;
}

button {
  padding: 12px 16px;
  cursor: pointer;
  font-weight: 800;
  box-shadow: 0 6px 0 rgba(35, 35, 35, 0.18);
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

button:hover {
  transform: translateY(-2px) rotate(-1deg);
  box-shadow: 0 10px 0 rgba(35, 35, 35, 0.14);
}

.primary-button {
  background: var(--accent);
  color: #fff8ec;
}

.primary-button:hover {
  background: var(--accent-strong);
}

#randomize {
  background: var(--accent-alt);
  color: #14302f;
}

#randomize:hover {
  background: #39bfb5;
}

.ghost-button {
  background: #fff3bf;
}

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

.control-actions {
  display: flex;
  gap: 12px;
}

.control-actions > * {
  flex: 1;
}

.asset-list-frame {
  border: 3px solid rgba(35, 35, 35, 0.9);
  border-radius: 24px;
  overflow: hidden;
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.7), transparent 30%),
    linear-gradient(180deg, #fff8db 0%, #ffe9a8 100%);
}

.asset-list {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  max-height: 660px;
  padding: 10px;
  overflow: auto;
  overflow-x: hidden;
  border: 0;
  border-radius: 0;
  background: transparent;
  scrollbar-gutter: stable;
  scrollbar-width: auto;
  scrollbar-color: rgba(35, 35, 35, 0.45) transparent;
}

.asset-list::-webkit-scrollbar {
  width: 16px;
}

.asset-list::-webkit-scrollbar-track {
  margin: 10px 6px 10px 0;
  background: transparent;
}

.asset-list::-webkit-scrollbar-thumb {
  border-radius: 999px;
  border: 3px solid transparent;
  background: rgba(35, 35, 35, 0.35);
  background-clip: padding-box;
}

.asset-list::-webkit-scrollbar-thumb:hover {
  background: rgba(35, 35, 35, 0.5);
  background-clip: padding-box;
}

.asset-list.empty-state {
  color: var(--muted);
}

.asset-item {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  min-height: 0;
  padding: 4px;
  border-radius: 20px;
  background: #fffaf0;
  border: 3px solid transparent;
  cursor: pointer;
  overflow: hidden;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
}

.asset-item:hover {
  transform: translateY(-3px) rotate(-2deg);
  border-color: rgba(35, 35, 35, 0.5);
}

.asset-item.is-selected {
  border-color: rgba(35, 35, 35, 0.95);
  background: #d8fff7;
}

.asset-item input {
  position: absolute;
  top: 4px;
  right: 4px;
  margin: 0;
  z-index: 1;
  transform: scale(0.7);
  transform-origin: top right;
}

.asset-preview {
  width: 60%;
  height: 60%;
  object-fit: contain;
  pointer-events: none;
}

.preview-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
  margin-bottom: 16px;
}

.preview-surface {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  border-radius: 28px;
  border: 3px solid rgba(35, 35, 35, 0.9);
  background-color: #fff7d6;
  background-image: none;
}

canvas {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  border-radius: 24px;
  border: 3px solid rgba(35, 35, 35, 0.9);
  box-shadow: 0 16px 30px rgba(93, 58, 18, 0.2);
  background: white;
}

output {
  font-size: 0.9rem;
  color: var(--muted);
}

@media (max-width: 1024px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .preview-panel {
    min-height: auto;
  }
}

@media (max-width: 640px) {
  .app-shell,
  .controls,
  .preview-panel {
    padding: 16px;
  }

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

  .preview-header {
    flex-direction: column;
    align-items: start;
  }
}
