:root {
  --bg: #0f172a;        /* slate-900 */
  --panel: #1e293b;     /* slate-800 */
  --text-main: #e2e8f0; /* slate-200 */
  --text-dim: #94a3b8;  /* slate-400 */
  --radius: 1rem;
  --shadow: 0 24px 48px rgba(0,0,0,0.6);
  --max-width: 1180px;
  --bg-gradient-mid: #1c2d46;
  --bg-gradient-end: #80a3cb;
}

body {
  background: linear-gradient(
    180deg,
    var(--bg) 0%,
    var(--bg-gradient-mid) 45%,
    var(--bg-gradient-end) 100%
  );
  color: var(--text-main);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
               Roboto, "Helvetica Neue", Arial, sans-serif;
  margin: 0;
  padding: clamp(1rem, 2vw, 2.5rem);
  line-height: 1.4;
  position: relative;
  overflow-x: hidden;
}

/* Ensure the HTML `hidden` attribute hides elements regardless of other styles */
[hidden] {
  display: none !important;
}

/* Decorative corner background image (place file as `corner-bg.png`).
   Rendered beneath content and the snow overlay. */
/* Decorative corner image now anchored to footer, not viewport */
.site-footer::after {
  content: "";
  position: absolute;
  right: max(0px, env(safe-area-inset-right));
  bottom: 100%;
  width: min(42vw, 560px);
  aspect-ratio: 3 / 2;
  background-image: url("corner-bg.png");
  background-repeat: no-repeat;
  background-size: contain;
  background-position: right bottom;
  opacity: 0.90; /* slightly stronger for visibility */
  pointer-events: none;
  z-index: 0;
}

.snow-layer {
  pointer-events: none;
  position: fixed;
  inset: 0;
  overflow: hidden;
  z-index: 0;
}

.snowflake {
  position: absolute;
  top: -10px;
  color: rgba(226,232,240,0.7);
  font-size: 0.6rem;
  line-height: 1;
  user-select: none;
  animation-name: fall;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
  filter: blur(0.5px);
  text-shadow:
    0 0 6px rgba(226,232,240,0.4),
    0 0 12px rgba(226,232,240,0.2);
}

@keyframes fall {
  0% {
    transform: translate3d(var(--x, 0vw), -10px, 0) rotate(0deg);
    opacity: var(--o, 0.7);
  }
  100% {
    transform: translate3d(var(--x-end, 0vw), 110vh, 0) rotate(360deg);
    opacity: 0;
  }
}

@media (max-width: 480px) {
  .snow-layer {
    display: none;
  }
}

/* Hide corner art on smaller screens to reduce clutter */
@media (max-width: 640px) {
  .site-footer::after { display: none; }
}

.top-bar {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: clamp(0.75rem, 2vw, 1.25rem) 0 1rem;
  position: relative; /* no longer sticky */
  top: auto;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: .75rem;
  background: var(--bg);
}

.brand-block {
  display: flex;
  align-items: center;
  gap: .85rem;
}

.brand-logo {
  width: clamp(60px, 12vw, 96px);
  height: auto;
  border-radius: .4rem;
  box-shadow: 0 8px 20px rgba(0,0,0,0.35);
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: .2rem;
}

.brand-title {
  font-size: clamp(1.2rem, 1rem + 1.5vw, 2rem);
  font-weight: 600;
  color: var(--text-main);
}

.brand-sub {
  font-size: .8rem;
  color: var(--text-dim);
  letter-spacing: .04em;
  text-transform: uppercase;
}

.top-nav {
  display: flex;
  gap: 1rem;
  font-size: .85rem;
  flex-wrap: wrap;
}

.top-nav a {
  color: #38bdf8;
  text-decoration: none;
}

.top-nav a:hover {
  text-decoration: underline;
}

.cta-banner {
  position: relative;
  margin: 0 auto clamp(0.75rem, 1.8vw, 1.25rem);
  max-width: var(--max-width);
  padding: 0.1rem; /* for gradient ring */
  border-radius: .9rem;
  background: linear-gradient(135deg, rgba(56,189,248,0.9), rgba(59,130,246,0.6));
}

.cta-inner {
  background: linear-gradient(135deg, rgba(15,23,42,0.9), rgba(15,23,42,0.88));
  border: 1px solid rgba(56,189,248,0.45);
  border-radius: .85rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .85rem;
  padding: .8rem 1rem;
}

.cta-text {
  display: flex;
  flex-direction: column;
  gap: .15rem;
}

.cta-title {
  font-size: clamp(1rem, 0.9rem + 1vw, 1.35rem);
  font-weight: 600;
  color: var(--text-main);
}

