:root {
  color-scheme: dark;
  font-family: "Segoe UI", "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  background: #101216;
  color: #f5f6f8;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: #101216;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  background: #101216;
  color: #f5f6f8;
}

button,
input {
  font: inherit;
}

button,
a,
label[for^="location-"] {
  -webkit-tap-highlight-color: transparent;
}

.page-shell {
  width: 100%;
  padding: 24px 16px 16px;
}

.tool {
  width: min(100%, 560px);
  margin: 0 auto;
}

.tool-header {
  margin-bottom: 20px;
  text-align: center;
}

.tool-header h1 {
  margin: 0;
  font-family: "Segoe UI Semibold", "SF Pro Display", "Helvetica Neue", Arial,
    sans-serif;
  font-size: clamp(1.35rem, 6vw, 1.75rem);
  line-height: 1.15;
  letter-spacing: 0.02em;
}

.tool-header p {
  margin: 7px 0 0;
  color: #8b93a1;
  font-size: 0.95rem;
}

.setup-card,
.result-card,
.tool-copy {
  border: 1px solid #2e333c;
}

.setup-card {
  padding: 18px;
  background: #191c22;
}

.rating-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 104px;
  align-items: center;
  gap: 16px;
  margin: 10px 0;
}

.rating-label {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 12px;
}

.favored-badge {
  margin-left: auto;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.favored-badge[data-tone="win"] {
  color: #7fd694;
}

.favored-badge[data-tone="loss"] {
  color: #f08a8a;
}

.favored-badge[data-tone="neutral"] {
  color: #8b93a1;
}

.rating-row label,
.location-fieldset legend {
  color: #8b93a1;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.rating-row input {
  width: 100%;
  min-height: 58px;
  border: 1px solid #2e333c;
  border-radius: 0;
  outline: 0;
  background: #23272f;
  color: #f5f6f8;
  caret-color: #e08a3c;
  font-family: "Segoe UI Semibold", "SF Pro Display", "Helvetica Neue", Arial,
    sans-serif;
  font-size: 1.7rem;
  font-weight: 700;
  text-align: center;
}

.rating-row input:focus {
  border-color: #e08a3c;
}

.location-fieldset {
  min-width: 0;
  margin: 24px 0 0;
  padding: 0;
  border: 0;
}

.location-fieldset legend {
  margin-bottom: 10px;
  padding: 0;
}

.location-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.location-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.location-switch label {
  display: flex;
  min-height: 52px;
  align-items: center;
  justify-content: center;
  background: #23272f;
  color: #8b93a1;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 700;
  user-select: none;
}

.location-switch label:active {
  background: #2e333c;
}

.location-input:checked + label {
  background: #e08a3c;
  color: #141414;
}

.location-input:checked + label:active {
  background: #f0a057;
}

.location-input:focus-visible + label {
  outline: 2px solid #f5f6f8;
  outline-offset: 2px;
}

#decide-button {
  width: 100%;
  min-height: 58px;
  margin-top: 18px;
  border: 0;
  border-radius: 0;
  background: #e08a3c;
  color: #141414;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

#decide-button:hover {
  background: #f0a057;
}

#decide-button:active {
  background: #d17c2f;
}

#decide-button:focus-visible {
  outline: 2px solid #f5f6f8;
  outline-offset: 3px;
}

#decide-button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.result-card {
  margin-top: 16px;
  padding: 24px 18px;
  background: #1d2027;
  text-align: center;
}

.result-card h2 {
  margin: 0 0 8px;
  color: #8b93a1;
  font-family: "Segoe UI Semibold", "SF Pro Display", "Helvetica Neue", Arial,
    sans-serif;
  font-size: clamp(1.8rem, 9vw, 2.55rem);
  line-height: 1.1;
}

.result-card[data-tone="win"] h2 {
  color: #7fd694;
}

.result-card[data-tone="loss"] h2 {
  color: #f08a8a;
}

.result-winner {
  min-height: 1.25em;
  margin: 0;
  color: #f5f6f8;
  font-size: 1rem;
  font-weight: 700;
}

.result-card[data-tone="neutral"] .result-winner {
  color: #8b93a1;
}

.result-winner.is-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: #8b93a1;
}

.loading-spinner {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  border: 3px solid #3a404a;
  border-top-color: #e08a3c;
  border-radius: 50%;
  animation: loading-spin 0.7s linear infinite;
}

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

.result-details {
  min-height: 46px;
  margin-top: 14px;
  color: #8b93a1;
  font-size: 0.84rem;
  line-height: 1.45;
}

.result-details p {
  margin: 3px 0;
  white-space: pre-wrap;
}

.error-message {
  min-height: 1.3em;
  margin: 10px 0 0;
  color: #f08a8a;
  font-size: 0.82rem;
  font-weight: 700;
  text-align: center;
}

.tool-copy {
  margin-top: 24px;
  padding: 18px;
  background: #191c22;
}

.tool-copy h2 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.tool-copy h3 {
  margin: 16px 0 4px;
  font-size: 0.9rem;
}

.tool-copy p {
  margin: 0;
  color: #8b93a1;
  font-size: 0.9rem;
  line-height: 1.6;
}

.site-footer {
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 16px 16px 28px;
  color: #8b93a1;
  font-size: 0.82rem;
}

.site-footer a,
.legal-page a {
  color: #8b93a1;
  text-underline-offset: 3px;
}

.site-footer a:hover,
.legal-page a:hover {
  color: #f5f6f8;
}

.legal-page {
  width: min(100%, 720px);
  margin: 0 auto;
  padding: 32px 18px 48px;
}

.legal-page h1 {
  margin: 0 0 8px;
  font-size: 1.8rem;
}

.legal-page h2 {
  margin: 28px 0 8px;
  font-size: 1.05rem;
}

.legal-page p,
.legal-page li {
  color: #8b93a1;
  line-height: 1.65;
}

.legal-page ul {
  padding-left: 20px;
}

.legal-page .back-link {
  display: inline-block;
  margin-bottom: 28px;
}

@media (prefers-reduced-motion: reduce) {
  .loading-spinner {
    animation: none;
    border-color: #e08a3c;
    border-right-color: #3a404a;
  }
}

@media (min-width: 600px) {
  .page-shell {
    padding-top: 48px;
  }

  .setup-card {
    padding: 22px;
  }

  .result-card {
    padding: 26px 22px;
  }
}
