:root{
  --green: #00ff00;
  --green-dim: #9fe89f;
  --bg: #050505;
  --panel-bg: #0a0f0a;
}

*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--green);
  font-family: "Courier New", monospace;
  padding: 24px;
}
h1 {
  text-align: center;
  font-size: 20px;
  letter-spacing: 4px;
  margin-bottom: 24px;
  color: var(--green);
  text-shadow: 0 0 8px rgba(0,255,0,0.4);
}
h2 {
  font-size: 13px;
  letter-spacing: 2px;
  margin: 0 0 12px;
  color: var(--green);
  text-shadow: 0 0 6px rgba(0,255,0,0.3);
}

.app {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* =========================================================
   PREVIEW — the actual UT/DR box stays authentic black/white,
   since that's the real deliverable people are making. Only
   the surrounding chrome below gets the FELINE LTD treatment.
========================================================= */
.preview-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.game-frame {
  width: 640px;
  max-width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  background-image:
    linear-gradient(45deg, #0a0a0a 25%, transparent 25%),
    linear-gradient(-45deg, #0a0a0a 25%, transparent 25%);
  background-size: 24px 24px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 20px;
  border: 2px solid #333;
}
.textbox {
  position: relative;
  width: 100%;
  min-height: 130px;
  background: #000;
  border: 4px solid #fff;
  border-radius: 2px;
  padding: 16px 20px;
  display: flex;
  gap: 16px;
  align-items: flex-start;
  image-rendering: pixelated;
  cursor: pointer;
}
.portrait-slot {
  width: 90px;
  height: 90px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.portrait-slot img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
}
.textbox-right {
  flex: 1;
  min-width: 0;
}
.name-tag {
  display: inline-block;
  background: #000;
  border: 3px solid #fff;
  padding: 2px 14px;
  font-family: "Courier New", monospace;
  font-weight: bold;
  font-size: 14px;
  color: #ffcc00;
  margin-bottom: 8px;
  margin-top: -34px;
  margin-left: -4px;
  position: relative;
}
.dialogue-text {
  font-family: "Courier New", monospace;
  font-size: 17px;
  line-height: 1.8;
  color: #fff;
  white-space: pre-wrap;
  word-break: break-word;
}
.advance-arrow {
  position: absolute;
  bottom: 10px;
  right: 16px;
  color: #fff;
  font-size: 14px;
  animation: bob 0.6s ease-in-out infinite alternate;
}
@keyframes bob {
  from { transform: translateY(0); }
  to { transform: translateY(4px); }
}

/* ===== PREVIEW / EXPORT CONTROLS ===== */
.preview-controls, .export-controls {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
}
button {
  font-family: "Courier New", monospace;
  font-weight: bold;
  font-size: 11px;
  letter-spacing: 0.5px;
  background: transparent;
  color: var(--green);
  border: 1px solid var(--green);
  padding: 10px 14px;
  cursor: pointer;
  transition: all 0.15s ease;
}
button:hover { background: var(--green); color: #050505; box-shadow: 0 0 10px rgba(0,255,0,0.4); }
button:active { transform: translateY(1px); }
#page-indicator {
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--green-dim);
  padding: 0 6px;
}
#export-status {
  font-size: 12px;
  color: var(--green-dim);
}

/* ===== PORTRAIT COMPOSER ===== */
.composer {
  background: var(--panel-bg);
  border: 1px solid var(--green);
  box-shadow: 0 0 8px rgba(0,255,0,0.1);
  padding: 16px;
}
.composer h2 {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}
.composer-hint {
  font-size: 11px;
  color: var(--green-dim);
  opacity: 0.7;
  letter-spacing: 0;
  text-shadow: none;
}
.composer-grid {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 18px;
}
.composer-col {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.asset-group {
  background: #030503;
  border: 1px solid rgba(0,255,0,0.3);
  padding: 10px;
}
.asset-group-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.asset-group-header span {
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--green);
}
.asset-group-header input[type="color"] {
  width: 40px;
  height: 24px;
  padding: 1px;
}
.asset-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.asset-thumb {
  width: 42px;
  height: 42px;
  border: 1px solid rgba(0,255,0,0.3);
  cursor: pointer;
  background: #000;
  padding: 2px;
  transition: all 0.15s ease;
  position: relative;
}
.asset-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
  filter: invert(1); /* white sprites shown visibly against dark thumbnail bg */
}
.asset-thumb.selected { border-color: var(--green); box-shadow: 0 0 8px rgba(0,255,0,0.5); }
.asset-thumb:hover { border-color: var(--green); }