.cta-sub {
  font-size: .8rem;
  color: var(--text-dim);
}

.cta-button {
  white-space: nowrap;
}

.cta-shadow {
  position: absolute;
  inset: -6px;
  filter: blur(18px);
  background: radial-gradient(80% 60% at 75% 50%, rgba(56,189,248,0.25), transparent 70%);
  border-radius: 1.2rem;
  z-index: 0;
  pointer-events: none;
}

@media (max-width: 560px) {
  .cta-inner {
    flex-direction: column;
    align-items: stretch;
    gap: .6rem;
  }
  .cta-button {
    align-self: flex-start;
  }
}

.season-banner {
  position: relative;
  margin: 0 auto clamp(0.5rem, 1.6vw, 1rem);
  max-width: var(--max-width);
  padding: 0.1rem;
  border-radius: .9rem;
  background: linear-gradient(135deg, rgba(52,211,153,0.9), rgba(34,197,94,0.6));
}

.season-inner {
  background: linear-gradient(135deg, rgba(15,23,42,0.92), rgba(15,23,42,0.9));
  border: 1px solid rgba(52,211,153,0.45);
  border-radius: .85rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .85rem;
  padding: .75rem 1rem;
}

.season-text {
  display: flex;
  flex-direction: column;
  gap: .15rem;
}

.season-title {
  font-size: clamp(0.95rem, 0.85rem + 0.9vw, 1.25rem);
  font-weight: 600;
  color: var(--text-main);
}

.season-sub {
  font-size: .8rem;
  color: var(--text-dim);
}

.season-banner #seasonSelect {
  min-width: 9.5rem;
  font-size: 1rem;
  padding: .5rem .7rem;
  border-color: rgba(52,211,153,0.6);
  box-shadow: 0 0 0 3px rgba(16,185,129,0.12);
}

.season-banner #seasonSelect:focus {
  outline: none;
  border-color: rgba(16,185,129,0.95);
  box-shadow: 0 0 0 4px rgba(16,185,129,0.25);
}

.season-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.btn-refresh {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(52,211,153,0.15);
  border: 1px solid rgba(52,211,153,0.35);
  color: rgba(52,211,153,0.95);
  padding: .5rem .75rem;
  border-radius: .5rem;
  font-size: .85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-refresh:hover {
  background: rgba(52,211,153,0.25);
  border-color: rgba(52,211,153,0.55);
  transform: translateY(-1px);
}

.btn-refresh:active {
  transform: translateY(0);
}

.btn-refresh:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-refresh svg {
  transition: transform 0.6s ease;
}

.btn-refresh:active:not(:disabled) svg {
  transform: rotate(360deg);
}

@media (max-width: 560px) {
  .btn-refresh-text {
    display: none;
  }
  .btn-refresh {
    padding: .5rem;
  }
}

.season-shadow {
  position: absolute;
  inset: -6px;
  filter: blur(16px);
  background: radial-gradient(80% 60% at 25% 50%, rgba(52,211,153,0.22), transparent 70%);
  border-radius: 1.2rem;
  z-index: 0;
  pointer-events: none;
}

@media (max-width: 560px) {
  .season-inner {
    flex-direction: column;
    align-items: stretch;
    gap: .6rem;
  }
}

.wrap {
  max-width: var(--max-width);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr;
  row-gap: 0.75rem;   /* tighter vertical spacing between sections */
  column-gap: 1.5rem; /* keep horizontal spacing the same */
  position: relative;
  z-index: 1;
}

.site-footer {
  margin-top: clamp(1.5rem, 3vw, 2.5rem);
  padding-top: clamp(1rem, 2vw, 1.5rem);
  border-top: 1px solid rgba(71,85,105,0.5);
  font-size: .78rem;
  color: var(--bg-gradient-mid); /* dark blue for stronger contrast */
  position: relative;
  overflow: visible; /* allow decorative image above footer */
  z-index: 0; /* ensure image sits behind the content frames */
}

.footer-wrap {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  align-items: center;
  position: relative;
  z-index: 1; /* ensure text sits above decorative image */
}

.footer-sep { color: var(--bg-gradient-mid); }

.footer-source { color: var(--bg-gradient-mid); }

.footer-link { color: var(--bg-gradient-mid); text-decoration: none; }

.footer-link:hover { text-decoration: underline; }

.card {
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem 1.5rem 1rem;
}

/* removed standalone header row + special season picker block; picker is now a tile */

#seasonSelect {
  background: #0f172a;
  color: var(--text-main);
  border-radius: .5rem;
  border: 1px solid #475569;
  width: 100%;
  font-size: .9rem;
  line-height: 1.2;
  padding: .35rem .55rem; /* tighter to match compact tiles */
  min-width: 7rem;
  cursor: pointer;
}

