:root {
  --bg: #fff8f0;
  --surface: #ffffff;
  --text: #3a2e27;
  --text-muted: #8a7a6d;
  --border: #eee0d3;
  --primary: #e4572e;
  --primary-text: #ffffff;
  --accent: #f2a541;
  --cold: #4a90d9;
  --warm: #f2a541;
  --hot: #e4572e;
  --borders: #8e5cd9;
  --correct: #3fa34d;
  --shadow: 0 2px 10px rgba(58, 46, 39, 0.08);
  --font-display: "Chewy", "Comic Sans MS", cursive;
  --crumb-opacity: 0.55;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #201a16;
    --surface: #2c241e;
    --text: #f3e9df;
    --text-muted: #b3a396;
    --border: #453a31;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
    --crumb-opacity: 0.8;
  }
}

* {
  box-sizing: border-box;
}

body {
  position: relative;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh;
}

/* Scattered cookies + crumbs, tiled behind everything -- kept subtle so
   cards stay readable on top of it. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: var(--crumb-opacity);
  background-repeat: repeat;
  background-size: 220px 220px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cg%3E%3Ccircle cx='42' cy='48' r='17' fill='%23d9a56b'/%3E%3Ccircle cx='36' cy='42' r='2.2' fill='%236b4226'/%3E%3Ccircle cx='49' cy='44' r='2.2' fill='%236b4226'/%3E%3Ccircle cx='40' cy='54' r='2.2' fill='%236b4226'/%3E%3Ccircle cx='50' cy='55' r='1.8' fill='%236b4226'/%3E%3Ccircle cx='34' cy='53' r='1.6' fill='%236b4226'/%3E%3Ccircle cx='166' cy='152' r='14' fill='%23d9a56b'/%3E%3Ccircle cx='161' cy='147' r='1.8' fill='%236b4226'/%3E%3Ccircle cx='171' cy='149' r='1.8' fill='%236b4226'/%3E%3Ccircle cx='163' cy='157' r='1.8' fill='%236b4226'/%3E%3Ccircle cx='172' cy='157' r='1.5' fill='%236b4226'/%3E%3Ccircle cx='100' cy='130' r='2.6' fill='%238a5a35'/%3E%3Cpath d='M97 127 l3 3 l-3 3 l-3 -3 z' fill='%238a5a35'/%3E%3Ccircle cx='130' cy='44' r='2' fill='%238a5a35'/%3E%3Ccircle cx='188' cy='78' r='2.2' fill='%238a5a35'/%3E%3Ccircle cx='22' cy='150' r='2.4' fill='%238a5a35'/%3E%3Ccircle cx='68' cy='182' r='1.8' fill='%238a5a35'/%3E%3Ccircle cx='188' cy='20' r='1.8' fill='%238a5a35'/%3E%3Ccircle cx='110' cy='190' r='2.2' fill='%238a5a35'/%3E%3Ccircle cx='8' cy='90' r='1.6' fill='%238a5a35'/%3E%3Ccircle cx='150' cy='100' r='1.6' fill='%238a5a35'/%3E%3C/g%3E%3C/svg%3E");
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.topbar h1 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 400;
  letter-spacing: 0.02em;
  margin: 0;
}

.auth-area {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.9rem;
}

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
}

.discord-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: #5865f2;
  color: #fff;
  padding: 0.5rem 0.9rem;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.85rem;
  transition: filter 0.15s ease;
}

.discord-btn:hover {
  filter: brightness(1.08);
}

.discord-btn svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  fill: #fff;
}

.app {
  max-width: 720px;
  margin: 0 auto;
  padding: 1.5rem 1rem 4rem;
}

.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 4px 4px 18px 18px;
  padding: 1.75rem 1.5rem 1.5rem;
  box-shadow: var(--shadow);
}

.card::before {
  content: "";
  position: absolute;
  top: -6px;
  left: -1px;
  right: -1px;
  height: 6px;
  background: var(--accent);
  border-radius: 4px 4px 0 0;
}

.card h2 {
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: 0.02em;
}

.start-card h2 {
  margin-top: 0;
}

.rules {
  color: var(--text-muted);
  line-height: 1.6;
  padding-left: 1.2rem;
}

.primary-btn {
  background: var(--primary);
  color: var(--primary-text);
  border: none;
  border-radius: 10px;
  padding: 0.75rem 1.5rem;
  font-family: var(--font-display);
  font-size: 1.1rem;
  letter-spacing: 0.02em;
  cursor: pointer;
}

.primary-btn:hover {
  filter: brightness(1.05);
}

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

.link-btn {
  background: none;
  border: none;
  color: var(--primary);
  font-weight: 600;
  cursor: pointer;
  padding: 0.5rem;
  font-size: 0.9rem;
}

.progress-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 1.25rem;
  padding-bottom: 0.9rem;
  border-bottom: 1px solid var(--border);
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.stat .stat-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.stat .stat-value {
  font-family: var(--font-display);
  font-size: 1.4rem;
}

.progress-row .stat:last-child {
  text-align: right;
  align-items: flex-end;
}

.hero-image {
  margin: -1.75rem -1.5rem 1.25rem;
  overflow: hidden;
  border-radius: 0;
  display: flex;
}

.hero-image img {
  width: 100%;
  max-height: 320px;
  object-fit: cover;
  background: var(--bg);
}

.hero-image img + img {
  border-left: 2px solid var(--surface);
}

.ingredients {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0;
  margin: 0 0 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.92rem;
}

.ingredients .label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-right: 0.6rem;
}

.ingredient-item + .ingredient-item::before {
  content: "\00b7";
  margin: 0 0.5rem;
  color: var(--text-muted);
}

.hint-banner {
  border-left: 3px solid var(--accent);
  padding: 0.1rem 0 0.1rem 0.8rem;
  margin-bottom: 1.25rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.guess-form {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.autocomplete {
  position: relative;
  flex: 1;
}

.autocomplete input {
  width: 100%;
  padding: 0.6rem 0.1rem;
  border-radius: 0;
  border: none;
  border-bottom: 2px solid var(--border);
  background: transparent;
  color: var(--text);
  font-size: 1rem;
  transition: border-color 0.15s ease;
}

.autocomplete input:focus {
  outline: none;
  border-bottom-color: var(--primary);
}

.autocomplete-menu {
  position: absolute;
  z-index: 5;
  top: calc(100% + 0.4rem);
  left: 0;
  right: 0;
  max-height: 15rem;
  overflow-y: auto;
  margin: 0;
  padding: 0.35rem;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 20px rgba(58, 46, 39, 0.18);
}

.autocomplete-menu li {
  padding: 0.5rem 0.7rem;
  border-radius: 8px;
  font-size: 0.95rem;
  cursor: pointer;
}

.autocomplete-menu li.active,
.autocomplete-menu li:hover {
  background: var(--bg);
  color: var(--primary);
}

.guess-meta {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
}

.error-text {
  color: var(--hot);
  font-size: 0.85rem;
  margin: -0.5rem 0 0.75rem;
}

.guess-history {
  list-style: none;
  padding: 0;
  margin: 0;
}

.guess-history li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.guess-history li:last-child {
  border-bottom: none;
}

.badge {
  border-radius: 999px;
  padding: 0.2rem 0.7rem;
  font-family: var(--font-display);
  font-size: 0.8rem;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-cold { background: var(--cold); }
.badge-warm { background: var(--warm); }
.badge-hot { background: var(--hot); }
.badge-borders { background: var(--borders); }
.badge-correct { background: var(--correct); }

.result-card {
  text-align: center;
}

.result-card h2 {
  margin-top: 0;
}

.result-card .points {
  font-family: var(--font-display);
  font-size: 2.5rem;
  font-weight: 400;
  color: var(--primary);
  margin: 0.25rem 0;
}

.result-card a {
  color: var(--primary);
  font-size: 0.9rem;
}

.result-hero {
  margin-bottom: 1.25rem;
}

.result-hero img {
  max-height: 220px;
}

.dish-name {
  font-family: var(--font-display);
  font-size: 1.3rem;
  margin: 0.25rem 0 0;
}

.dish-tagline {
  color: var(--text-muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0.2rem 0 1rem;
}

.score-summary {
  text-align: center;
  margin-bottom: 1.5rem;
}

.score-summary .total {
  font-family: var(--font-display);
  font-size: 3rem;
  font-weight: 400;
  color: var(--primary);
  display: block;
}

.breakdown-list {
  list-style: none;
  padding: 0;
  margin: 0 0 1.5rem;
}

.breakdown-list li {
  display: flex;
  justify-content: space-between;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
}

.breakdown-list li:last-child {
  border-bottom: none;
}

.breakdown-list .miss {
  color: var(--text-muted);
}

.leaderboard-list {
  list-style: none;
  padding: 0;
  margin: 1rem 0;
}

.leaderboard-list li {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border);
}

.leaderboard-list li:last-child {
  border-bottom: none;
}

.leaderboard-list .rank {
  font-weight: 700;
  color: var(--text-muted);
  width: 1.5rem;
}

.leaderboard-list .lb-score {
  margin-left: auto;
  font-weight: 700;
}

.button-row {
  display: flex;
  gap: 0.6rem;
  justify-content: center;
  flex-wrap: wrap;
}

.muted {
  color: var(--text-muted);
  font-size: 0.9rem;
}
