:root {
  --bg: #202010;
  --panel: #303030;
  --text: #e6e8eb;
  --muted: #9aa3af;
  --accent: #6ca0ff;
  --border: #272d36;
  --backdrop: rgba(0,0,0,0.5);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, Segoe UI, Roboto, Arial, sans-serif;
}

/* Layout */
.container {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 16px;
  padding: 16px;
}

/* Controls panel */
.controls {
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 14px;
  border-radius: 12px;
}

.header-row {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 8px;
}

.help-btn {
  cursor: pointer;
  border: 1px solid var(--border);
  background: #0f1216;
  color: var(--text);
  padding: 8px 10px;
  border-radius: 8px;
  font-weight: 600;
}
.help-btn:hover { border-color: var(--accent); }

.field { margin-bottom: 12px; }
.field:last-child { margin-bottom: 0; }
label, legend { font-weight: 600; }
input[type="number"], input[type="file"], input[type="color"] {
  display: block;
  margin-top: 6px;
  width: 100%;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #0f1216;
  color: var(--text);
}

fieldset {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
}
fieldset label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-right: 14px;
  font-weight: 500;
}

.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}
button {
  cursor: pointer;
  border: 1px solid var(--border);
  background: #0f1216;
  color: var(--text);
  padding: 10px 12px;
  border-radius: 10px;
  font-weight: 600;
}
button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
button:hover:not(:disabled) {
  border-color: var(--accent);
}

/* Preview panel */
.preview {
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 14px;
  border-radius: 12px;
  min-height: 60vh;
  display: grid;
  grid-template-rows: 1fr auto;
}
.canvas-wrap {
  display: grid;
  place-items: center;
  background: #0b0e12;
  border: 1px dashed var(--border);
  border-radius: 10px;
  min-height: 50vh;
  overflow: auto;
  background-image: url("PixelGridLogo33pct.png");
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  position: relative;
}

.canvas-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 0.25rem;
  padding: 1rem;
  pointer-events: none;           /* clicks pass through to canvas */
  color: var(--text);
  opacity: 0.9;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}


.canvas-overlay h1 {
  margin: 0;
  font-weight: 800;
  font-size: clamp(24px, 5vw, 48px);
}

.canvas-overlay h2 {
  margin: 0;
  font-weight: 700;
  font-size: clamp(16px, 3.5vw, 24px);
  color: var(--muted);
}

.canvas-overlay p {
  margin: 6px 0 0 0;
  font-weight: 600;
  font-size: clamp(14px, 3vw, 18px);
  color: var(--muted);
}

.canvas-wrap.no-placeholder .canvas-overlay { display: none; }

.canvas-wrap.no-placeholder {
  background-image: none;
}

canvas { image-rendering: pixelated; max-width: 100%; height: auto; }
.meta { margin-top: 10px; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* Pulsing yellow cue for primary next action */
.pulse {
  position: relative;
  border-color: #ffd500 !important;
  outline: 2px solid #ffd500;     /* visible on inputs that ignore border */
  outline-offset: 2px;
  animation: pulse-ring 1.2s ease-out infinite;
  box-shadow:
    0 0 0 2px rgba(255,213,0,0.65),
    0 0 0 8px rgba(255,213,0,0);
}

@keyframes pulse-ring {
  0%   { box-shadow: 0 0 0 2px rgba(255,213,0,0.65), 0 0 0 8px rgba(255,213,0,0); }
  70%  { box-shadow: 0 0 0 2px rgba(255,213,0,0.35), 0 0 0 16px rgba(255,213,0,0); }
  100% { box-shadow: 0 0 0 2px rgba(255,213,0,0.65), 0 0 0 8px rgba(255,213,0,0); }
}



/* Help modal */
.modal {
  position: fixed;
  inset: 0;
  display: none;
}
.modal[aria-hidden="false"] { display: block; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: var(--backdrop);
}

.modal-card {
  position: absolute;
  inset: 10% 5% auto 5%;
  max-width: 900px;
  margin: 0 auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 16px 8px 16px;
  left: 50%;
  transform: translateX(-50%);
}
.modal-close {
  position: absolute;
  top: 8px;
  right: 10px;
  width: 32px; height: 32px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #0f1216;
  color: var(--text);
  font-size: 18px;
  line-height: 28px;
}
.modal-close:hover { border-color: var(--accent); }
.help-steps {
  white-space: pre-wrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--text);
  font-size: 13px;
}

/* Responsive tweaks for tablets/phones */
@media (max-width: 1024px) {
  .container {
    grid-template-columns: 1fr;
  }
  .controls, .preview {
    min-height: auto;
  }
  .grid2 {
    grid-template-columns: 1fr; /* stack fields vertically on narrow screens */
  }
  .actions button {
    flex: 1 1 auto; /* buttons expand to full width rows if needed */
  }
  .modal-card {
    inset: 8% 3% auto 3%;
  }
}

/* Footer credits */
.site-footer {
  margin-top: 16px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
}

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

.credit-item {
  display: flex;
  align-items: center;
  gap: 10px;
  line-height: 1.4;
}

.credit-icon {
  height: 1.5em;
  width: auto;
  image-rendering: auto;
  flex: 0 0 auto;
}

.site-footer a {
  color: var(--text);
  text-decoration: underline;
}
.site-footer a:hover {
  color: var(--accent);
}

@media (max-width: 1024px) {
  .site-footer { padding: 12px; }
}