.totals-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.4rem;
  margin-top: .5rem;
}

.total-box {
  background: rgba(15,23,42,0.45);
  border: 1px solid rgba(71,85,105,0.6);
  border-radius: .75rem;
  padding: 0.45rem 0.75rem; /* tighter vertical padding */
  display: flex;
  flex-direction: column;
  gap: .20rem;            /* tighter spacing between label/value/note */
  justify-content: center; /* center content vertically */
  min-height: clamp(56px, 8vh, 86px); /* more compact overall height */
}

/* Holiday badges */
.holiday-badges {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  margin-top: .1rem;
}

.holiday-badge {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  font-size: .78rem;
  padding: .18rem .5rem;
  border-radius: 9999px;
  border: 1px solid rgba(71,85,105,0.6);
  color: var(--text-main);
  background: rgba(71,85,105,0.18);
  white-space: nowrap;
}

.holiday-badge .amt { opacity: 0.9; }

.holiday-badge.is-yes {
  background: rgba(34,197,94,0.22);
  border-color: rgba(134,239,172,0.6);
  color: rgba(187,247,208,1);
}

.holiday-badge.is-no {
  background: rgba(71,85,105,0.2);
  border-color: rgba(71,85,105,0.6);
  color: #cbd5e1;
}

.holiday-badge.is-missing {
  background: rgba(245,158,11,0.18);
  border-color: rgba(245,158,11,0.6);
  color: #fbbf24;
}

.total-subhead {
  font-size: .7rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.total-value {
  font-size: clamp(0.9rem, 0.8rem + 0.8vw, 1.125rem);
  font-weight: 600;
  line-height: 1.1;
  color: var(--text-main);
}

#first-snow-value,
#last-snow-value {
  font-size: clamp(0.725rem, 0.6rem + 0.55vw, 1rem);
  line-height: 1.2;
}

#first-snow-note,
#last-snow-note {
  line-height: 1.3;
}

.total-note {
  font-size: .78rem;
  color: var(--text-dim);
}

.footnote {
  font-size: .78rem;
  color: var(--text-dim);
  margin-top: 1rem;
  line-height: 1.3;
}

.footnote a {
  color: var(--text-main);
  text-decoration: underline;
}

.record-loading {
  font-size: .85rem;
  color: var(--text-dim);
  margin-top: .35rem;
}

