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

:root {
  --bg: #1a1a2e;
  --surface: #16213e;
  --surface2: #0f3460;
  --accent: #e94560;
  --text: #eaeaea;
  --muted: #888;
  --green: #4caf50;
  --yellow: #ffc107;
  --orange: #ff9800;
  --red: #f44336;
  --radius: 6px;
  --font: system-ui, sans-serif;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  min-height: 100vh;
  padding: 1rem;
}

header {
  text-align: center;
  padding: 2rem 0 1.5rem;
}

header h1 { font-size: 2rem; color: var(--accent); }
.subtitle { color: var(--muted); margin-top: 0.4rem; }

main { max-width: 640px; margin: 0 auto; }

/* Guess input row */
#guess-section {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  position: relative;
}

#autocomplete-wrapper {
  flex: 1;
  position: relative;
}

#guess-input {
  width: 100%;
  padding: 0.6rem 0.8rem;
  background: var(--surface);
  border: 1px solid var(--surface2);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 1rem;
}

#guess-input:focus { outline: 2px solid var(--accent); }

#autocomplete-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--surface2);
  border-radius: var(--radius);
  list-style: none;
  z-index: 10;
  max-height: 240px;
  overflow-y: auto;
}

#autocomplete-list li {
  padding: 0.5rem 0.8rem;
  cursor: pointer;
}

#autocomplete-list li:hover,
#autocomplete-list li[aria-selected="true"] {
  background: var(--surface2);
}

button {
  padding: 0.6rem 1.2rem;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  white-space: nowrap;
}

button.secondary {
  background: var(--surface2);
  color: var(--text);
}

button:disabled { opacity: 0.4; cursor: default; }

/* Revealed card */
#result-section {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1.5rem;
  text-align: center;
}

#result-section h2 { margin-bottom: 0.8rem; }

#similar-cards { margin-top: 1.2rem; border-top: 1px solid var(--surface2); padding-top: 1rem; }
#similar-cards h3 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 0.6rem; }
#similar-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; text-align: left; }
#similar-table th { color: var(--muted); font-weight: normal; padding: 0.3rem 0.5rem; border-bottom: 1px solid var(--surface2); }
#similar-table td { padding: 0.4rem 0.5rem; border-bottom: 1px solid var(--surface2); }

#revealed-card img {
  max-width: 240px;
  border-radius: 8px;
  display: block;
  margin: 0 auto 0.5rem;
}

#revealed-card .card-name { font-size: 1.2rem; font-weight: bold; }
#revealed-card .card-type { color: var(--muted); font-size: 0.9rem; }

/* Guess history table */
#history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

#history-table th {
  text-align: left;
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid var(--surface2);
  color: var(--muted);
  font-weight: normal;
}

#history-table td {
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--surface2);
}

.sim-bar-cell { width: 180px; }

.sim-bar-wrapper {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sim-bar {
  flex: 1;
  height: 10px;
  background: var(--surface2);
  border-radius: 5px;
  overflow: hidden;
}

.sim-bar-fill {
  height: 100%;
  border-radius: 5px;
  transition: width 0.3s ease;
}

.sim-pct { font-variant-numeric: tabular-nums; min-width: 3ch; }

/* Similarity colour tiers */
.tier-hot  { background: var(--green); }
.tier-warm { background: var(--yellow); }
.tier-cool { background: var(--orange); }
.tier-cold { background: var(--red); }

.rank-cell { color: var(--muted); font-size: 0.85rem; }

.feature-hints { font-size: 0.7rem; color: var(--muted); margin-top: 3px; }

.card-name-cell { font-weight: 500; cursor: default; }
.card-name-cell[data-image-uri] { cursor: pointer; }
.card-type-cell { color: var(--muted); font-size: 0.8rem; margin-top: 0.1rem; }

/* Floating card image tooltip */
#card-tooltip {
  position: fixed;
  z-index: 100;
  pointer-events: none;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.6));
}

#card-tooltip img {
  width: 200px;
  border-radius: 10px;
  display: block;
}

.mana-cost-cell { white-space: nowrap; }
.mana-sym { width: 1.1rem; height: 1.1rem; vertical-align: middle; margin-right: 1px; }

/* Pinned best guess */
#best-guess-section {
  background: var(--surface);
  border: 1px solid var(--surface2);
  border-radius: var(--radius);
  padding: 0.7rem 0.9rem;
  margin-bottom: 1rem;
}

.best-guess-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.4rem;
}

.best-guess-row {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

#best-guess-name {
  font-weight: 600;
  min-width: 8rem;
  flex-shrink: 0;
}

#best-guess-section .sim-bar-wrapper { flex: 1; }

/* About section */
#about {
  margin: 1.5rem 0;
  border: 1px solid var(--surface2);
  border-radius: var(--radius);
  overflow: hidden;
}

#about summary {
  padding: 0.65rem 0.9rem;
  background: var(--surface);
  cursor: pointer;
  user-select: none;
  font-weight: 600;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

#about summary::before {
  content: "▶";
  font-size: 0.7rem;
  transition: transform 0.2s;
  color: var(--muted);
}

#about[open] summary::before { transform: rotate(90deg); }

.about-content {
  padding: 1rem 1.1rem;
  background: var(--surface);
  border-top: 1px solid var(--surface2);
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  font-size: 0.92rem;
  line-height: 1.6;
  color: var(--text);
}

.about-content h3 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.2rem;
}

.about-content ul {
  padding-left: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.about-content a { color: var(--accent); }

.about-note {
  color: var(--muted);
  font-size: 0.85rem;
  font-style: italic;
}