.stacked-accessories {
  margin-top: 10px;
  border-top: 1px solid rgba(0,255,0,0.3);
  padding-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.empty-hint {
  font-size: 10px;
  color: var(--green-dim);
  opacity: 0.5;
  font-style: italic;
}
.stacked-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #000;
  border: 1px solid rgba(0,255,0,0.2);
  padding: 6px 8px;
}
.stacked-item .stacked-name {
  flex: 1;
  font-size: 11px;
  color: var(--green-dim);
}
.stacked-item input[type="color"] {
  width: 30px;
  height: 22px;
  padding: 0;
}
.stacked-item button {
  font-size: 9px;
  padding: 4px 6px;
}

.composer-preview-col {
  align-items: center;
}
.composer-preview {
  width: 120px;
  height: 120px;
  background:
    linear-gradient(45deg, #0a0a0a 25%, transparent 25%),
    linear-gradient(-45deg, #0a0a0a 25%, transparent 25%);
  background-size: 16px 16px;
  background-color: #000;
  border: 1px solid var(--green);
  box-shadow: 0 0 8px rgba(0,255,0,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
}
#composer-canvas {
  width: 96px;
  height: 96px;
  image-rendering: pixelated;
}
#composer-name {
  width: 140px;
}
#btn-add-composed-portrait {
  width: 140px;
  font-size: 9px;
  white-space: nowrap;
  padding: 10px 6px;
}

/* ===== CONTROLS ===== */
.controls {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}
.panel {
  background: var(--panel-bg);
  border: 1px solid var(--green);
  box-shadow: 0 0 8px rgba(0,255,0,0.1);
  padding: 16px;
}
.field-label {
  display: block;
  font-size: 11px;
  letter-spacing: 0.5px;
  color: var(--green-dim);
  opacity: 0.8;
  margin: 14px 0 6px;
}
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
}
input[type="text"], textarea, select {
  width: 100%;
  background: #000;
  border: 1px solid rgba(0,255,0,0.4);
  color: var(--green);
  font-family: "Courier New", monospace;
  font-size: 13px;
  padding: 8px;
}
input[type="text"]:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 6px rgba(0,255,0,0.3);
}
textarea { resize: vertical; }
input[type="range"] { width: 100%; accent-color: var(--green); }
input[type="color"] {
  width: 100%;
  height: 32px;
  background: #000;
  border: 1px solid rgba(0,255,0,0.4);
  padding: 2px;
}
#speed-value { font-size: 11px; color: var(--green-dim); }

.portrait-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.portrait-thumb {
  width: 48px;
  height: 48px;
  border: 1px solid rgba(0,255,0,0.4);
  overflow: hidden;
  position: relative;
}
.portrait-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
}
.portrait-thumb .thumb-name {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: rgba(0,0,0,0.8);
  color: var(--green-dim);
  font-size: 7px;
  text-align: center;
  padding: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.page-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}
.page-tab {
  font-size: 10px;
  letter-spacing: 0.5px;
  padding: 6px 9px;
  background: #000;
  border: 1px solid rgba(0,255,0,0.4);
  color: var(--green-dim);
  cursor: pointer;
  transition: all 0.15s ease;
}
.page-tab:hover { border-color: var(--green); }
.page-tab.active {
  border-color: var(--green);
  color: var(--green);
  box-shadow: 0 0 6px rgba(0,255,0,0.3);
}
.small-btn {
  font-size: 9px;
  padding: 8px 10px;
  margin-right: 6px;
}

@media (max-width: 900px) {
  .controls { grid-template-columns: 1fr; }
  .composer-grid { grid-template-columns: 1fr; }
  .game-frame { aspect-ratio: 4/3; }
}
