:root {
  color-scheme: dark;
  --ink: #07030d;
  --panel: #120a1c;
  --panel-light: #1b1029;
  --line: #3b2454;
  --muted: #b39ec8;
  --gold: #f5d89a;
  --rose: #ff4d84;
  --cyan: #52e8ff;
  --green: #69f0ae;
  --purple: #be6eff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: radial-gradient(ellipse at 50% 0%, #2b103d 0%, var(--ink) 72%);
  color: #f6f0fa;
  font: 14px/1.5 "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
  min-height: 100vh;
}

main {
  width: min(1600px, 100% - 16px);
  margin: 6px auto 16px;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 10px;
}

header .sub {
  margin: 0;
  color: var(--gold);
  font-size: 11.5px;
  letter-spacing: 0.12em;
  font-weight: 700;
}

h1 {
  font-size: clamp(20px, 2.4vw, 27px);
  margin: 2px 0 0;
  line-height: 1.15;
  letter-spacing: -0.04em;
  text-shadow: 0 2px 16px #ff248066;
}

.header-badges {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.badge {
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  background: #1f1330;
  border: 1px solid #4c326a;
  color: #e6d3f5;
}

.badge.sync {
  border-color: #2f7a68;
  color: var(--green);
  background: #0f2620;
}

.badge.warn {
  border-color: #8f3ad4;
  color: #e3b8ff;
  background: #27103b;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 290px;
  gap: 10px;
}

.stage,
aside {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 16px 44px #020106ee;
}

.boss-hud {
  padding: 10px 16px;
  background: linear-gradient(90deg, #1b0c28, #12081c 60%, #1c0f2b);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 14px;
}

.boss-portrait {
  width: 52px;
  height: 52px;
  border-radius: 10px;
  border: 1.5px solid #d468a8;
  object-fit: cover;
  object-position: center 20%;
  box-shadow: 0 0 14px #c8247466;
  flex-shrink: 0;
}

.boss-bars {
  flex: 1;
  min-width: 0;
}

.boss-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 5px;
  flex-wrap: wrap;
}

.boss-name {
  font-weight: 800;
  font-size: 14px;
  color: #fff2fb;
}

.status-pills {
  display: flex;
  align-items: center;
  gap: 6px;
}

.erosion-pill {
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 800;
  border: 1px solid #ff4d84;
  background: rgba(180, 16, 68, 0.35);
  color: #ffd1e0;
  animation: pulseWarn 1.4s ease-in-out infinite;
}

.erosion-pill.hidden {
  display: none;
}

@keyframes pulseWarn {
  0%, 100% { box-shadow: 0 0 6px rgba(255, 77, 132, 0.35); }
  50% { box-shadow: 0 0 14px rgba(255, 77, 132, 0.85); }
}

.world-pill {
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  border: 1px solid #3f6d9c;
  background: #10243a;
  color: var(--cyan);
  transition: all 0.25s ease;
}

.world-pill.death {
  border-color: #9e3f76;
  background: #331028;
  color: var(--rose);
  box-shadow: 0 0 12px rgba(255, 77, 132, 0.45);
}

.progress-track {
  height: 8px;
  border-radius: 999px;
  background: #0a0511;
  border: 1px solid #331d49;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #52e8ff, #be6eff, #ff4d84);
  transition: width 0.2s ease-out;
}

/* Influence Gauge (Largo vs Yurisie) */
.influence-row {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 5px;
}

.inf-label {
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

.inf-label.largo {
  color: #7eeeff;
}

.inf-label.yurisie {
  color: #ff82b2;
}

.influence-track {
  position: relative;
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, #4b1236, #b81d66);
  border: 1px solid #3d2154;
  overflow: hidden;
}

.influence-fill {
  height: 100%;
  background: linear-gradient(90deg, #38bdf8, #52e8ff, #f5d89a);
  transition: width 0.25s ease-out;
  box-shadow: 0 0 8px rgba(82, 232, 255, 0.7);
}

.influence-mid {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  background: rgba(255, 255, 255, 0.7);
  transform: translateX(-50%);
}

.hud-stats {
  display: flex;
  gap: 12px;
  align-items: center;
  font-size: 12px;
  color: var(--muted);
  flex-shrink: 0;
}

.hud-stats strong {
  color: #fff;
  font-size: 14px;
}

.canvas-wrap {
  position: relative;
  background: #06030b;
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1158 / 720;
}

.intro-gif {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.48;
  mix-blend-mode: screen;
  pointer-events: none;
  z-index: 2;
}

.intro-gif.hidden {
  display: none;
}

.overlay {
  position: absolute;
  inset: 0;
  background: rgba(8, 4, 15, 0.86);
  backdrop-filter: blur(5px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  z-index: 5;
}

.overlay.hidden {
  display: none;
}

.overlay .quote {
  color: var(--gold);
  font-size: 13px;
  margin-bottom: 6px;
}

.overlay h2 {
  margin: 0 0 10px;
  font-size: 26px;
  color: #fff;
}

.overlay p {
  max-width: 580px;
  margin: 0 0 14px;
  color: #d9cae8;
}

.overlay-stats {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  margin-bottom: 16px;
}

.overlay-stats.hidden {
  display: none;
}

.stat-chip {
  background: #1b102c;
  border: 1px solid #482e68;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 12px;
  color: #e6d8f7;
}

.stat-chip strong {
  color: var(--gold);
  margin-left: 4px;
}

.btn-primary {
  background: linear-gradient(135deg, #c82474, #7e22ce);
  color: #fff;
  border: 1px solid #ff78b8;
  padding: 10px 26px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 6px 22px #c8247466;
}

.btn-primary:hover {
  filter: brightness(1.1);
}

/* Timeline Sync Bar */
.timeline-bar {
  padding: 8px 14px 10px;
  background: #0e0717;
  border-top: 1px solid var(--line);
}

.timeline-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 11.5px;
  color: var(--muted);
  margin-bottom: 5px;
}

.timeline-track {
  position: relative;
  height: 16px;
  border-radius: 8px;
  background: #1a0f29;
  border: 1px solid #3c2556;
  overflow: hidden;
  cursor: pointer;
}

.timeline-track:hover {
  border-color: #7c52ad;
}

.timeline-cursor {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 3px;
  background: #ffffff;
  box-shadow: 0 0 8px #ffffff;
  z-index: 3;
  pointer-events: none;
}

.timeline-marker {
  position: absolute;
  top: 2px;
  bottom: 2px;
  width: 4px;
  border-radius: 2px;
  background: var(--rose);
  transform: translateX(-50%);
  z-index: 2;
  pointer-events: none;
}

.timeline-marker.void {
  background: var(--purple);
  width: 5px;
}

.timeline-marker.chain {
  background: var(--green);
}

.timeline-marker.flower {
  background: var(--cyan);
}

.timeline-marker.counter {
  background: var(--gold);
  width: 5px;
}

.controls-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--panel-light);
  border-top: 1px solid var(--line);
}

.btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

button.ctrl,
select.ctrl {
  background: #241638;
  color: #efe4fa;
  border: 1px solid #4d326d;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}

select.ctrl option {
  background: #1a0f29;
  color: #efe4fa;
}

button.ctrl:hover,
select.ctrl:hover {
  border-color: var(--gold);
}

button.ctrl.active {
  background: #432263;
  border-color: var(--cyan);
  color: var(--cyan);
}

.vol-wrap {
  display: inline-flex;
  align-items: center;
  padding: 0 4px;
}

.vol-wrap input[type="range"] {
  width: 68px;
  accent-color: var(--cyan);
  cursor: pointer;
}

.cue-box {
  padding: 10px 14px;
  background: #140c21;
  border-top: 1px solid var(--line);
  font-size: 13px;
  color: #f4e8ff;
}

.cue-box strong {
  color: var(--gold);
}

.voice-sub {
  margin-top: 4px;
  font-size: 12px;
  color: var(--cyan);
  min-height: 18px;
}

/* Sidebar */
aside {
  display: flex;
  flex-direction: column;
  max-height: 790px;
}

.aside-head {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: #180e26;
}

.aside-head h3 {
  margin: 0;
  font-size: 14px;
  color: var(--gold);
}

.aside-head p {
  margin: 3px 0 0;
  font-size: 11.5px;
  color: var(--muted);
}

.step-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.step-item {
  text-align: left;
  width: 100%;
  background: #180f25;
  border: 1px solid #301e46;
  border-radius: 9px;
  padding: 8px 10px;
  color: #d8c8eb;
  cursor: pointer;
  transition: all 0.12s;
}

.step-item:hover {
  border-color: #6b4696;
}

.step-item.active {
  background: #291642;
  border-color: var(--cyan);
  color: #fff;
}

.step-item.done {
  border-color: #2c6e58;
}

.step-item .step-num {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  font-weight: 800;
  color: var(--gold);
}

.step-badge {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(105, 240, 174, 0.14);
  border: 1px solid #2c8a66;
  color: var(--green);
}

.step-item .step-title {
  font-size: 12px;
  font-weight: 700;
  margin-top: 2px;
}

.key-help {
  padding: 10px 14px;
  border-top: 1px solid var(--line);
  background: #11091c;
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.65;
}

.key-help kbd {
  background: #27183b;
  border: 1px solid #4e356e;
  border-radius: 4px;
  padding: 1px 5px;
  color: #fff;
  font-family: inherit;
  font-size: 11px;
}

@media (max-width: 1024px) {
  .layout {
    grid-template-columns: 1fr;
  }
  aside {
    max-height: 360px;
  }
}
