:root {
  --bg: #0b0b0c;
  --panel: #141416;
  --panel-2: #1b1b1e;
  --line: rgba(255, 255, 255, 0.1);
  --text: #f4f4f2;
  --muted: rgba(244, 244, 242, 0.62);
  --red: #e51c32;
  --red-dark: #b41023;
  --red-light: #ff6b7c;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 "Barlow", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.wrap { width: min(1240px, 100% - 32px); margin-inline: auto; }
h1, h2 { font-family: "Barlow Condensed", "Barlow", Arial, sans-serif; text-transform: uppercase; margin: 0; }
h1 { font-size: clamp(44px, 8vw, 84px); font-weight: 800; line-height: 0.95; letter-spacing: 0.01em; }
h1 span { color: var(--red); }
h2 { font-size: 24px; font-weight: 800; letter-spacing: 0.03em; margin: 28px 0 12px; display: flex; gap: 12px; align-items: baseline; }
h2 b { color: var(--red); font-size: 14px; letter-spacing: 0.18em; }
.kicker { margin: 0 0 10px; color: var(--red-light); font: 600 12px "Barlow", sans-serif; letter-spacing: 0.24em; text-transform: uppercase; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.tag { display: inline-block; padding: 1px 7px; border: 1px solid rgba(229, 28, 50, 0.6); color: var(--red-light); font: 600 11px "Barlow", sans-serif; letter-spacing: 0.1em; text-transform: uppercase; font-style: normal; }

.top { padding: 48px 0 28px; border-bottom: 1px solid var(--line); background: radial-gradient(80% 120% at 100% 0%, rgba(229, 28, 50, 0.16), transparent 60%); }
.top .muted { max-width: 640px; margin: 14px 0 0; }

.panel {
  margin: 28px 0 8px;
  padding: 4px 28px 28px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  clip-path: polygon(22px 0, 100% 0, 100% calc(100% - 22px), calc(100% - 22px) 100%, 0 100%, 0 22px);
  box-shadow: inset 0 0 0 1px var(--line);
}

.slots { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 12px; }
.slot {
  position: relative; display: grid; place-items: center; aspect-ratio: 4 / 3;
  border: 1px dashed rgba(255, 255, 255, 0.22); background: #0e0e10; cursor: pointer; overflow: hidden;
}
.slot.main { border-color: rgba(229, 28, 50, 0.55); }
.slot:hover { border-color: var(--red); }
.slot.has { border-style: solid; }
.slot img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #fff; }
.plus { font-size: 40px; color: var(--muted); line-height: 1; }
.slot-name { position: absolute; left: 0; bottom: 0; padding: 4px 8px; background: rgba(0, 0, 0, 0.72); font: 600 11px "Barlow", sans-serif; letter-spacing: 0.12em; text-transform: uppercase; }
.slot-x { position: absolute; top: 6px; right: 6px; width: 28px; height: 28px; border: 0; background: rgba(0, 0, 0, 0.75); color: #fff; font-size: 18px; cursor: pointer; }

.engines { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.engine input { position: absolute; opacity: 0; }
.engine-card {
  display: flex; flex-direction: column; gap: 2px; height: 100%; padding: 14px 16px;
  border: 1px solid var(--line); background: #0e0e10; cursor: pointer; transition: border-color 0.15s, background 0.15s;
}
.engine-card strong { font: 800 20px "Barlow Condensed", sans-serif; text-transform: uppercase; letter-spacing: 0.02em; }
.engine-card small { color: var(--muted); font-size: 12px; }
.engine-card span { font-size: 14px; color: rgba(244, 244, 242, 0.8); margin-top: 4px; }
.engine-card .tag { align-self: flex-start; margin-top: 8px; }
.engine input:checked + .engine-card { border-color: var(--red); background: rgba(229, 28, 50, 0.1); box-shadow: inset 3px 0 0 var(--red); }
.engine input:focus-visible + .engine-card { outline: 2px solid var(--red-light); outline-offset: 2px; }

.go { display: flex; gap: 10px; flex-wrap: wrap; }
.go input, .login-card input {
  flex: 1; min-width: 220px; height: 48px; padding: 0 14px; border: 1px solid rgba(255, 255, 255, 0.16);
  background: #0e0e10; color: var(--text); font: 16px "Barlow", sans-serif; outline: none;
}
.go input:focus, .login-card input:focus { border-color: var(--red); }
.btn-red, .login-card button {
  height: 48px; padding: 0 26px; border: 0; background: var(--red); color: #fff; cursor: pointer;
  font: 700 14px "Barlow", sans-serif; letter-spacing: 0.16em; text-transform: uppercase;
  clip-path: polygon(10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%, 0 10px);
}
.btn-red:hover, .login-card button:hover { background: var(--red-dark); }
.btn-red:disabled { opacity: 0.5; cursor: wait; }
.btn-ghost {
  display: inline-flex; align-items: center; height: 34px; padding: 0 12px; border: 1px solid rgba(255, 255, 255, 0.2);
  background: transparent; color: var(--text); font: 600 12px "Barlow", sans-serif; letter-spacing: 0.1em;
  text-transform: uppercase; text-decoration: none; cursor: pointer;
}
.btn-ghost:hover { border-color: var(--red); }
.btn-ghost.danger { color: var(--red-light); }
.token { margin-top: 14px; padding: 14px 16px; border-left: 3px solid var(--red); background: rgba(229, 28, 50, 0.08); }
.token.has { border-left-color: #22c55e; background: rgba(34, 197, 94, 0.06); }
.token p { margin: 0 0 10px; color: rgba(244, 244, 242, 0.85); }
.btn-ghost.tall { height: 48px; padding: 0 20px; }
.note { min-height: 1.5em; margin: 12px 0 0; color: var(--red-light); }

.res-head { display: flex; justify-content: space-between; align-items: baseline; }
.results { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; padding-bottom: 60px; }
.card { background: var(--panel); box-shadow: inset 0 0 0 1px var(--line); display: flex; flex-direction: column; }
.card.is-done { box-shadow: inset 0 0 0 1px var(--line), inset 0 3px 0 var(--red); }
.stage { position: relative; aspect-ratio: 1; background: radial-gradient(circle at 50% 40%, #2a2a2e, #101012 70%); display: grid; place-items: center; }
.stage model-viewer { width: 100%; height: 100%; --poster-color: transparent; }
.thumb { position: absolute; left: 10px; bottom: 10px; width: 72px; height: 54px; object-fit: contain; background: #fff; border: 1px solid var(--line); pointer-events: none; }
.spin { width: 42px; height: 42px; border: 3px solid rgba(255, 255, 255, 0.12); border-top-color: var(--red); border-radius: 50%; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.prog { position: absolute; top: calc(50% + 34px); left: 16px; right: 16px; margin: 0; text-align: center; color: var(--muted); font-size: 14px; }
.fail { padding: 20px; color: var(--red-light); font-size: 14px; overflow-wrap: anywhere; }
.meta { padding: 14px 16px 6px; display: flex; flex-direction: column; }
.meta strong { font: 800 20px "Barlow Condensed", sans-serif; text-transform: uppercase; }
.meta small { color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; padding: 8px 16px 16px; }

dialog { width: min(1100px, 100vw - 24px); height: min(820px, 100vh - 24px); padding: 0; border: 0; background: #101012; color: var(--text); box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6); }
dialog::backdrop { background: rgba(0, 0, 0, 0.75); backdrop-filter: blur(4px); }
dialog[open] { display: flex; flex-direction: column; }
.viewer-bar { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
dialog model-viewer { flex: 1; width: 100%; background: radial-gradient(circle at 50% 40%, #2a2a2e, #0c0c0e 70%); }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: radial-gradient(70% 80% at 100% 0%, rgba(229, 28, 50, 0.18), transparent 60%), var(--bg); }
.login-card { width: min(420px, 100%); display: flex; flex-direction: column; gap: 12px; padding: 36px 30px; background: var(--panel); clip-path: polygon(22px 0, 100% 0, 100% calc(100% - 22px), calc(100% - 22px) 100%, 0 100%, 0 22px); box-shadow: inset 0 0 0 1px var(--line); }
.login-card h1 { font-size: 56px; }
.login-card .err { margin: 0; color: var(--red-light); }

@media (max-width: 700px) {
  .slots { grid-template-columns: 1fr 1fr; }
  .slot.main { grid-column: 1 / -1; }
  .panel { padding: 4px 16px 20px; }
  .results { grid-template-columns: 1fr; }
}
