:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #111316;
  color: #f7f2e8;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  overflow: hidden;
  user-select: none;
  background:
    radial-gradient(circle at 50% 44%, rgba(231, 191, 92, 0.12), transparent 32rem),
    linear-gradient(145deg, #15181d 0%, #0e1114 100%);
}

button {
  font: inherit;
}

input,
select {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

.game {
  position: relative;
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 1.5rem;
}

.score-button {
  display: grid;
  width: min(72vmin, 32rem);
  aspect-ratio: 1;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  cursor: pointer;
  outline-offset: 1rem;
  -webkit-tap-highlight-color: transparent;
}

.game[data-auth-state="loading"] .score-button,
.game[data-auth-state="signed-out"] .score-button,
.game[data-auth-state="needs-nickname"] .score-button,
.game[data-auth-state="loading"] .upgrade-card,
.game[data-auth-state="signed-out"] .upgrade-card,
.game[data-auth-state="needs-nickname"] .upgrade-card,
.game[data-auth-state="loading"] .leaderboard-card,
.game[data-auth-state="signed-out"] .leaderboard-card,
.game[data-auth-state="needs-nickname"] .leaderboard-card {
  opacity: 0;
  pointer-events: none;
}

.game[data-auth-state="signed-in"] .login-panel,
.game[data-auth-state="needs-nickname"] .login-panel {
  opacity: 0;
  pointer-events: none;
  transform: translateY(0.5rem);
}

.score-button:active .score {
  transform: scale(0.965);
}

.focus-overlay {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: none;
  place-items: center;
  border: 0;
  background: rgba(7, 8, 10, 0.42);
  color: #f7f2e8;
  cursor: pointer;
  font-size: clamp(1.05rem, 2vw, 1.5rem);
  font-weight: 800;
  letter-spacing: 0;
  backdrop-filter: blur(10px);
}

.game[data-auth-state="signed-in"][data-focus-state="paused"] .focus-overlay {
  display: grid;
}

.score {
  display: grid;
  width: 100%;
  max-width: 100%;
  place-items: center;
  font-size: clamp(4.5rem, 18vmin, 12rem);
  font-weight: 800;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-variant-numeric: tabular-nums lining-nums;
  font-feature-settings: "tnum" 1, "lnum" 1;
  line-height: 0.9;
  letter-spacing: 0;
  text-align: center;
  text-wrap: balance;
  transition: transform 90ms ease;
  user-select: none;
  white-space: nowrap;
}

.upgrade-card,
.leaderboard-card,
.login-panel {
  position: fixed;
  display: grid;
  width: min(22rem, calc(100vw - 2rem));
  gap: 0.62rem;
  padding: 1rem;
  border: 1px solid rgba(247, 242, 232, 0.14);
  border-radius: 8px;
  background: rgba(17, 19, 22, 0.84);
  box-shadow: 0 1rem 2rem rgba(0, 0, 0, 0.26);
  backdrop-filter: blur(14px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.upgrade-card {
  top: 1rem;
  right: 1rem;
}

.leaderboard-card {
  top: 1rem;
  left: 1rem;
}

.login-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  gap: 1rem;
  transform: translate(-50%, -50%);
  z-index: 4;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.player-heading {
  justify-content: center;
}

.upgrade-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  min-height: 1.25rem;
}

.meta-label {
  color: rgba(247, 242, 232, 0.56);
  font-size: 0.78rem;
  font-weight: 720;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.text-button {
  min-height: 1.8rem;
  padding: 0.18rem 0.42rem;
  border: 1px solid rgba(247, 242, 232, 0.14);
  border-radius: 6px;
  background: rgba(247, 242, 232, 0.07);
  color: rgba(247, 242, 232, 0.72);
  cursor: pointer;
  font-size: 0.76rem;
  font-weight: 740;
  letter-spacing: 0;
}

.name-button,
.select-control,
.text-input {
  min-width: 0;
  border: 1px solid rgba(247, 242, 232, 0.14);
  border-radius: 6px;
  background: rgba(247, 242, 232, 0.07);
  color: rgba(247, 242, 232, 0.86);
  letter-spacing: 0;
}

.name-button {
  max-width: 13.5rem;
  min-height: 1.8rem;
  padding: 0.18rem 0.48rem;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 760;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.select-control {
  min-height: 1.8rem;
  padding: 0.18rem 1.8rem 0.18rem 0.48rem;
  background-color: #171a1f;
  color: #f7f2e8;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 740;
}

.select-control option {
  background: #171a1f;
  color: #f7f2e8;
}

.text-input {
  width: 100%;
  min-height: 2.75rem;
  padding: 0.62rem 0.72rem;
  background: rgba(247, 242, 232, 0.1);
  font-size: 1rem;
}

.text-button:hover,
.text-button:focus-visible,
.name-button:hover,
.name-button:focus-visible,
.select-control:hover,
.select-control:focus-visible,
.text-input:focus-visible {
  background: rgba(247, 242, 232, 0.12);
  color: #f7f2e8;
}

.meta-value {
  max-width: 13.5rem;
  color: #f7f2e8;
  font-size: 0.95rem;
  font-weight: 720;
  letter-spacing: 0;
  overflow-wrap: anywhere;
  text-align: right;
}

.tier-rate {
  color: rgba(247, 242, 232, 0.5);
  font-size: 0.78rem;
  font-weight: 680;
  margin-left: 0.45rem;
}

.upgrade-action {
  position: relative;
}

.upgrade-action::after {
  position: absolute;
  right: 0;
  bottom: calc(100% + 0.55rem);
  z-index: 2;
  width: max-content;
  max-width: min(18rem, calc(100vw - 3rem));
  padding: 0.55rem 0.7rem;
  border: 1px solid rgba(247, 242, 232, 0.12);
  border-radius: 6px;
  background: rgba(7, 8, 10, 0.94);
  color: rgba(247, 242, 232, 0.88);
  content: attr(data-tooltip);
  font-size: 0.82rem;
  font-weight: 650;
  letter-spacing: 0;
  line-height: 1.3;
  opacity: 0;
  overflow-wrap: anywhere;
  pointer-events: none;
  text-align: left;
  transform: translateY(0.25rem);
  transition: opacity 120ms ease, transform 120ms ease;
}

.upgrade-action:hover::after,
.upgrade-action:focus-within::after {
  opacity: 1;
  transform: translateY(0);
}

.upgrade {
  width: 100%;
  min-height: 3rem;
  padding: 0.8rem 1rem;
  border: 1px solid rgba(247, 242, 232, 0.16);
  border-radius: 8px;
  background: #e7bf5c;
  color: #18130a;
  cursor: pointer;
  font-weight: 760;
  letter-spacing: 0;
}

.upgrade:disabled {
  background: rgba(247, 242, 232, 0.09);
  color: rgba(247, 242, 232, 0.42);
  cursor: not-allowed;
  box-shadow: none;
}

.leaderboard-list {
  display: grid;
  gap: 0.4rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.leaderboard-row {
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 0.7rem;
  min-height: 1.65rem;
  color: rgba(247, 242, 232, 0.74);
  font-size: 0.9rem;
  font-weight: 680;
}

.leaderboard-row.is-current {
  color: #f7f2e8;
}

.leaderboard-self-rank {
  margin-top: 0.55rem;
  padding-top: 0.55rem;
  border-top: 1px solid rgba(247, 242, 232, 0.12);
}

.leaderboard-rank {
  color: rgba(247, 242, 232, 0.46);
  font-variant-numeric: tabular-nums;
}

.leaderboard-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard-score {
  color: #e7bf5c;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.leaderboard-detail {
  color: #e7bf5c;
  font-variant-numeric: tabular-nums;
  max-width: 8.5rem;
  overflow-wrap: anywhere;
  text-align: right;
}

.leaderboard-empty {
  color: rgba(247, 242, 232, 0.46);
  font-size: 0.9rem;
  font-weight: 650;
}

.brand {
  display: grid;
  gap: 0.3rem;
}

.title {
  margin: 0;
  color: #f7f2e8;
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: 0;
  line-height: 1.1;
}

.subtitle {
  margin: 0;
  color: rgba(247, 242, 232, 0.62);
  font-size: 0.95rem;
  line-height: 1.35;
}

.google-login {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  width: 100%;
  min-height: 3rem;
  padding: 0.8rem 1rem;
  border: 1px solid rgba(247, 242, 232, 0.16);
  border-radius: 8px;
  background: #e7bf5c;
  color: #18130a;
  cursor: pointer;
  font-weight: 760;
  letter-spacing: 0;
}

#googleLogin {
  margin: 0;
}

.google-mark {
  display: grid;
  width: 1.25rem;
  aspect-ratio: 1;
  place-items: center;
  border-radius: 50%;
  background: #f7f2e8;
  color: #18130a;
  font-size: 0.88rem;
  font-weight: 850;
  line-height: 1;
}

.fine-print {
  margin: 0;
  color: rgba(247, 242, 232, 0.42);
  font-size: 0.8rem;
  line-height: 1.35;
}

.modal-shell {
  position: fixed;
  inset: 0;
  z-index: 6;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(7, 8, 10, 0.58);
}

.modal-shell[hidden] {
  display: none;
}

.modal-panel {
  display: grid;
  width: min(22rem, calc(100vw - 2rem));
  gap: 1rem;
  padding: 1rem;
  border: 1px solid rgba(247, 242, 232, 0.14);
  border-radius: 8px;
  background: rgba(17, 19, 22, 0.96);
  box-shadow: 0 1.25rem 3rem rgba(0, 0, 0, 0.42);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.modal-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0;
}

.icon-button {
  display: grid;
  width: 2rem;
  aspect-ratio: 1;
  place-items: center;
  border: 1px solid rgba(247, 242, 232, 0.14);
  border-radius: 6px;
  background: rgba(247, 242, 232, 0.07);
  color: rgba(247, 242, 232, 0.72);
  cursor: pointer;
  font-size: 1rem;
  font-weight: 760;
  line-height: 1;
}

.modal-form,
.modal-actions {
  display: grid;
  gap: 0.7rem;
}

.form-label {
  color: rgba(247, 242, 232, 0.56);
  font-size: 0.78rem;
  font-weight: 720;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.form-message {
  min-height: 1.1rem;
  margin: -0.25rem 0 0;
  color: rgba(247, 242, 232, 0.56);
  font-size: 0.82rem;
  line-height: 1.35;
}

.form-message.is-error {
  color: #ffb4a8;
}

.form-message.is-success {
  color: #bce7aa;
}

.full-action {
  width: 100%;
  min-height: 2.75rem;
}

.danger-button {
  width: 100%;
  min-height: 2.75rem;
  padding: 0.7rem 0.9rem;
  border: 1px solid rgba(255, 129, 112, 0.26);
  border-radius: 8px;
  background: rgba(255, 129, 112, 0.12);
  color: #ffb4a8;
  cursor: pointer;
  font-weight: 760;
  letter-spacing: 0;
}

.stripe-button {
  width: 100%;
  min-height: 3rem;
  padding: 0.8rem 1rem;
  border: 1px solid rgba(99, 91, 255, 0.34);
  border-radius: 8px;
  background: #635bff;
  color: #ffffff;
  cursor: pointer;
  font-weight: 760;
  letter-spacing: 0;
}

.stripe-button:disabled {
  background: rgba(247, 242, 232, 0.09);
  color: rgba(247, 242, 232, 0.42);
  cursor: wait;
}

.upgrade-summary {
  display: grid;
  gap: 0.62rem;
}

@media (max-width: 520px) {
  .game {
    align-items: end;
    padding-top: 24rem;
    padding-bottom: 3rem;
  }

  .leaderboard-card {
    top: 0.75rem;
    right: 0.75rem;
    left: 0.75rem;
    width: auto;
  }

  .upgrade-card {
    top: 11.25rem;
    right: 0.75rem;
    left: 0.75rem;
    width: auto;
  }

  .login-panel {
    top: auto;
    right: 0.75rem;
    bottom: 3rem;
    left: 0.75rem;
    width: auto;
    transform: none;
  }

  .score-button {
    width: min(86vmin, 28rem);
  }

  .score {
    font-size: clamp(4rem, 22vmin, 8.5rem);
  }
}
