:root {
  color-scheme: light;
  --ink: #17212b;
  --muted: #5b6572;
  --paper: #f7f3ec;
  --panel: #ffffff;
  --accent: #d44f2f;
  --accent-dark: #a9321c;
  --teal: #1f8a8a;
  --border: #ded6ca;
  --shadow: 0 24px 80px rgba(23, 33, 43, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 18% 18%, rgba(31, 138, 138, 0.14), transparent 28rem),
    linear-gradient(135deg, #f7f3ec 0%, #e7eef0 52%, #f4d9cb 100%);
}

.app-header {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 2;
  width: 100%;
  padding: 24px clamp(22px, 4vw, 44px);
}

.app-logo {
  display: inline-flex;
  align-items: center;
  color: var(--ink);
  font-size: clamp(1.25rem, 2.6vw, 1.65rem);
  font-weight: 800;
  letter-spacing: 0;
  text-decoration: none;
}

.app-logo img {
  display: block;
  width: clamp(178px, 28vw, 268px);
  height: auto;
}

.counter-shell {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 22px;
  min-height: 100vh;
  padding: 112px 24px 76px;
}

.counter-panel,
.history-panel {
  width: min(100%, 520px);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.counter-panel {
  min-height: min(680px, calc(100vh - 154px));
  padding: clamp(44px, 7vw, 72px) clamp(28px, 5.5vw, 58px);
  text-align: center;
}

.history-panel {
  padding: 24px;
}

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.history-kicker {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.history-panel h2 {
  margin: 0;
  color: var(--ink);
  font-size: 1.05rem;
  line-height: 1.2;
}

.history-list {
  display: grid;
  gap: 10px;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-top: 1px solid rgba(91, 101, 114, 0.18);
}

.history-item div {
  display: grid;
  gap: 3px;
}

.history-item time,
.history-empty {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 650;
}

.history-item strong {
  font-size: 1rem;
}

.history-item span {
  font-variant-numeric: tabular-nums;
  font-size: 1.3rem;
  font-weight: 900;
}

.history-empty {
  margin: 0;
}

.label-row {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 32px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
  text-transform: uppercase;
}

.live-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #a0a6ad;
}

.is-live .live-dot {
  background: var(--teal);
  box-shadow: 0 0 0 5px rgba(31, 138, 138, 0.14);
}

.has-error .live-dot {
  background: var(--accent);
}

.phrase-kicker {
  margin: 34px 0 10px;
  color: var(--muted);
  font-size: clamp(0.84rem, 2.4vw, 0.98rem);
  font-weight: 700;
}

h1 {
  max-width: 9.5em;
  margin: 0 auto 14px;
  overflow-wrap: anywhere;
  font-size: clamp(2.9rem, 14vw, 4.6rem);
  line-height: 1.08;
  letter-spacing: 0;
}

.subtitle {
  max-width: 20rem;
  margin: 0 auto 28px;
  color: var(--muted);
  font-size: clamp(0.92rem, 2.5vw, 1.02rem);
  font-weight: 650;
  line-height: 1.35;
}

.tally-wrap {
  display: grid;
  gap: 12px;
  margin: 0 auto 24px;
}

.tally-label {
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.tally {
  font-variant-numeric: tabular-nums;
  font-size: clamp(4rem, 18vw, 6.25rem);
  line-height: 0.9;
}

.count-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: min(100%, 320px);
  min-height: 58px;
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: var(--accent);
  box-shadow: 0 12px 28px rgba(164, 50, 28, 0.28);
  cursor: pointer;
  font: inherit;
  font-size: 0.98rem;
  font-weight: 900;
  transition:
    transform 120ms ease,
    background 120ms ease,
    box-shadow 120ms ease;
}

.count-button:hover {
  background: var(--accent-dark);
  transform: translateY(-1px);
}

.count-button:active {
  transform: translateY(1px) scale(0.99);
}

.count-button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
  transform: none;
}

.button-icon {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  font-size: 1.5rem;
  line-height: 1;
}

.helper-text {
  min-height: 1.5rem;
  margin: 22px auto 0;
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.5;
}

.app-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px clamp(18px, 4vw, 36px);
  border-top-right-radius: 8px;
  background: rgba(247, 243, 236, 0.72);
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 650;
  backdrop-filter: blur(12px);
}

.app-footer a {
  color: var(--ink);
  font-weight: 800;
  text-decoration-color: rgba(23, 33, 43, 0.35);
  text-underline-offset: 3px;
}

.app-footer a:hover {
  text-decoration-color: currentColor;
}

.version-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border: 1px solid rgba(91, 101, 114, 0.22);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.54);
  color: var(--muted);
  font-size: 0.76rem;
}

@media (max-width: 520px) {
  .app-header {
    position: static;
    padding: 20px 20px 0;
  }

  .counter-shell {
    min-height: calc(100vh - 58px);
    padding: 28px 14px 82px;
  }

  .counter-panel {
    min-height: auto;
    padding: 36px 20px;
  }

  .history-panel {
    padding: 20px;
  }

  h1 {
    font-size: clamp(2.65rem, 15vw, 4rem);
  }

  .count-button {
    min-height: 66px;
  }

  .app-footer {
    justify-content: center;
    flex-wrap: wrap;
    width: 100%;
    padding: 12px 18px;
    border-top-right-radius: 0;
    text-align: center;
  }
}
