:root {
  --bg: #0a0604;
  --ink: #f3d7a8;
  --dim: #8a7a63;
  --ember: #ff8700;
  --stone: #2a2522;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: radial-gradient(ellipse at 50% 70%, #1a0e06 0%, #0a0604 60%, #050302 100%);
  color: var(--ink);
  font-family: "SF Mono", ui-monospace, "Cascadia Code", Menlo, Consolas, monospace;
  min-height: 100vh;
}

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 28px 18px 60px;
  text-align: center;
}

/* The simulation-only config is meaningless when mirroring a real torrent. */
body.live .panel .grid, body.live .hint { display: none; }

.stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 11;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 0 60px rgba(255, 110, 0, 0.18), inset 0 0 40px rgba(0,0,0,0.6);
}

#furnace { width: 100%; height: 100%; display: block; image-rendering: pixelated; }

/* Next / previous torrent arrows — sit in the dark side margins, clear of the
   stone box enclosing the fire. Shown only in live mode with >1 torrent. */
.nav {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 2;
  display: none; align-items: center; justify-content: center;
  width: 38px; height: 56px; border-radius: 9px;
  background: rgba(20, 11, 6, 0.5); border: 1px solid var(--stone);
  color: var(--ink); font-size: 30px; line-height: 1; cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.nav-prev { left: 10px; }
.nav-next { right: 10px; }
.nav:hover {
  border-color: var(--ember); color: #ffcf6b;
  background: rgba(40, 20, 6, 0.7); box-shadow: 0 0 16px rgba(255, 110, 0, 0.25);
}
.nav:active { transform: translateY(-50%) scale(0.94); }
.nav-indicator {
  position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%); z-index: 2;
  display: none; font-size: 11px; color: var(--dim); letter-spacing: 0.08em;
  background: rgba(10, 6, 4, 0.6); padding: 3px 10px; border-radius: 10px;
}

/* Fullscreen toggle — small, top-right of the stage */
.fs-btn {
  position: absolute; top: 10px; right: 10px; z-index: 2;
  width: 30px; height: 30px; border-radius: 7px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; font-size: 16px;
  background: rgba(20, 11, 6, 0.4); border: 1px solid var(--stone); color: var(--dim);
  transition: color 0.15s, border-color 0.15s, opacity 0.2s;
}
.fs-btn:hover { color: #ffcf6b; border-color: var(--ember); }

/* Fullscreen mode: nothing but the fire, a maximized square centred on black. */
body.fs { overflow: hidden; }
body.fs main {
  max-width: none; width: 100vw; height: 100vh; margin: 0; padding: 0;
  display: flex; align-items: center; justify-content: center; background: #000;
}
body.fs .readout, body.fs #panel, body.fs #toggle-panel, body.fs footer,
body.fs .nav, body.fs .nav-indicator, body.fs .fs-btn { display: none !important; }
body.fs .stage {
  width: min(100vw, 100vh); height: min(100vw, 100vh);
  aspect-ratio: auto; border-radius: 0; box-shadow: none;
}

.readout { margin: 16px auto 0; max-width: 560px; }

.pct-row { display: flex; align-items: center; gap: 12px; }
#percent {
  font-size: 22px; font-weight: 700; color: #ffd700;
  min-width: 82px; text-align: right;
  text-shadow: 0 0 12px rgba(255, 215, 0, 0.4);
}
.bar {
  flex: 1; height: 12px; border-radius: 6px;
  background: #1c130c; border: 1px solid var(--stone); overflow: hidden;
}
.bar-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, #d73600, #ff8700, #ffd700);
  transition: width 0.15s linear;
}

.meta-row {
  display: flex; justify-content: space-between;
  margin-top: 8px; font-size: 13px; color: var(--dim);
}
.status.active { color: var(--ember); }
.status.done { color: #87ff5f; }
.status.stalled { color: var(--dim); }
.name { margin-top: 4px; font-size: 12px; color: var(--dim); word-break: break-all; }

.toggle {
  margin-top: 22px; background: none; border: 1px solid var(--stone);
  color: var(--dim); padding: 6px 14px; border-radius: 6px;
  cursor: pointer; font: inherit; font-size: 13px;
}
.toggle:hover { color: var(--ink); border-color: var(--ember); }

.panel {
  margin: 14px auto 0; max-width: 560px; text-align: left;
  background: rgba(20, 11, 6, 0.8); border: 1px solid var(--stone);
  border-radius: 10px; padding: 16px; overflow: hidden;
}
.panel.collapsed { display: none; }
.hint { color: var(--dim); font-size: 12px; margin: 0 0 12px; }
.hint code { color: var(--ember); }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--dim); }
.grid label.check { flex-direction: row; align-items: center; gap: 8px; }
.grid input[type="text"], .grid input[type="number"] {
  background: #0d0906; border: 1px solid var(--stone); color: var(--ink);
  padding: 7px 9px; border-radius: 5px; font: inherit; font-size: 13px;
}
.grid input:focus { outline: none; border-color: var(--ember); }

.buttons { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.buttons button {
  background: #1c130c; border: 1px solid var(--stone); color: var(--ink);
  padding: 8px 16px; border-radius: 6px; cursor: pointer; font: inherit; font-size: 13px;
}
.buttons button:hover { border-color: var(--ember); color: #ffcf6b; }
#apply { background: linear-gradient(180deg, #6b3a00, #4a2800); border-color: var(--ember); }

.legend { margin: 16px 0 0; font-size: 12px; display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; }
.legend dt { color: #ffcf6b; }
.legend dd { margin: 0; color: var(--dim); }

footer { margin-top: 30px; color: #5a4d3c; font-size: 11px; letter-spacing: 0.05em; }

@media (max-width: 480px) {
  .grid { grid-template-columns: 1fr; }
}
