:root {
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --paper:   #FCF8F1;
  --paper-2: #F7EFE2;
  --card:    #FFFFFF;
  --ink:     #2B2620;
  --ink-2:   #6E665A;
  --ink-3:   #A89F90;
  --line:    #ECE3D4;
  --line-2:  #E0D4C0;
  --track:   #F1EADC;
  --heat:    #D85A30;

  --shadow: 0 1px 2px rgba(70, 50, 20, .05), 0 2px 10px rgba(70, 50, 20, .035);
  --radius: 14px;
  --radius-sm: 9px;
}

.t-national-alltime { --acc:#BA7517; --tint:#FAEEDA; --tnk:#633806; }
.t-state-alltime    { --acc:#534AB7; --tint:#EEEDFE; --tnk:#3C3489; }
.t-national-monthly { --acc:#1D9E75; --tint:#E1F5EE; --tnk:#0F6E56; }
.t-state-monthly    { --acc:#185FA5; --tint:#E6F1FB; --tnk:#0C447C; }
.t-station          { --acc:#4F7D17; --tint:#EAF3DE; --tnk:#27500A; }
.t-none             { --acc:#CDBFA6; --tint:#F1EDE4; --tnk:#6E665A; }

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--paper);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, p { margin: 0; }

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--card);
  color: var(--ink);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  z-index: 50;
}
.skip-link:focus { left: 12px; top: 12px; box-shadow: 0 0 0 3px rgba(184, 117, 23, .35); }

.app {
  max-width: 940px;
  margin: 0 auto;
  padding: 26px 22px 40px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.brand { display: flex; align-items: center; gap: 11px; }
.brand__mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  border-radius: 11px;
  background: var(--tint, #FAEEDA);
  color: #BA7517;
}
.brand__mark { background: #FAEEDA; color: #BA7517; }
.brand__text { display: flex; flex-direction: column; }
.brand__title { font-size: 16px; font-weight: 600; letter-spacing: -.01em; }
.brand__sub { font-size: 12px; color: var(--ink-3); margin-top: 1px; }

.status { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink-2); }
.status__dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: #3DA35D;
  box-shadow: 0 0 0 0 rgba(61, 163, 93, .5);
  animation: pulse-dot 2s ease-in-out infinite;
}
.status.is-stale .status__dot { background: var(--ink-3); animation: none; }

.stale-banner {
  display: flex;
  align-items: center;
  gap: 9px;
  background: #FBF0D8;
  color: #7A5512;
  border: .5px solid #EBD49B;
  border-radius: var(--radius-sm);
  padding: 9px 13px;
  font-size: 13px;
  margin-bottom: 16px;
}

.card {
  background: var(--card);
  border: .5px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.hero {
  position: relative;
  overflow: hidden;
  background: var(--card);
  border: .5px solid var(--line);
  border-left: 4px solid var(--acc);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  margin-bottom: 22px;
}
.hero.is-broken { background: var(--tint); }

.hero.is-alltime-record { animation: hero-glow 3.4s ease-in-out infinite; }
.hero.is-alltime-record .hero__badge { animation: badge-pulse 2.1s ease-in-out infinite; }
.hero__top {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 14px;
}
.hero__grid {
  display: grid;
  grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr);
  gap: 26px;
  align-items: start;
}
.hero__recordlabel { font-size: 12px; color: var(--ink-2); margin-bottom: 2px; }
.hero__value { font-size: 34px; font-weight: 600; line-height: 1.05; letter-spacing: -.02em; }
.hero__meta { font-size: 12px; color: var(--ink-2); margin-top: 5px; display: flex; align-items: center; gap: 5px; }
.hero__badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--acc); color: #fff;
  font-size: 12px; font-weight: 500;
  padding: 3px 11px; border-radius: 999px;
  margin-top: 9px; cursor: help;
}

.hero__currenthead {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 10px; margin-bottom: 9px; font-size: 12px; color: var(--ink-2);
}

.gauge__track {
  position: relative;
  height: 12px;
  background: var(--track);
  border-radius: 999px;
  overflow: hidden;
}
.gauge__fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 999px; background: var(--heat); }
.gauge__marker {
  position: absolute; top: -3px; bottom: -3px; width: 3px;
  border-radius: 2px; background: var(--acc);
}
.gauge__scale {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 7px; font-size: 11px; color: var(--ink-3);
}
.gauge__gap { color: var(--acc); font-weight: 500; }
.gauge__gap.is-broken { color: var(--acc); }

