/* ---------- Fonts ---------- */
@font-face { font-family: 'Determination Mono'; src: url('../fonts/DeterminationMono.ttf') format('truetype'); font-display: block; }
@font-face { font-family: 'Determination Sans'; src: url('../fonts/DeterminationSans.ttf') format('truetype'); font-display: block; }
@font-face { font-family: 'Press Start 2P'; src: url('../fonts/PressStart2P-Regular.ttf') format('truetype'); font-display: block; }
@font-face { font-family: 'VT323'; src: url('../fonts/VT323-Regular.ttf') format('truetype'); font-display: block; }

/* ---------- Base ---------- */
:root {
  --bg: #121318;
  --panel: #1c1e26;
  --panel2: #24262f;
  --line: #34364a;
  --text: #e8e8f0;
  --dim: #9a9db1;
  --accent: #ffdd00;
  --accent2: #ff4757;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, 'Segoe UI', sans-serif;
}
header { text-align: center; padding: 26px 16px 8px; }
h1 {
  font-family: 'Determination Mono', monospace;
  font-size: 34px; margin: 0; letter-spacing: 1px;
  color: #fff;
  display: flex; align-items: center; justify-content: center; gap: 14px;
}
h1 .logo { width: 30px; height: 30px; image-rendering: pixelated; }
.tagline { color: var(--dim); margin: 8px 0 2px; }
.privacy { color: #7ee787; font-size: 13px; margin: 2px 0 0; }
h2 { font-family: 'Determination Mono', monospace; font-size: 20px; margin: 0 0 10px; color: var(--accent); }
footer { color: var(--dim); font-size: 12.5px; text-align: center; padding: 24px 16px 40px; max-width: 900px; margin: 0 auto; }
code { background: var(--panel2); padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }

/* ---------- Layout ---------- */
.app {
  display: grid;
  grid-template-columns: minmax(330px, 430px) 1fr;
  gap: 20px;
  max-width: 1500px;
  margin: 18px auto;
  padding: 0 18px;
  align-items: start;
}
@media (max-width: 980px) { .app { grid-template-columns: 1fr; } }

.controls, .stage { min-width: 0; }

/* ---------- Controls panel ---------- */
details {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  margin: 12px 0;
  padding: 0 14px;
}
details > summary {
  cursor: pointer; padding: 11px 0; font-weight: 600; color: var(--text);
  list-style: none; user-select: none;
}
details > summary::before { content: '\25B8'; color: var(--accent); margin-right: 8px; }
details[open] > summary::before { content: '\25BE'; }
details > *:not(summary) { margin-bottom: 10px; }

.row {
  display: flex; align-items: center; gap: 10px; margin: 9px 0;
}
.row > label { flex: 0 0 130px; color: var(--dim); font-size: 13.5px; }
.row.sub { margin-top: -4px; padding-left: 140px; }
.row input[type=range] { flex: 1; accent-color: var(--accent); min-width: 0; }
.row output { width: 42px; text-align: right; color: var(--dim); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.row select, .row input[type=file] {
  flex: 1; min-width: 0; background: var(--panel2); color: var(--text);
  border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; font-size: 13px;
}
.row input[type=color] {
  width: 44px; height: 28px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--panel2); padding: 2px; cursor: pointer;
}
.row input[type=checkbox] { accent-color: var(--accent); width: 16px; height: 16px; }
.filename { color: var(--dim); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 180px; }

button {
  background: var(--panel2); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 14px; font-size: 14px; cursor: pointer;
}
button:hover { border-color: var(--accent); }
button.big { font-weight: 700; padding: 10px 18px; }
button.accent { background: var(--accent); color: #111; border-color: var(--accent); }
button.accent:hover { filter: brightness(1.1); }
button.mini { padding: 3px 9px; font-size: 12px; border-radius: 6px; }
button:disabled { opacity: .45; cursor: default; }
button:focus-visible, select:focus-visible, input:focus-visible, .filebtn:focus-within, a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.filebtn {
  display: inline-block; background: var(--panel2); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 14px; font-size: 14px; cursor: pointer;
}
.filebtn:hover { border-color: var(--accent); }
.hint { color: var(--dim); font-size: 12.5px; line-height: 1.5; }
.hidden { display: none !important; }

/* ---------- Box cards ---------- */
#addBox { width: 100%; margin-top: 4px; }
.boxCard {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  margin: 10px 0;
}
.boxHead { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.boxTitle { font-family: 'Determination Mono', monospace; color: var(--accent); font-size: 15px; }
.boxBtns { display: flex; gap: 5px; }
.tagbar { display: flex; gap: 5px; margin-bottom: 7px; flex-wrap: wrap; align-items: center; }
.tagbar .tagBtn { padding: 3px 10px; font-size: 12px; border-radius: 6px; }
.tagbar .tagColor { width: 30px; height: 24px; padding: 1px; border: 1px solid var(--line); border-radius: 5px; background: var(--panel2); cursor: pointer; }
textarea.boxText {
  width: 100%; resize: vertical;
  background: #0d0e12; color: #fff;
  border: 1px solid var(--line); border-radius: 8px;
  padding: 10px; font: 15px/1.5 'Determination Mono', monospace;
}
textarea.boxText:focus { outline: none; border-color: var(--accent); }
textarea.boxText.overflowing { border-color: var(--accent2); }
.overflowWarn {
  color: var(--accent2); font-size: 12.5px; margin-top: 6px;
  border-left: 3px solid var(--accent2); padding: 2px 0 2px 9px;
}
.boxOpts { margin: 8px 0 2px; background: var(--panel2); }
.boxOpts summary { font-size: 12.5px; font-weight: 500; color: var(--dim); }
.portraitThumb {
  width: 56px; height: 56px; object-fit: contain;
  image-rendering: pixelated; background: #0d0e12;
  border: 1px solid var(--line); border-radius: 6px;
}

/* ---------- Stage ---------- */
.orientRow { display: flex; gap: 16px; margin-bottom: 12px; flex-wrap: wrap; }
.orientOpt {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 14px; cursor: pointer; font-size: 14px;
}
.orientOpt:has(input:checked) { border-color: var(--accent); color: var(--accent); }
.orientOpt input { accent-color: var(--accent); }

.canvasWrap {
  border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
  background:
    repeating-conic-gradient(#2a2c36 0% 25%, #202230 0% 50%) 0 0 / 24px 24px;
  width: fit-content; max-width: 100%; margin: 0 auto;
}
#preview {
  display: block; max-width: 100%; height: auto;
  max-height: 74vh;
}

.transport {
  display: flex; align-items: center; gap: 10px; margin: 12px 0 18px; flex-wrap: wrap;
}
.transport input[type=range] { flex: 1; accent-color: var(--accent); min-width: 120px; }
#timeLabel { color: var(--dim); font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- Export ---------- */
.exportPanel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 14px 16px;
}
.exportPanel .row > label { flex-basis: 90px; }
progress { width: 100%; height: 10px; accent-color: var(--accent); }
.status { color: var(--dim); font-size: 13px; min-height: 18px; margin-top: 6px; }
.downloadLink {
  display: inline-block; margin-top: 10px;
  background: #7ee787; color: #10241a; font-weight: 700;
  padding: 10px 18px; border-radius: 8px; text-decoration: none;
}
.downloadLink:hover { filter: brightness(1.08); }
