*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  color-scheme: dark;
  --bg-page: #070b16;
  --bg-card: rgba(15, 23, 42, 0.8);
  --bg-input: rgba(15, 23, 42, 0.92);
  --bg-chip: rgba(30, 41, 59, 0.78);
  --border-subtle: rgba(148, 163, 184, 0.18);
  --border-input: rgba(51, 65, 85, 0.9);
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --gold-light: #fde68a;
  --gold-main: #fbbf24;
  --gold-dark: #f59e0b;
  --emerald-text: #a7f3d0;
  --emerald-bright: #6ee7b7;
  --emerald-bg: rgba(16, 185, 129, 0.12);
  --emerald-border: rgba(16, 185, 129, 0.35);
  --rose-text: #fecdd3;
  --rose-bg: rgba(244, 63, 94, 0.12);
  --rose-border: rgba(244, 63, 94, 0.38);
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background:
    radial-gradient(circle at 50% -10%, rgba(245, 158, 11, 0.16), transparent 52%),
    radial-gradient(circle at 100% 20%, rgba(79, 70, 229, 0.16), transparent 45%),
    var(--bg-page);
  color: var(--text-main);
  min-height: 100dvh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

.page-shell {
  width: 100%;
  max-width: 42rem;
  margin: 0 auto;
  padding: 1.25rem 1rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

@media (min-width: 640px) {
  .page-shell {
    padding: 2rem 1.5rem 3.5rem;
  }
}

.header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.65rem;
  text-align: center;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.8rem;
  border-radius: 9999px;
  border: 1px solid rgba(251, 191, 36, 0.25);
  background: rgba(251, 191, 36, 0.1);
  color: #fcd34d;
  font-size: 0.75rem;
  font-weight: 500;
}

.status-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 9999px;
  background: var(--gold-main);
}

.status-dot--ok {
  background: #34d399;
}

.status-dot--err {
  background: #fb7185;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-icon {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 0.75rem;
  box-shadow: 0 8px 20px rgba(245, 158, 11, 0.12);
}

.brand-title {
  margin: 0;
  font-size: 1.9rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(90deg, #fde68a, #fbbf24, #fef08a);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

@media (min-width: 640px) {
  .brand-title {
    font-size: 2.25rem;
  }
}

.brand-subtitle {
  margin: 0;
  max-width: 28rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.glass-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: 1rem;
  padding: 1rem;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.35);
}

@media (min-width: 640px) {
  .glass-card {
    padding: 1.5rem;
  }
}

.form-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.section-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.sample-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
}

.sample-caption {
  font-size: 0.7rem;
  color: var(--text-dim);
}

.sample-btn {
  appearance: none;
  border: 1px solid rgba(51, 65, 85, 0.85);
  background: var(--bg-chip);
  color: #cbd5e1;
  border-radius: 0.5rem;
  padding: 0.28rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, transform 0.1s ease;
}

.sample-btn:hover {
  border-color: rgba(251, 191, 36, 0.5);
  color: var(--gold-light);
}

.sample-btn:active {
  transform: scale(0.96);
}

.solve-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.hints-stack {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.hint-field {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-radius: 0.75rem;
  border: 1px solid var(--border-input);
  background: var(--bg-input);
  padding: 0.625rem 0.875rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.hint-field:focus-within {
  border-color: rgba(251, 191, 36, 0.75);
  box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.16);
}

.hint-num {
  width: 1.5rem;
  height: 1.5rem;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.375rem;
  background: rgba(251, 191, 36, 0.15);
  color: #fcd34d;
  font-size: 0.75rem;
  font-weight: 700;
}

.hint-input {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text-main);
  font-size: 1rem;
  font-weight: 500;
  outline: none;
}

.hint-input::placeholder {
  color: var(--text-dim);
}