.record-summary-grid {
  display: grid;
  gap: .75rem;
  margin-top: .6rem;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.record-timeline {
  grid-column: 1 / -1;
  background: rgba(15,23,42,0.45);
  border: 1px solid rgba(71,85,105,0.6);
  border-radius: .75rem;
  padding: .85rem 1rem 1.15rem;
  position: relative;
}

.timeline-track {
  position: relative;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 1rem;
  align-items: start;
  justify-items: center;
  padding-top: .5rem;
}

.timeline-track::before {
  content: "";
  position: absolute;
  top: 18px;
  left: 0;
  right: 0;
  height: 2px;
  background: rgba(148,163,184,0.25);
}

.timeline-event {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .45rem;
  text-align: center;
  padding-top: 1.4rem;
}

.timeline-dot {
  width: 14px;
  height: 14px;
  border-radius: 9999px;
  border: 2px solid rgba(56,189,248,0.6);
  background: var(--panel);
  position: relative;
  z-index: 1;
  box-shadow: 0 0 0 4px rgba(56,189,248,0.18);
}

.timeline-event.is-latest-first .timeline-dot {
  border-color: rgba(251,191,36,0.9);
  box-shadow: 0 0 0 4px rgba(251,191,36,0.18);
}

.timeline-event.is-earliest-last .timeline-dot {
  border-color: rgba(52,211,153,0.8);
  box-shadow: 0 0 0 4px rgba(52,211,153,0.18);
}

.timeline-event.is-latest-last .timeline-dot {
  border-color: rgba(248,113,113,0.9);
  box-shadow: 0 0 0 4px rgba(248,113,113,0.2);
}

.timeline-event-text {
  display: flex;
  flex-direction: column;
  gap: .18rem;
}

.timeline-event-label {
  font-size: .7rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.timeline-event-date {
  font-size: .95rem;
  font-weight: 600;
  color: var(--text-main);
}

.timeline-event-season {
  font-size: .75rem;
  color: var(--text-dim);
}

@media (max-width: 640px) {
  .timeline-track {
    grid-template-columns: 1fr;
    gap: 1.25rem;
    justify-items: stretch;
  }
  .timeline-track::before {
    display: none;
  }
  .timeline-event {
    flex-direction: row;
    align-items: center;
    text-align: left;
    padding-top: 0;
  }
  .timeline-dot {
    margin-right: .6rem;
  }
  .timeline-event-text {
    gap: .12rem;
  }
}

.record-summary-item {
  background: rgba(15,23,42,0.45);
  border: 1px solid rgba(71,85,105,0.6);
  border-radius: .75rem;
  padding: .65rem .9rem;
  display: flex;
  flex-direction: column;
  gap: .25rem;
}

.record-label {
  font-size: .68rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.record-value {
  font-size: clamp(1.05rem, 0.95rem + 0.6vw, 1.35rem);
  font-weight: 600;
  color: var(--text-main);
}

.record-detail {
  font-size: .78rem;
  color: var(--text-dim);
}

.record-table-wrapper {
  margin-top: .75rem;
  overflow-x: auto;
}

.record-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .8rem;
  min-width: 520px;
}

.record-table thead th {
  text-align: left;
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  padding: .35rem .5rem;
  color: var(--text-dim);
  border-bottom: 1px solid rgba(71,85,105,0.5);
}

.record-table tbody td {
  padding: .45rem .5rem;
  border-bottom: 1px solid rgba(71,85,105,0.3);
  color: var(--text-main);
}

.record-table tbody tr:last-child td {
  border-bottom: none;
}

.range-form {
  display: flex;
  flex-wrap: wrap;
  gap: .85rem;
  align-items: flex-end;
  margin-top: .65rem;
}

.range-field {
  display: flex;
  flex-direction: column;
  gap: .35rem;
  min-width: min(220px, 100%);
}

.range-field label {
  font-size: .7rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.range-field input[type="date"] {
  background: #0f172a;
  color: var(--text-main);
  border: 1px solid rgba(71,85,105,0.8);
  border-radius: .5rem;
  padding: .4rem .55rem;
  font-size: .9rem;
}

.range-actions {
  display: flex;
  gap: .5rem;
  align-items: center;
}

.btn-primary,
.btn-secondary,
.btn-link {
  border-radius: .5rem;
  padding: .45rem .9rem;
  font-size: .85rem;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  border: none;
}

.btn-primary {
  background: linear-gradient(135deg, rgba(56,189,248,0.95), rgba(14,165,233,0.9));
  color: #0f172a;
  box-shadow: 0 10px 20px rgba(56,189,248,0.25);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 30px rgba(56,189,248,0.28);
}

.btn-secondary {
  background: rgba(71,85,105,0.35);
  color: var(--text-main);
  border: 1px solid rgba(71,85,105,0.7);
}

.btn-secondary:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 20px rgba(71,85,105,0.25);
}

.btn-link {
  background: transparent;
  color: #38bdf8;
  padding: 0;
  border-radius: 0;
}

.btn-link[disabled] {
  opacity: 0.5;
  pointer-events: none;
}

.range-message {
  width: 100%;
  font-size: .78rem;
  margin-top: .5rem;
  color: rgba(148,163,184,0.95);
}

.range-message[data-type="error"] {
  color: rgba(248,113,113,0.95);
}

.range-message[data-type="success"] {
  color: rgba(52,211,153,0.95);
}

.range-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: .75rem;
  margin-top: .75rem;
}

.range-summary-item {
  background: rgba(15,23,42,0.45);
  border: 1px solid rgba(71,85,105,0.6);
  border-radius: .75rem;
  padding: .6rem .85rem;
  display: flex;
  flex-direction: column;
  gap: .22rem;
}

.range-summary-label {
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-dim);
}

.range-summary-value {
  font-size: clamp(1.1rem, 0.95rem + 0.65vw, 1.45rem);
  font-weight: 600;
  color: var(--text-main);
}

.range-summary-note {
  font-size: .78rem;
  color: var(--text-dim);
}

.range-chart-box {
  min-height: clamp(320px, 48vh, 580px);
}

.chart-card-header {
  font-size: .95rem;
  font-weight: 500;
  color: var(--text-main);
  margin-bottom: .5rem;
  display: flex;
  flex-direction: column;
}

.chart-sub {
  font-size: .8rem;
  color: var(--text-dim);
  line-height: 1.3;
}

.data-toolbar {
  margin-top: .4rem;
  font-size: .78rem;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
}

.data-link {
  color: #38bdf8;
  text-decoration: none;
}

.data-link:hover {
  text-decoration: underline;
}

