:root {
  --bg: #0f1411;
  --bg-accent: #1a231d;
  --panel: #16201a;
  --panel-2: #1c2b22;
  --ink: #f1f4ef;
  --muted: #a7b2a6;
  --accent: #ff6b3d;
  --accent-2: #6ad2a6;
  --border: #2a3a2f;
  --shadow: rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
}

body {
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  color: var(--ink);
  background: linear-gradient(120deg, #0d120f, #141b16);
}

/* Full-screen canvas */
.canvas-wrap {
  position: absolute;
  inset: 0;
  background: linear-gradient(160deg, #111916, #0b110e);
  touch-action: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
}

.loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 18px;
  color: var(--muted);
  background: rgba(15, 20, 17, 0.9);
  z-index: 100;
}

/* Overlay controls - centered top */
.overlay-controls {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  z-index: 10;
}

.btn {
  border: 1px solid var(--border);
  background: rgba(22, 32, 26, 0.95);
  color: var(--ink);
  padding: 10px 16px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: all 0.2s;
}

.btn:hover {
  background: rgba(26, 35, 29, 0.98);
  border-color: var(--accent-2);
}

.btn.primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  padding: 14px 32px;
  font-size: 16px;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(255, 107, 61, 0.4);
}

.btn.primary:hover {
  background: #ff7a4f;
}

/* Status overlay - bottom left */
.status-overlay {
  position: absolute;
  bottom: 20px;
  left: 20px;
  display: flex;
  gap: 20px;
  padding: 12px 16px;
  background: rgba(22, 32, 26, 0.95);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  color: var(--muted);
  backdrop-filter: blur(8px);
  z-index: 10;
}

.status-overlay strong {
  color: var(--ink);
  font-size: 16px;
}

/* Decor picker modal */
.decor-modal {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 12, 10, 0.85);
  backdrop-filter: blur(4px);
  z-index: 50;
}

.decor-modal-content {
  width: min(600px, 90vw);
  max-height: 80vh;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.decor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.decor-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.btn-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 32px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
}

.btn-close:hover {
  color: var(--ink);
}

#searchDecor {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #101814;
  color: var(--ink);
  font-size: 14px;
}

.decor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
  max-height: 400px;
  overflow-y: auto;
  padding: 4px;
}

.decor-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 8px;
  background: #111a15;
  cursor: pointer;
  transition: all 0.2s;
}

.decor-item:hover {
  background: #141f1a;
  border-color: var(--accent-2);
}

.decor-item.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(255, 107, 61, 0.2);
}

.decor-item small {
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.decor-thumb {
  width: 60px;
  height: 60px;
  border-radius: 6px;
  background: #0a0f0c;
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
}

.decor-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.selection-preview {
  width: 48px;
  height: 48px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.selection-preview canvas {
  max-width: 100%;
  max-height: 100%;
}

.selection-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.selection-info span {
  font-size: 13px;
}

#selectedName {
  font-weight: 600;
  color: var(--ink);
}

#rotationLabel {
  color: var(--muted);
  font-size: 11px;
}

.rotation-controls {
  display: flex;
  gap: 6px;
}

.btn-icon {
  border-radius: 6px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--ink);
  cursor: pointer;
  font-size: 16px;
  transition: all 0.2s;
}

.btn-icon:hover {
  background: var(--bg-accent);
  border-color: var(--accent-2);
}


/* Mutation Panel */
.mutation-panel {
  padding: 12px;
  background: var(--panel-2);
  border-radius: 8px;
  border: 1px solid var(--border);
  margin-top: 10px;
}

.mutation-panel h4 {
  margin: 0 0 10px 0;
  font-size: 14px;
  color: var(--accent-2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.mutation-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mutation-list label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  padding: 4px 10px;
  background: rgba(13, 20, 16, 0.6);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
}

.mutation-list label:hover {
  border-color: var(--accent-2);
  background: rgba(106, 210, 166, 0.1);
}

.mutation-list label:has(input:checked) {
  border-color: var(--accent);
  background: rgba(255, 107, 61, 0.1);
  color: var(--accent);
}

.mutation-list input {
  display: none;
}

/* Import/Export modal */
.modal {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(10, 12, 10, 0.85);
  backdrop-filter: blur(4px);
  z-index: 60;
}

.modal.show {
  display: flex;
}

.modal-card {
  width: min(720px, 92vw);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-card header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-card textarea {
  min-height: 300px;
  background: #0d1410;
  border: 1px solid var(--border);
  color: var(--ink);
  border-radius: 8px;
  padding: 12px;
  font-family: ui-monospace, monospace;
  font-size: 13px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.btn.ghost {
  background: transparent;
}

.noscript {
  padding: 20px;
  text-align: center;
  background: #2a1f1d;
}

/* Controls Tooltip - bottom right */
.controls-tooltip {
  position: absolute;
  bottom: 20px;
  right: 20px;
  background: rgba(22, 32, 26, 0.9);
  padding: 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  backdrop-filter: blur(4px);
  z-index: 100;
  max-width: 250px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  pointer-events: auto;
}

.controls-tooltip p {
  margin: 0 0 8px 0;
  font-size: 14px;
}

.controls-tooltip ul {
  margin: 0;
  padding: 0;
  font-size: 13px;
  color: var(--muted);
  list-style-type: none;
}

.controls-tooltip li {
  margin-bottom: 0;
  padding: 6px 0;
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.controls-tooltip li:last-child {
  border-bottom: none;
}

.close-tooltip {
  position: absolute;
  top: 8px;
  right: 8px;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 0;
}

.close-tooltip:hover {
  color: var(--ink);
}

/* Device-specific control display */
.desktop .mobile-only {
  display: none !important;
}

.mobile .desktop-only {
  display: none !important;
}