:root {
  color-scheme: dark;
  --surface: rgba(20, 24, 25, .96);
  --surface-raised: #24292b;
  --border: #596266;
  --divider: #444c4f;
  --track: #313739;
  --text: #f1f4f4;
  --secondary: #aab2b4;
  --accent: #e98224;
  --accent-text: #f29a48;
  --success: #a2c76a;
  --warning: #e4a04f;
  --danger: #e26c5e;
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: transparent;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
}

.overlay {
  position: relative;
  width: 125vw;
  height: 125vh;
  transform: scale(.8);
  transform-origin: top left;
}
body[data-ready="false"] .overlay { visibility: hidden; }
.label { color: var(--secondary); font-size: 13px; font-weight: 500; letter-spacing: .07em; text-transform: uppercase; }

.status-rail {
  position: absolute;
  top: 24px;
  left: 32px;
  right: 32px;
  height: 84px;
  display: grid;
  grid-template-columns: .8fr 1.35fr .9fr;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: 4px 4px 0 rgba(0,0,0,.3);
}

.dragon-status-rail { grid-template-columns: .75fr .45fr .8fr 1.45fr; }
.dragon-status-rail .rail-cell { display: flex; min-width: 0; flex-direction: column; justify-content: center; }
.dragon-status-rail strong { margin-top: 5px; overflow: hidden; font-size: 18px; font-weight: 550; text-overflow: ellipsis; white-space: nowrap; }
.dragon-time-cell strong { color: var(--accent-text); font: 500 27px ui-monospace, SFMono-Regular, Menlo, monospace; font-variant-numeric: tabular-nums; }
.dragon-deaths-cell strong { font: 500 27px ui-monospace, SFMono-Regular, Menlo, monospace; font-variant-numeric: tabular-nums; }
.dragon-effect-cell small { margin-top: 4px; overflow: hidden; color: var(--secondary); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }

.status-rail::before, .goal-roadmap::before, .active-action::before, .alert::before {
  content: "";
  position: absolute;
  left: -1px;
  top: -1px;
  width: 6px;
  height: calc(100% + 2px);
  background: var(--accent);
}

.rail-cell { min-width: 0; padding: 13px 20px; border-right: 1px solid var(--divider); }
.rail-cell:last-child { border-right: 0; }
.timer-cell { display: flex; flex-direction: column; justify-content: center; }
.timer-cell strong { margin-top: 4px; font: 500 30px ui-monospace, SFMono-Regular, Menlo, monospace; font-variant-numeric: tabular-nums; }
.timer-cell small { margin-top: 2px; color: var(--secondary); font: 500 11px ui-monospace, monospace; }
body[data-show-state="paused"] .timer-cell { padding-block: 9px; }
body[data-show-state="paused"] .timer-cell strong { font-size: 25px; }
.goal-cell { display: flex; flex-direction: column; justify-content: center; }
.goal-line { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; font-size: 19px; font-weight: 500; }
#goal-count { color: var(--accent-text); font: 500 17px ui-monospace, monospace; white-space: nowrap; }
.progress { height: 7px; margin-top: 9px; overflow: hidden; background: var(--track); }
.progress > span { display: block; width: 0; height: 100%; background: var(--accent); transition: width .6s ease-in-out; }
.segment-cell { display: flex; flex-direction: column; justify-content: center; }
.segment-cell strong { margin-top: 5px; overflow: hidden; font-size: 18px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }

.goal-roadmap {
  position: absolute;
  right: 32px;
  bottom: 28px;
  width: 420px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: 4px 4px 0 rgba(0,0,0,.3);
  transition: transform .42s ease, opacity .35s ease;
}
.goal-roadmap header { display: flex; justify-content: space-between; gap: 14px; padding: 11px 16px 10px 20px; border-bottom: 1px solid var(--divider); background: var(--surface-raised); font-size: 14px; font-weight: 500; }
.goal-roadmap header span:last-child { color: var(--secondary); font-family: ui-monospace, monospace; font-variant-numeric: tabular-nums; }
.previous-goal { display: flex; align-items: center; gap: 8px; margin: 10px 15px 0 20px; color: var(--secondary); font-size: 13px; }
.check { display: grid; width: 18px; height: 18px; place-content: center; border: 1px solid #6d7a60; background: #28302a; color: var(--success); }
.current-goal { margin: 10px 15px 0 20px; padding: 12px 14px; border: 1px solid #6a594a; background: #1d2021; transition: transform .42s ease, opacity .35s ease, border-color .25s, background .25s; }
.current-top { display: flex; justify-content: space-between; gap: 18px; }
.current-top > div { display: flex; min-width: 0; flex-direction: column; }
.current-top strong { margin-top: 4px; overflow: hidden; font-size: 18px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.current-count { padding-top: 3px; font: 500 14px ui-monospace, monospace; white-space: nowrap; }
.upcoming-goals { padding: 11px 15px 13px 20px; }
#upcoming-list { margin-top: 6px; }
.upcoming-row { display: grid; grid-template-columns: 70px 1fr; gap: 9px; padding: 5px 0; border-top: 1px solid #353c3e; color: var(--secondary); font-size: 13px; }
.upcoming-row:first-child { border-top: 0; }
.upcoming-row span:first-child { color: #c5cbcc; font-family: ui-monospace, monospace; }
.goal-roadmap.goal-complete .current-goal { border-color: #75815f; background: #202620; }
.goal-roadmap.goal-complete .current-goal .progress > span { background: var(--success); }
.goal-roadmap.goal-advance { transform: translateY(-14px); opacity: .08; }

.alert {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(620px, calc(100vw - 64px));
  min-height: 132px;
  transform: translate(-50%, -45%);
  padding: 25px 32px 23px 38px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: 7px 7px 0 rgba(0,0,0,.38);
  opacity: 0;
}
.alert.visible { animation: alert-enter .32s ease-out forwards; }
.alert.leaving { animation: alert-exit .25s ease-in forwards; }
.alert strong { display: block; margin-top: 6px; font-size: 32px; font-weight: 500; }
.alert > span:last-of-type { display: block; margin-top: 8px; color: var(--secondary); font-size: 17px; }
.alert-drain { position: absolute; left: 6px; right: 0; bottom: 0; height: 5px; background: var(--track); }
.alert-drain span { display: block; width: 100%; height: 100%; background: var(--accent); transform-origin: left; }
.alert-drain.running span { animation: drain var(--alert-duration, 5s) linear forwards; }

.event-toast-stack {
  position: absolute;
  right: 32px;
  bottom: 350px;
  display: flex;
  width: min(410px, calc(100vw - 64px));
  max-height: calc(100vh - 152px);
  flex-direction: column;
  justify-content: flex-end;
  gap: 8px;
  pointer-events: none;
}
.event-toast-stack.shift { animation: toast-stack-shift .28s ease-out; }
.event-toast { position: relative; flex: 0 0 auto; padding: 12px 16px 12px 21px; overflow: hidden; border: 1px solid var(--border); background: var(--surface); box-shadow: 4px 4px 0 rgba(0,0,0,.3); opacity: 0; transform: translateY(10px); transition: transform .25s ease, opacity .22s ease; }
.event-toast::before { content: ""; position: absolute; inset: -1px auto -1px -1px; width: 5px; background: var(--accent); }
.event-toast.visible { opacity: 1; transform: translateY(0); }
.event-toast.leaving { opacity: 0; transform: translateX(18px); }
.event-toast strong { display: block; margin-top: 4px; overflow-wrap: anywhere; font-size: 18px; font-weight: 550; }
.event-toast > span:last-child { display: block; margin-top: 4px; color: var(--secondary); font-size: 13px; }

.chat-vote { position: absolute; left: 50%; bottom: 28px; width: min(600px, calc(100vw - 64px)); transform: translateX(-50%); padding: 17px 20px 19px 26px; border: 1px solid var(--border); background: var(--surface); box-shadow: 4px 4px 0 rgba(0,0,0,.3); }
.chat-vote::before { content: ""; position: absolute; inset: -1px auto -1px -1px; width: 6px; background: var(--accent); }
.chat-vote header { display: flex; justify-content: space-between; gap: 16px; font-size: 18px; }
.chat-vote header strong { font-weight: 500; }
.chat-vote time { color: var(--accent-text); font: 500 16px ui-monospace, monospace; }
.vote-options { margin-top: 12px; }
.vote-option { display: grid; grid-template-columns: minmax(95px, auto) 1fr 44px; align-items: center; gap: 10px; margin-top: 7px; font-size: 14px; }
.vote-option .progress { margin-top: 0; }
.vote-option > span:last-child { color: var(--secondary); font: 500 13px ui-monospace, monospace; text-align: right; }

.active-action {
  position: absolute;
  left: 32px;
  bottom: 28px;
  min-width: 380px;
  max-width: 600px;
  min-height: 68px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 18px;
  padding: 12px 18px 12px 23px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: 6px 6px 0 rgba(0,0,0,.32);
}
.active-dot { width: 11px; height: 11px; background: var(--accent); }
.active-action div { display: flex; flex-direction: column; }
.active-action strong { margin-top: 4px; font-size: 17px; font-weight: 500; }
.active-action time { font: 500 19px ui-monospace, monospace; font-variant-numeric: tabular-nums; }

.status-stack { position: absolute; top: 124px; right: 32px; display: grid; width: min(410px, calc(100vw - 64px)); gap: 10px; }
.status-toast { position: relative; display: grid; gap: 5px; padding: 14px 18px 14px 22px; border: 1px solid var(--border); background: var(--surface); box-shadow: 4px 4px 0 rgba(0,0,0,.3); }
.status-toast::before { content: ""; position: absolute; inset: -1px auto -1px -1px; width: 5px; background: var(--warning); }
.status-toast strong { font-size: 19px; font-weight: 550; }
.status-toast > span, .break-toast div > span { color: var(--secondary); font-size: 13px; }
.break-toast { grid-template-columns: 1fr auto; align-items: center; gap: 18px; }
.break-toast div { display: grid; gap: 5px; }
.break-toast time { color: var(--accent-text); font: 500 25px ui-monospace, monospace; font-variant-numeric: tabular-nums; }

.major-moment { position: absolute; top: 124px; left: 50%; width: min(720px, calc(100vw - 64px)); display: grid; transform: translateX(-50%); padding: 17px 24px 18px 30px; border: 1px solid var(--border); background: var(--surface); box-shadow: 5px 5px 0 rgba(0,0,0,.32); text-align: left; }
.major-moment strong { margin-top: 5px; font-size: 25px; font-weight: 500; }
.major-moment span { margin-top: 7px; color: var(--secondary); font-size: 14px; }
.major-moment .label { margin-top: 0; color: var(--accent-text); font-size: 12px; }
.ending-message { border-color: #697276; }
.ending-message::before, .major-moment::before { content: ""; position: absolute; inset: -1px auto -1px -1px; width: 6px; background: var(--accent); }
.victory-message { border-color: #75815f; }
.victory-message::before { background: var(--success); }
.victory-message .label { color: var(--success); }

body[data-view="persistent"] .alert,
body[data-view="persistent"] .chat-vote,
body[data-view="persistent"] .status-stack,
body[data-view="persistent"] .event-toast-stack,
body[data-view="persistent"] .major-moment,
body[data-view="alerts"] .status-rail,
body[data-view="alerts"] .goal-roadmap,
body[data-view="alerts"] .active-action,
body[data-view="alerts"] .major-moment,
body[data-view="full"] .status-rail,
body[data-view="full"] .goal-roadmap,
body[data-view="full"] .active-action,
body[data-view="full"] .status-stack,
body[data-view="full"] .event-toast-stack,
body[data-view="full"] .alert { display: none !important; }
body[data-view="full"] .chat-vote { display: none !important; }
body[data-roadmap="false"] .goal-roadmap { display: none !important; }
body[data-alert-active="true"] .chat-vote { display: none !important; }
.connection-warning { position: absolute; right: 32px; top: 124px; padding: 8px 11px; border: 1px solid #76534a; background: var(--surface); color: #efb1a9; font-size: 13px; }
[hidden] { display: none !important; }

@keyframes alert-enter { from { transform: translate(-50%, -38%); opacity: 0; } to { transform: translate(-50%, -50%); opacity: 1; } }
@keyframes alert-exit { from { transform: translate(-50%, -50%); opacity: 1; } to { transform: translate(-50%, -56%); opacity: 0; } }
@keyframes drain { from { transform: scaleX(1); } to { transform: scaleX(0); } }
@keyframes toast-stack-shift { from { transform: translateY(7px); } to { transform: translateY(0); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

body[data-motion="reduce"] *,
body[data-motion="reduce"] *::before,
body[data-motion="reduce"] *::after {
  animation-duration: .01ms !important;
  transition-duration: .01ms !important;
}

@media (max-width: 1120px) {
  .alert {
    top: 220px;
  }

  .chat-vote {
    left: 32px;
    top: 310px;
    bottom: auto;
    transform: none;
  }

  body[data-alert-active="true"] .status-stack {
    display: none !important;
  }
}