.data-link[aria-disabled="true"] {
  opacity: 0.55;
  pointer-events: none;
  cursor: default;
  text-decoration: none;
}

.data-sep { color: var(--text-dim); }
.data-source { color: var(--text-dim); }

.chart-box {
  position: relative;
  width: 100%;
  height: clamp(320px, 45vh, 560px);
}

.no-snow-message {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: .85rem;
  color: rgba(148,163,184,0.95);
  pointer-events: none;
  padding: 0 1.5rem;
}

#contest-results-card {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

#guess-stats-card {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.guess-stats-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.85rem;
}

@media (min-width: 640px) {
  .totals-grid {
    grid-template-columns: 1fr;
  }
}

.guess-stat-box {
  background: rgba(15,23,42,0.45);
  border: 1px solid rgba(71,85,105,0.6);
  border-radius: .75rem;
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: .35rem;
}

.guess-stat-label {
  font-size: .72rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.guess-stat-value {
  font-size: clamp(1.6rem, 1.3rem + 1.2vw, 2rem);
  font-weight: 600;
  line-height: 1.1;
  color: var(--text-main);
}

.guess-stat-note {
  font-size: .78rem;
  color: var(--text-dim);
}

.guess-chart-box {
  margin-top: .6rem;
  padding: .75rem .85rem 0.5rem;
  background: rgba(15,23,42,0.35);
  border: 1px solid rgba(71,85,105,0.45);
  border-radius: .75rem;
  height: clamp(200px, 30vh, 320px);
}

.guess-chart-box canvas {
  width: 100% !important;
  height: 100% !important;
}

.weatherstar-card {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.weatherstar-embed {
  position: relative;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
}

.weatherstar-embed iframe {
  width: 100%;
  aspect-ratio: 4 / 3;
  border: 0;
  border-radius: 0.5rem;
  box-shadow: none;
  background: #000;
}

@media (min-width: 768px) {
  .weatherstar-card {
    grid-column: 2 / -1;
  }
}

.result-line {
  display: flex;
  flex-direction: column;
  gap: .3rem;
  background: rgba(15,23,42,0.45);
  border: 1px solid rgba(71,85,105,0.6);
  border-radius: .75rem;
  padding: .7rem .8rem;
}

.result-line strong {
  font-weight: 600;
  color: var(--text-main);
}

.result-subhead {
  font-size: .72rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.result-detail {
  font-size: .8rem;
  color: var(--text-dim);
}

.holiday-result-list {
  display: flex;
  flex-direction: column;
}

.holiday-result-row {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.35rem 0;
  border-top: 1px solid rgba(71,85,105,0.45);
}

.holiday-result-row:first-child {
  border-top: none;
  padding-top: 0;
}

.holiday-result-label {
  font-weight: 600;
  color: var(--text-main);
  font-size: .82rem;
}

.holiday-result-meta,
.holiday-result-winners {
  font-size: .8rem;
  color: var(--text-dim);
}

.result-highlight {
  font-weight: 500;
  color: rgba(248,113,113,1);
}

.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15,23,42,0.6);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: row;
  font-size: .9rem;
  font-weight: 500;
  color: var(--text-main);
  z-index: 10;
}

.spinner {
  width: 24px;
  height: 24px;
  border-radius: 9999px;
  border: 3px solid rgba(226,232,240,0.3);
  border-top-color: rgba(226,232,240,1);
  animation: spin 0.8s linear infinite;
  margin-right: .5rem;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (min-width: 540px) {
  .totals-grid {
    grid-template-columns: 1fr;
  }

  .total-box {
    padding: 0.45rem 0.85rem; /* keep compact on larger screens too */
  }

  .top-bar {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }
}

@media (min-width: 768px) {
  .wrap {
    grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
    align-items: start;
  }
  #total-card {
    position: sticky;
    top: clamp(0.5rem, 1.5vw, 1rem); /* stick near the top */
    align-self: start;
    height: fit-content;
    /* Span many rows so right column items stack at the top
       without inheriting the tall left column's row height */
    grid-row: 1 / span 100;
  }
  #chart-card,
  #contest-results-card,
  #guess-stats-card,
  .weatherstar-card {
    grid-column: 2 / -1;
  }
  .guess-stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1024px) {
  .totals-grid {
    grid-template-columns: 1fr;
  }

  .guess-stats-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .guess-chart-box {
    height: clamp(220px, 28vh, 360px);
  }
}

@media (min-width: 1100px) {
  .wrap {
    /* keep two-column layout to avoid tall-row gaps from mixed heights */
    grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
    column-gap: 1.25rem;
  }

  #guess-stats-card {
    grid-column: 2 / -1;
  }
}
