:root {
  --bg: #F6F3EC;
  --surface: #FFFFFF;
  --surface-2: #EFEAE0;
  --border: #DED7C7;
  --text: #16181F;
  --text-muted: #6B6F7C;
  --accent-blue: #3457D5;
  --accent-blue-soft: #E9EDFC;
  --accent-bacon: #D9480F;
  --accent-bacon-soft: #FBE7DA;
  --accent-gold: #9A6B0A;
  --gold-soft: #FBF0D6;
  --ticker-up: #1E9E5A;
  --ticker-down: #D6304B;
  --shadow: 0 1px 2px rgba(20,20,30,0.06), 0 8px 24px -12px rgba(20,20,30,0.18);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0A0E17;
    --surface: #121826;
    --surface-2: #1A2233;
    --border: #263049;
    --text: #EDEFF6;
    --text-muted: #8892A8;
    --accent-blue: #6E93FF;
    --accent-blue-soft: #1B2340;
    --accent-bacon: #FF7A45;
    --accent-bacon-soft: #3A2013;
    --accent-gold: #F5C24C;
    --gold-soft: #3A2E10;
    --ticker-up: #3DDC84;
    --ticker-down: #FF5C72;
    --shadow: 0 1px 2px rgba(0,0,0,0.4), 0 12px 32px -12px rgba(0,0,0,0.6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0A0E17; --surface: #121826; --surface-2: #1A2233; --border: #263049;
  --text: #EDEFF6; --text-muted: #8892A8; --accent-blue: #6E93FF; --accent-blue-soft: #1B2340;
  --accent-bacon: #FF7A45; --accent-bacon-soft: #3A2013; --accent-gold: #F5C24C; --gold-soft: #3A2E10;
  --ticker-up: #3DDC84; --ticker-down: #FF5C72; color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #F6F3EC; --surface: #FFFFFF; --surface-2: #EFEAE0; --border: #DED7C7;
  --text: #16181F; --text-muted: #6B6F7C; --accent-blue: #3457D5; --accent-blue-soft: #E9EDFC;
  --accent-bacon: #D9480F; --accent-bacon-soft: #FBE7DA; --accent-gold: #9A6B0A; --gold-soft: #FBF0D6;
  --ticker-up: #1E9E5A; --ticker-down: #D6304B; color-scheme: light;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}
.mono {
  font-family: ui-monospace, "SF Mono", "Cascadia Code", "Consolas", "Roboto Mono", monospace;
}

/* ---------- Top nav ---------- */
.bc-nav {
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}
.bc-wordmark {
  display: flex;
  flex-direction: column;
  line-height: 1;
  margin-right: 8px;
}
.bc-wordmark .name {
  font-weight: 800;
  font-size: 1.28rem;
  letter-spacing: -0.02em;
  font-stretch: condensed;
}
.bc-wordmark .name b { color: var(--accent-bacon); }
.bc-wordmark .tag {
  font-size: 0.62rem;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: 2px;
}
.bc-tabs {
  display: flex;
  gap: 4px;
  flex: 1;
}
.bc-tab {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-weight: 600;
  font-size: 0.86rem;
  padding: 8px 14px;
  border-radius: 7px;
  cursor: pointer;
}
.bc-tab:hover { color: var(--text); background: var(--surface-2); }
.bc-tab.active { color: var(--accent-blue); background: var(--accent-blue-soft); }
.bc-tab:focus-visible, .bc-answer:focus-visible, .bc-close:focus-visible {
  outline: 2px solid var(--accent-blue);
  outline-offset: 2px;
}
.bc-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.76rem;
  color: var(--text-muted);
  white-space: nowrap;
}
.bc-status .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--ticker-up);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ticker-up) 22%, transparent);
}

/* ---------- Ticker ---------- */
.bc-ticker-wrap {
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  overflow: hidden;
  position: sticky;
  top: 53px;
  z-index: 19;
}
.bc-ticker {
  display: flex;
  gap: 40px;
  white-space: nowrap;
  padding: 7px 0;
  width: max-content;
  animation: bc-scroll 32s linear infinite;
  font-size: 0.78rem;
}
.bc-ticker span { color: var(--text-muted); }
.bc-ticker b { color: var(--text); font-weight: 600; }
.bc-up { color: var(--ticker-up); }
.bc-down { color: var(--ticker-down); }
@keyframes bc-scroll {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}
@media (prefers-reduced-motion: reduce) {
  .bc-ticker { animation: none; }
}

