:root {
  --bcp-bg: #f5f0e8;
  --bcp-paper: #fff;
  --bcp-ink: #1c1c1c;
  --bcp-muted: #7b6c55;
  --bcp-gold: #c8973a;
  --bcp-gold-dark: #8b6310;
  --bcp-gold-light: #efd9aa;
  --bcp-cream: #faf4e8;
  --bcp-orange: #e8a020;
  --bcp-red: #d85a30;
  --bcp-green: #5b8f45;
}

.bcp-entry,
.bcp-entry *,
.bcp-standalone,
.bcp-standalone * { box-sizing: border-box; }

.bcp-entry {
  margin: 0 0 28px;
  border: 0;
  border-radius: 20px;
  background: transparent;
}

.bcp-entry-head {
  width: min(100%, 640px);
  min-height: 108px;
  margin: 0 auto 12px;
  padding: 20px 22px;
  display: flex;
  align-items: center;
  gap: 14px;
  border: 1.5px solid rgba(139, 99, 16, .15);
  border-radius: 20px;
  color: var(--bcp-ink);
  background: var(--bcp-paper);
  box-shadow: 0 4px 24px rgba(90, 62, 10, .1);
  font-family: "Noto Sans TC", sans-serif;
  text-align: left;
  cursor: pointer;
}

.bcp-entry-head:hover { box-shadow: 0 8px 28px rgba(90, 62, 10, .14); }
.bcp-entry-head:focus-visible,
.bcp-btn:focus-visible,
.bcp-chip:focus-visible,
.bcp-stage:focus-visible,
.bcp-level:focus-visible {
  outline: 3px solid rgba(87, 137, 190, .55);
  outline-offset: 3px;
}

.bcp-entry-icon {
  width: 52px;
  height: 52px;
  flex: 0 0 52px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #f8edd5;
  font-size: 27px;
  line-height: 1;
}

.bcp-entry-copy { flex: 1; min-width: 0; }
.bcp-entry-copy strong {
  display: block;
  color: #4b3716;
  font-family: "Noto Serif TC", serif;
  font-size: 22px;
  font-weight: 900;
}
.bcp-entry-copy span {
  display: block;
  margin-top: 5px;
  color: var(--bcp-muted);
  font-size: 13px;
  line-height: 1.6;
}

.bcp-entry-action,
.bcp-btn {
  min-height: 42px;
  padding: 9px 18px;
  border: 1px solid transparent;
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(135deg, var(--bcp-orange), var(--bcp-red));
  box-shadow: 0 3px 8px rgba(216, 90, 48, .2);
  font: 800 13px "Noto Sans TC", sans-serif;
  white-space: nowrap;
  cursor: pointer;
}
.bcp-entry-action { min-height: auto; padding: 8px 16px; }
.bcp-btn.secondary {
  border-color: #d5b670;
  color: var(--bcp-gold-dark);
  background: #fff;
  box-shadow: none;
}
.bcp-btn.danger { border-color: #fdba74; color: #9a3412; background: #fff4ee; box-shadow: none; }
.bcp-btn:disabled { opacity: .48; cursor: not-allowed; }

.bcp-panel {
  width: min(100%, 640px);
  margin: 0 auto;
  padding: 0;
  border: 0;
  background: transparent;
}
.bcp-panel[hidden],
.bcp-view[hidden],
.bcp-modal[hidden] { display: none !important; }

.bcp-login,
.bcp-panel > .bcp-note[data-bcp-status] {
  width: 100%;
  margin: 0 0 12px;
  padding: 11px 14px;
  border: 2px solid var(--bcp-gold);
  border-radius: 26px;
  background: var(--bcp-cream);
  box-shadow: 0 4px 14px rgba(139, 99, 16, .1);
}
.bcp-login { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; }
.bcp-login p,
.bcp-note { margin: 0; color: var(--bcp-muted); font-size: 13px; line-height: 1.65; }
.bcp-panel > .bcp-note[data-bcp-status]:empty { display: none; }

.bcp-view {
  padding: 22px 20px;
  border: 1.5px solid rgba(139, 99, 16, .15);
  border-radius: 20px;
  background: var(--bcp-paper);
  box-shadow: 0 4px 24px rgba(90, 62, 10, .1);
}
.bcp-toolbar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 18px;
  text-align: center;
}
.bcp-toolbar h2 {
  margin: 0;
  color: #4b3716;
  font: 900 23px "Noto Serif TC", serif;
}