.hero__secondary {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px;
  margin-top: 13px; padding-top: 11px;
  border-top: .5px solid var(--line);
  font-size: 13px; color: var(--ink-2);
}

.block { margin-bottom: 22px; }
.block__head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 10px; margin-bottom: 11px;
}
.block__title { font-size: 15px; font-weight: 600; letter-spacing: -.01em; }
.block__hint { font-size: 12px; color: var(--ink-3); }
.block__note { font-size: 12.5px; color: var(--ink-2); margin: 0 0 12px; max-width: 64ch; line-height: 1.55; }

.states-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(232px, 1fr));
  gap: 12px;
}
.state {
  position: relative;
  overflow: hidden;
  background: var(--card);
  border: .5px solid var(--line);
  border-left: 3px solid var(--acc);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 13px 14px;
}
.state.is-broken { background: var(--tint); }
.state__head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 8px; margin-bottom: 10px;
}
.state__name { font-size: 14.5px; font-weight: 600; }
.state__current { font-size: 12px; color: var(--ink-2); white-space: nowrap; }
.state__badge {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--acc); color: #fff;
  font-size: 11px; font-weight: 500;
  padding: 2px 9px; border-radius: 999px;
  margin-bottom: 10px; cursor: help;
}

.rec-row { position: relative; }
.rec-row + .rec-row { margin-top: 9px; }
.rec-row__line {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; margin-bottom: 4px; font-size: 11.5px;
}
.rec-row__val { color: var(--ink-2); white-space: nowrap; }
.rec-row__val strong { color: var(--ink); font-weight: 600; }
.rec-row__gap { color: var(--tnk); font-weight: 500; }

.bar {
  position: relative; height: 7px;
  background: var(--track); border-radius: 999px; overflow: hidden;
}
.bar__fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 999px; background: var(--acc); }

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--tint); color: var(--tnk);
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  white-space: nowrap;
}
.chip svg { opacity: .85; }