.controls-row {
  margin-top: 0.35rem;
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

@media (min-width: 640px) {
  .controls-row {
    flex-direction: row;
    align-items: center;
  }
}

.primary-btn {
  flex: 1;
  appearance: none;
  border: 0;
  border-radius: 0.75rem;
  background: linear-gradient(90deg, var(--gold-main), var(--gold-dark));
  color: #020617;
  padding: 0.875rem 1.25rem;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(245, 158, 11, 0.22);
  transition: filter 0.15s ease, transform 0.1s ease, opacity 0.15s ease;
}

.primary-btn:hover:not(:disabled) {
  filter: brightness(1.06);
}

.primary-btn:active:not(:disabled) {
  transform: scale(0.99);
}

.primary-btn:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.secondary-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.top-n-select {
  border-radius: 0.75rem;
  border: 1px solid var(--border-input);
  background: var(--bg-input);
  color: #e2e8f0;
  padding: 0.75rem 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
  outline: none;
}

.top-n-select:focus {
  border-color: var(--gold-main);
}

.clear-btn {
  flex: 1;
  appearance: none;
  border-radius: 0.75rem;
  border: 1px solid var(--border-input);
  background: rgba(30, 41, 59, 0.85);
  color: #cbd5e1;
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, transform 0.1s ease;
}

.clear-btn:hover {
  border-color: #64748b;
  color: #ffffff;
}

.clear-btn:active {
  transform: scale(0.97);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.alert-box {
  border-radius: 0.75rem;
  border: 1px solid var(--rose-border);
  background: var(--rose-bg);
  color: var(--rose-text);
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
}

.hidden {
  display: none !important;
}

.results-section {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.hero-card {
  border-radius: 1rem;
  border: 1px solid rgba(251, 191, 36, 0.42);
  background: linear-gradient(135deg, #0f172a, rgba(30, 27, 75, 0.85), #0f172a);
  padding: 1.25rem;
  box-shadow: 0 20px 40px rgba(245, 158, 11, 0.1);
}

@media (min-width: 640px) {
  .hero-card {
    padding: 1.5rem;
  }
}

.hero-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.hero-kicker {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(252, 211, 77, 0.9);
}

.latency-badge {
  border-radius: 9999px;
  background: rgba(30, 41, 59, 0.9);
  padding: 0.15rem 0.65rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: #cbd5e1;
}

.hero-main {
  margin-top: 0.75rem;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
}

.hero-word {
  margin: 0;
  font-size: 2rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #fcd34d;
  overflow-wrap: anywhere;
}

@media (min-width: 640px) {
  .hero-word {
    font-size: 2.35rem;
  }
}

.hero-badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.badge-cov {
  border-radius: 0.5rem;
  border: 1px solid var(--emerald-border);
  background: var(--emerald-bg);
  color: var(--emerald-bright);
  padding: 0.25rem 0.625rem;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-score {
  border-radius: 0.5rem;
  border: 1px solid rgba(251, 191, 36, 0.32);
  background: rgba(251, 191, 36, 0.12);
  color: var(--gold-light);
  padding: 0.25rem 0.625rem;
  font-size: 0.75rem;
  font-weight: 600;
}

.hero-breakdown-wrap {
  margin-top: 1rem;
}

.hero-breakdown-label {
  margin: 0 0 0.5rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
}

.pills-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
}

.clue-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border-input);
  background: rgba(15, 23, 42, 0.72);
  color: var(--text-dim);
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 500;
}

.clue-pill--matched {
  border-color: var(--emerald-border);
  background: var(--emerald-bg);
  color: var(--emerald-text);
}

.clue-pill-pmi {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  color: var(--text-dim);
}

.clue-pill--matched .clue-pill-pmi {
  color: var(--emerald-bright);
}

.list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.list-title {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #cbd5e1;
}

.results-count {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.candidates-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.cand-card {
  border-radius: 0.75rem;
  border: 1px solid rgba(30, 41, 59, 0.95);
  background: rgba(15, 23, 42, 0.65);
  padding: 0.875rem;
}

.cand-card--first {
  border-color: rgba(251, 191, 36, 0.42);
  background: rgba(251, 191, 36, 0.06);
}

.cand-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.cand-left {
  display: flex;
  align-items: center;
  gap: 0.625rem;
}

.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.5rem;
  height: 1.5rem;
  padding: 0 0.375rem;
  border-radius: 0.375rem;
  background: #1e293b;
  color: #cbd5e1;
  font-size: 0.75rem;
  font-weight: 700;
}

.rank-badge--first {
  background: var(--gold-main);
  color: #020617;
  font-weight: 800;
}

.cand-word {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text-main);
}

.cand-cov {
  border-radius: 0.375rem;
  background: #1e293b;
  color: #cbd5e1;
  padding: 0.125rem 0.5rem;
  font-size: 0.7rem;
  font-weight: 500;
}

.cand-right {
  font-size: 0.75rem;
  text-align: right;
}

.cand-score {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-weight: 600;
  color: #fcd34d;
}

.cand-raw {
  margin-left: 0.45rem;
  color: var(--text-muted);
}

.score-progress {
  width: 100%;
  height: 0.375rem;
  margin: 0.625rem 0;
  border: 0;
  border-radius: 9999px;
  overflow: hidden;
  appearance: none;
  -webkit-appearance: none;
  background-color: #1e293b;
}

.score-progress::-webkit-progress-bar {
  background-color: #1e293b;
  border-radius: 9999px;
}

.score-progress::-webkit-progress-value {
  background: rgba(129, 140, 248, 0.85);
  border-radius: 9999px;
}

.score-progress::-moz-progress-bar {
  background: rgba(129, 140, 248, 0.85);
  border-radius: 9999px;
}

.score-progress--first::-webkit-progress-value {
  background: linear-gradient(90deg, var(--gold-main), #fde047);
}

.score-progress--first::-moz-progress-bar {
  background: linear-gradient(90deg, var(--gold-main), #fde047);
}
