/* Card editor — Rollbit casino voice on the sportsbook's calm UI: navy page, real card colours (#1A1D29 / #1F212E,
   radius 10), brand yellow #FADA26 for the one thing to press, Montserrat throughout (brain MOTION.md). */
@font-face { font-family: "Montserrat"; font-weight: 500; src: url("../fonts/Montserrat-Medium.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "Montserrat"; font-weight: 600; src: url("../fonts/Montserrat-SemiBold.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "Montserrat"; font-weight: 700; src: url("../fonts/Montserrat-Bold.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "Montserrat"; font-weight: 800; src: url("../fonts/Montserrat-ExtraBold.ttf") format("truetype"); font-display: swap; }

:root {
  --page: #12151E;
  --panel: #1A1D29;
  --card: #1F212E;
  --card-hi: #262938;
  --line: rgba(255, 255, 255, .07);
  --line-hi: rgba(255, 255, 255, .14);
  --text: #F2F4F8;
  --muted: #A0A8B9;
  --faint: #6E7689;
  --yellow: #FADA26;
  --yellow-ink: #1B1600;
  --red: #FF6B6E;
  --green: #46E88C;
  --radius: 10px;
  --ease: cubic-bezier(.2, .9, .3, 1);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--page);
  color: var(--text);
  font: 500 14px/1.45 "Montserrat", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
button { font: inherit; color: inherit; }
svg { display: block; }
[hidden] { display: none !important; }

#app {
  position: fixed; inset: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  background:
    radial-gradient(120% 90% at 38% 30%, rgba(46, 52, 78, .55) 0%, rgba(38, 43, 66, .42) 22%, rgba(28, 32, 50, .26) 45%,
      rgba(20, 23, 36, .12) 68%, rgba(18, 21, 30, 0) 100%),
    var(--page);
}
#app.compact { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }

/* ── stage ─────────────────────────────────────────────────────────────────────────────────────────── */
.stage-wrap { position: relative; display: grid; place-items: center; min-width: 0; min-height: 0; padding: 24px; }
#app.compact .stage-wrap { padding: 14px 14px 8px; }
.stage {
  position: relative;
  width: var(--stage, 560px); height: var(--stage, 560px);
  border-radius: 14px;
  outline: none;
  touch-action: none;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .06) inset, 0 24px 60px rgba(4, 6, 14, .55), 0 6px 18px rgba(4, 6, 14, .35);
}
.stage:focus-visible { box-shadow: 0 0 0 2px var(--yellow), 0 24px 60px rgba(4, 6, 14, .55); }
.layer { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 14px; pointer-events: none; }
.plate { background: #0d0f16; }
.chars { overflow: hidden; }
.placeholder, .result { opacity: 0; }
.char { position: absolute; left: 0; top: 0; transform-origin: 50% 50%; will-change: transform; }
.char img { width: 100%; height: 100%; display: block; pointer-events: none; -webkit-user-drag: none; }
.overlay { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.sel-box { fill: none; stroke: var(--yellow); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.sel-shade { fill: none; stroke: rgba(10, 8, 0, .45); stroke-width: 4; }
.handle { fill: #fff; stroke: var(--yellow); stroke-width: 2; pointer-events: all; cursor: nwse-resize; }
.handle.ne, .handle.sw { cursor: nesw-resize; }
.handle-hit { fill: transparent; pointer-events: all; }
.handle-hit.nw, .handle-hit.se { cursor: nwse-resize; }
.handle-hit.ne, .handle-hit.sw { cursor: nesw-resize; }
.guide { stroke: var(--yellow); stroke-width: 1; opacity: .85; vector-effect: non-scaling-stroke; }
.guide-label { fill: var(--yellow-ink); font: 700 10px "Montserrat"; letter-spacing: .04em; }
.guide-pill { fill: var(--yellow); }
.stage.grabbing, .stage.grabbing * { cursor: grabbing !important; }
.stage.can-grab { cursor: grab; }

.stage-tools { position: absolute; top: 18px; left: 18px; display: flex; gap: 8px; z-index: 3; }
#app.compact .stage-tools { top: 10px; left: 10px; }
.icon-btn {
  width: 40px; height: 40px; display: grid; place-items: center;
  background: rgba(26, 29, 41, .86); border: 1px solid var(--line-hi); border-radius: var(--radius);
  cursor: pointer; backdrop-filter: blur(8px);
  transition: background .18s var(--ease), opacity .18s var(--ease), transform .12s var(--ease);
}
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: var(--text); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn:hover:not(:disabled) { background: var(--card-hi); }
.icon-btn:active:not(:disabled) { transform: scale(.94); }
.icon-btn:disabled { opacity: .35; cursor: default; }

.toast {
  position: absolute; left: 50%; bottom: 22px;
  padding: 10px 16px; border-radius: 999px;
  background: rgba(31, 33, 46, .94); border: 1px solid var(--line-hi);
  color: var(--text); font-weight: 600; font-size: 13px; white-space: nowrap;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
  opacity: 0; transform: translate(-50%, 12px); pointer-events: none;
}
#app.compact .toast { bottom: 12px; font-size: 12px; }
.toast b { color: var(--yellow); font-weight: 700; }

/* ── panel ─────────────────────────────────────────────────────────────────────────────────────────── */
.panel {
  display: flex; flex-direction: column; min-height: 0;
  background: var(--panel); border-left: 1px solid var(--line);
}
#app.compact .panel { border-left: 0; border-top: 1px solid var(--line); }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 22px 22px 14px; }
#app.compact .panel-head { padding: 14px 16px 10px; }
.eyebrow { color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.title { margin: 4px 0 0; font-size: 17px; font-weight: 800; line-height: 1.25; }
#app.compact .title { font-size: 15px; }
.link-btn {
  flex: none; margin-top: 2px; padding: 7px 10px; border-radius: 8px; border: 1px solid var(--line-hi);
  background: transparent; color: var(--text); font-size: 12px; font-weight: 700; cursor: pointer;
  transition: background .18s var(--ease);
}
.link-btn:hover { background: var(--card-hi); }

.panel-body { flex: 1; min-height: 0; overflow-y: auto; overflow-anchor: none; padding: 0 22px 10px; overscroll-behavior: contain; touch-action: pan-y; }
#app.compact .panel-body { padding: 0 16px 8px; }
.section { padding: 14px 0 6px; }
.section + .section { border-top: 1px solid var(--line); }
.section-head { display: flex; align-items: baseline; justify-content: space-between; }
.section h2 { margin: 0; font-size: 13px; font-weight: 800; letter-spacing: .02em; }
.count { color: var(--muted); font-size: 12px; font-weight: 600; }
.help { margin: 6px 0 12px; color: var(--muted); font-size: 13px; line-height: 1.45; }
.help.small { font-size: 12px; margin: 8px 0 4px; }
.empty-sel { margin-top: 16px; padding: 12px 14px; border: 1px dashed var(--line-hi); border-radius: var(--radius); }

.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
#app.compact .tiles { grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); }
.tile {
  position: relative; aspect-ratio: 3 / 4; padding: 8px; border-radius: var(--radius);
  background: radial-gradient(90% 70% at 50% 35%, #2B2F42 0%, #262a3b 30%, #22253433 70%, transparent 100%), var(--card);
  border: 1px solid var(--line); cursor: pointer; overflow: hidden;
  transition: border-color .18s var(--ease), background-color .18s var(--ease), transform .12s var(--ease);
}
.tile:hover { border-color: var(--line-hi); }
.tile:active { transform: scale(.96); }
.tile img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 6px 10px rgba(0, 0, 0, .45)); pointer-events: none; }
.tile .tick {
  position: absolute; top: 6px; right: 6px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--yellow); display: grid; place-items: center; transform: scale(0); opacity: 0;
}
.tile .tick svg { width: 12px; height: 12px; fill: none; stroke: var(--yellow-ink); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.tile.on { border-color: var(--yellow); box-shadow: 0 0 0 1px var(--yellow) inset; }
.tile.current { background-color: #2a2d3e; }

.sel-section { overflow: hidden; height: 0; padding: 0; border-top: 0 !important; }
.selected-inner { padding: 14px 0 6px; border-top: 1px solid var(--line); }
.tools { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }
.tool {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 4px 8px;
  border-radius: var(--radius); border: 1px solid var(--line); background: var(--card); cursor: pointer;
  font-size: 11px; font-weight: 700; color: var(--text);
  transition: background .18s var(--ease), border-color .18s var(--ease), transform .12s var(--ease);
}
.tool svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tool:hover { background: var(--card-hi); border-color: var(--line-hi); }
.tool:active { transform: scale(.95); }
.tool.toggle[aria-pressed="true"] { border-color: rgba(250, 218, 38, .55); color: var(--yellow); }
.tool.danger { color: var(--red); }

.slider-row { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 14px; margin-top: 16px; font-weight: 700; font-size: 13px; }
input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 28px; background: transparent; cursor: pointer; touch-action: none; }
input[type="range"]::-webkit-slider-runnable-track {
  height: 6px; border-radius: 999px;
  background: linear-gradient(90deg, var(--yellow) 0 var(--fill, 50%), #343849 var(--fill, 50%) 100%);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 20px; height: 20px; margin-top: -7px; border-radius: 50%;
  background: #fff; border: 3px solid var(--yellow); box-shadow: 0 2px 8px rgba(0, 0, 0, .45);
}
input[type="range"]::-moz-range-track { height: 6px; border-radius: 999px; background: #343849; }
input[type="range"]::-moz-range-progress { height: 6px; border-radius: 999px; background: var(--yellow); }
input[type="range"]::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: #fff; border: 3px solid var(--yellow); }

.panel-foot { display: grid; grid-template-columns: auto 1fr; gap: 10px; padding: 14px 22px 18px; border-top: 1px solid var(--line); }
#app.compact .panel-foot { padding: 10px 16px calc(12px + env(safe-area-inset-bottom)); }
.foot-note { grid-column: 1 / -1; margin: 2px 0 0; color: var(--faint); font-size: 11.5px; text-align: center; }
.btn {
  height: 46px; padding: 0 18px; border-radius: var(--radius); border: 1px solid transparent;
  font-size: 14px; font-weight: 800; letter-spacing: .01em; cursor: pointer; white-space: nowrap;
  transition: background .18s var(--ease), border-color .18s var(--ease), opacity .18s var(--ease), transform .12s var(--ease);
}
.btn:active:not(:disabled) { transform: scale(.97); }
.btn.primary { background: var(--yellow); color: var(--yellow-ink); box-shadow: 0 6px 18px rgba(250, 218, 38, .18); }
.btn.primary:hover:not(:disabled) { background: #FFE24A; }
.btn.primary:disabled { background: #3a3d4c; color: #8C93A4; box-shadow: none; cursor: default; }
.btn.ghost { background: transparent; border-color: var(--line-hi); color: var(--text); }
.btn.ghost:hover { background: var(--card-hi); }
button:focus-visible, .tile:focus-visible, input:focus-visible { outline: 2px solid var(--yellow); outline-offset: 2px; }

/* ── look: accent, background filter, glow ─────────────────────────────────────────────────────────── */
.look-row { margin-top: 12px; }
.look-row + .look-row { margin-top: 16px; }
.look-label { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; font-size: 13px; }
.look-label b { font-weight: 700; }
.look-label span { color: var(--muted); font-size: 12px; font-weight: 600; }
.look-row .help.small { margin: 2px 0 8px; }
.swatches { display: flex; flex-wrap: wrap; gap: 7px; }
.sw {
  position: relative; width: 28px; height: 28px; padding: 0; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--c); box-shadow: 0 0 0 1px rgba(255, 255, 255, .12) inset;
  transition: transform .12s var(--ease);
}
.sw:hover { transform: scale(1.08); }
.sw:active { transform: scale(.94); }
.sw::after {
  content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid var(--yellow);
  opacity: 0; transform: scale(.8); transition: opacity .2s var(--ease), transform .25s var(--ease);
}
.sw[aria-checked="true"]::after { opacity: 1; transform: scale(1); }
.sw.pill {
  width: auto; padding: 0 11px 0 30px; border-radius: 999px; background: var(--card); color: var(--text);
  font-size: 11.5px; font-weight: 700; box-shadow: 0 0 0 1px var(--line-hi) inset;
}
.sw.pill::before {
  content: ""; position: absolute; left: 6px; top: 6px; width: 16px; height: 16px; border-radius: 50%; background: var(--c);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .15) inset;
}
.sw.pill::after { border-radius: 999px; }
.segmented {
  position: relative; display: grid; grid-template-columns: repeat(3, 1fr); margin-top: 8px; padding: 3px;
  border-radius: var(--radius); background: var(--card); border: 1px solid var(--line);
}
.segmented button {
  position: relative; z-index: 1; height: 34px; border: 0; background: transparent; border-radius: 8px; cursor: pointer;
  font-size: 12.5px; font-weight: 700; color: var(--muted); transition: color .2s var(--ease);
}
.segmented button[aria-checked="true"] { color: var(--yellow-ink); }
.seg-thumb { position: absolute; top: 3px; bottom: 3px; left: 3px; width: calc((100% - 6px) / 3); border-radius: 8px; background: var(--yellow); }
.updating {
  position: absolute; top: 18px; right: 18px; z-index: 3;
  display: grid; gap: 7px; min-width: 210px; padding: 10px 14px 11px; border-radius: 12px;
  background: rgba(26, 29, 41, .92); border: 1px solid var(--line-hi); backdrop-filter: blur(8px);
  font-size: 12.5px; font-weight: 700; text-align: center; box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
}
#app.compact .updating { top: 10px; right: 10px; min-width: 0; }
.updating .bar { margin: 0; height: 4px; }

/* ── sheets (loading, picker, building, done, problem) ─────────────────────────────────────────────── */
.sheet-veil { position: fixed; inset: 0; background: rgba(8, 10, 18, .5); backdrop-filter: blur(3px); opacity: 0; z-index: 10; }
.sheet {
  position: fixed; left: 50%; top: 50%; z-index: 11;
  width: min(440px, calc(100vw - 32px)); max-height: calc(100vh - 40px); overflow: auto;
  padding: 24px; border-radius: 16px;
  background: var(--panel); border: 1px solid var(--line-hi);
  box-shadow: 0 30px 80px rgba(0, 0, 0, .55);
  opacity: 0; transform: translate(-50%, -50%);
}
.sheet h2 { margin: 0; font-size: 19px; font-weight: 800; }
.sheet .row { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
.sheet .row .btn { flex: 1; }
#picker { width: min(720px, calc(100vw - 32px)); }
#done { top: auto; bottom: 22px; left: calc((100vw - 340px) / 2); transform: translate(-50%, 0); width: min(560px, calc(100vw - 380px));
        display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 4px 14px; padding: 16px 18px; }
#done .done-mark { grid-row: 1 / 3; margin: 0; width: 40px; height: 40px; }
#done h2 { font-size: 16px; }
#done .help { grid-column: 2; margin: 0; font-size: 12.5px; }
#done .row { grid-column: 3; grid-row: 1 / 3; margin: 0; flex-direction: column; gap: 8px; }
#done .row .btn { height: 38px; font-size: 13px; }
body.compact #done { left: 50%; bottom: 12px; width: calc(100vw - 24px); grid-template-columns: auto 1fr; }
body.compact #done .row { grid-column: 1 / -1; grid-row: auto; flex-direction: row; margin-top: 8px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; margin-top: 6px; }
.pick {
  padding: 0; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); background: var(--card);
  cursor: pointer; text-align: left; transition: border-color .18s var(--ease), transform .12s var(--ease);
}
.pick:hover { border-color: var(--line-hi); }
.pick:active { transform: scale(.97); }
.pick.current { border-color: var(--yellow); }
.pick img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; background: #0d0f16; }
.pick div { padding: 8px 10px 10px; }
.pick b { display: block; font-size: 12px; font-weight: 800; }
.pick span { display: block; color: var(--muted); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.bar { position: relative; height: 6px; margin-top: 16px; border-radius: 999px; background: #2b2e3d; overflow: hidden; }
.bar i { position: absolute; inset: 0 auto 0 0; width: 100%; border-radius: inherit; background: var(--yellow); transform-origin: 0 50%; transform: scaleX(0); }

.steps { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 12px; }
.steps li { display: flex; align-items: center; gap: 12px; color: var(--faint); font-weight: 600; transition: color .25s var(--ease); }
.steps li b {
  flex: none; width: 22px; height: 22px; border-radius: 50%; border: 2px solid #3a3e50; display: grid; place-items: center;
  transition: border-color .25s var(--ease), background .25s var(--ease);
}
.steps li.now { color: var(--text); }
.steps li.now b { border-color: var(--yellow); }
.steps li.now b::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--yellow); }
.steps li.ok { color: var(--muted); }
.steps li.ok b { background: var(--yellow); border-color: var(--yellow); }
.steps li.ok b::after {
  content: ""; width: 9px; height: 5px; margin-top: -2px; border-left: 2.5px solid var(--yellow-ink); border-bottom: 2.5px solid var(--yellow-ink);
  transform: rotate(-45deg);
}

.done-mark { width: 48px; height: 48px; margin-bottom: 14px; border-radius: 50%; background: var(--yellow); display: grid; place-items: center; }
.done-mark svg { width: 26px; height: 26px; fill: none; stroke: var(--yellow-ink); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }

/* the whole page fades in once, then nothing moves unless it means something */
#app.is-booting .panel, #app.is-booting .stage { opacity: 0; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
