:root {
  color-scheme: dark;
  --paper: #f4e7cb;
  --ink: #1a120c;
  --brass: #e4b15a;
  --verm: #e85d3a;
  --good: #c6ef9a;
  --partial: #f0d48a;
  --fail: #ffb0a1;
  --twist: #e0d0ff;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: transparent;
}

#stage {
  position: absolute;
  width: 1920px;
  height: 1080px;
  left: 0;
  top: 0;
  transform-origin: top left;
  overflow: hidden;
  background: transparent;
  pointer-events: none;
  font-family: "Source Serif 4", Georgia, "Iowan Old Style", serif;
  color: var(--paper);
}

#scenechip,
#modeflag,
#toast,
#dm,
#lane {
  position: absolute;
}

#scenechip {
  top: 36px;
  left: 48px;
  display: flex;
  gap: 14px;
  align-items: baseline;
  padding: 10px 16px 12px;
  background: rgba(12, 10, 8, 0.72);
  border-left: 3px solid var(--brass);
  max-width: 980px;
}

#chipTitle,
#modeflag,
#dmKicker,
#laneKicker,
#outcome,
#die {
  font-family: Syne, "Trebuchet MS", "Segoe UI", sans-serif;
}

#chipTitle {
  letter-spacing: 0.16em;
  font-size: 13px;
  color: var(--brass);
}

#chipLoc {
  font-size: 22px;
  font-weight: 620;
}

#chipMeta {
  font-family: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  font-style: normal;
  font-size: 14px;
  letter-spacing: 0.08em;
  color: rgba(244, 231, 203, 0.78);
}

#modeflag {
  top: 36px;
  right: 48px;
  padding: 8px 12px;
  font-size: 14px;
  letter-spacing: 0.18em;
  background: rgba(12, 10, 8, 0.55);
  color: var(--brass);
}

#toast {
  top: 96px;
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  max-width: 1100px;
  padding: 10px 18px;
  background: rgba(232, 93, 58, 0.92);
  color: #fff8f2;
  font-family: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  font-size: 16px;
  opacity: 0;
  transition: opacity 160ms linear, transform 160ms linear;
}

#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

#danmaku {
  position: absolute;
  inset: 0;
}

.bullet {
  position: absolute;
  left: 0;
  white-space: nowrap;
  font-family: Syne, "Trebuchet MS", sans-serif;
  font-weight: 700;
  font-size: 30px;
  letter-spacing: 0.01em;
  text-shadow:
    0 2px 0 rgba(0, 0, 0, 0.65),
    0 0 18px rgba(0, 0, 0, 0.45);
  animation-name: fly;
  animation-timing-function: linear;
  animation-fill-mode: forwards;
}

.density-low .bullet {
  font-size: 40px;
}

.density-high .bullet {
  font-size: 20px;
}

.bullet b {
  font-family: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  font-weight: 500;
  font-size: 0.48em;
  letter-spacing: 0.08em;
  margin-right: 0.7em;
  opacity: 0.78;
  text-transform: uppercase;
}

.bullet.spam span {
  color: #ffd56a;
}

@keyframes fly {
  from {
    transform: translateX(1920px);
  }
  to {
    transform: translateX(-120%);
  }
}

#dm {
  left: 48px;
  bottom: 176px;
  width: 920px;
  padding: 22px 26px 18px;
  background: rgba(10, 9, 8, 0.8);
  border-top: 3px solid var(--brass);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
}

#dm header {
  display: flex;
  gap: 12px;
  align-items: baseline;
  margin-bottom: 8px;
}

#dmKicker {
  letter-spacing: 0.16em;
  font-size: 13px;
  color: var(--brass);
}

#dm.resolving #dmKicker {
  color: var(--verm);
}

#dmActor {
  font-family: Syne, "Trebuchet MS", sans-serif;
  font-size: 20px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

#dmAction {
  font-family: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  font-size: 14px;
  color: rgba(244, 231, 203, 0.76);
}

#narration {
  margin: 0;
  font-size: 28px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

#effects {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}

#effects li {
  font-family: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  font-size: 13px;
  letter-spacing: 0.04em;
  padding: 4px 8px;
  border: 1px solid rgba(228, 177, 90, 0.45);
  color: var(--brass);
}

#lane {
  left: 48px;
  right: 48px;
  bottom: 32px;
  height: 120px;
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 0 22px;
  background: rgba(8, 7, 6, 0.78);
  border-bottom: 3px solid rgba(228, 177, 90, 0.85);
}

#lane.pulse {
  animation: lane-pulse 480ms ease-out;
}

@keyframes lane-pulse {
  from {
    filter: brightness(1.45);
  }
  to {
    filter: brightness(1);
  }
}

#die {
  width: 88px;
  height: 88px;
  flex: none;
  display: grid;
  place-items: center;
  background: var(--paper);
  color: var(--ink);
  font-size: 40px;
  font-weight: 800;
  box-shadow: 5px 5px 0 rgba(0, 0, 0, 0.4);
}

#die.nat20 {
  background: #f0c14a;
}

#die.nat1 {
  background: var(--verm);
  color: #fff8f3;
}

.lane-copy {
  min-width: 0;
  flex: 1;
}

#laneKicker {
  letter-spacing: 0.18em;
  font-size: 13px;
  color: var(--brass);
}

#laneHighlight {
  margin-top: 4px;
  font-family: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  font-size: 26px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#outcome {
  flex: none;
  min-width: 148px;
  text-align: center;
  letter-spacing: 0.14em;
  font-size: 22px;
  font-weight: 800;
}

#outcome.success {
  color: var(--good);
}
#outcome.partial {
  color: var(--partial);
}
#outcome.fail {
  color: var(--fail);
}
#outcome.twist {
  color: var(--twist);
}

.layer-chat #dm,
.layer-chat #lane,
.layer-chat #scenechip {
  visibility: hidden;
}

.layer-dm #danmaku {
  visibility: hidden;
}

@media (prefers-reduced-motion: reduce) {
  .bullet {
    animation: none;
    position: relative;
    top: auto !important;
    display: block;
    margin: 8px 48px 0 auto;
    text-align: right;
    transform: none;
  }
  #toast,
  #lane {
    animation: none;
    transition: none;
  }
}
