/* Lightning Rips player UI. Built for a webview placed between a native operator header and a native bottom navigation.
   We own only the middle: no logo bar, no bottom nav, no page chrome of our own. */
:root {
  --bg: #0b0d17; --surface: #141829; --surface2: #1b2036; --line: #2a3150; --text: #eef1fb; --muted: #9aa3c4;
  --accent: #ffd23f; --accent-ink: #1a1400; --violet: #7c5cff; --good: #3ddc97; --bad: #ff6b6b; --warn: #ffb020;
  --common: #9aa4b2; --uncommon: #4ade80; --rare: #38bdf8; --epic: #c084fc; --legendary: #fbbf24;
  --radius: 16px; --tap: 48px;
}
[data-theme="light"] {
  --bg: #f4f5fb; --surface: #ffffff; --surface2: #eceef8; --line: #d6daee; --text: #14172b; --muted: #596085;
  --common: #6b7280; --uncommon: #15803d; --rare: #0369a1; --epic: #7e22ce; --legendary: #b45309;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overscroll-behavior: none; }
body { background: var(--bg); color: var(--text); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-tap-highlight-color: transparent; touch-action: manipulation; -webkit-text-size-adjust: 100%; }
button { font: inherit; color: inherit; cursor: pointer; border: 1px solid var(--line); background: var(--surface2); border-radius: 12px; min-height: var(--tap); padding: 0 16px; }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 700; }
button.ghost { background: transparent; }
button.danger { color: var(--bad); }
button.sm { min-height: 44px; padding: 0 14px; font-size: 15px; }
input, select { font: inherit; font-size: 16px; /* 16px stops iOS zooming on focus */ color: var(--text); background: var(--surface2); border: 1px solid var(--line); border-radius: 12px; min-height: var(--tap); padding: 0 14px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
a { color: var(--accent); }
.muted { color: var(--muted); } .sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.t-common { color: var(--common); } .t-uncommon { color: var(--uncommon); } .t-rare { color: var(--rare); } .t-epic { color: var(--epic); } .t-legendary { color: var(--legendary); }

/* ---- shell: fills exactly the area the native app gives the webview */
#app { height: 100vh; height: 100dvh; display: flex; flex-direction: column; position: relative; overflow: hidden; padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
#tabs { flex: none; display: flex; align-items: center; gap: 2px; padding: 4px 6px; background: var(--bg); border-bottom: 1px solid var(--line); }
.tab { flex: 1; min-width: 0; min-height: 52px; display: grid; place-items: center; align-content: center; gap: 2px; text-decoration: none; color: var(--muted); border-radius: 12px; font-size: 12px; font-weight: 600; position: relative; }
.tab svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tab.on { color: var(--accent); background: var(--surface); }
.tab .dot { position: absolute; top: 4px; right: calc(50% - 22px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--violet); color: #fff; font-size: 11px; line-height: 18px; text-align: center; }
.tab .dot.urgent { background: var(--bad); }
.balchip { flex: none; margin-left: 4px; padding: 0 10px; min-height: 36px; display: grid; place-items: center; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); font-weight: 700; font-size: 14px; }
#scroll { flex: 1; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; scroll-behavior: smooth; }
#main { padding: 12px 12px 24px; max-width: 980px; margin: 0 auto; outline: none; }
#cta { flex: none; }
.ctabar { display: flex; gap: 10px; align-items: center; padding: 10px 12px max(10px, env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--line); }
.ctabar .grow { flex: 1; } .ctabar button { flex: none; } .ctabar button.primary { flex: 1; }
h1 { font-size: 22px; margin: 4px 0 2px; } h2 { font-size: 18px; margin: 18px 0 8px; } h3 { margin: 0; font-size: 16px; } h4 { margin: 18px 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.sub { color: var(--muted); margin: 0 0 12px; font-size: 14px; }

/* ---- banners */
.banner { display: flex; gap: 10px; align-items: center; width: 100%; text-align: left; padding: 10px 12px; margin-bottom: 12px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--warn); min-height: var(--tap); }
.banner.urgent { border-left-color: var(--bad); } .banner.info { border-left-color: var(--violet); cursor: default; }
.banner b { font-variant-numeric: tabular-nums; }
.notice { padding: 10px 12px; margin: 0 0 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--violet); font-size: 14px; }
.notice.warn { border-left-color: var(--warn); } .notice.bad { border-left-color: var(--bad); }

