* { box-sizing: border-box; }
html { color-scheme: light; scroll-padding-block: 1rem 12rem; }
body { margin: 0; color: var(--rl-ink); background: var(--rl-abyss); font: 500 1rem/1.7 var(--rl-font-body); }
button, select { font: inherit; }
button { cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: default; opacity: .55; }
[hidden] { display: none !important; }
:where(a, button, select, summary, [tabindex]):focus-visible { outline: 3px solid var(--rl-focus); outline-offset: 4px; }
a { color: var(--rl-action); text-underline-offset: .25em; }
h1, h2, h3, p { margin: 0; overflow-wrap: anywhere; }
h1, h2, h3 { font-family: var(--rl-font-display); line-height: 1.4; }
h1 { font-size: clamp(1.5rem, 2.6vw, 2.25rem); }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.125rem; }
strong, b, .target-count { font-variant-numeric: tabular-nums; }
.skip-link { position: fixed; inset: .75rem auto auto .75rem; z-index: 100; padding: .75rem; color: var(--rl-ink); background: var(--rl-paper); transform: translateY(-200%); }
.skip-link:focus { transform: none; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; clip-path: inset(50%); overflow: hidden; white-space: nowrap; }
.app { width: min(var(--rl-width-tool), calc(100% - 2rem)); margin: auto; padding-bottom: 12rem; }
.topbar { padding: 1.5rem 0 2rem; color: var(--rl-foam); }
.topbar p { margin-top: .5rem; font-size: .875rem; }
#dataVerified { display: inline-block; min-width: 10ch; }
/* Reserve the initial control and result areas while the data module loads. */
#selectionControls { min-height: 22.625rem; }
.layout { display: grid; grid-template-columns: 19rem minmax(0, 1fr); gap: 1.5rem; align-items: start; }
.panel, .result-stage, .history-panel { min-width: 0; padding: 1.5rem; border-radius: var(--rl-radius-small); }
.selection-panel { background: var(--rl-surface); }
.panel-title { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.panel-title > span { color: var(--rl-muted); font-size: .875rem; }
.select-wrap { position: relative; }
.event-select { width: 100%; min-height: 48px; padding: .625rem; border: 1px solid var(--rl-boundary); border-radius: var(--rl-radius-small); color: var(--rl-ink); background: var(--rl-foam); font-size: 1rem; }
.select-icon { display: none; }
.event-meta { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .75rem; font-size: .875rem; }
.tag { border-bottom: 1px solid var(--rl-boundary); }
.section-title { margin: 1.5rem 0 .75rem; font-size: 1rem; font-weight: 800; }
.segmented { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .25rem; }
.segmented button, .target-mode button, .idol-filter button { min-width: 0; min-height: 44px; padding: .5rem; border: 1px solid var(--rl-boundary); border-radius: var(--rl-radius-small); color: var(--rl-ink); background: var(--rl-foam); font-size: .875rem; font-weight: 700; }
.segmented button { padding-inline: .25rem; }
.target-mode { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; margin-top: .75rem; }
button.active { border-color: var(--rl-ink); color: var(--rl-on-selected); background: var(--rl-selected); }
.filter-options { margin-top: 1.25rem; border-block: 1px solid var(--rl-boundary); }
summary { cursor: pointer; min-height: 44px; padding-block: .75rem; font-size: .875rem; font-weight: 700; }
.idol-filter button { min-width: 44px; }
.idol-filter { display: flex; flex-wrap: wrap; gap: .5rem; padding-bottom: 1rem; }
.section-link { display: flex; align-items: center; min-height: 44px; margin-top: .75rem; font-weight: 700; font-size: .875rem; }
.result-stage { min-height: 46.5rem; background: var(--rl-paper); padding: 1.5rem 2rem; }
.stage-head { display: flex; align-items: start; justify-content: space-between; gap: 1.5rem; }
.stage-title { min-width: 0; }
.stage-title h2 { margin: .375rem 0; font-size: clamp(1.375rem, 2.4vw, 2rem); }
.stage-title small { color: var(--rl-muted); font-size: .875rem; }
.pity-box { flex: 0 0 auto; text-align: right; min-width: 4.5rem; font-size: .875rem; color: var(--rl-muted); }
.pity-box strong { display: block; color: var(--rl-ink); font: 800 1.75rem/1.5 var(--rl-font-display); }
.period-card { margin-top: 1rem; padding-top: .75rem; border-top: 1px solid var(--rl-divider); font-size: .875rem; }
.period-card span { display: block; color: var(--rl-muted); }
.period-card strong { font-weight: 500; }
.ready { display: grid; place-items: center; min-height: 17rem; margin-top: 1.25rem; padding: 2rem; color: var(--rl-foam); background: var(--rl-deep); text-align: center; }
.ready strong { display: block; margin-bottom: .75rem; font: 800 2rem/1.4 var(--rl-font-display); }
.ready span { display: block; max-width: 25rem; }
.cards-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .625rem; margin-top: 1.25rem; }
.gacha-card { display: flex; align-content: start; align-items: baseline; flex-wrap: wrap; gap: .375rem; min-width: 0; min-height: 9rem; padding: .75rem; border: 1px solid var(--rl-divider); border-radius: var(--rl-radius-small); background: var(--rl-foam); }
.gacha-card.sr { background: var(--rl-surface); }
.gacha-card.ssr { border-color: var(--rl-action); background: var(--rl-surface); }
.card-type, .pickup-badge, .new-badge { font-size: .75rem; font-weight: 800; }
.card-type { color: var(--rl-muted); }
.pickup-badge { padding-inline: .25rem; color: var(--rl-on-selected); background: var(--rl-selected); }
.new-badge { color: var(--rl-success); }
.rarity { flex-basis: 100%; color: var(--rl-ink); font: 800 1.625rem/1.5 var(--rl-font-display); }
.ssr .rarity { color: var(--rl-action); }
.card-name { flex-basis: 100%; font-size: .875rem; font-weight: 700; overflow-wrap: anywhere; }
.pull-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin-top: 1.25rem; padding: 1rem 0; border-block: 1px solid var(--rl-divider); }
.pull-chip span, .pull-chip small { display: block; color: var(--rl-muted); font-size: .875rem; }
.pull-chip strong { font: 800 1.5rem/1.4 var(--rl-font-display); }
.current-cost { display: flex; align-items: baseline; flex-wrap: wrap; gap: .25rem 1rem; margin-top: 1.5rem; font-size: .875rem; }
.current-cost strong { font: 800 1.75rem/1.5 var(--rl-font-display); overflow-wrap: anywhere; }
.current-cost span { flex-basis: 100%; color: var(--rl-muted); }
.targets { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem 1.5rem; }
.target-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .75rem; padding-block: .5rem; font-size: .875rem; }
.target-name { overflow-wrap: anywhere; }
.goal-flag { display: inline-block; margin-right: .5rem; color: var(--rl-muted); font-size: .75rem; }
.target-count { align-self: center; font-weight: 800; }
.meter { height: 4px; margin-top: .5rem; background: var(--rl-divider); }
.meter i { display: block; height: 100%; background: var(--rl-action); }
.complete .meter i { background: var(--rl-success); }
.pity-alert { margin-top: 1rem; padding: 1rem; border: 1px solid var(--rl-boundary); background: var(--rl-surface); }
.pity-alert span, .pity-alert small, .pity-alert strong { display: block; }
.pity-alert strong { margin-block: .25rem; font-size: 1.25rem; }
.pity-alert small { color: var(--rl-muted); font-size: .875rem; }
.complete-box { margin-top: 1.25rem; padding-block: 1rem; border-block: 1px solid var(--rl-divider); }
.complete-box h3 { color: var(--rl-success); font-size: 1.5rem; }
.complete-box p { margin-top: .5rem; }
.history-panel { grid-column: 1 / -1; background: var(--rl-foam); padding: 2rem; }
.history-panel > h2 { font-size: 1.5rem; }
.summary-strip { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.5rem; padding-block: 1.5rem; margin-bottom: 1rem; border-bottom: 1px solid var(--rl-divider); }
.stat-chip span { display: block; color: var(--rl-muted); font-size: .875rem; }
.stat-chip strong { display: block; font: 800 clamp(1.25rem, 2vw, 1.75rem)/1.5 var(--rl-font-display); overflow-wrap: anywhere; }
.mini-list { display: grid; gap: .5rem; margin-top: .75rem; }
.mini-row { display: flex; align-items: baseline; flex-wrap: wrap; justify-content: space-between; gap: .25rem 1rem; font-size: .875rem; }
.rate-card { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 1rem; padding-block: 1.5rem; }
.rate-card span { display: block; color: var(--rl-muted); font-size: .875rem; }
.rate-card b { display: block; font-size: 1.125rem; }
.bars { position: relative; height: 11rem; border-bottom: 1px solid var(--rl-boundary); margin-top: 2rem; padding: 0 0 0 4rem; }
.bar-ticks { position: absolute; inset: 0; pointer-events: none; }
.bar-ticks span { position: absolute; inset-inline: 0; display: flex; align-items: center; gap: .5rem; transform: translateY(50%); }
.bar-ticks b { order: -1; width: 3.5rem; text-align: right; color: var(--rl-muted); font-size: .875rem; }
.bar-ticks i { flex: 1; border-top: 1px solid var(--rl-divider); }
.bar-columns { display: flex; align-items: end; gap: .5rem; height: 100%; position: relative; }
.bar { flex: 1; min-width: 0; background: var(--rl-action); }
.bar.pity { background: var(--rl-warning); }
.bar:focus-visible { outline-offset: 2px; }
.timeline { margin-top: 1rem; }
.empty-history { padding-block: 1rem; color: var(--rl-muted); }
.history-card { border-top: 1px solid var(--rl-divider); padding-block: .5rem; }
.history-card summary { padding-block: .75rem; }
.history-card summary b { font-size: 1rem; }
.history-card summary span { display: block; margin-top: .375rem; color: var(--rl-muted); }
.history-detail { padding: .5rem 0 1rem; font-size: .875rem; }
.history-detail p { color: var(--rl-muted); }
.history-detail dl { display: grid; gap: .5rem 1rem; grid-template-columns: repeat(2, minmax(0, 1fr)); margin: .75rem 0 0; }
.history-detail dt { font-weight: 800; }
.history-detail dd { margin: .25rem 0 0; }
.btn { min-height: 48px; padding: .625rem 1rem; border: 1px solid var(--rl-boundary); border-radius: var(--rl-radius-small); color: var(--rl-ink); background: var(--rl-foam); font-weight: 800; font-size: .875rem; }
.btn:hover:not(:disabled) { border-color: var(--rl-ink); }
.btn.primary { color: var(--rl-on-selected); background: var(--rl-selected); border-color: var(--rl-selected); }
.btn.blue { color: var(--rl-on-action); background: var(--rl-action); border-color: var(--rl-action); }
.btn.stop { color: var(--rl-on-action); background: var(--rl-danger); border-color: var(--rl-danger); }
.danger { color: var(--rl-danger); }
.reset-button { display: block; margin-top: 1.5rem; }
.dock { position: fixed; inset: auto 0 0; z-index: 10; padding: 1rem max(16px, calc((100% - 1280px) / 2)); border-top: 1px solid var(--rl-boundary); color: var(--rl-foam); background: var(--rl-abyss); }
.dock-inner { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1.5rem; align-items: center; }
.dock-context { min-width: 0; min-height: 3.225rem; font-size: .875rem; }
#dockEvent { font-weight: 800; }
#dockGoal { margin-top: .25rem; }
.actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem; }
.dock :focus-visible { outline-color: var(--rl-sun); outline-offset: 4px; }
.confirm-backdrop { max-width: min(30rem, calc(100% - 2rem)); max-height: calc(100dvh - 2rem); padding: 1.5rem; border: 1px solid var(--rl-boundary); border-radius: var(--rl-radius); color: var(--rl-ink); background: var(--rl-paper); }
.confirm-backdrop::backdrop { background: #032d4aaa; }
.confirm-card h3 { margin-bottom: .75rem; font-size: 1.375rem; }
.confirm-card p { line-height: 1.8; }
.confirm-actions { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: 1.5rem; }
.confirm-actions .warn { color: var(--rl-on-action); background: var(--rl-danger); border-color: var(--rl-danger); }
body[data-auto-mode=none] .cards-grid { animation: deal-in 160ms var(--rl-ease); }
@keyframes deal-in { from { opacity: .8; transform: translateY(3px); } to { opacity: 1; transform: none; } }
@media (max-width: 1000px) {
  .layout { grid-template-columns: 1fr; }
  .result-stage { padding: 1.5rem; }
  .selection-panel { max-width: none; }
  .dock-inner { grid-template-columns: 1fr; gap: .75rem; }
}
@media (max-width: 600px) {
  .panel, .result-stage, .history-panel { padding: 1.25rem; }
  .stage-head { gap: .75rem; }
  .stage-title h2 { font-size: 1.375rem; }
  .cards-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }
  .gacha-card { min-height: 7rem; }
  .targets, .history-detail dl { grid-template-columns: 1fr; }
  .summary-strip { grid-template-columns: 1fr; gap: 1rem; }
  .rate-card { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dock { padding-block: .75rem max(.75rem, env(safe-area-inset-bottom)); }
  .app { padding-bottom: 16rem; }
  .actions .btn { padding: .5rem .375rem; min-height: 52px; }
  .dock-context { font-size: .875rem; }
}
@media (prefers-reduced-motion: reduce) { body[data-auto-mode=none] .cards-grid { animation: none; } }

body { --rl-ink: #40364d; --rl-muted: #6b5c73; --rl-action: #785271; --rl-paper: #faf4f5; --rl-foam: #fff9fa; --rl-surface: #eee3ef; --rl-selected: #e5b9c6; --rl-on-selected: #4d304b; --rl-divider: #dacbdc; }
.selection-panel { background: #eee3ef; }
.result-stage { background: #faf4f5; box-shadow: 0 18px 48px #09172d30; }
.ready { background: radial-gradient(ellipse at 70% 0%, #805878, transparent 65%), #3c3858; }
.gacha-card.ssr { background: #f8e8d8; border-color: #ab7758; }
.gacha-card.sr { background: #ece4f2; }

@media(min-width:1600px) and (min-height:900px) {
  .app { width: min(1800px,calc(100% - 48px)); max-width: 1800px; padding-top: 16px; padding-bottom: 110px; }
  .topbar { margin: 0; padding: 0 0 14px; }
  .topbar h1 { font-size: 28px; }
  .layout { grid-template-columns: 280px minmax(0,1fr) 470px; gap: 20px; }
  .panel, .result-stage, .history-panel { padding: 20px; }
  .result-stage { min-height: 0; }
  .stage-title h2 { font-size: 1.5rem; }
  .ready { min-height: 12rem; padding: 20px; }
  .gacha-card { min-height: 7rem; padding: 8px; }
  .cards-grid { gap: 8px; margin-top: 12px; }
  .pull-summary { margin-top: 12px; padding-block: 10px; }
  .current-cost { margin-top: 12px; }
  .section-title { margin-top: 14px; }
  .targets { gap: 4px 16px; }
  .complete-box, .pity-alert { margin-top: 10px; padding: 10px; }
  .history-panel { grid-column: auto; height: calc(100dvh - 280px); display: flex; flex-direction: column; }
  .history-panel > h2 { font-size: 1.25rem; }
  #statsView { display: flex; flex-direction: column; min-height: 0; flex: 1; }
  #statsView > :not(.timeline) { flex-shrink: 0; }
  .summary-strip { gap: 10px; padding-block: 12px; margin-bottom: 10px; }
  .stat-chip strong { font-size: 1.2rem; }
  .mini-list { grid-template-columns: repeat(3,minmax(0,1fr)); gap: 12px; }
  .rate-card { grid-template-columns: repeat(3,minmax(0,1fr)); gap: 8px; padding-block: 12px; }
  .bars { height: 100px; margin-top: 20px; }
  .timeline { min-height: 64px; flex: 1; overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; margin-top: 8px; }
  .history-panel .reset-button { margin-top: 10px; flex-shrink: 0; }
  .dock { padding-inline: max(24px,calc((100% - 1760px)/2)); }
}


@media(min-width:1600px) and (min-height:900px) {
  .period-card { display: flex; gap: 16px; align-items: baseline; margin-top: 10px; padding-top: 8px; }
  .gacha-card { min-height: 6rem; }
  .pull-summary { gap: 12px; padding-block: 8px; }
  .pull-chip strong { font-size: 1.25rem; }
  .current-cost { margin-top: 8px; }
  .current-cost strong { font-size: 1.5rem; }
  .current-cost span { flex-basis: auto; }
  #statsView { gap: 0; }
  .rate-card { row-gap: 6px; }
  .rate-card b { line-height: 1.4; }
  .empty-history { padding-block: 4px; }
}


@media(min-width:1600px) and (min-height:900px) {
  .complete-stage { display: grid; grid-template-columns: minmax(0,1fr) 230px; gap: 0 16px; }
  .complete-stage > .cards-grid, .complete-stage > .pull-summary { grid-column: 1; }
  .complete-stage > .complete-box { grid-column: 2; grid-row: 1 / 3; align-self: start; }
  .complete-box .mini-list { grid-template-columns: 1fr; }
  #statsView .panel-title { margin-bottom: 4px; }
  #statsView .mini-list { margin-top: 8px; }
  #statsView .rate-card { padding-block: 8px; gap: 4px 8px; }
  #statsView .section-title { margin-block: 8px 6px; }
  #statsView .bars { height: 80px; margin-top: 16px; }
}

/* Reserve space for ten results, exchange notices and goal details before drawing. */
.result-stage { height: 64rem; overflow-y: auto; scrollbar-gutter: stable; }
@media (max-width: 600px) { .result-stage { height: 100rem; } }
@media (min-width: 1600px) and (min-height: 900px) { .result-stage { height: calc(100dvh - 280px); } }