/* ---------- Layout ---------- */
.bc-main {
  flex: 1;
  display: grid;
  grid-template-columns: 1.7fr 1fr;
  gap: 22px;
  padding: 26px;
  max-width: 1180px;
  width: 100%;
  margin: 0 auto;
  align-items: start;
}
@media (max-width: 820px) {
  .bc-main { grid-template-columns: 1fr; }
}
.bc-panel { display: none; }
.bc-panel.active { display: block; }

.bc-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

/* ---------- Play panel ---------- */
.bc-play-card { padding: 28px; }
.bc-eyebrow {
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent-blue);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}
.bc-eyebrow .badge {
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 0.68rem;
  color: var(--text-muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 2px 7px;
  border-radius: 5px;
  text-transform: none;
  letter-spacing: 0;
}
.bc-question {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.28;
  text-wrap: balance;
  margin: 0 0 22px;
  max-width: 60ch;
}
.bc-answers {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 18px;
}
.bc-answer {
  text-align: left;
  font: inherit;
  font-size: 0.98rem;
  font-weight: 600;
  padding: 13px 16px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  display: flex;
  gap: 12px;
}
.bc-answer:hover:not(:disabled) { border-color: var(--accent-blue); }
.bc-answer:disabled { cursor: default; }
.bc-answer .letter {
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  color: var(--text-muted);
  font-weight: 700;
}
.bc-answer.correct { border-color: var(--ticker-up); background: color-mix(in srgb, var(--ticker-up) 14%, var(--surface)); }
.bc-answer.wrong { border-color: var(--ticker-down); background: color-mix(in srgb, var(--ticker-down) 12%, var(--surface)); }

.bc-feedback {
  min-height: 22px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
}
.bc-feedback.good { color: var(--ticker-up); }
.bc-feedback.bad { color: var(--ticker-down); }

/* ---------- Bacon meter sidebar ---------- */
.bc-meter-card {
  position: sticky;
  top: 105px;
  padding: 22px;
}
.bc-meter-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 4px;
}
.bc-meter-head h3 { margin: 0; font-size: 0.95rem; }
.bc-meter-head .count {
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-variant-numeric: tabular-nums;
  font-size: 0.78rem;
  color: var(--text-muted);
}
.bc-strip-visual {
  height: 192px;
  border-radius: 12px;
  margin: 16px 0 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
  padding: 14px 16px 10px;
}

/* chain-of-stages, laid across the top edge of the bacon */
.bc-chain {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: center;
  margin-bottom: 10px;
}
.bc-chain .seg {
  flex: 1;
  height: 2px;
  background: var(--border);
  transition: background .35s ease;
}
.bc-chain .seg.done { background: var(--accent-bacon); }
.bc-chain .node {
  width: 15px; height: 15px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--border);
  flex-shrink: 0;
  transition: background .35s ease, border-color .35s ease, box-shadow .35s ease;
}
.bc-chain .node.done { background: var(--accent-bacon); border-color: var(--accent-bacon); }
.bc-chain .node.current {
  border-color: var(--accent-bacon);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent-bacon) 25%, transparent);
}
.bc-stage-caption {
  position: relative;
  z-index: 3;
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 8px;
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
}
.bc-stage-caption b { color: var(--accent-bacon); font-weight: 700; }

