.lg {
  width: min(100%, 28.5rem);
  margin: 0 auto;
  background: #e7f3ef;
  color: #17312c;
  border-radius: 16px;
  overflow: visible;
}

.lg button {
  font: inherit;
  font-size: max(16px, 1rem);
}

.lg-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  background: #123f36;
  color: #f7fbf9;
  border-radius: 16px 16px 0 0;
}

.lg-bar strong {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: 0.01em;
}

.lg-bar button,
.lg-end-actions button[data-act="legend-exit"] {
  border: 0;
  background: transparent;
  color: #f7fbf9;
  font-weight: 700;
  padding: 0.2rem 0;
}

.lg-code {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.lg-body {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  padding: 1rem 1rem 1.15rem;
  border-radius: 0 0 16px 16px;
}

.lg-label {
  margin: 0;
  color: #2f8f84;
  font-weight: 700;
}

.lg-id,
.lg-playhead {
  display: grid;
  grid-template-columns: 5.4rem minmax(0, 1fr);
  gap: 0.8rem;
  align-items: center;
}

.lg-avatar {
  width: 5.4rem;
  height: 5.4rem;
  display: grid;
  place-items: center;
  background: var(--coat);
  border: 1px solid rgb(22 49 44 / 0.12);
}

.lg-avatar svg {
  width: 3.1rem;
  height: 3.1rem;
}

.lg-id h2,
.lg-scene h2 {
  margin: 0;
  color: #142824;
  font-size: 1.85rem;
  line-height: 1.15;
  font-weight: 800;
}

.lg-scene h2 {
  font-size: 1.35rem;
}

.lg-id-kicker,
.lg-id-en,
.lg-id-years,
.lg-id-place,
.lg-who,
.lg-meters p,
.lg-mapcap,
.lg-notes p,
.lg-blurb,
.lg-foot p {
  margin: 0;
}

.lg-id-kicker {
  color: #2f8f84;
  font-weight: 800;
}

.lg-id-en,
.lg-id-years,
.lg-id-place,
.lg-who {
  color: #3d5c56;
  line-height: 1.45;
}

.lg-id-en {
  font-weight: 700;
}

.is-alert {
  color: #9d2748;
  font-weight: 800;
}

.lg-fund {
  margin: 0.15rem 0 0.45rem;
  font-weight: 800;
}

.lg-fund b {
  font-variant-numeric: tabular-nums;
}

.lg-years {
  display: flex;
  flex-direction: column;
  gap: 0.22rem;
}

.lg-year {
  display: grid;
  grid-template-columns: 3.4rem minmax(0, 1fr);
  gap: 0.35rem;
  align-items: center;
}

.lg-year span {
  color: #5d8f86;
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
}

.lg-map,
.lg-year .lg-map {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 2px;
  justify-content: stretch;
  min-height: 0;
}

.lg-map-empty {
  grid-column: 1 / -1;
  color: #5d8f86;
  font-size: 0.85rem;
}

.lg-cell,
.lg-year .lg-cell {
  width: auto;
  height: auto;
  aspect-ratio: 1;
  background: #d5e5e0;
}

.lg-cell.is-empty {
  background: transparent;
  border: 1px solid #9fc3ba;
  box-sizing: border-box;
}

.lg-cell.is-gold { background: #0e4f45; }
.lg-cell.is-silver { background: #2f8f7a; }
.lg-cell.is-grey { background: #d7e6e1; }
.lg-cell.is-green {
  background: #bfe8c9;
  border: 0;
}
.lg-cell.is-black { background: #1a1a1a; }
.lg-cell.is-lemon { background: #ffe9a3; }
.lg-cell.is-sky { background: #b9dcff; }

.lg-meters {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.28rem 0.7rem;
}

.lg-meter {
  display: grid;
  grid-template-columns: 4.4rem minmax(0, 1fr);
  gap: 0.3rem;
  align-items: center;
}

.lg-meter span {
  color: #3d7f76;
  font-size: 0.78rem;
}

.lg-meter i {
  display: block;
  height: 0.38rem;
  border-radius: 99px;
  background: #d3e5e0;
}

.lg-meter b {
  display: block;
  height: 100%;
  border-radius: 99px;
  background: #123f36;
}

.lg-meters p,
.lg-mapcap {
  color: #5d8f86;
  font-size: 0.78rem;
  line-height: 1.45;
}

.lg-meters p { grid-column: 1 / -1; }

.lg-scene,
.lg-scene p,
.lg-body > p {
  margin: 0;
  line-height: 1.55;
}

.lg-options {
  display: grid;
  gap: 0.5rem;
}

.lg-options button,
.lg-go {
  min-height: 3rem;
  border-radius: 14px;
  padding: 0.65rem 0.85rem;
}

.lg-options button {
  border: 1px solid #d5e4df;
  background: #fff;
  color: #17312c;
  font-weight: 700;
  text-align: left;
}

.lg-options button .lg-impact {
  display: block;
  margin: 0.22rem 0 0;
  font-size: 0.75rem;
  font-weight: 500;
  color: #8a918e;
  line-height: 1.4;
}

.lg-go {
  border: 0;
  background: #123f36;
  color: #f4fbf8;
  font-weight: 800;
  text-align: center;
}

.lg-options button:focus-visible,
.lg-go:focus-visible,
.lg-bar button:focus-visible,
.lg-speeds button:focus-visible {
  outline: 2px solid #123f36;
  outline-offset: 2px;
}

.lg-facts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem 1rem;
  margin: 0;
}

.lg-facts div { min-width: 0; }

.lg-facts dt {
  color: #5d8f86;
  font-size: 0.82rem;
}

.lg-facts dd {
  margin: 0.12rem 0 0;
  color: #142824;
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1.3;
  font-variant-numeric: tabular-nums;
}

.lg-facts small {
  display: block;
  margin-top: 0.1rem;
  color: #5d8f86;
  font-size: 0.72rem;
  font-weight: 600;
}

.lg.is-end .lg-percent {
  margin: 0.15rem 0 0;
  color: #143f36;
  font-size: clamp(3.2rem, 20vw, 4.6rem);
  line-height: 0.85;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.04em;
}

.lg-vs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem 1rem;
}

.lg-vs dt {
  color: #5d8f86;
  font-size: 0.82rem;
}

.lg-vs dd {
  margin: 0.12rem 0 0;
  color: #142824;
  font-size: 1.05rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.lg-lead {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 800;
  line-height: 1.45;
}

.lg-notes {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.lg-notes p,
.lg-blurb {
  margin: 0;
  color: #3d5c56;
  font-size: 0.92rem;
  line-height: 1.45;
}

.lg-foot {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 0.8rem;
}

.lg-foot p {
  font-weight: 800;
  color: #142824;
  line-height: 1.35;
}

.lg-foot strong {
  flex: 0 0 auto;
  color: #123f36;
  font-size: 1.05rem;
}

.lg-end-actions {
  display: grid;
  gap: 0.35rem;
}

.lg-end-actions button[data-act="legend-exit"] {
  color: #123f36;
  min-height: 2.6rem;
}

.lg.is-play {
  background: #f7f6f3;
  color: #1c1c1c;
}

.lg.is-play .lg-bar {
  background: #fff;
  color: #1c1c1c;
  border-bottom: 1px solid #eceae4;
}

.lg.is-play .lg-bar button,
.lg.is-play .lg-lead,
.lg.is-play .lg-body > p,
.lg.is-play .lg-facts dd,
.lg.is-play .lg-focus h2 {
  color: #1c1c1c;
}

.lg.is-play .lg-label,
.lg.is-play .lg-who,
.lg.is-play .lg-mapcap,
.lg.is-play .lg-year span,
.lg.is-play .lg-facts dt,
.lg.is-play .lg-log header p,
.lg.is-play .lg-note small,
.lg.is-play .lg-note time {
  color: #8a8680;
}

.lg.is-play .lg-now,
.lg.is-play .lg-fund {
  color: #1c1c1c;
}

.lg.is-play .lg-fund.is-alert {
  color: #9d2748;
}

.lg.is-play .lg-pace {
  color: #8a8680;
}

.lg.is-play .lg-go {
  background: #1c1c1c;
  color: #fff;
}

.lg.is-play .lg-options button {
  background: #fff;
  color: #1c1c1c;
  border-color: #e4e2dc;
}

.lg.is-play .lg-options button .lg-impact {
  color: #8a8680;
}

.lg-ticker {
  position: sticky;
  top: 0;
  z-index: 6;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin: 0 -0.2rem;
  padding: 0.2rem 0.2rem 0.55rem;
  background: #e7f3ef;
}

.lg.is-play .lg-ticker {
  background: #f7f6f3;
  box-shadow: 0 10px 14px -12px rgb(28 28 28 / 0.35);
}

.lg-now {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.7rem;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.lg-pace {
  margin: 0;
  color: #8a8680;
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0;
}

.lg-count {
  height: 3px;
  background: #e4e2dc;
  overflow: hidden;
}

.lg-count i {
  display: block;
  height: 100%;
  width: 100%;
  background: #e10600;
  transform-origin: left center;
}

.lg-count i.is-run {
  animation-name: lg-drain;
  animation-timing-function: linear;
  animation-fill-mode: forwards;
}

@keyframes lg-drain {
  from { transform: scaleX(1); }
  to { transform: scaleX(0); }
}

.lg-marquee {
  overflow: hidden;
  margin: 0.8rem 0 0;
  padding: 0.65rem 0;
  border-top: 1px solid #e4e2dc;
  color: #1c1c1c;
  font-size: 0.95rem;
}

.lg-marquee span {
  display: inline-block;
  padding-left: 100%;
  white-space: nowrap;
  animation: lg-marquee 22s linear infinite;
}

@keyframes lg-marquee {
  from { transform: translateX(0); }
  to { transform: translateX(-100%); }
}

@media (prefers-reduced-motion: reduce) {
  .lg-marquee span {
    padding-left: 0;
    white-space: normal;
    animation: none;
  }

  .lg-count i.is-run {
    animation: none;
  }
}

.lg-speeds {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.lg-speeds button {
  min-height: 2.25rem;
  padding: 0.3rem 0.55rem;
  border: 1px solid #e4e2dc;
  border-radius: 8px;
  background: #fff;
  color: #1c1c1c;
  font-size: max(16px, 0.95rem);
}

.lg-speeds button.is-on {
  background: #1c1c1c;
  color: #fff;
  border-color: #1c1c1c;
}

.lg-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.45rem;
}

.lg-stat {
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
  min-width: 0;
}

.lg-stat span {
  color: #8a8680;
  font-size: 0.72rem;
}

.lg-stat b {
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
}

.lg-stat i {
  display: block;
  height: 0.28rem;
  border-radius: 99px;
  background: #e6e4de;
}

.lg-stat em {
  display: block;
  height: 100%;
  border-radius: 99px;
  background: #1c1c1c;
}

.lg-stat.is-alert b {
  color: #e10600;
}

.lg-stat.is-alert em {
  background: #e10600;
}

.lg-log header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.6rem;
  margin-bottom: 0.35rem;
}

.lg-log header p,
.lg-log-empty,
.lg-note p,
.lg-note small {
  margin: 0;
}

.lg-log-empty {
  color: #8a8680;
  line-height: 1.45;
}

.lg-note {
  display: grid;
  grid-template-columns: 5.6rem minmax(0, 1fr);
  gap: 0.55rem;
  padding: 0.7rem 0;
  border-top: 1px solid #eceae4;
  background: transparent;
  color: #1c1c1c;
}

.lg-note time {
  font-size: 0.78rem;
  line-height: 1.35;
}

.lg-note p {
  font-size: 0.98rem;
  line-height: 1.45;
  font-weight: 700;
  color: #1c1c1c;
}

.lg-note small {
  display: block;
  margin-top: 0.15rem;
  color: #8a8680;
  font-size: 0.75rem;
}

.lg-note.is-choice {
  background: #fff6d8;
  box-shadow: inset 3px 0 0 #b45309;
}

.lg.is-play .lg-note.is-choice p {
  color: #9a3412;
}

.lg.is-play .lg-note.is-choice small,
.lg.is-play .lg-note.is-choice time {
  color: #b45309;
}

.lg-specials {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.lg.is-play .lg-note p {
  color: #1c1c1c;
}

.lg-note.is-special {
  color: #1d4ed8;
  box-shadow: inset 3px 0 0 #1d4ed8;
}

.lg-note.is-special p,
.lg.is-play .lg-note.is-special p {
  color: #1d4ed8;
}

.lg.is-play .lg-note.is-special small,
.lg.is-play .lg-note.is-special time {
  color: #3b82f6;
}

.lg-board {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.lg-board h2,
.lg-log h2 {
  margin: 0;
  font-size: 1.15rem;
  line-height: 1.3;
}

.lg-earlier {
  display: block;
  width: 100%;
  margin-top: 0.85rem;
  min-height: 2.75rem;
  border: 1px solid #d9d6cf;
  border-radius: 12px;
  background: #fff;
  color: #1c1c1c;
}

.lg-scrim {
  position: fixed;
  z-index: 40;
  inset: 0 0 var(--tabbar-h, 0px) 0;
  display: grid;
  place-items: start center;
  padding: 16px;
  overflow-y: auto;
  overflow-anchor: none;
  background: rgb(10 18 22 / 0.52);
}

.lg-scrim > .lg-focus {
  width: min(28.5rem, 100%);
  margin-block: auto;
}

.lg-focus {
  padding: 1rem 1rem 1.05rem;
  border: 1px solid #e4e2dc;
  border-radius: 14px;
  background: #fff;
  color: #1c1c1c;
}

.lg-focus header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.lg-focus header button,
.lg-peek button {
  border: 1px solid #e4e2dc;
  border-radius: 999px;
  background: #fff;
  color: #1c1c1c;
  font-size: max(16px, 0.95rem);
  font-weight: 700;
  padding: 0.35rem 0.75rem;
  white-space: nowrap;
}

.lg-focus header button.lg-fold {
  width: 1.7rem;
  min-width: 1.7rem;
  height: 1.7rem;
  min-height: 1.7rem;
  padding: 0;
  display: inline-grid;
  place-items: center;
  border-radius: 8px;
  color: #8a8680;
  font-size: 0;
}

.lg-fold svg {
  width: 0.82rem;
  height: 0.82rem;
}

.lg-context {
  margin: 0.7rem 0 0;
  color: #3d5c56;
  line-height: 1.45;
}

.lg-focus h2 {
  margin: 0.35rem 0 0.75rem;
  font-size: 1.35rem;
  line-height: 1.35;
}

.lg-peek {
  position: fixed;
  z-index: 40;
  left: 50%;
  bottom: calc(12px + var(--tabbar-h, 0px));
  transform: translateX(-50%);
  width: min(28.5rem, calc(100% - 24px));
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0.7rem 0.7rem 1rem;
  border: 1px solid #e4e2dc;
  border-radius: 14px;
  background: #fff;
  color: #1c1c1c;
}

.lg-peek div {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.lg-peek b {
  font-size: 0.95rem;
}

.lg-peek small {
  color: #8a8680;
  font-size: 0.85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lg-talk-stamp {
  color: #8a8680;
  font-size: 0.82rem;
}

.lg-talk-box {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.45rem;
}

.lg-talk-input {
  width: 100%;
  min-height: 3rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid #d5e4df;
  border-radius: 12px;
  background: #fff;
  color: #1c1c1c;
  font: inherit;
  font-size: max(16px, 1rem);
  box-sizing: border-box;
}

.lg-alias {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.lg-alias-label {
  margin: 0;
  color: #2f8f84;
  font-weight: 700;
}

.lg.is-play .lg-alias-label {
  color: #8a8680;
}

.lg-end-title {
  margin: 0 0 0.65rem;
  font-size: 1.22rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  line-height: 1.4;
  color: #123f36;
}

.lg-end-hero {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.85rem 0.95rem;
  border-radius: 14px;
  background: rgb(255 255 255 / 0.55);
  border: 1px solid rgb(18 63 54 / 0.12);
}

.lg-memos,
.lg-bio {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding-top: 0.4rem;
  border-top: 1px solid rgb(18 63 54 / 0.12);
}

.lg-memo {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.55rem 0.75rem;
  border-radius: 10px;
  background: rgb(255 255 255 / 0.5);
}

.lg-memo time {
  color: #5d8f86;
  font-size: 0.76rem;
}

.lg-memo-q,
.lg-memo-a,
.lg-memo-empty,
.lg-bio p,
.lg-pre-line {
  margin: 0;
  line-height: 1.45;
}

.lg-memo-q {
  color: #142824;
  font-weight: 700;
}

.lg-memo-a {
  color: #2f8f84;
  font-weight: 700;
}

.lg-memo-empty,
.lg-bio p {
  color: #3d5c56;
  font-size: 0.92rem;
}

.lg-epitaph {
  margin: 0.2rem 0 0;
  padding: 0.75rem 0.9rem;
  border: 0;
  border-left: 3px solid #1d4ed8;
  border-radius: 0 12px 12px 0;
  background: rgb(255 255 255 / 0.55);
  color: #1c1c1c;
  font-size: 0.92rem;
  line-height: 1.55;
}

@media (max-width: 380px) {
  .lg-id h2 { font-size: 1.55rem; }
  .lg-year { grid-template-columns: 3.1rem minmax(0, 1fr); }
  .lg-talk-box { grid-template-columns: 1fr; }
}