.bcp-fieldset {
  margin: 0 0 14px;
  padding: 15px;
  border: 1px solid rgba(139, 99, 16, .18);
  border-radius: 14px;
  background: linear-gradient(180deg, #fbf5e7 0%, #fff 100%);
}
.bcp-fieldset legend {
  padding: 4px 10px;
  border-radius: 999px;
  color: var(--bcp-gold-dark);
  background: #f8edd5;
  font-size: 12px;
  font-weight: 900;
}
.bcp-fieldset > h3 { font-family: "Noto Serif TC", serif; }

.bcp-choice-row,
.bcp-categories,
.bcp-actions,
.bcp-levels,
.bcp-rounds { display: flex; gap: 9px; flex-wrap: wrap; }
.bcp-choice-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
.bcp-actions { justify-content: center; }

.bcp-chip {
  position: relative;
  min-height: 42px;
  padding: 9px 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 2px solid #d4b87a;
  border-radius: 999px;
  color: #806d4c;
  background: #fffdf8;
  font: 800 13px "Noto Sans TC", sans-serif;
  text-align: center;
  cursor: pointer;
}
.bcp-chip:has(input:checked),
.bcp-chip.is-active {
  border-color: transparent;
  color: #fff;
  background: linear-gradient(135deg, var(--bcp-orange), var(--bcp-red));
  box-shadow: 0 3px 8px rgba(216, 90, 48, .2);
}
.bcp-chip input { width: 15px; height: 15px; margin: 0; accent-color: var(--bcp-gold-dark); }
.bcp-chip:has(input:checked) input { accent-color: #fff; }

.bcp-search {
  margin-top: 10px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}
.bcp-search input,
.bcp-answer-input {
  width: 100%;
  min-height: 44px;
  padding: 9px 12px;
  border: 1.5px solid #d9c38b;
  border-radius: 12px;
  box-sizing: border-box;
  font: 16px "Noto Sans TC", sans-serif;
}
.bcp-search input:focus,
.bcp-answer-input:focus { outline: 3px solid rgba(200, 151, 58, .28); border-color: var(--bcp-gold-dark); }

.bcp-search-results,
.bcp-manual-list { display: grid; gap: 8px; margin-top: 10px; }
.bcp-search-result,
.bcp-picked {
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid rgba(139, 99, 16, .18);
  border-radius: 12px;
  background: #fff;
}
.bcp-word-main { color: var(--bcp-ink); font: 800 21px/1.65 "Sarabun", "Noto Sans Thai", sans-serif; }
.bcp-word-meta { color: #806a3a; font-size: 12px; line-height: 1.55; }
.bcp-spacer { flex: 1; }

.bcp-dashboard { display: grid; gap: 15px; }
.bcp-word-card {
  overflow: hidden;
  padding: 0 18px 18px;
  border: 1.5px solid rgba(139, 99, 16, .15);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 4px 20px rgba(90, 62, 10, .08);
}
.bcp-word-head {
  margin: 0 -18px 14px;
  padding: 15px 18px 13px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  border-bottom: 2px solid rgba(184, 134, 40, .5);
  background: linear-gradient(180deg, #efddb4 0%, #f8f0de 100%);
}
.bcp-word-head h3 { margin: 0; color: #3a2a0a; font: 900 30px/1.45 "Sarabun", "Noto Sans Thai", sans-serif; }
.bcp-status {
  padding: 5px 10px;
  display: inline-flex;
  border-radius: 999px;
  color: #6a4a12;
  background: #fff3d8;
  font-size: 11px;
  font-weight: 800;
}
.bcp-status.cleared { color: #166534; background: #dcfce7; }
.bcp-section-title {
  width: fit-content;
  margin: 14px 0 9px;
  padding: 4px 10px;
  border-radius: 999px;
  color: var(--bcp-gold-dark);
  background: #f8edd5;
  font: 900 12px "Noto Sans TC", sans-serif;
}
.bcp-stages { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.bcp-stage {
  min-height: 48px;
  padding: 8px;
  border: 1.5px solid rgba(139, 99, 16, .25);
  border-radius: 10px;
  color: #5a3e0a;
  background: #fff;
  font: 800 12px "Noto Sans TC", sans-serif;
  cursor: pointer;
}
.bcp-stage.is-passed { border-color: #9ccc65; color: #3b6d11; background: #eef7e3; }
.bcp-stage:disabled { border-color: #ddd8cc; color: #827d72; background: #f3f1eb; cursor: not-allowed; }

.bcp-levels { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.bcp-level {
  min-width: 0;
  min-height: 52px;
  padding: 9px 10px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 3px 8px;
  align-items: center;
  border: 2px solid #d4b87a;
  border-radius: 12px;
  color: #806d4c;
  background: #fffdf8;
  text-align: left;
  cursor: pointer;
}
.bcp-level strong { font-size: 16px; }
.bcp-level small { font-size: 11px; }
.bcp-level.is-selected { border-color: transparent; color: #fff; background: linear-gradient(135deg, var(--bcp-orange), var(--bcp-red)); }
.bcp-level.is-passed { box-shadow: inset 0 0 0 2px #4d9a6a; }
.bcp-level:disabled { opacity: .48; cursor: not-allowed; }
.bcp-rounds { margin-top: 9px; }
.bcp-rounds .bcp-btn { min-height: 38px; padding: 7px 13px; font-size: 12px; }
.bcp-lock-reason { margin: 9px 0; color: var(--bcp-gold-dark); font-size: 12px; line-height: 1.6; }

.bcp-modal {
  position: fixed;
  z-index: 10020;
  inset: 0;
  padding: 18px;
  display: grid;
  place-items: center;
  background: rgba(33, 27, 18, .48);
}
.bcp-modal-card {
  width: min(520px, 100%);
  max-height: calc(100dvh - 36px);
  overflow: auto;
  padding: 20px;
  border: 1px solid rgba(139, 99, 16, .24);
  border-radius: 20px;
  background: #fffdf8;
  box-shadow: 0 18px 48px rgba(58, 42, 12, .22);
}
.bcp-modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.bcp-modal-head h3 { margin: 0; color: #4b3716; font: 900 20px "Noto Serif TC", serif; }
.bcp-close { width: 34px; height: 34px; border: 0; color: var(--bcp-gold-dark); background: transparent; font-size: 22px; cursor: pointer; }
.bcp-prompt {
  margin: 22px -20px;
  padding: 18px 22px;
  border-block: 2px solid rgba(184, 134, 40, .5);
  color: #3a2a0a;
  background: linear-gradient(180deg, #efddb4 0%, #f8f0de 100%);
  font: 900 34px/1.65 "Sarabun", "Noto Sans Thai", "Noto Sans TC", sans-serif;
  text-align: center;
}
.bcp-answer-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.bcp-feedback { min-height: 24px; margin-top: 12px; font-size: 13px; font-weight: 700; }
.bcp-feedback.ok { color: #166534; }
.bcp-feedback.bad { color: #9a3412; }
.bcp-preview-note { margin-top: 10px; padding: 8px 10px; border-radius: 10px; color: #9a3412; background: #fff7ed; font-size: 12px; }

body.bcp-standalone {
  min-width: 320px;
  min-height: 100dvh;
  margin: 0;
  padding: 60px 0 0;
  color: var(--bcp-ink);
  background: var(--bcp-bg);
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
}
.bcp-site-nav {
  position: fixed;
  z-index: 999;
  inset: 0 0 auto;
  height: 60px;
  padding: 0 clamp(16px, 3vw, 32px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid rgba(200, 151, 58, .2);
  background: rgba(17, 17, 17, .97);
}
.bcp-brand { color: var(--bcp-gold); font: 900 15px "Noto Serif TC", serif; letter-spacing: 1px; }
.bcp-brand span { color: #fff; }
.bcp-preview-label { padding: 6px 12px; border: 1px solid var(--bcp-gold); border-radius: 4px; color: var(--bcp-gold); font-size: 11px; font-weight: 800; }
.bcp-game-shell { width: min(100%, 688px); min-height: calc(100dvh - 60px); margin: 0 auto; padding: 12px 24px calc(56px + env(safe-area-inset-bottom, 0px)); }
.bcp-page-header { margin: 0 auto 10px; text-align: center; }
.bcp-page-header h1 { margin: 0; color: var(--bcp-gold-dark); font: 900 clamp(21px, 5vw, 28px) "Noto Serif TC", serif; letter-spacing: 2px; }
.bcp-page-header p { margin: 4px 0 0; color: #b08040; font-size: 12px; }
.bcp-preview-status {
  min-height: 57px;
  margin: 0 auto 12px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 2px solid var(--bcp-gold);
  border-radius: 26px;
  color: #633806;
  background: var(--bcp-cream);
  box-shadow: 0 4px 14px rgba(139, 99, 16, .1);
  font-size: 12px;
  line-height: 1.45;
}
.bcp-preview-status span { flex: 1; min-width: 0; }
.bcp-preview-reset { min-height: 32px; padding: 5px 11px; border: 1px solid rgba(200, 151, 58, .48); border-radius: 999px; color: #7a5510; background: #fff; font-weight: 800; white-space: nowrap; cursor: pointer; }
.bcp-standalone .bcp-entry { margin-bottom: 0; }

@media (max-width: 700px) {
  .bcp-entry-head { align-items: flex-start; flex-wrap: wrap; }
  .bcp-entry-action { margin-left: 66px; }
  .bcp-stages { grid-template-columns: 1fr; }
  .bcp-levels { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bcp-search { grid-template-columns: 1fr; }
  .bcp-answer-options { grid-template-columns: 1fr; }
  .bcp-view { padding: 18px 14px; }
  .bcp-game-shell { padding-inline: 12px; }
}

@media (max-width: 430px) {
  .bcp-entry-head { min-height: 0; padding: 17px 15px; gap: 11px; }
  .bcp-entry-icon { width: 44px; height: 44px; flex-basis: 44px; font-size: 23px; }
  .bcp-entry-copy strong { font-size: 19px; }
  .bcp-entry-copy span { font-size: 12px; }
  .bcp-entry-action { width: 100%; margin: 0; text-align: center; }
  .bcp-toolbar h2 { font-size: 20px; }
  .bcp-choice-row { grid-template-columns: 1fr; }
  .bcp-categories { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bcp-chip { width: 100%; }
  .bcp-levels { grid-template-columns: 1fr; }
  .bcp-preview-status { align-items: flex-start; border-radius: 18px; }
}

@media (max-width: 900px) and (max-height: 500px) {
  body.bcp-standalone { padding-top: 48px; }
  .bcp-site-nav { height: 48px; }
  .bcp-game-shell { padding-top: 7px; }
  .bcp-page-header { display: flex; align-items: baseline; justify-content: center; gap: 10px; }
  .bcp-page-header h1 { font-size: 19px; }
  .bcp-page-header p { margin: 0; }
  .bcp-preview-status { min-height: 44px; margin-bottom: 8px; padding-block: 6px; }
  .bcp-entry-head { min-height: 74px; margin-bottom: 8px; padding-block: 11px; }
  .bcp-entry-icon { width: 42px; height: 42px; flex-basis: 42px; font-size: 22px; }
  .bcp-entry-copy strong { font-size: 18px; }
  .bcp-entry-copy span { margin-top: 2px; font-size: 11px; }
  .bcp-view { padding: 14px; }
  .bcp-toolbar { margin-bottom: 10px; }
  .bcp-fieldset { margin-bottom: 9px; padding: 10px; }
  .bcp-modal { place-items: start center; overflow: auto; }
  .bcp-modal-card { max-height: none; }
  .bcp-prompt { margin-block: 12px; font-size: 27px; }
  .bcp-word-card { padding-bottom: 12px; }
  .bcp-levels { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