.bc-bacon-stage {
  position: absolute; inset: 52px 0 0 0;
  display: flex; align-items: center; justify-content: center;
}
.bc-bacon-emoji {
  font-size: 5.4rem;
  line-height: 1;
  display: inline-block;
  transform: rotate(-8deg);
  filter: var(--bacon-filter, none);
  transition: filter .5s ease;
}
/* mini plate under the meter — fills up as strips are completed */
.bc-plate-widget {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.bc-plate-dish {
  position: relative;
  width: 240px;
  height: 240px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--surface), var(--surface-2) 72%, var(--border) 100%);
  border: 1px solid var(--border);
  box-shadow: inset 0 2px 7px rgba(0,0,0,.12), 0 2px 4px rgba(0,0,0,.08);
}
.bc-plate-empty {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  text-align: center; padding: 0 18px;
  font-size: 0.72rem;
  color: var(--text-muted);
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
}
.bc-plate-piece {
  position: absolute;
  left: 50%; top: 50%;
  font-size: 5.4rem;
  transform: translate(-50%, -50%) rotate(var(--rot, 0deg)) scale(1);
  filter: saturate(1.5) brightness(0.8) sepia(0.4) contrast(1.25) drop-shadow(0 4px 6px rgba(0,0,0,.35));
  animation: bc-plate-drop .5s cubic-bezier(.34,1.56,.64,1);
  pointer-events: none;
}
@keyframes bc-plate-drop {
  0%   { transform: translate(-50%, -50%) translateY(-40px) rotate(var(--rot, 0deg)) scale(0.45); opacity: 0; }
  65%  { opacity: 1; }
  100% { transform: translate(-50%, -50%) translateY(0) rotate(var(--rot, 0deg)) scale(1); opacity: 1; }
}
.bc-plate-count {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-variant-numeric: tabular-nums;
}
@media (prefers-reduced-motion: reduce) {
  .bc-plate-piece { animation: none; }
}

/* idle sizzle: grease bubbles popping around the strip, livelier at higher stages */
.bc-bubble {
  position: absolute;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: #fffaf0;
  box-shadow: 0 0 0 1px rgba(120,70,30,0.25) inset;
  transform-origin: center;
  animation: bc-bubble-pop 1.6s ease-in-out infinite;
  animation-duration: var(--bubble-speed, 1.6s);
  opacity: 0;
}
@keyframes bc-bubble-pop {
  0%   { transform: scale(0.4); opacity: 0; }
  35%  { transform: scale(1);   opacity: var(--bubble-max, 0); }
  70%  { transform: scale(1.3); opacity: 0; }
  100% { transform: scale(0.4); opacity: 0; }
}

.bc-bubbles { position: absolute; inset: 0; z-index: 2; pointer-events: none; }

/* idle steam, rising off the strip once it starts cooking */
.bc-steam-layer {
  position: absolute; left: 10px; right: 10px; bottom: 18px; height: 90px;
  z-index: 2; pointer-events: none;
  opacity: var(--steam-opacity, 0);
  transition: opacity .5s ease;
}
.bc-steam {
  position: absolute; bottom: 0;
  width: 16px; height: 26px;
  border-radius: 50%;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--text) 22%, transparent), transparent 75%);
  filter: blur(3px);
  animation: bc-rise 2.6s ease-in infinite;
}
.bc-steam:nth-child(1) { left: 18%; animation-delay: 0s; }
.bc-steam:nth-child(2) { left: 46%; animation-delay: .9s; }
.bc-steam:nth-child(3) { left: 74%; animation-delay: 1.7s; }
@keyframes bc-rise {
  0%   { transform: translateY(0) scale(0.8); opacity: 0; }
  20%  { opacity: .8; }
  100% { transform: translateY(-72px) scale(1.3); opacity: 0; }
}

/* reactive feedback on the meter when you answer */
.bc-meter-card.flash-good .bc-strip-visual { animation: bc-flash-good .55s ease; }
.bc-meter-card.shake-bad .bc-strip-visual { animation: bc-shake-bad .4s ease; }
@keyframes bc-flash-good {
  0%   { transform: scale(1); }
  35%  { transform: scale(1.035); box-shadow: 0 0 0 6px color-mix(in srgb, var(--ticker-up) 22%, transparent) inset; }
  100% { transform: scale(1); }
}
@keyframes bc-shake-bad {
  0%, 100% { transform: translateX(0); }
  25%      { transform: translateX(-5px); }
  75%      { transform: translateX(5px); }
}

.bc-chain .node.just-done { animation: bc-node-pop .5s cubic-bezier(.34,1.56,.64,1); }
@keyframes bc-node-pop {
  0%   { transform: scale(0.6); }
  55%  { transform: scale(1.4); }
  100% { transform: scale(1); }
}

