:root {
  color-scheme: dark;
  --black: #090909;
  --surface: #111111;
  --surface-raised: #171717;
  --orange: #ff5a00;
  --orange-light: #ff8a38;
  --orange-dark: #b63f00;
  --cream: #fff8f1;
  --muted: #a99f98;
  --line: rgba(255, 112, 31, 0.2);
  --radius: 24px;
  --font-display: "Archivo Black", Impact, sans-serif;
  --font-body: "DM Sans", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--black);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--cream);
  background:
    radial-gradient(circle at 50% -10%, rgba(255, 90, 0, 0.18), transparent 35rem),
    var(--black);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

button,
select {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

[hidden] {
  display: none !important;
}

.background-grid {
  position: fixed;
  inset: 0;
  z-index: -1;
  opacity: 0.28;
  background-image:
    linear-gradient(rgba(255, 90, 0, 0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 90, 0, 0.055) 1px, transparent 1px);
  background-size: 38px 38px;
  mask-image: linear-gradient(to bottom, black, transparent 75%);
}

.shell {
  width: min(100%, 680px);
  margin: 0 auto;
  padding: 22px 16px 40px;
}

.brand {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  margin-bottom: 34px;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 2px solid var(--orange);
  border-radius: 12px;
  color: var(--black);
  background: var(--orange);
  box-shadow: 0 0 28px rgba(255, 90, 0, 0.25);
  font-family: var(--font-display);
  font-size: 1.35rem;
  transform: rotate(-3deg);
}

.brand h1,
.brand p,
.section-heading h2,
.section-heading p,
.welcome-row h2,
.welcome-row p {
  margin: 0;
}

.brand h1 {
  font-family: var(--font-display);
  font-size: clamp(1.16rem, 5vw, 1.65rem);
  letter-spacing: -0.045em;
  line-height: 1;
}

.brand h1 span {
  color: var(--orange);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--orange-light);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.live-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(17, 17, 17, 0.8);
  font-size: 0;
}

.live-pill.connected {
  color: var(--orange-light);
}

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

.connected .live-dot {
  background: var(--orange);
  box-shadow: 0 0 12px var(--orange);
  animation: pulse 1.8s infinite;
}

.login-card,
.counter-card,
.leaderboard-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(145deg, rgba(24, 24, 24, 0.96), rgba(13, 13, 13, 0.98));
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
}

.login-card {
  padding: 30px 22px 24px;
}

.card-icon {
  display: grid;
  width: 50px;
  height: 50px;
  margin-bottom: 26px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--orange);
  background: rgba(255, 90, 0, 0.08);
  font-size: 1.4rem;
}

.login-card h2,
.counter-card h2,
.leaderboard-card h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.65rem, 7vw, 2.35rem);
  letter-spacing: -0.045em;
  line-height: 1.08;
}

.muted {
  color: var(--muted);
  line-height: 1.55;
}

.login-card .muted {
  margin: 14px 0 28px;
}

label {
  display: block;
  margin-bottom: 9px;
  font-size: 0.82rem;
  font-weight: 700;
}

.select-wrap {
  position: relative;
}

.select-wrap::after {
  position: absolute;
  top: 50%;
  right: 16px;
  color: var(--orange);
  content: "▼";
  font-size: 0.65rem;
  pointer-events: none;
  transform: translateY(-50%);
}

select {
  width: 100%;
  height: 54px;
  padding: 0 44px 0 15px;
  border: 1px solid #35302d;
  border-radius: 13px;
  outline: none;
  color: var(--cream);
  background: #0c0c0c;
  appearance: none;
}

select:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(255, 90, 0, 0.14);
}

.form-error {
  min-height: 22px;
  margin: 8px 0;
  color: #ff9a64;
  font-size: 0.82rem;
}

.primary-button {
  display: flex;
  width: 100%;
  min-height: 55px;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  border: 0;
  border-radius: 13px;
  color: #130700;
  background: var(--orange);
  font-weight: 800;
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease;
}

.primary-button:hover {
  background: var(--orange-light);
}

.primary-button:active {
  transform: scale(0.98);
}

.primary-button:disabled {
  opacity: 0.6;
  cursor: wait;
}

.welcome-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
  padding: 0 4px;
}

.welcome-row h2 {
  max-width: 260px;
  font-family: var(--font-display);
  font-size: clamp(1.2rem, 6vw, 1.75rem);
  letter-spacing: -0.04em;
}

.personal-score {
  text-align: right;
}

.personal-score span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
}

.personal-score strong {
  color: var(--orange);
  font-family: var(--font-display);
  font-size: 2rem;
}

.counter-card {
  position: relative;
  overflow: hidden;
  padding: 25px 22px 24px;
  text-align: center;
}

.counter-card::before {
  position: absolute;
  top: -120px;
  left: 50%;
  width: 320px;
  height: 320px;
  border-radius: 50%;
  background: rgba(255, 90, 0, 0.09);
  content: "";
  filter: blur(25px);
  transform: translateX(-50%);
  pointer-events: none;
}