.recent { overflow: hidden; padding: 2px 0; }
.recent__row {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 14px;
}
.recent__row + .recent__row { border-top: .5px solid var(--line); }
.recent__date { width: 60px; flex-shrink: 0; font-size: 11px; color: var(--ink-3); }
.recent__time { display: block; font-size: 11px; color: var(--ink-3); margin-top: 1px; white-space: nowrap; }
.recent__where { flex: 1; min-width: 0; font-size: 12.5px; }
.recent__where .muted { color: var(--ink-3); }
.recent__vals { width: 104px; text-align: right; font-size: 12px; color: var(--ink-2); flex-shrink: 0; }
.recent__vals strong { color: var(--ink); font-weight: 600; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips .chip { border: .5px solid color-mix(in srgb, var(--acc) 28%, transparent); padding: 4px 10px; font-size: 11.5px; }

.empty {
  font-size: 13px; color: var(--ink-3);
  padding: 14px 16px;
  border: .5px dashed var(--line-2);
  border-radius: var(--radius);
  background: var(--paper-2);
}

.footer {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
  margin-top: 30px; padding-top: 15px;
  border-top: .5px solid var(--line);
  font-size: 11.5px; color: var(--ink-3);
}
.footer__link {
  font: inherit; color: var(--ink-2);
  background: none; border: 0; padding: 0; cursor: pointer;
  text-decoration: underline; text-underline-offset: 2px;
}
.footer__link:hover { color: var(--ink); }

.error {
  text-align: center; padding: 40px 20px; color: var(--ink-2);
}

.modal {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal[hidden] { display: none; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(43, 38, 32, .42); }
.modal__dialog {
  position: relative;
  width: 100%; max-width: 560px; max-height: 86vh; overflow-y: auto;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(40, 28, 12, .25);
  padding: 4px 22px 22px;
}
.modal__head {
  position: sticky; top: 0; background: var(--card);
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 0 12px; margin-bottom: 6px;
  border-bottom: .5px solid var(--line);
}
.modal__title { font-size: 17px; font-weight: 600; }
.modal__close {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 8px;
  border: .5px solid var(--line); background: var(--card);
  color: var(--ink-2); cursor: pointer;
}
.modal__close:hover { background: var(--paper-2); color: var(--ink); }
.modal__body p { font-size: 13.5px; color: var(--ink-2); margin-top: 13px; line-height: 1.6; }
.modal__body strong { color: var(--ink); font-weight: 600; }
.modal__note { font-size: 12px !important; color: var(--ink-3) !important; font-style: italic; }

.confetti {
  position: absolute; top: -14px; width: 7px; height: 10px;
  border-radius: 1px; pointer-events: none;
  animation: confetti-fall 2.9s linear infinite;
  will-change: transform, opacity;
}

:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(184, 117, 23, .35); border-radius: 6px; }

@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 0 0 rgba(61, 163, 93, .5); }
  50% { box-shadow: 0 0 0 5px rgba(61, 163, 93, 0); }
}
@keyframes confetti-fall {
  0%   { transform: translateY(-14px) rotate(0); opacity: 0; }
  12%  { opacity: 1; }
  100% { transform: translateY(190px) rotate(400deg); opacity: 0; }
}
@keyframes hero-glow {
  0%, 100% { box-shadow: var(--shadow); }
  50% { box-shadow: 0 0 0 1px rgba(186, 117, 23, .22), 0 0 26px 1px rgba(186, 117, 23, .28); }
}
@keyframes badge-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.045); }
}

@media (max-width: 640px) {
  .app { padding: 20px 15px 32px; }
  .hero__grid { grid-template-columns: 1fr; gap: 18px; }
  .hero__value { font-size: 30px; }
  .status { order: 3; }
  .recent__row { gap: 8px; padding: 9px 11px; }
  .recent__where { font-size: 12px; }
  .recent__vals { width: 82px; }
  .recent__row .chip { flex-shrink: 0; }
}

/* Große Monitore (≥1080p bleibt unverändert): Layout + prominente Elemente skalieren mit. */
@media (min-width: 2000px) {
  .app { max-width: 1240px; padding: 34px 28px 52px; }
  .states-grid { grid-template-columns: repeat(auto-fit, minmax(264px, 1fr)); gap: 14px; }
  .brand__title { font-size: 18px; }
  .brand__sub, .status, .block__hint { font-size: 13px; }
  .stale-banner { font-size: 14px; }
  .hero { padding: 22px 26px; }
  .hero__value { font-size: 40px; }
  .hero__recordlabel, .hero__meta, .hero__currenthead { font-size: 13px; }
  .hero__secondary { font-size: 14px; }
  .block__title { font-size: 17px; }
  .state { padding: 15px 17px; }
  .state__name { font-size: 16px; }
  .state__current { font-size: 13px; }
  .recent__where { font-size: 13.5px; }
  .recent__vals { font-size: 13px; }
}
@media (min-width: 3000px) {
  .app { max-width: 1560px; padding: 40px 34px 64px; }
  .states-grid { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
  .brand__title { font-size: 21px; }
  .brand__sub, .status, .block__hint { font-size: 14px; }
  .hero { padding: 26px 32px; }
  .hero__value { font-size: 48px; }
  .hero__recordlabel, .hero__meta, .hero__currenthead { font-size: 14px; }
  .hero__secondary { font-size: 15px; }
  .block__title { font-size: 19px; }
  .state { padding: 17px 20px; }
  .state__name { font-size: 18px; }
  .state__current { font-size: 14px; }
  .recent__where { font-size: 15px; }
  .recent__vals { font-size: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  .status__dot,
  .hero.is-alltime-record,
  .hero.is-alltime-record .hero__badge { animation: none; }
  .confetti { display: none; }
  * { scroll-behavior: auto; }
}
