/* Forbidden Bonbons: game-only styles on top of candy-kit (kit.css + theme.css): the stage scene
 * (board, side panel, ladder), the mine selector, the wordmark, the preloader and a few modal
 * bits. Everything else is kit components themed by tokens. */

html, body { margin: 0; height: 100%; background: var(--ck-bg); color: var(--ck-text); font-family: var(--ck-font); }
body { overflow: hidden; -webkit-font-smoothing: antialiased; }
#fb-root { height: 100vh; height: 100dvh; }
.fb-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ---- wordmark: flat, typeset (Inter 800), the heart-bonbon mark ---- */
.fb-wordmark {
  display: inline-flex; align-items: center; gap: .3em;
  font-family: var(--ck-font); font-weight: 800; line-height: 1; letter-spacing: -.03em;
  text-transform: uppercase; white-space: nowrap; user-select: none;
}
.fb-wordmark__mark { width: 1.15em; height: 1.15em; flex: none; display: inline-flex; }
.fb-wordmark__mark svg { width: 100%; height: 100%; }
.fb-wordmark__a { color: var(--ck-text); }
.fb-wordmark__b { color: var(--ck-accent); }
.fb-logo--side { font-size: 19px; }
.fb-logo--phone { font-size: 11px; flex-direction: column; align-items: center; gap: 1px; letter-spacing: -.02em; }
.fb-logo--phone .fb-wordmark__mark { display: none; }