.bc-bubbles { transition: opacity .5s ease; }

@media (prefers-reduced-motion: reduce) {
  .bc-bubble, .bc-steam, .bc-meter-card.flash-good .bc-strip-visual,
  .bc-meter-card.shake-bad .bc-strip-visual, .bc-chain .node.just-done {
    animation: none;
  }
}

/* ---------- Plate panel ---------- */
.bc-plate-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
.bc-cert {
  padding: 18px;
  border-radius: 12px;
}
.bc-cert .num { font-family: ui-monospace, Consolas, monospace; color: var(--accent-gold); font-weight: 700; font-size: 0.8rem; }
.bc-cert h4 { margin: 8px 0 4px; font-size: 1.02rem; }
.bc-cert .meta { color: var(--text-muted); font-size: 0.78rem; font-family: ui-monospace, Consolas, monospace; }
.bc-empty-plate {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.92rem;
}

/* Handle form input and button */
.bc-handle-form { margin-bottom: 20px; }
.bc-handle-form .label {
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-muted); font-weight: 700;
}
.bc-input {
  flex: 1; font: inherit; font-size: 0.92rem; padding: 10px 12px;
  border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text);
}
.bc-input:focus-visible { outline: 2px solid var(--accent-blue); outline-offset: 1px; }
.bc-button {
  font: inherit; font-weight: 700; font-size: 0.88rem; padding: 10px 16px;
  border-radius: 8px; border: none; background: var(--accent-blue);
  color: white; cursor: pointer;
}
.bc-button:hover { background: color-mix(in srgb, var(--accent-blue) 88%, black); }
.bc-button:focus-visible { outline: 2px solid var(--accent-blue); outline-offset: 2px; }

/* ---------- Leaderboard ---------- */
.bc-lb-card { padding: 6px 0; }
table.bc-lb { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
table.bc-lb th {
  text-align: left;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 14px 20px 10px;
  border-bottom: 1px solid var(--border);
}
table.bc-lb td { padding: 12px 20px; border-bottom: 1px solid var(--border); }
table.bc-lb tr:last-child td { border-bottom: none; }
table.bc-lb td.rank { font-family: ui-monospace, Consolas, monospace; color: var(--text-muted); width: 40px; }
table.bc-lb td.count { font-family: ui-monospace, Consolas, monospace; font-variant-numeric: tabular-nums; text-align: right; font-weight: 700; color: var(--accent-bacon); }
table.bc-lb tr.you td { background: var(--accent-blue-soft); }

/* ---------- Modal ---------- */
.bc-modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(10,12,20,0.55);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
}
.bc-modal-backdrop.show { display: flex; animation: bc-backdrop-in .25s ease; }
@keyframes bc-backdrop-in { from { opacity: 0; } to { opacity: 1; } }
.bc-modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  max-width: 380px;
  width: 100%;
  padding: 30px 26px 24px;
  text-align: center;
  box-shadow: var(--shadow);
  animation: bc-modal-in .45s cubic-bezier(.2,.9,.3,1.3);
}
@keyframes bc-modal-in {
  from { opacity: 0; transform: translateY(14px) scale(.94); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.bc-modal .seal {
  font-size: 2.6rem; margin-bottom: 6px;
  display: inline-block;
  animation: bc-seal-stamp .5s cubic-bezier(.2,.9,.3,1.4) .1s both;
}
@keyframes bc-seal-stamp {
  0%   { transform: scale(2.4) rotate(-18deg); opacity: 0; }
  60%  { transform: scale(0.9) rotate(4deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg); }
}
@media (prefers-reduced-motion: reduce) {
  .bc-modal-backdrop.show, .bc-modal, .bc-modal .seal { animation: none; }
}
.bc-modal .eyebrow-gold {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent-gold);
  font-weight: 700;
}
.bc-modal h3 { margin: 6px 0 10px; font-size: 1.25rem; }
.bc-modal p { color: var(--text-muted); font-size: 0.9rem; margin: 0 0 20px; }
.bc-close {
  font: inherit; font-weight: 700; font-size: 0.9rem;
  padding: 10px 20px; border-radius: 9px; border: none;
  background: var(--accent-blue); color: white; cursor: pointer;
}
