:root {
  color-scheme: dark;
  --bg: #09090b;
  --bg-subtle: #0d0d11;
  --panel: rgba(18, 18, 22, 0.75);
  --panel-solid: #121216;
  --muted: #a1a1aa;
  --muted-dark: #71717a;
  --text: #fafafa;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.15);
  --coral: #ff595e;
  --coral-hover: #ee494e;
  --coral-glow: rgba(255, 89, 94, 0.25);
  --coral-subtle: rgba(255, 89, 94, 0.12);
  --emerald: #10b981;
  --emerald-subtle: rgba(16, 185, 129, 0.12);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background-color: var(--bg);
  background-image: 
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(255, 89, 94, 0.08), transparent 70%),
    radial-gradient(rgba(255, 255, 255, 0.12) 1px, transparent 1px);
  background-size: 100% 100%, 18px 18px;
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font-sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

::selection {
  background: rgba(255, 89, 94, 0.3);
  color: #ffffff;
}

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

.notice {
  max-width: 1100px;
  margin: 18px auto 0;
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.3);
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-size: 12px;
  color: #fcd34d;
  width: calc(100% - 40px);
}

main {
  max-width: 1140px;
  margin: 0 auto;
  padding: 40px 20px 48px;
  flex: 1;
  width: 100%;
}

.hero {
  text-align: center;
  padding: 32px 20px 40px;
  max-width: 820px;
  margin: 0 auto;
}

.pill-badge-wrap {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: rgba(18, 18, 22, 0.7);
  border: 1px solid var(--line);
  padding: 6px 16px;
  border-radius: var(--radius-full);
  margin-bottom: 24px;
  backdrop-filter: blur(12px);
}

.pill-brand {
  font-weight: 700;
  font-size: 13px;
  letter-spacing: -0.3px;
  color: #fff;
}

.brand-coral {
  color: var(--coral);
}

.pill-sep {
  color: rgba(255, 255, 255, 0.2);
  font-size: 13px;
}

.pill-tag {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

.badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  border: 1px solid rgba(16, 185, 129, 0.3);
  background: var(--emerald-subtle);
  color: #34d399;
}

h1 {
  font-size: clamp(34px, 5vw, 56px);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -1.5px;
  margin: 0 0 20px;
  color: #fff;
}

.accent-coral {
  color: var(--coral);
}

.hero .lede {
  font-size: 17px;
  line-height: 1.6;
  color: var(--muted);
  max-width: 620px;
  margin: 0 auto 28px;
}

button {
  font: inherit;
  cursor: pointer;
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s, transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
}

button:active:not(:disabled) {
  transform: translateY(0);
}

button:focus-visible, summary:focus-visible, a:focus-visible, input:focus-visible {
  outline: 2px solid var(--coral);
  outline-offset: 3px;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.primary {
  background: var(--coral);
  color: #ffffff;
  font-weight: 600;
  font-size: 14px;
  padding: 12px 24px;
  border-radius: var(--radius-full);
  box-shadow: 0 10px 25px -8px rgba(255, 89, 94, 0.6);
}

.primary:hover:not(:disabled) {
  background: var(--coral-hover);
  box-shadow: 0 14px 30px -8px rgba(255, 89, 94, 0.8);
}

.primary span {
  margin-left: 10px;
}

.secondary {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line-strong);
  color: var(--text);
  font-weight: 500;
  font-size: 14px;
  padding: 12px 24px;
  border-radius: var(--radius-full);
  backdrop-filter: blur(8px);
}

.secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.25);
}

.subtle {
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
}

.subtle:hover:not(:disabled) {
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--line);
}

.intro-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin: 20px 0 16px;
  flex-wrap: wrap;
}

.fine {
  color: var(--muted-dark);
  font-size: 12px;
}

.topline {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 16px 0 16px;
}

.eyebrow {
  font-size: 11px;
  letter-spacing: 1.5px;
  font-weight: 700;
  color: var(--coral);
  text-transform: uppercase;
  margin: 0;
}

/* Core Layout - align-items: start prevents any vertical stretching */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(320px, 1fr);
  gap: 24px;
  align-items: start;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  padding: 28px 32px;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 20px 50px -20px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.counter-badge {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  padding: 4px 12px;
  border-radius: var(--radius-full);
}

.signal {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--emerald);
  box-shadow: 0 0 10px var(--emerald);
}

.progress {
  height: 4px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 2px;
  overflow: hidden;
  margin: -6px 0 -4px;
}