/* ---- stage scene ---- */
.fb-shell .ck-stage__hud, .fb-shell .ck-stage__art { display: none; }
.fb-shell .ck-stage__canvas { container: fb-scene / size; }
.fb-scene {
  position: absolute; inset: 0; display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 290px);
  grid-template-rows: minmax(0, 1fr) auto;
  grid-template-areas: "board side" "ladder ladder";
  gap: 14px 20px; padding: 18px 22px 14px;
}
.fb-scene__board { grid-area: board; min-width: 0; min-height: 0; container: fb-board / size; display: flex; align-items: center; justify-content: center; }
.fb-scene__side { grid-area: side; align-self: center; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.fb-ladder { grid-area: ladder; }
.fb-scene.has-candy { grid-template-columns: minmax(150px, 26%) minmax(0, 1fr) minmax(220px, 290px); grid-template-areas: "candy board side" "ladder ladder ladder"; }

/* Candy on the left of the box: a cut-out per mood (idle / win / bust), anchored to the floor */
.fb-scene__candy { grid-area: candy; position: relative; min-width: 0; min-height: 0; pointer-events: none; }
.fb-scene__candy img { position: absolute; left: 50%; bottom: -14px; height: calc(100% + 14px); max-width: 135%; object-fit: contain; object-position: bottom center; transform: translateX(-50%); transition: opacity 260ms ease; }
.fb-scene__candy img:not(.is-on) { opacity: 0; }
.fb-scene__candy.is-empty { display: none; }

/* board */
.fb-board {
  --gap: clamp(5px, 1.6cqmin, 10px);
  width: min(100cqw, 100cqh); height: min(100cqw, 100cqh);
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); grid-template-rows: repeat(5, minmax(0, 1fr));
  gap: var(--gap);
  touch-action: manipulation;
}
.fb-tile {
  position: relative; min-width: 0; min-height: 0; padding: 0; margin: 0;
  border: 1px solid var(--fb-tile-border); border-radius: clamp(8px, 2.4cqmin, 14px);
  background: var(--fb-tile-bg); color: inherit;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--ck-dur), transform 140ms ease, border-color var(--ck-dur), opacity 240ms;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation; user-select: none;
}
.fb-tile__face { width: 92%; height: 92%; display: flex; transform: translateY(-3%); }
.fb-tile__art { width: 100%; height: 100%; display: block; }
.fb-board.is-live .fb-tile.is-closed { cursor: pointer; }
.fb-board.is-live .fb-tile.is-closed:hover { background: var(--fb-tile-bg-hover); border-color: var(--ck-line-strong); transform: translateY(-2px); }
.fb-board.is-live .fb-tile.is-closed:active { transform: translateY(0) scale(.97); }
.fb-board:not(.is-live) .fb-tile.is-closed { cursor: default; }
.fb-board[data-phase="idle"] .fb-tile.is-closed .fb-tile__art,
.fb-board[data-phase="booting"] .fb-tile.is-closed .fb-tile__art { opacity: .6; }
.fb-tile:focus-visible { outline: 2px solid var(--ck-focus); outline-offset: 2px; }
.fb-tile.is-pending { background: var(--fb-tile-bg-hover); }
.fb-tile.is-pending .fb-tile__face { animation: fb-wobble 520ms ease-in-out infinite; }
.fb-tile.is-sweet { background: var(--fb-tile-sweet); border-color: color-mix(in srgb, var(--ck-success) 45%, transparent); }
.fb-tile.is-hit { background: var(--fb-tile-hit); border-color: var(--ck-danger); }
.fb-tile.is-mine { opacity: .62; }
.fb-tile.is-spare { opacity: .38; }
.fb-tile.is-flip .fb-tile__face { animation: fb-pop 320ms cubic-bezier(.2, .9, .3, 1.3) both; }
.fb-tile.is-hit.is-flip { animation: fb-shake 380ms ease-in-out both; }
.fb-tile.is-unveil .fb-tile__face { animation: fb-fade 420ms ease-out both; animation-delay: calc(var(--i) * 14ms); }
@keyframes fb-pop { from { transform: scale(.55) rotate(-8deg); opacity: .2; } to { transform: none; opacity: 1; } }
@keyframes fb-fade { from { transform: scale(.85); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fb-wobble { 0%, 100% { transform: rotate(0); } 30% { transform: rotate(-5deg); } 70% { transform: rotate(5deg); } }
@keyframes fb-shake { 0%, 100% { transform: none; } 20% { transform: translateX(-4px); } 40% { transform: translateX(4px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(2px); } }

/* side panel */
.fb-side__head { display: flex; flex-direction: column; gap: 2px; }
.fb-side__label { font-size: var(--ck-fs-xs); font-weight: 600; text-transform: uppercase; letter-spacing: var(--ck-tracking-caps); color: var(--ck-text-muted); }
.fb-mult { display: flex; align-items: baseline; font-weight: 800; letter-spacing: -.03em; line-height: 1; font-variant-numeric: tabular-nums; font-size: clamp(40px, 9cqmin, 76px); }
.fb-mult__x { font-size: .5em; margin-right: .06em; color: var(--ck-text-muted); }
.fb-mult__digits { color: var(--ck-text); }
.fb-scene__side[data-tone="live"] .fb-mult__digits { color: #fff; }
.fb-scene__side[data-tone="good"] .fb-mult__digits, .fb-scene__side[data-tone="good"] .fb-mult__x { color: var(--ck-mult-cashed); }
.fb-scene__side[data-tone="bad"] .fb-mult__digits, .fb-scene__side[data-tone="bad"] .fb-mult__x { color: var(--ck-mult-crashed); }
.fb-scene__side[data-tone="idle"] .fb-mult { opacity: .7; }
.fb-side__status { margin: 0; min-height: 2.8em; font-size: var(--ck-fs-sm); line-height: 1.4; color: var(--ck-text-muted); }
.fb-stats { display: grid; gap: 1px; border-radius: var(--ck-radius-card); overflow: hidden; background: var(--ck-line); box-shadow: inset 0 0 0 1px var(--ck-line); }
.fb-stat { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 9px 12px; background: color-mix(in srgb, var(--ck-surface-1) 82%, transparent); }
.fb-stat__label { font-size: var(--ck-fs-sm); color: var(--ck-text-muted); }
.fb-stat__value { font-size: var(--ck-fs-md); font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.fb-stat__value--win { color: var(--ck-win); }
.fb-random { gap: 8px; justify-content: center; }

/* ladder: multiplier per sweet pick */
.fb-ladder {
  list-style: none; margin: 0; padding: 2px 0 4px; display: flex; gap: 6px; overflow-x: auto; overflow-y: hidden;
  scrollbar-width: none; scroll-snap-type: x proximity;
  mask-image: linear-gradient(90deg, transparent 0, #000 16px, #000 calc(100% - 16px), transparent 100%);
}
.fb-ladder::-webkit-scrollbar { display: none; }
.fb-ladder__step {
  flex: none; scroll-snap-align: center; display: flex; flex-direction: column; align-items: center; gap: 1px;
  min-width: 64px; padding: 5px 8px; border-radius: var(--ck-radius-chip); background: var(--ck-surface-2);
  box-shadow: inset 0 0 0 1px var(--ck-line);
}
.fb-ladder__step:first-child { margin-left: 16px; }
.fb-ladder__step:last-child { margin-right: 16px; }
.fb-ladder__k { font-size: 10px; color: var(--ck-text-dim); font-weight: 600; }
.fb-ladder__v { font-size: var(--ck-fs-sm); font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ck-text-muted); white-space: nowrap; }
.fb-ladder__step.is-done { background: color-mix(in srgb, var(--ck-success) 16%, var(--ck-surface-2)); }
.fb-ladder__step.is-done .fb-ladder__v { color: var(--ck-text); }
.fb-ladder__step.is-next { box-shadow: inset 0 0 0 1.5px var(--ck-accent); }
.fb-ladder__step.is-next .fb-ladder__v { color: var(--ck-text); }
.fb-ladder__step.is-bust { box-shadow: inset 0 0 0 1.5px var(--ck-danger); }

/* stacked scene when the stage is narrow (tablet portrait, small desktop) */
@container fb-scene (max-width: 820px) {
  .fb-scene.has-candy { grid-template-columns: minmax(0, 1fr) minmax(200px, 260px); grid-template-areas: "board side" "ladder ladder"; }
  .fb-scene__candy { display: none; }
}
@container fb-scene (max-width: 620px) {
  .fb-scene, .fb-scene.has-candy { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto; grid-template-areas: "side" "board" "ladder"; padding: 12px; gap: 10px; }
  .fb-scene__side { display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "head stats" "status status"; gap: 6px 14px; align-items: center; }
  .fb-side__head { grid-area: head; }
  .fb-stats { grid-area: stats; }
  .fb-side__status { grid-area: status; min-height: 0; }
  .fb-random { display: none; }
}

/* ---- mine selector (inside the kit bet panel's top row) ---- */
.fb-shell .ck-betpanel__top { display: flex; padding: 0; min-height: 0; }
.fb-mines { display: flex; align-items: center; gap: 10px; width: 100%; min-width: 0; padding: 2px 2px 0 6px; }
.fb-mines__label { font-size: var(--ck-fs-xs); font-weight: 600; text-transform: uppercase; letter-spacing: var(--ck-tracking-caps); color: var(--ck-text-muted); flex: none; }
.fb-mines__chips { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(34px, 1fr); gap: 4px; flex: 1 1 auto; min-width: 0; }
.fb-mines__chip {
  height: 30px; padding: 0 6px; border: 0; border-radius: var(--ck-radius-chip); background: var(--ck-surface-2); color: var(--ck-text-muted);
  font-size: var(--ck-fs-sm); font-weight: 700; font-variant-numeric: tabular-nums; transition: background var(--ck-dur), color var(--ck-dur);
}
.fb-mines__chip:hover:not(:disabled) { background: var(--ck-surface-hover); color: var(--ck-text); }
.fb-mines__chip[aria-pressed="true"] { background: var(--ck-accent); color: #fff; }
.fb-mines__chip:disabled { opacity: .45; }
.fb-mines__chip[aria-pressed="true"]:disabled { opacity: .75; }
.fb-mines__stepper { display: grid; grid-template-columns: 30px 38px 30px; align-items: center; height: 30px; flex: none; border-radius: var(--ck-radius-chip); background: var(--ck-surface-3); box-shadow: inset 0 0 0 1px var(--ck-line); }
.fb-mines__step { height: 30px; border: 0; background: transparent; color: var(--ck-text-muted); display: flex; align-items: center; justify-content: center; border-radius: var(--ck-radius-chip); }
.fb-mines__step:hover:not(:disabled) { color: var(--ck-text); background: var(--ck-surface-hover); }
.fb-mines__step:disabled { opacity: .35; }
.fb-mines__value { width: 100%; height: 30px; border: 0; background: transparent; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; font-size: var(--ck-fs-md); }
.fb-mines__value:disabled { opacity: .75; }
.ck-betpanel.is-live { border-color: color-mix(in srgb, var(--ck-success) 40%, transparent); }

/* ---- phone ---- */
@container ck-shell (max-width: 767.98px) {
  .fb-shell .ck-slot--stage { aspect-ratio: auto; min-height: 0; flex: none; }
  .fb-shell .ck-stage { min-height: 0; }
  .fb-shell .ck-stage__canvas { position: relative; inset: auto; container-type: inline-size; }
  .fb-scene, .fb-scene.has-candy { position: relative; inset: auto; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto auto; grid-template-areas: "side" "board" "ladder"; padding: 10px; gap: 10px; }
  .fb-scene__board { container-type: inline-size; }
  .fb-board { width: 100%; height: auto; aspect-ratio: 1; --gap: 6px; }
  .fb-tile { border-radius: 10px; }
  .fb-scene__side { display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "head stats" "status status"; gap: 6px 12px; align-items: center; }
  .fb-side__head { grid-area: head; }
  .fb-mult { font-size: 36px; }
  .fb-stats { grid-area: stats; }
  .fb-stat { padding: 5px 9px; }
  .fb-stat__label, .fb-stat__value { font-size: var(--ck-fs-xs); }
  .fb-side__status { grid-area: status; min-height: 0; font-size: var(--ck-fs-xs); }
  .fb-random { display: none; }
  .fb-shell .ck-stepper__cur { display: none; }
  .fb-mines { flex-wrap: wrap; gap: 6px 8px; padding-left: 2px; }
  .fb-mines__label { flex: 1 1 auto; }
  .fb-mines__chips { order: 3; flex: 1 1 100%; grid-auto-columns: minmax(30px, 1fr); }
  .fb-mines__chip, .fb-mines__step, .fb-mines__stepper, .fb-mines__value { height: 36px; }
  .fb-mines__stepper { grid-template-columns: 32px 34px 32px; }
}

/* ---- fairness modal: mini boards ---- */
.fb-fair__boards { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 12px; }
.fb-mini { margin: 0; display: flex; flex-direction: column; gap: 6px; align-items: center; }
.fb-mini__grid { display: grid; grid-template-columns: repeat(5, 22px); grid-auto-rows: 22px; gap: 3px; }
.fb-mini__cell { border-radius: 5px; background: var(--ck-surface-3); box-shadow: inset 0 0 0 1px var(--ck-line); }
.fb-mini__cell.is-picked { background: color-mix(in srgb, var(--ck-success) 55%, var(--ck-surface-2)); }
.fb-mini__cell.is-mine { background: #3a0f1c; box-shadow: inset 0 0 0 1.5px var(--ck-danger); }
.fb-mini__cell.is-hit { background: var(--ck-danger); }
.fb-mini__cap { font-size: var(--ck-fs-xs); color: var(--ck-text-muted); }
.fb-pill--lost .ck-kv__value { color: var(--ck-danger); }
.fb-pill--won .ck-kv__value { color: var(--ck-win); }

/* ---- modals ---- */
.fb-list { margin: 0 0 12px; padding-left: 20px; line-height: 1.55; }
.fb-list li + li { margin-top: 4px; }
.fb-h3 { margin: 16px 0 8px; font-size: var(--ck-fs-xs); font-weight: 600; text-transform: uppercase; letter-spacing: var(--ck-tracking-caps); color: var(--ck-text-muted); }
.fb-muted { color: var(--ck-text-muted); font-size: var(--ck-fs-sm); line-height: 1.5; }
.fb-menu { display: grid; gap: 8px; margin-bottom: 12px; }
.fb-menu-btn { justify-content: flex-start; width: 100%; }
kbd { display: inline-block; min-width: 1.6em; padding: 1px 6px; border-radius: 6px; background: var(--ck-surface-3); border: 1px solid var(--ck-line-strong); font: 500 12px var(--ck-font-mono); text-align: center; }

/* ---- preloader (index.html #fb-preloader, driven by src/ui/preloader.js) ---- */
.fb-pre {
  position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 24px;
  background: radial-gradient(120% 90% at 50% 20%, #3a1a2c 0%, #1a0c16 55%, #0f090e 100%);
  transition: opacity 400ms ease, visibility 400ms;
}
.fb-pre.is-leaving { opacity: 0; visibility: hidden; pointer-events: none; }
.fb-pre__art { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.fb-pre__art img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 50%; display: block; animation: fb-drift 14s ease-in-out infinite alternate; }
/* the panel sits right of Candy on wide screens and under her on tall ones */
.fb-pre__veil { position: absolute; inset: 0; pointer-events: none; background: linear-gradient(90deg, rgba(15, 9, 14, 0) 45%, rgba(15, 9, 14, .55) 75%, rgba(15, 9, 14, .75) 100%); }
/* panel centred, as on the other Candi games; on tall screens it sits low so Candy stays visible */
@media (min-aspect-ratio: 9/10) {
  /* slide the art left so Candy and her box sit clear of the centred panel */
  .fb-pre__art img { width: 110%; max-width: none; margin-left: -10%; object-position: 0 50%; }
}
@media (min-aspect-ratio: 9/10) { .fb-pre__veil { background: radial-gradient(60% 70% at 50% 55%, rgba(15, 9, 14, .55) 0%, rgba(15, 9, 14, .15) 70%, rgba(15, 9, 14, 0) 100%); } }
@media (max-aspect-ratio: 9/10) {
  .fb-pre { align-items: flex-end; padding-bottom: max(24px, env(safe-area-inset-bottom, 0px)); }
  .fb-pre__veil { background: linear-gradient(180deg, rgba(15, 9, 14, 0) 45%, rgba(15, 9, 14, .7) 78%, rgba(15, 9, 14, .9) 100%); }
}
.fb-pre__panel {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center;
  width: min(420px, 100%); padding: 28px 24px 22px; border-radius: 20px;
  background: rgba(23, 14, 21, .78); border: 1px solid rgba(255, 255, 255, .08); backdrop-filter: blur(8px);
}
.fb-pre__title { margin: 0; font-size: clamp(26px, 6.4vw, 40px); line-height: 1; }
.fb-wordmark--pre { flex-direction: column; gap: .08em; }
.fb-pre__tagline { margin: 0 0 6px; font-size: var(--ck-fs-md, 15px); color: rgba(251, 242, 246, .78); }
.fb-pre__bar { position: relative; width: 100%; height: 4px; border-radius: 2px; background: rgba(255, 255, 255, .12); overflow: hidden; }
.fb-pre__fill { position: absolute; inset: 0; transform: scaleX(0); transform-origin: left center; background: var(--ck-accent); transition: transform 240ms ease; }
.fb-pre__status { margin: 0; min-height: 1.4em; font-size: var(--ck-fs-sm, 13px); color: rgba(251, 242, 246, .7); }
.fb-pre__choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; margin-top: 4px; }
.fb-pre__choices[hidden] { display: none; }
.fb-pre__btn { min-height: 52px; gap: 8px; font-size: var(--ck-fs-md, 15px); text-transform: uppercase; letter-spacing: var(--ck-tracking-caps); font-weight: var(--ck-fw-bold); }
.fb-pre__hint { margin: 0; font-size: var(--ck-fs-xs, 12px); color: rgba(251, 242, 246, .5); }
.fb-pre:not(.is-ready) .fb-pre__hint { visibility: hidden; }
.fb-pre.is-ready .fb-pre__bar { opacity: 0; height: 0; margin: -6px 0 0; transition: opacity 200ms, height 200ms, margin 200ms; }
.fb-pre.is-ready .fb-pre__choices { animation: fb-up 260ms ease-out both; }
@keyframes fb-drift { from { transform: scale(1.02); } to { transform: scale(1.06) translateY(-1%); } }
@keyframes fb-up { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  .fb-shell *, .ck-overlay *, .fb-pre, .fb-pre * { transition-duration: 0ms !important; animation-duration: 0ms !important; animation-delay: 0ms !important; }
}
.fb-reduced .fb-shell *, .fb-reduced .fb-pre * { animation-duration: 0ms !important; animation-delay: 0ms !important; }
.fb-stat__value--win.is-zero { color: var(--ck-text-muted); }