/* ---- art (generated from emoji + hue: no image assets needed) */
.art { position: relative; display: grid; place-items: center; background: radial-gradient(120% 120% at 30% 20%, hsl(var(--h) 80% 55% / .9), hsl(var(--h) 70% 22%) 70%); overflow: hidden; }
.art .emoji { filter: drop-shadow(0 4px 10px rgba(0, 0, 0, .45)); line-height: 1; }
.art .tag { position: absolute; top: 8px; left: 8px; font-size: 11px; font-weight: 800; letter-spacing: .4px; text-transform: uppercase; padding: 2px 8px; border-radius: 99px; background: rgba(0, 0, 0, .55); color: #fff; }

/* ---- lobby */
.hero-row { display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory; margin: 0 -12px 14px; padding: 0 12px; scrollbar-width: none; }
.hero-row::-webkit-scrollbar { display: none; }
.hero { flex: 0 0 88%; max-width: 420px; scroll-snap-align: center; border-radius: 20px; padding: 16px; min-height: 168px; position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end; gap: 4px; color: #fff; background: radial-gradient(120% 140% at 85% 0%, hsl(var(--h) 85% 55%), hsl(var(--h) 70% 18%) 75%); border: 0; text-align: left; }
.hero .bigemoji { position: absolute; right: 12px; top: 6px; font-size: 92px; opacity: .95; filter: drop-shadow(0 6px 14px rgba(0, 0, 0, .5)); }
.hero .hname { font-size: 22px; font-weight: 800; } .hero .hmeta { opacity: .9; font-size: 14px; max-width: 70%; }
.hero .hcta { display: flex; gap: 10px; align-items: center; margin-top: 8px; }
.hero .hprice { font-size: 22px; font-weight: 800; } .hero .go { margin-left: auto; padding: 10px 18px; border-radius: 12px; background: #fff; color: #111; font-weight: 800; min-height: 44px; display: grid; place-items: center; }
.toolbar { display: grid; gap: 10px; margin-bottom: 12px; }
.search { width: 100%; }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; min-height: 44px; border-radius: 99px; padding: 0 16px; background: var(--surface); }
.chip.on { background: var(--violet); border-color: var(--violet); color: #fff; font-weight: 700; }
.toolrow { display: flex; gap: 10px; align-items: center; } .toolrow .count { color: var(--muted); font-size: 14px; flex: 1; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(2, 1fr); }
@media (min-width: 560px) { .grid { grid-template-columns: repeat(3, 1fr); } .hero { flex-basis: 46%; } }
@media (min-width: 860px) { .grid { grid-template-columns: repeat(4, 1fr); } }
.tile { padding: 0; overflow: hidden; border-radius: var(--radius); background: var(--surface); text-align: left; display: flex; flex-direction: column; min-height: 0; }
.tile .art { aspect-ratio: 1 / .8; font-size: 54px; }
.tile .tbody { padding: 10px 12px 12px; display: grid; gap: 1px; }
.tile .tname { font-weight: 700; } .tile .tmeta { color: var(--muted); font-size: 13px; } .tile .tprice { font-weight: 800; color: var(--accent); font-size: 18px; margin-top: 4px; }
.tile.off { opacity: .55; }
.empty { text-align: center; color: var(--muted); padding: 32px 12px; }
.footnote { color: var(--muted); font-size: 13px; margin-top: 18px; }

/* ---- bottom sheets (pack details, confirmations) */
#layer { position: absolute; inset: 0; pointer-events: none; z-index: 20; }
#layer > * { pointer-events: auto; }
.backdrop { position: absolute; inset: 0; background: rgba(4, 5, 12, .6); opacity: 0; transition: opacity .2s; }
.sheet { position: absolute; left: 0; right: 0; bottom: 0; max-height: 94%; display: flex; flex-direction: column; background: var(--surface); border-radius: 22px 22px 0 0; border-top: 1px solid var(--line); transform: translateY(100%); transition: transform .25s ease; max-width: 640px; margin: 0 auto; }
#layer.open .backdrop { opacity: 1; } #layer.open .sheet { transform: none; }
.grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 8px auto 0; flex: none; }
.sh-head { display: flex; gap: 12px; align-items: center; padding: 10px 14px; flex: none; }
.sh-head .art { width: 56px; height: 56px; border-radius: 14px; font-size: 30px; flex: none; }
.sh-head .ttl { flex: 1; min-width: 0; } .sh-head .ttl b { display: block; font-size: 18px; }
.sh-head .x { width: var(--tap); padding: 0; font-size: 20px; }
.sh-body { overflow-y: auto; padding: 0 14px 12px; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.sh-foot { flex: none; padding: 10px 14px max(12px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--surface); display: flex; gap: 10px; }
.sh-foot button { flex: 1; } .sh-foot .wide { flex: 1; display: grid; gap: 2px; }
.seg { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.seg button { padding: 6px 2px; min-height: 64px; display: grid; gap: 4px; place-items: center; align-content: center; font-size: 12px; font-weight: 600; line-height: 1.15; }
.seg button.on { background: var(--violet); border-color: var(--violet); color: #fff; }
.seg button[disabled] { opacity: .35; }
.bars { display: flex; gap: 2px; align-items: flex-end; height: 14px; } .bars i { width: 4px; background: currentColor; opacity: .35; border-radius: 1px; } .bars i.f { opacity: 1; }
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0; }
.kv > div { background: var(--surface2); border-radius: 12px; padding: 8px 12px; font-size: 13px; color: var(--muted); } .kv b { display: block; color: var(--text); font-size: 17px; }
.oddsbar { display: flex; height: 14px; border-radius: 7px; overflow: hidden; background: var(--surface2); gap: 1px; }
.oddsbar i { display: block; min-width: 3px; } .bg-common { background: var(--common); } .bg-uncommon { background: var(--uncommon); } .bg-rare { background: var(--rare); } .bg-epic { background: var(--epic); } .bg-legendary { background: var(--legendary); }
.odds { margin: 8px 0 0; } .odds .orow { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); min-height: 40px; }
.orow .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; } .orow .nm { flex: 1; font-weight: 600; } .orow .pc { font-variant-numeric: tabular-nums; }
details.cards { margin: 6px 0 0; } details.cards summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; color: var(--accent); font-size: 14px; }
details.cards ul { margin: 0; padding: 0 0 8px; list-style: none; font-size: 14px; } details.cards li { display: flex; justify-content: space-between; padding: 4px 0; }
.opts { display: grid; gap: 8px; } .opt { display: flex; gap: 12px; background: var(--surface2); border-radius: 12px; padding: 10px 12px; font-size: 14px; } .opt .ic { font-size: 20px; width: 26px; text-align: center; } .opt b { display: block; }
.sheet.small { max-width: 520px; } .sheet .pad { padding: 8px 16px 4px; }
.line { display: flex; gap: 10px; padding: 6px 0; } .line .sp { flex: 1; }

/* ---- reveal (full area of the webview) */
.reveal { position: absolute; inset: 0; background: var(--bg); display: flex; flex-direction: column; z-index: 30; }
/* margin:auto centres when there is room and scrolls from the top when there is not (grid centring would clip the top) */
.reveal .stage { flex: 1; overflow-y: auto; display: flex; flex-direction: column; align-items: center; padding: 14px 14px; text-align: center; gap: 10px; min-height: 0; }
.reveal .stage > :first-child { margin-top: auto; } .reveal .stage > :last-child { margin-bottom: auto; }
.packfx { width: 150px; height: 210px; border-radius: 18px; display: grid; place-items: center; font-size: 64px; border: 3px solid var(--accent); background: linear-gradient(160deg, var(--violet), #2a1a7a); animation: shake .5s infinite alternate, glow 1.1s infinite alternate; }
@keyframes shake { from { transform: rotate(-3deg) scale(1); } to { transform: rotate(3deg) scale(1.05); } }
@keyframes glow { from { box-shadow: 0 0 20px rgba(124, 92, 255, .5); } to { box-shadow: 0 0 70px rgba(255, 210, 63, .85); } }
.rcard { flex: none; width: min(200px, 54vw); border-radius: 20px; padding: 10px 10px 12px; background: var(--surface); border: 3px solid var(--line); animation: pop .5s ease-out; }
.rcard .art { width: 100%; aspect-ratio: 1.15; border-radius: 14px; font-size: min(72px, 20vw); }
.rcard .nm { font-size: 19px; font-weight: 800; margin-top: 4px; }
.rcard.tier-uncommon { border-color: var(--uncommon); } .rcard.tier-rare { border-color: var(--rare); box-shadow: 0 0 30px color-mix(in srgb, var(--rare) 40%, transparent); }
.rcard.tier-epic { border-color: var(--epic); box-shadow: 0 0 40px color-mix(in srgb, var(--epic) 50%, transparent); } .rcard.tier-legendary { border-color: var(--legendary); box-shadow: 0 0 60px color-mix(in srgb, var(--legendary) 60%, transparent); }
@keyframes pop { from { transform: scale(.6) rotate(-4deg); filter: brightness(3); opacity: 0; } to { transform: none; filter: none; opacity: 1; } }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; max-width: 420px; width: 100%; margin: 0 auto; text-align: left; }
.stats > div { background: var(--surface); border-radius: 12px; padding: 8px 12px; font-size: 13px; color: var(--muted); } .stats b { display: block; font-size: 17px; color: var(--text); }
.reveal .acts { flex: none; padding: 10px 14px max(12px, env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--line); display: grid; gap: 8px; }
.reveal .acts .r2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.again { background: none; border: 0; color: var(--accent); min-height: 44px; }
@media (prefers-reduced-motion: reduce) { .packfx, .rcard { animation: none; } .sheet, .backdrop { transition: none; } }

/* ---- collection rows */
.sumbar { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; } .sumbar .grow { flex: 1; }
.rowcard { display: grid; grid-template-columns: 64px 1fr; gap: 6px 12px; padding: 10px; margin-bottom: 10px; border-radius: var(--radius); background: var(--surface); border: 2px solid var(--line); }
.rowcard .art { width: 64px; height: 64px; border-radius: 12px; font-size: 34px; grid-row: span 1; }
.rowcard.tier-rare { border-color: color-mix(in srgb, var(--rare) 55%, var(--line)); } .rowcard.tier-epic { border-color: color-mix(in srgb, var(--epic) 60%, var(--line)); } .rowcard.tier-legendary { border-color: var(--legendary); }
.rowcard.sel { outline: 3px solid var(--accent); }
.rc-name { font-weight: 700; } .rc-sub { font-size: 13px; color: var(--muted); }
.rc-state { margin-top: 4px; }
.rc-actions { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 99px; font-size: 13px; background: var(--surface2); border: 1px solid var(--line); }
.pill.good { color: var(--good); } .pill.warn { color: var(--warn); } .pill.bad { color: var(--bad); }
.timer { font-variant-numeric: tabular-nums; font-weight: 800; } .timer.low { color: var(--bad); }
.chk { width: 26px; height: 26px; border-radius: 8px; border: 2px solid var(--line); display: grid; place-items: center; font-weight: 900; }
.sel .chk { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.list-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: 10px; }
.list-card .top { display: flex; gap: 8px; align-items: center; } .list-card .top .sp { flex: 1; }
.hist { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 10px 0; border-bottom: 1px solid var(--line); } .hist .amt { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; } .hist small { color: var(--muted); grid-column: 1 / -1; }

#toasts { position: absolute; left: 12px; right: 12px; bottom: 12px; display: grid; gap: 8px; z-index: 40; pointer-events: none; justify-items: center; }
.toast { pointer-events: auto; background: var(--surface2); color: var(--text); border: 1px solid var(--line); border-left: 4px solid var(--violet); padding: 10px 14px; border-radius: 12px; max-width: 420px; box-shadow: 0 6px 24px rgba(0, 0, 0, .4); }
.toast.bad { border-left-color: var(--bad); } .toast.good { border-left-color: var(--good); }

/* ---- CMS-driven lobby sections */
.sec-head { display: flex; align-items: baseline; gap: 10px; margin: 18px 0 8px; scroll-margin-top: 8px; }
.sec-head h2 { margin: 0; font-size: 18px; }
.row-scroll { display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x proximity; margin: 0 -12px; padding: 0 12px 4px; scrollbar-width: none; }
.row-scroll::-webkit-scrollbar { display: none; }
.tile.compact { flex: 0 0 150px; scroll-snap-align: start; }
.tile.compact .art { font-size: 44px; }