.progress > div {
  height: 100%;
  background: linear-gradient(90deg, #ff595e, #ff8e88);
  border-radius: 2px;
  transition: width 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  width: 0;
}

.question-area {
  padding: 6px 0 4px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.overline {
  font-size: 10px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--coral);
  margin: 0;
}

h2 {
  font-size: clamp(24px, 2.5vw, 32px);
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.8px;
  margin: 0;
  color: #fff;
}

#guess-description {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.5;
  margin: 0;
}

.answer-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.answer {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: var(--radius-md);
  padding: 13px 18px;
  font-size: 14px;
  font-weight: 500;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.15s ease;
}

.answer:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 89, 94, 0.4);
  transform: translateY(-1px);
}

.answer.key-active {
  background: rgba(255, 89, 94, 0.2);
  border-color: var(--coral);
  box-shadow: 0 0 12px var(--coral-glow);
}

.answer span {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  color: var(--muted-dark);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 2px 7px;
  border-radius: 4px;
}

.answer.unknown {
  grid-column: 1 / -1;
  background: transparent;
  border: 1px dashed var(--line-strong);
  color: var(--muted);
}

.answer.unknown:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  border-color: var(--coral);
}

.busy {
  color: var(--coral);
  font-size: 13px;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.busy-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 89, 94, 0.2);
  border-top-color: var(--coral);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Inspector Column */
.inspector {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  padding: 24px;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 20px 50px -20px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.inspector-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.inspector-head h3 {
  font-size: 18px;
  font-weight: 600;
  margin: 4px 0 0;
  letter-spacing: -0.4px;
  color: #fff;
}

.engine-chip {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  background: rgba(255, 89, 94, 0.1);
  border: 1px solid rgba(255, 89, 94, 0.25);
  color: var(--coral);
}

.inspector-desc {
  font-size: 12px;
  color: var(--muted-dark);
  line-height: 1.5;
  margin: 0;
}

/* shadcn 2x2 stats grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.stat-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--muted-dark);
}

.stat-value {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.3px;
}

.stat-sub {
  font-size: 10px;
  color: var(--muted);
  font-family: var(--font-mono);
}

/* Details & Radar */
details {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  list-style: none;
}

summary::-webkit-details-marker {
  display: none;
}

.radar-badge, .reveal-badge {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 4px;
  background: rgba(255, 89, 94, 0.15);
  border: 1px solid rgba(255, 89, 94, 0.35);
  color: var(--coral);
}

.reveal-badge {
  background: var(--emerald-subtle);
  border-color: rgba(16, 185, 129, 0.4);
  color: #34d399;
}

.radar-controls {
  margin: 12px 0 8px;
  display: flex;
  align-items: center;
}

.toggle-control {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--muted);
  cursor: pointer;
}

.toggle-control input {
  accent-color: var(--coral);
  cursor: pointer;
}

#candidates {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 380px;
  overflow-y: auto;
  padding-right: 4px;
}

#candidates::-webkit-scrollbar, #catalog-list::-webkit-scrollbar {
  width: 5px;
}

#candidates::-webkit-scrollbar-thumb, #catalog-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 3px;
}

.candidate {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  transition: all 0.15s ease;
}

.candidate.top-candidate {
  background: rgba(255, 89, 94, 0.08);
  border-color: rgba(255, 89, 94, 0.35);
}

.candidate.outside-candidate {
  background: rgba(255, 255, 255, 0.02);
  border: 1px dashed var(--line);
  margin-top: 8px;
}

.candidate-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
}

.candidate-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.candidate-rank {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  color: var(--muted-dark);
  background: rgba(255, 255, 255, 0.06);
  padding: 2px 5px;
  border-radius: 4px;
}

.top-candidate .candidate-rank {
  color: #ffffff;
  background: var(--coral);
}

.outside-tag {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 5px;
  border-radius: 4px;
}

.candidate-name {
  font-weight: 500;
  color: var(--text);
}

.candidate-weight {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 11px;
  color: var(--muted);
}

.top-candidate .candidate-weight {
  color: var(--coral);
  font-weight: 700;
}

.bar {
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.06);
  margin-top: 6px;
  overflow: hidden;
}

.bar > div {
  height: 100%;
  background: var(--coral);
  border-radius: 2px;
  transition: width 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.top-candidate .bar > div {
  background: linear-gradient(90deg, #ff595e, #ff8e88);
  box-shadow: 0 0 10px var(--coral-glow);
}

.bar.outside-bar > div {
  background: #71717a;
}

/* History / Clues */
.history {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin-top: 24px;
  backdrop-filter: blur(16px);
}

.history summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
}

.count-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
  padding: 2px 6px;
  border-radius: 10px;
  margin-left: 8px;
}