.counter-copy {
  position: relative;
}

.counter-copy .muted {
  min-height: 48px;
  margin: 10px auto 18px;
  font-size: 0.9rem;
}

.counter-button {
  position: relative;
  display: flex;
  width: min(73vw, 260px);
  aspect-ratio: 1;
  margin: 0 auto;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  border: 2px solid #ff8a38;
  border-radius: 50%;
  color: #160800;
  background:
    radial-gradient(circle at 38% 30%, #ff9b53 0, #ff6811 32%, #ff4f00 72%),
    var(--orange);
  box-shadow:
    0 0 0 9px rgba(255, 90, 0, 0.08),
    0 20px 50px rgba(255, 70, 0, 0.25),
    inset 0 -12px 24px rgba(118, 37, 0, 0.23);
  cursor: pointer;
  transition: transform 170ms ease, filter 170ms ease, box-shadow 170ms ease;
}

.counter-button:hover:not(:disabled) {
  filter: brightness(1.08);
  transform: translateY(-3px);
  box-shadow:
    0 0 0 11px rgba(255, 90, 0, 0.1),
    0 25px 60px rgba(255, 70, 0, 0.32),
    inset 0 -12px 24px rgba(118, 37, 0, 0.2);
}

.counter-button:active:not(:disabled),
.counter-button.bump {
  transform: scale(0.95);
}

.counter-button:focus-visible,
.primary-button:focus-visible {
  outline: 3px solid var(--cream);
  outline-offset: 4px;
}

.counter-button:disabled {
  border-color: #393939;
  color: #9d9692;
  background: #262626;
  box-shadow: 0 0 0 9px rgba(255, 255, 255, 0.025);
  cursor: not-allowed;
}

.button-kicker,
.button-label {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.button-main {
  margin: 2px 0 1px;
  font-family: var(--font-display);
  font-size: clamp(4rem, 18vw, 5.5rem);
  letter-spacing: -0.08em;
  line-height: 1;
}

.daily-progress {
  display: flex;
  justify-content: center;
  gap: 9px;
  margin-top: 26px;
}

.progress-dot {
  width: 36px;
  height: 5px;
  border-radius: 99px;
  background: #38332f;
  transition: background 220ms ease, box-shadow 220ms ease;
}

.progress-dot.done {
  background: var(--orange);
  box-shadow: 0 0 9px rgba(255, 90, 0, 0.45);
}

.leaderboard-card {
  margin-top: 18px;
  padding: 23px 18px 10px;
}

.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 0 4px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.section-heading h2 {
  font-size: 1.5rem;
}

.player-count {
  flex: 0 0 auto;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--orange-light);
  background: rgba(255, 90, 0, 0.07);
  font-size: 0.72rem;
  font-weight: 700;
}

.leaderboard {
  margin: 0;
  padding: 0;
  list-style: none;
}

.leaderboard-item {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  align-items: center;
  gap: 10px;
  min-height: 68px;
  padding: 8px 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.055);
}

.leaderboard-item:last-child {
  border-bottom: 0;
}

.leaderboard-item.me {
  margin: 0 -8px;
  padding-right: 12px;
  padding-left: 12px;
  border-radius: 12px;
  background: rgba(255, 90, 0, 0.07);
}

.rank {
  color: #716963;
  font-family: var(--font-display);
  font-size: 1rem;
  text-align: center;
}

.leaderboard-item:nth-child(1) .rank {
  color: var(--orange);
  font-size: 1.2rem;
}

.leaderboard-name {
  overflow: hidden;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.you-label {
  margin-left: 7px;
  color: var(--orange-light);
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.leaderboard-score {
  min-width: 44px;
  color: var(--orange-light);
  font-family: var(--font-display);
  font-size: 1.16rem;
  text-align: right;
}

.empty-state {
  padding: 20px 0;
  color: var(--muted);
  text-align: center;
}

footer {
  padding: 26px 10px 0;
  color: #706964;
  font-size: 0.7rem;
  text-align: center;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 18px;
  left: 16px;
  z-index: 5;
  max-width: 470px;
  margin: auto;
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--cream);
  background: #1b1512;
  box-shadow: 0 12px 38px rgba(0, 0, 0, 0.5);
  font-size: 0.86rem;
  font-weight: 600;
  text-align: center;
  animation: toast-in 220ms ease both;
}

@keyframes pulse {
  50% { opacity: 0.48; }
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px); }
}

@media (min-width: 520px) {
  .shell {
    padding: 32px 24px 50px;
  }

  .live-pill {
    font-size: 0.7rem;
  }

  .login-card {
    padding: 42px 38px 34px;
  }

  .counter-card {
    padding: 34px 32px 28px;
  }

  .counter-copy .muted {
    min-height: 0;
  }

  .leaderboard-card {
    padding: 27px 26px 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