.timeline {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
}

.clue-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 12px;
}

.clue-num {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--coral);
}

.clue-text {
  flex: 1;
  color: var(--text);
}

.clue-pill {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 3px 8px;
  border-radius: 4px;
  white-space: nowrap;
}

.clue-yes {
  background: var(--emerald-subtle);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #34d399;
}

.clue-no {
  background: rgba(248, 81, 73, 0.15);
  border: 1px solid rgba(248, 81, 73, 0.3);
  color: #ff8e88;
}

.clue-probably {
  background: rgba(163, 113, 247, 0.15);
  border: 1px solid rgba(163, 113, 247, 0.3);
  color: #d2a8ff;
}

.clue-probably_not {
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: #fbbf24;
}

.clue-unknown {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  color: var(--muted);
}

/* Explanation Cards */
.explanation {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin: 32px 0 40px;
}

.step-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.step {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--coral);
  display: block;
  margin-bottom: 8px;
}

.step-card h3 {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 6px;
  color: #fff;
}

.step-card p {
  font-size: 13px;
  color: var(--muted);
  margin: 0;
  line-height: 1.5;
}

/* Footer & Single Clean Link */
footer {
  border-top: 1px solid var(--line);
  padding: 32px 20px 48px;
  max-width: 1140px;
  margin: 0 auto;
  width: 100%;
}

.footer-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 13px;
  color: var(--muted-dark);
}

.footer-content p {
  margin: 0;
}

.footer-content a {
  color: var(--muted);
  text-decoration: none;
  transition: color 0.15s;
}

.footer-content a:hover {
  color: #fff;
}

.footer-links {
  display: flex;
  align-items: center;
}

.review-link {
  font-size: 13px;
  font-weight: 500;
  color: var(--coral) !important;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: opacity 0.15s ease;
}

.review-link:hover {
  opacity: 0.85;
  text-decoration: underline;
}

.error {
  border: 1px solid rgba(248, 81, 73, 0.4);
  background: rgba(248, 81, 73, 0.1);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  margin-top: 20px;
  font-size: 13px;
  color: #ff8e88;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Dialog */
dialog {
  background: var(--panel-solid);
  color: var(--text);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-xl);
  width: min(720px, 92vw);
  padding: 28px 32px;
  max-height: 85vh;
  box-shadow: 0 25px 70px -10px rgba(0, 0, 0, 0.8);
  opacity: 0;
  transform: scale(0.96);
  transition-property: opacity, transform, display, overlay;
  transition-duration: 0.25s;
  transition-timing-function: cubic-bezier(0.16, 1, 0.3, 1);
  transition-behavior: allow-discrete;
}

dialog[open] {
  opacity: 1;
  transform: scale(1);

  @starting-style {
    opacity: 0;
    transform: scale(0.96);
  }
}

dialog::backdrop {
  background-color: rgba(0, 0, 0, 0);
  backdrop-filter: blur(0px);
  transition:
    display 0.25s allow-discrete,
    overlay 0.25s allow-discrete,
    background-color 0.25s ease,
    backdrop-filter 0.25s ease;
}

dialog[open]::backdrop {
  background-color: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);

  @starting-style {
    background-color: rgba(0, 0, 0, 0);
    backdrop-filter: blur(0px);
  }
}

.dialog-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

dialog h2 {
  font-size: 22px;
  margin: 0;
}

dialog p {
  font-size: 13px;
  color: var(--muted);
  margin-top: 6px;
}

.catalog-search-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0 14px;
}

#catalog-search {
  flex: 1;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 13px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  transition: border-color 0.15s;
}

#catalog-search:focus {
  border-color: var(--coral);
}

.count-pill {
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

#catalog-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  max-height: 48vh;
  overflow-y: auto;
  padding-right: 6px;
}

.catalog-entry {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  transition: all 0.15s;
}

.catalog-entry:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 89, 94, 0.4);
}

.catalog-entry-name {
  font-weight: 600;
  font-size: 13px;
  color: #fff;
}

.catalog-entry small {
  color: var(--muted);
  font-size: 11px;
}

[hidden] {
  display: none !important;
}

@media (max-width: 860px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .explanation {
    grid-template-columns: 1fr;
  }
  .footer-content {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 600px) {
  .card {
    padding: 20px 18px;
  }
  .answer-grid {
    grid-template-columns: 1fr;
  }
  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }
  #catalog-list {
    grid-template-columns: 1fr;
  }
}
