@import url('./RewardReveal.css');

/* Native symbols, stepped frames and hard shadows: one small game panel. */
#game-root .card-ui-hud, #game-root .card-ui-dialog, #game-root .card-ui-run-mode, #game-root .card-ui-toast, #game-root .card-ui-flight-layer { box-sizing: border-box; }
#game-root .card-ui-hud [hidden], #game-root .card-ui-dialog [hidden], #game-root .card-ui-run-mode[hidden], #game-root .card-ui-hud[hidden], #game-root .card-ui-toast[hidden] { display: none !important; }
#game-root .card-ui-sr { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; border: 0 !important; overflow: hidden !important; clip-path: inset(50%); white-space: nowrap; }
#game-root .card-ui-icon { width: 40px; height: 40px; flex: 0 0 auto; image-rendering: pixelated; display: block; }
#game-root .card-ui-hud { position: absolute; z-index: 1100; left: max(20px, env(safe-area-inset-left)); bottom: 20px; display: flex; gap: 8px; align-items: stretch; pointer-events: auto; }
#game-root .card-ui-hud-slots { display: flex; gap: 4px; padding: 0; border: 0; background: none; cursor: pointer; touch-action: manipulation; }
#game-root:not(.touch-layout):has(.render-settings) .card-ui-hud { bottom: 64px; }
#game-root .card-ui-slot { box-sizing: border-box; font-family: var(--font); position: relative; width: 44px; min-height: 48px; display: flex; align-items: center; justify-content: center; padding: 2px; background: #0b2035; border: 2px solid #567f90; color: #e3f5ed; cursor: pointer; box-shadow: inset 0 -3px #06152b; touch-action: manipulation; }
#game-root .card-ui-slot.card-ui-empty { border-color: #476977; }
#game-root .card-ui-slot.card-ui-locked { border-color: #314c65; color: #93b6bb; }
#game-root .card-ui-slot[data-quality] { border-color: var(--quality-color); }
#game-root .card-ui-slot .card-ui-quality-marks { position: absolute; left: 3px; bottom: 3px; width: 24px; height: 5px; }
#game-root .card-ui-locked .card-ui-icon { opacity: .55; }
#game-root .card-ui-slot-rank { position: absolute; right: 3px; bottom: 2px; font-size: 8px; line-height: 1; color: #d5e8df; }
#game-root .card-ui-deck-button { display: flex; align-items: center; justify-content: center; gap: 5px; min-height: 48px; padding: 7px 10px; font: 9px var(--font); color: #b8fff6; border: 2px solid #497881; background: #0b2035; cursor: pointer; touch-action: manipulation; box-shadow: inset 0 -3px #06152b; }
#game-root .card-ui-deck-button .card-ui-icon { width: 20px; height: 20px; }
#game-root .card-ui-deck-button.card-ui-combo-active { color: #ffdc8a; border-color: #b49154; }
#game-root .card-ui-plain .card-ui-hud-slots { display: none; }
#game-root.touch-layout .card-ui-hud, #game-root.touch-layout:has(.render-settings) .card-ui-hud { bottom: calc(var(--touch-dock-height) + var(--touch-safe-bottom) + 12px); left: calc(24px + var(--touch-safe-left)); gap: 0; }
#game-root.touch-layout .card-ui-hud-slots { gap: 0; }
#game-root.touch-layout .card-ui-hud-slots::before { content: 'SKILLS'; position: absolute; left: 0; top: -13px; color: #b4d9d9; font: 7px var(--font); }
#game-root.touch-layout .card-ui-hud-slots .card-ui-slot { width: 32px; }
#game-root.touch-layout .card-ui-hud-slots .card-ui-icon { width: 20px; height: 20px; }
#game-root.touch-layout .card-ui-hud-slots .card-ui-quality-marks { top: 4px; bottom: auto; }
#game-root.touch-layout .card-ui-deck-button { display: none; }
#game-root.touch-layout .card-ui-plain .card-ui-deck-button { display: flex; }
#game-root.touch-layout .card-ui-hud .card-ui-deck-button { width: 44px; padding: 5px; }
#game-root.touch-layout .card-ui-deck-button > span { display: none; }
#game-root .card-ui-run-mode { padding: 8px 0; margin: 0 auto 14px; max-width: 340px; }
#game-root:has(.card-ui-run-mode:not([hidden])) .render-settings { display: none; }
#game-root .card-ui-mode-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
#game-root .card-ui-mode-choices button { display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; font: 10px var(--font); color: #9bb6be; border: 2px solid #31556b; padding: 5px 8px; background: #0c2035; cursor: pointer; touch-action: manipulation; box-shadow: inset 0 -3px #06152b; }
#game-root .card-ui-mode-choices .card-ui-icon { width: 20px; height: 20px; }
#game-root .card-ui-mode-choices button[aria-pressed="true"] { color: #d7f4c4; background: #21443f; border-color: #8db58a; }
#game-root .card-ui-dialog { margin: auto; width: min(620px, calc(100vw - 48px - env(safe-area-inset-left) - env(safe-area-inset-right))); max-height: calc(100dvh - 48px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); padding: 20px; color: #e8f0e9; border: 0; background: #10243c; overflow: auto; overscroll-behavior: contain; box-shadow: 0 -4px 0 #618691, 0 4px 0 #25415d, -4px 0 0 #618691, 4px 0 0 #25415d, 0 -8px 0 #061228, 0 8px 0 #061228, -8px 0 0 #061228, 8px 0 0 #061228, 8px 12px 0 #020b19; }
#game-root .card-ui-dialog::backdrop { background: #030c1bbe; }
#game-root .card-ui-dialog * { box-sizing: border-box; }
#game-root .card-ui-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; min-height: 44px; }
#game-root .card-ui-heading > div:first-child { display: flex; align-items: center; gap: 10px; }
#game-root .card-ui-heading .card-ui-icon { width: 40px; height: 40px; }
#game-root .card-ui-heading h2 { font: 18px/1.3 var(--font); margin: 0; color: #eff5d9; text-shadow: 2px 2px #031225; }
#game-root .card-ui-close, #game-root .card-ui-primary, #game-root .card-ui-secondary, #game-root .card-ui-info-button { display: flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; padding: 4px; border: 2px solid #517787; background: #19364c; color: #c9e3df; cursor: pointer; touch-action: manipulation; box-shadow: inset 0 -3px #06172c, 2px 2px #061225; }
#game-root .card-ui-close .card-ui-icon, #game-root .card-ui-primary .card-ui-icon, #game-root .card-ui-secondary .card-ui-icon, #game-root .card-ui-info-button .card-ui-icon { width: 20px; height: 20px; }
#game-root .card-ui-primary { background: #2f5842; border-color: #b9d489; }
#game-root .card-ui-dialog button:disabled { opacity: .45; cursor: default; }
#game-root .card-ui-dialog button:focus-visible, #game-root .card-ui-hud button:focus-visible, #game-root .card-ui-run-mode button:focus-visible { outline: 2px solid #fff1a8; outline-offset: 3px; }
#game-root .card-ui-deck-slots { display: grid; grid-template-columns: repeat(3, 72px); justify-content: center; gap: 12px; margin-bottom: 16px; }
#game-root .card-ui-deck-slots .card-ui-slot { width: 72px; min-height: 72px; padding: 5px; box-shadow: inset 0 3px #091b30, inset 0 -3px #294659, 3px 3px #061225; }
#game-root .card-ui-deck-slots .card-ui-slot-rank { bottom: 4px; right: 5px; font-size: 9px; }
#game-root .card-ui-deck-slots[data-selecting="true"] .card-ui-slot:not(.card-ui-locked), #game-root .card-ui-slot.card-ui-drop-target { border-color: #e1ce84; background: #25423e; }
#game-root .card-ui-deck-slots .card-ui-slot[data-selected-slot="true"] { border-color: #f2dc9a; background: #294a52; box-shadow: inset 0 3px #c2a969, inset 0 -3px #102737, 3px 3px #061225; }
#game-root .card-ui-slot-brackets { position: absolute; inset: -6px; pointer-events: none; }
#game-root .card-ui-slot-brackets > span { position: absolute; width: 12px; height: 12px; border-left: 3px solid #f8e1a5; border-top: 3px solid #f8e1a5; }
#game-root .card-ui-slot-brackets > [data-corner="tl"] { top: 0; left: 0; }
#game-root .card-ui-slot-brackets > [data-corner="tr"] { top: 0; right: 0; transform: scaleX(-1); }
#game-root .card-ui-slot-brackets > [data-corner="bl"] { bottom: 0; left: 0; transform: scaleY(-1); }
#game-root .card-ui-slot-brackets > [data-corner="br"] { bottom: 0; right: 0; transform: scale(-1); }
#game-root .card-ui-deck-slots .card-ui-slot-cursor { position: absolute; top: 2px; left: calc(50% - 5px); width: 10px; height: 10px; transform: rotate(90deg); }
#game-root .card-ui-slot-hint { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 24px; margin: 0 0 12px; color: #f2dda2; font: 8px/1.4 var(--font); }
#game-root .card-ui-slot-hint .card-ui-icon { width: 20px; height: 20px; transform: rotate(90deg); }
#game-root .card-ui-collection[data-selected-slot]:not([data-selected-slot=""]) { border-top: 2px solid #c4af75; padding-top: 8px; }
#game-root .card-ui-reaction { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; margin: -3px 0 14px; }
#game-root .card-ui-reaction-group { display: inline-flex; align-items: center; gap: 3px; }
#game-root .card-ui-reaction .card-ui-icon { width: 20px; height: 20px; }
#game-root .card-ui-selection { display: flex; justify-content: flex-end; margin: -8px 0 10px; }
#game-root .card-ui-selection:empty { display: none; }
#game-root .card-ui-collection, #game-root .card-ui-keep-cards, #game-root .card-ui-offers, #game-root .card-ui-replacement-targets { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
#game-root .card-ui-offers[data-count="1"] > .card-ui-card-frame { grid-column: 1 / -1; width: calc((100% - 24px) / 3); min-width: 140px; max-width: 220px; justify-self: center; }
#game-root .card-ui-draft-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-top: 16px; }
#game-root .card-ui-draft-actions button { padding: 8px 12px; font: 9px/1.4 var(--font); }
#game-root .card-ui-victory-enter .card-ui-draft-actions { animation: reward-victory-controls var(--reward-controls-ms, 160ms) ease-out var(--reward-controls-delay, 620ms) backwards; }
@media (prefers-reduced-motion: reduce) { #game-root .card-ui-victory-enter .card-ui-draft-actions { animation: none; } }
#game-root .card-ui-card-frame { position: relative; min-width: 0; }
#game-root .card-ui-card { --card-color: #c9dd9a; position: relative; width: 100%; min-width: 0; min-height: 0; aspect-ratio: 5 / 7; padding: 18px 6px 14px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; border: 2px solid #52768a; color: #eaf0d9; background: #1b3750; box-shadow: inset 0 3px #3e5c72, inset 0 -5px #0a1e35, 3px 3px #040f24; cursor: pointer; touch-action: manipulation; text-align: center; transform-origin: center; }
#game-root .card-ui-card::before { content: ''; position: absolute; left: 4px; right: 4px; top: 4px; bottom: 7px; border: 1px solid #355570; pointer-events: none; }
#game-root .card-ui-card:hover { border-color: var(--card-color); }
#game-root .card-ui-card[data-quality] { border-color: var(--quality-color); }
#game-root .card-ui-card[data-quality]::before { border-top-color: var(--quality-color); }
#game-root .card-ui-card[data-quality="fine"]::before { border-left-color: var(--quality-color); border-right-color: var(--quality-color); }
#game-root .card-ui-card[data-quality="rare"]::before { border-color: var(--quality-color); }
#game-root .card-ui-card[data-quality="prism"]::before { border: 2px solid var(--quality-color); }
#game-root .card-ui-border-art { position: absolute; inset: -2px; pointer-events: none; z-index: 1; }
#game-root .card-ui-border-corner { position: absolute; width: 16px; height: 16px; image-rendering: pixelated; }
#game-root .card-ui-border-corner[data-stroke="3"] { display: none; }
#game-root .card-ui-border-corner[data-corner="tl"] { top: 0; left: 0; }
#game-root .card-ui-border-corner[data-corner="tr"] { top: 0; right: 0; transform: scaleX(-1); }
#game-root .card-ui-border-corner[data-corner="bl"] { bottom: 0; left: 0; transform: scaleY(-1); }
#game-root .card-ui-border-corner[data-corner="br"] { bottom: 0; right: 0; transform: scale(-1); }
#game-root .card-ui-rank-tabs { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
#game-root .card-ui-rank-tabs canvas { position: absolute; width: 12px; height: 10px; top: 25px; image-rendering: pixelated; }
#game-root .card-ui-rank-tabs [data-side="left"] { left: -4px; }
#game-root .card-ui-rank-tabs [data-side="right"] { right: -4px; transform: scaleX(-1); }
#game-root .card-ui-quality-row { position: relative; min-height: 24px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; color: var(--quality-color); }
#game-root .card-ui-face-quality { font: 7px/1.3 var(--font); white-space: nowrap; }
#game-root .card-ui-quality-marks { display: block; width: 48px; height: 10px; image-rendering: pixelated; flex: 0 0 auto; }
#game-root .card-ui-quality-row .card-ui-gain-mark { position: absolute; left: calc(50% + 28px); top: -3px; width: 20px; height: 20px; }
#game-root .card-ui-art { position: relative; display: grid; place-items: center; width: 100%; max-width: 100px; height: 62px; background: #10253e; border-top: 2px solid #0a1c31; border-bottom: 2px solid #33536a; }
#game-root .card-ui-symbol { width: 60px; height: 60px; }
#game-root .card-ui-card-title { position: relative; font: 11px/1.4 var(--font); color: #eaf1dc; min-height: 30px; display: flex; align-items: center; justify-content: center; }
#game-root .card-ui-face-stats { display: flex; flex-direction: column; align-self: stretch; gap: 4px; min-height: 44px; justify-content: center; }
#game-root .card-ui-face-stat { display: flex; align-items: center; justify-content: center; gap: 5px; font: 10px/1.4 var(--font); color: #f1e6b4; white-space: nowrap; }
#game-root .card-ui-face-stat .card-ui-icon { width: 20px; height: 20px; }
#game-root .card-ui-face-value { font-variant-numeric: tabular-nums; }
#game-root .card-ui-rank-pips { display: flex; gap: 3px; position: absolute; top: 6px; left: 50%; transform: translateX(-50%); }
#game-root .card-ui-rank-pips > span { width: 7px; height: 4px; border: 1px solid #537080; background: #11263d; }
#game-root .card-ui-rank-pips > span.filled { background: var(--card-color); border-color: var(--card-color); }
#game-root .card-ui-card[aria-pressed="true"] { border-color: var(--quality-color); background: #294852; }
#game-root .card-ui-card:is([aria-pressed="true"], :hover, :focus-visible) { box-shadow: inset 0 3px #5b7780, inset 0 -5px #132e3a, 3px 3px #040f24; }
#game-root .card-ui-card:is([aria-pressed="true"], :hover, :focus-visible) > .card-ui-border-art::before { content: ''; position: absolute; inset: 0; background: linear-gradient(var(--quality-color), var(--quality-color)) 16px 0 / calc(100% - 32px) 3px no-repeat, linear-gradient(var(--quality-color), var(--quality-color)) 16px 100% / calc(100% - 32px) 3px no-repeat, linear-gradient(var(--quality-color), var(--quality-color)) 0 16px / 3px calc(100% - 32px) no-repeat, linear-gradient(var(--quality-color), var(--quality-color)) 100% 16px / 3px calc(100% - 32px) no-repeat; }
#game-root .card-ui-card:is([aria-pressed="true"], :hover, :focus-visible) > .card-ui-border-art > [data-stroke="2"] { display: none; }
#game-root .card-ui-card:is([aria-pressed="true"], :hover, :focus-visible) > .card-ui-border-art > [data-stroke="3"] { display: block; }
#game-root .card-ui-dialog .card-ui-card:focus-visible { outline: none; }
#game-root .card-ui-card-frame:has(> .card-ui-card[aria-pressed="true"]) { position: relative; z-index: 1; transform: translateY(-4px); animation: none; }
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
    #game-root .card-ui-card-frame:has(> .card-ui-info-button:hover:not(:disabled)) { z-index: 2; transform: perspective(700px) scale(1.04) rotateY(9deg); }
}
#game-root .card-ui-card-frame:has(> .card-ui-info-button:is(:hover, :focus-visible)) > .card-ui-card { border-color: var(--quality-color); }
#game-root .card-ui-card[aria-pressed="true"] .card-ui-art { background: #1a3c4b; border-top-color: #537685; border-bottom-color: var(--card-color); }
#game-root .card-ui-selection-sparks { display: none; position: absolute; inset: 0; pointer-events: none; }
#game-root .card-ui-card[aria-pressed="true"] .card-ui-selection-sparks { display: block; }
#game-root .card-ui-selection-spark { position: absolute; width: 6px; height: 6px; opacity: 0; animation: card-ui-selection-twinkle 4800ms steps(1, end) infinite; }
#game-root .card-ui-selection-spark::before, #game-root .card-ui-selection-spark::after { content: ''; position: absolute; background: var(--card-color); }
#game-root .card-ui-selection-spark::before { left: 2px; top: 0; width: 2px; height: 6px; }
#game-root .card-ui-selection-spark::after { left: 0; top: 2px; width: 6px; height: 2px; box-shadow: inset 2px 0 var(--card-color), inset -2px 0 var(--card-color); background: #fff4c8; }
#game-root .card-ui-selection-spark:nth-child(1) { top: -2px; left: -4px; }
#game-root .card-ui-selection-spark:nth-child(2) { bottom: -2px; right: -4px; animation-delay: -1200ms; }
#game-root .card-ui-selection-spark:nth-child(3) { bottom: -2px; left: -4px; animation-delay: -2400ms; }
#game-root .card-ui-selection-spark:nth-child(4) { top: -2px; right: -4px; animation-delay: -3600ms; }
#game-root .card-ui-collection:has(.card-ui-card[aria-pressed="true"]) > .card-ui-card-frame:not(:has(.card-ui-card[aria-pressed="true"])):not(:hover):not(:focus-within) .card-ui-card { background: #10273b; box-shadow: inset 0 3px #284457, inset 0 -5px #081a2b, 3px 3px #040f24; }
#game-root .card-ui-collection:has(.card-ui-card[aria-pressed="true"]) > .card-ui-card-frame:not(:has(.card-ui-card[aria-pressed="true"])):not(:hover):not(:focus-within) .card-ui-art { background: #091d30; border-top-color: #07182a; border-bottom-color: #29475a; }
#game-root .card-ui-collection:has(.card-ui-card[aria-pressed="true"]) > .card-ui-card-frame:not(:has(.card-ui-card[aria-pressed="true"])):not(:hover):not(:focus-within) .card-ui-symbol { opacity: .55; }
#game-root .card-ui-collection:has(.card-ui-card[aria-pressed="true"]) > .card-ui-card-frame:not(:has(.card-ui-card[aria-pressed="true"])):not(:hover):not(:focus-within) .card-ui-card-title { color: #ced9cb; }
#game-root .card-ui-collection:has(.card-ui-card[aria-pressed="true"]) > .card-ui-card-frame:not(:has(.card-ui-card[aria-pressed="true"])):not(:hover):not(:focus-within) .card-ui-face-stat { color: #c4c8ac; }
#game-root .card-ui-dialog[data-kind="keep"] .card-ui-keep-cards:has(.card-ui-card[aria-pressed="true"]) > .card-ui-card-frame:not(:has(.card-ui-card[aria-pressed="true"])) { opacity: .5; }
#game-root .card-ui-card.card-ui-banked::after { content: ''; position: absolute; left: 6px; bottom: 8px; width: 4px; height: 4px; background: #a2c69c; }
/* The corner fold reaches 8px past the card edge so near misses still open details. */
#game-root .card-ui-info-button { --fold-inset: 11px; position: absolute; z-index: 3; bottom: -8px; right: -8px; width: 60px; height: 60px; margin: 0; padding: 0; border: 0; background: none; box-shadow: none; }
#game-root .card-ui-info-button::before { content: ''; position: absolute; bottom: var(--fold-inset); right: var(--fold-inset); width: 24px; height: 24px; background: var(--quality-color, #b8e5e0); box-shadow: inset -2px -2px #385b70; clip-path: polygon(100% 0, 100% 100%, 0 100%, 0 20px, 4px 20px, 4px 16px, 8px 16px, 8px 12px, 12px 12px, 12px 8px, 16px 8px, 16px 4px, 20px 4px, 20px 0); transform-origin: 100% 100%; transition: transform 160ms cubic-bezier(.2,.75,.2,1); }
#game-root .card-ui-info-button::after { content: ''; position: absolute; bottom: var(--fold-inset); right: calc(var(--fold-inset) + 20px); width: 4px; height: 4px; background: #dceee6; box-shadow: 4px -4px #dceee6, 8px -8px #dceee6, 12px -12px #dceee6, 16px -16px #dceee6, 20px -20px #dceee6; transform-origin: 24px 4px; transition: transform 160ms cubic-bezier(.2,.75,.2,1); }
#game-root .card-ui-info-button:is(:hover, :focus-visible)::before { background: #eff5d9; }
/* Tease the inspect flip: the fold peels open and the card starts to lift and turn. */
#game-root .card-ui-info-button:is(:hover, :focus-visible):not(:disabled)::before, #game-root .card-ui-info-button:is(:hover, :focus-visible):not(:disabled)::after { transform: scale(1.5); }
#game-root .card-ui-card-frame { transition: transform 180ms cubic-bezier(.2,.75,.2,1); }
#game-root .card-ui-dialog .card-ui-info-button:focus-visible { outline: none; }
#game-root .card-ui-equipped, #game-root .card-ui-destination { display: flex; align-items: center; position: absolute; bottom: 5px; right: 5px; font: 8px var(--font); color: #cad9ba; }
#game-root .card-ui-card-frame > .card-ui-card:has(.card-ui-equipped, .card-ui-destination) { padding-bottom: 28px; }
#game-root .card-ui-card-frame > .card-ui-card :is(.card-ui-equipped, .card-ui-destination) { right: 48px; }
#game-root .card-ui-equipped .card-ui-icon, #game-root .card-ui-destination .card-ui-icon { width: 20px; height: 20px; }
#game-root .card-ui-collection-empty { grid-column: 1 / -1; min-height: 150px; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 12px; background: #0c2036; box-shadow: inset 0 3px #07172b, inset 0 -3px #274059; }
#game-root .card-ui-empty-symbol { width: 80px; height: 80px; opacity: .65; }
#game-root .card-ui-collection-empty > span { display: flex; gap: 12px; }
#game-root .card-ui-collection-empty > span .card-ui-icon { width: 20px; height: 20px; }
#game-root .card-ui-info-panel { display: flex; align-items: center; gap: 10px; margin-top: 14px; padding: 10px; background: #0b2035; border: 2px solid #3f6579; box-shadow: 2px 2px #061225; }
#game-root .card-ui-info-panel strong { font: 10px/1.4 var(--font); color: #e8f2d5; }
#game-root .card-ui-info-content { min-width: 0; flex: 1; }
#game-root .card-ui-info-panel p { margin: 5px 0 0; font: 12px/1.45 system-ui, sans-serif; color: #b6d0d3; }
#game-root .card-ui-quality-badge { display: inline-flex; align-items: center; gap: 6px; color: var(--quality-color); font: 8px/1.5 var(--font); }
#game-root .card-ui-info-content > .card-ui-quality-badge { display: flex; margin-top: 8px; }
#game-root .card-ui-quality-badge .card-ui-quality-marks { width: 24px; height: 5px; }
#game-root .card-ui-roll-label { color: #a1b4c2; margin-right: 2px; }
#game-root .card-ui-quality-comparison { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; margin-top: 10px; }
#game-root .card-ui-quality-comparison .card-ui-icon { width: 20px; height: 20px; }
#game-root .card-ui-best-retained { display: block; color: #a9c7c4; font: 7px/1.5 var(--font); margin-top: 6px; }
#game-root .card-ui-info-stat { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; color: #dfd5a1; font: 8px/1.5 var(--font); }
#game-root .card-ui-stat-label { flex: 1; min-width: 72px; color: #a1b4c2; }
#game-root .card-ui-stat-previous { color: #90a9b3; }
#game-root .card-ui-info-stat .card-ui-icon { width: 20px; height: 20px; }
#game-root .card-ui-info-stat .card-ui-stat-value { color: #dfd5a1; font: inherit; }
#game-root .card-ui-stat-gain .card-ui-stat-value { color: #c6e7a6; }
#game-root .card-ui-info-panel .card-ui-keep-reset { padding-top: 7px; border-top: 1px solid #375268; color: #cadbb6; }
#game-root .card-ui-swap { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; padding: 10px; margin-bottom: 14px; background: #263f3b; border: 2px solid #99b075; box-shadow: 3px 3px #07152a; }
#game-root .card-ui-swap-symbols { display: flex; align-items: center; flex-wrap: wrap; gap: 3px; }
#game-root .card-ui-swap-symbols > .card-ui-icon { width: 20px; height: 20px; }
#game-root .card-ui-slot-number { font: 10px var(--font); }
#game-root .card-ui-swap-storm { display: flex; align-items: center; gap: 4px; color: #e5c985; font: 8px var(--font); }
#game-root .card-ui-swap-storm .card-ui-icon { width: 20px; height: 20px; }
#game-root .card-ui-swap-actions { display: flex; gap: 6px; margin-left: auto; }
#game-root .card-ui-countdown { display: flex; align-items: center; gap: 4px; }
#game-root .card-ui-countdown .card-ui-icon { width: 20px; height: 20px; }
#game-root .card-ui-countdown strong { font: 26px/1 var(--font); color: #f4d18b; }
#game-root .card-ui-countdown-track { height: 5px; background: #0a1b30; margin: -5px 0 16px; overflow: hidden; }
#game-root .card-ui-auto-pick { border-color: #ceb96f; }
#game-root .card-ui-auto-label { position: absolute; left: 5px; top: 18px; }
#game-root .card-ui-auto-label .card-ui-icon { width: 20px; height: 20px; }
#game-root .card-ui-combo-hint { position: absolute; bottom: 6px; left: 5px; }
#game-root .card-ui-combo-hint .card-ui-icon { width: 20px; height: 20px; }
#game-root .card-ui-keep-finish { margin-top: 16px; width: 100%; gap: 8px; font: 11px var(--font); }
#game-root .card-ui-replacement-incoming { display: flex; align-items: center; gap: 12px; padding: 10px; border: 2px solid var(--quality-color); background: #0b2035; box-shadow: 3px 3px #061225; }
#game-root .card-ui-replacement-incoming > div { flex: 1; min-width: 0; }
#game-root .card-ui-replacement-incoming strong { display: block; font: 11px/1.5 var(--font); }
#game-root .card-ui-replacement-incoming .card-ui-quality-badge { display: flex; margin-top: 7px; }
#game-root .card-ui-replacement-incoming .card-ui-face-stats { align-self: center; flex: 0 0 auto; }
#game-root .card-ui-replacement-arrow { width: 20px; height: 20px; margin: 8px auto; transform: rotate(90deg); }
#game-root .card-ui-replacement-actions { display: flex; justify-content: center; margin-top: 14px; }
#game-root [data-replacement-cancel] { font: 10px var(--font); gap: 8px; padding-inline: 12px; }
#game-root .card-ui-toast { position: absolute; z-index: 1200; left: 50%; transform: translateX(-50%); bottom: 82px; max-width: calc(100% - 40px); padding: 8px 12px; background: #0e273e; color: #deebc9; border: 2px solid #719987; box-shadow: 3px 3px #061225; font: 10px/1.5 var(--font); text-align: center; pointer-events: none; }
#game-root.touch-layout .card-ui-toast { bottom: calc(var(--touch-dock-height) + var(--touch-safe-bottom) + 140px); }
#game-root .card-ui-flight-layer { pointer-events: none; position: fixed; inset: 0; z-index: 9990; }
#game-root .card-ui-flying-card { position: fixed; width: 50px; height: 64px; display: grid; place-items: center; background: #1b3750; border: 2px solid var(--quality-color, #d5d99b); box-shadow: inset 0 -5px #0a1e35, 3px 3px #07152a; }
#game-root .card-ui-flying-card .card-ui-icon { width: 40px; height: 40px; }
#game-root .card-ui-flying-card .card-ui-quality-marks { width: 24px; height: 5px; }
#game-root .card-ui-deal { animation: card-ui-deal 160ms steps(4, end) both; animation-delay: var(--deal-delay, 0ms); }
#game-root .card-ui-reward-flash { animation: card-ui-dock 240ms steps(3, end); }
@keyframes card-ui-deal { from { transform: translateY(8px) scaleX(.15); } to { transform: translateY(0) scaleX(1); } }
@keyframes card-ui-dock { 0%, 65% { outline: 3px solid #f3e5a5; background: #456251; } 100% { outline: 0 solid transparent; } }
@keyframes card-ui-selection-twinkle { 0%, 63%, 89%, 100% { opacity: 0; } 70%, 82% { opacity: .5; } 76% { opacity: 1; } }
@media (max-width: 520px) {
    #game-root .card-ui-mode-choices button { font-size: 9px; padding-inline: 5px; gap: 4px; }
    #game-root .card-ui-dialog { width: calc(100vw - 40px - env(safe-area-inset-left) - env(safe-area-inset-right)); padding: 14px; max-height: calc(100dvh - 40px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); }
    #game-root .card-ui-heading { margin-bottom: 12px; gap: 8px; }
    #game-root .card-ui-heading > div:first-child { gap: 5px; }
    #game-root .card-ui-heading h2 { font-size: 14px; }
    #game-root .card-ui-heading .card-ui-icon { width: 20px; height: 20px; }
    #game-root .card-ui-heading .card-ui-countdown .card-ui-icon { display: none; }
    #game-root .card-ui-countdown strong { font-size: 23px; }
    #game-root .card-ui-deck-slots { grid-template-columns: repeat(3, 64px); gap: 10px; margin-bottom: 14px; }
    #game-root .card-ui-deck-slots .card-ui-slot { width: 64px; min-height: 64px; }
    #game-root .card-ui-collection, #game-root .card-ui-keep-cards, #game-root .card-ui-offers, #game-root .card-ui-replacement-targets { gap: 8px; }
    #game-root .card-ui-card { min-height: 0; padding: 12px 3px 10px; gap: 3px; }
    #game-root .card-ui-art { width: 60px; height: 42px; max-width: 100%; }
    #game-root .card-ui-symbol { width: 40px; height: 40px; }
    #game-root .card-ui-card-title { font-size: 8px; min-height: 24px; line-height: 1.5; }
    #game-root .card-ui-face-stat { font-size: 8px; gap: 3px; }
    #game-root .card-ui-face-stat .card-ui-icon { width: 20px; height: 20px; }
    #game-root .card-ui-rank-pips { top: 6px; gap: 2px; }
    #game-root .card-ui-rank-pips > span { width: 5px; }
    #game-root .card-ui-auto-label { left: 3px; top: 18px; }
    #game-root .card-ui-auto-label .card-ui-icon { width: 10px; height: 10px; }
    #game-root .card-ui-slot-hint { font-size: 7px; gap: 6px; }
    #game-root .card-ui-destination, #game-root .card-ui-equipped { bottom: 1px; right: 1px; }
    #game-root .card-ui-destination .card-ui-icon, #game-root .card-ui-equipped .card-ui-icon { width: 10px; height: 10px; }
    #game-root .card-ui-combo-hint { left: 1px; bottom: 0; }
    #game-root .card-ui-combo-hint .card-ui-icon { width: 20px; height: 20px; }
    #game-root .card-ui-info-panel { padding: 8px; }
    #game-root .card-ui-quality-row .card-ui-quality-marks { width: 24px; height: 5px; }
    #game-root .card-ui-quality-row .card-ui-gain-mark { left: calc(50% + 15px); top: -2px; width: 10px; height: 10px; }
    #game-root .card-ui-quality-row { min-height: 19px; gap: 5px; }
    #game-root .card-ui-face-quality { font-size: 6px; }
    #game-root .card-ui-stat-label { flex: 0 0 100%; }
    #game-root .card-ui-quality-comparison .card-ui-quality-marks { display: none; }
    #game-root .card-ui-info-panel p { font-size: 11px; }
    #game-root .card-ui-swap { padding: 8px; }
    #game-root .card-ui-replacement-incoming { gap: 6px; padding: 8px; flex-wrap: wrap; }
    #game-root .card-ui-replacement-incoming strong { font-size: 9px; }
    #game-root .card-ui-replacement-incoming .card-ui-quality-badge { font-size: 7px; }
    #game-root .card-ui-replacement-incoming .card-ui-face-stats { width: 100%; flex-direction: row; justify-content: space-evenly; min-height: 24px; }
}
@media (max-width: 350px) {
    #game-root .card-ui-face-stat { font-size: 7px; }
    #game-root .card-ui-face-stat .card-ui-icon { width: 10px; height: 10px; }
}
@media (max-height: 500px) and (orientation: landscape) {
    #game-root .card-ui-dialog { padding: 12px 18px; max-height: calc(100dvh - 32px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); }
    #game-root .card-ui-heading { margin-bottom: 10px; }
    #game-root .card-ui-heading h2 { font-size: 15px; }
    #game-root .card-ui-card { min-height: 0; gap: 4px; padding-top: 14px; padding-bottom: 12px; }
    #game-root .card-ui-art { width: 80px; height: 42px; }
    #game-root .card-ui-symbol { width: 40px; height: 40px; }
    #game-root .card-ui-card-title { font-size: 9px; min-height: 24px; }
    #game-root .card-ui-face-stat { font-size: 9px; }
    #game-root .card-ui-face-quality { font-size: 6px; }
    #game-root .card-ui-quality-row .card-ui-quality-marks { width: 24px; height: 5px; }
    #game-root .card-ui-quality-row { min-height: 17px; gap: 4px; }
    #game-root .card-ui-quality-row .card-ui-gain-mark { left: calc(50% + 15px); width: 10px; height: 10px; top: -2px; }
    #game-root .card-ui-collection[data-count="4"], #game-root .card-ui-keep-cards[data-count="4"] { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    #game-root .card-ui-collection[data-count="5"], #game-root .card-ui-keep-cards[data-count="5"] { grid-template-columns: repeat(5, minmax(0, 1fr)); }
    #game-root .card-ui-deck-slots { grid-template-columns: repeat(3, 56px); gap: 10px; margin-bottom: 10px; }
    #game-root .card-ui-deck-slots .card-ui-slot { width: 56px; min-height: 56px; }
    #game-root .card-ui-run-mode { padding: 5px 0; margin-bottom: 8px; }
    #game-root .card-ui-hud { bottom: 14px; }
    #game-root.touch-layout .card-ui-hud, #game-root.touch-layout:has(.render-settings) .card-ui-hud { bottom: calc(var(--touch-dock-height) + var(--touch-safe-bottom) + 12px); }
    #game-root .card-ui-hud .card-ui-slot, #game-root .card-ui-deck-button { min-height: 44px; }
    #game-root .card-ui-dialog[open][data-kind="deck"] { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 5px; padding: 8px 18px; width: min(760px, calc(100vw - 48px - env(safe-area-inset-left) - env(safe-area-inset-right))); }
    #game-root .card-ui-dialog[data-kind="deck"] .card-ui-heading { grid-column: 1; grid-row: 1; margin-bottom: 0; }
    #game-root .card-ui-dialog[data-kind="deck"] .card-ui-close { position: absolute; top: 6px; right: 6px; }
    #game-root .card-ui-dialog[data-kind="deck"] .card-ui-deck-slots { grid-column: 2; grid-row: 1; padding-right: 48px; margin-bottom: 0; }
    #game-root .card-ui-dialog[data-kind="deck"] .card-ui-reaction { grid-column: 1; grid-row: 2; margin: 0; justify-content: flex-start; }
    #game-root .card-ui-dialog[data-kind="deck"] .card-ui-slot-hint { grid-column: 2; grid-row: 2; margin: 0; min-height: 20px; padding-right: 48px; }
    #game-root .card-ui-dialog[data-kind="deck"] .card-ui-selection { grid-column: 1 / -1; grid-row: 3; margin: 0; }
    #game-root .card-ui-dialog[data-kind="deck"] .card-ui-swap { grid-column: 1 / -1; grid-row: 3; margin-bottom: 0; }
    #game-root .card-ui-dialog[data-kind="deck"]:has(.card-ui-swap:not([hidden])) .card-ui-selection { display: none; }
    #game-root .card-ui-dialog[data-kind="deck"] .card-ui-collection { grid-column: 1 / -1; grid-row: 4; }
    #game-root .card-ui-dialog[data-kind="deck"] .card-ui-info-panel { grid-column: 1 / -1; }
    #game-root .card-ui-dialog[open][data-kind="replace"] { display: grid; grid-template-columns: 160px 24px minmax(0, 1fr); gap: 8px; width: min(760px, calc(100vw - 48px - env(safe-area-inset-left) - env(safe-area-inset-right))); }
    #game-root .card-ui-dialog[data-kind="replace"] .card-ui-heading { grid-column: 1 / -1; margin-bottom: 0; }
    #game-root .card-ui-dialog[data-kind="replace"] .card-ui-replacement-incoming { grid-column: 1; grid-row: 2; align-self: stretch; flex-direction: column; justify-content: center; gap: 8px; text-align: center; }
    #game-root .card-ui-dialog[data-kind="replace"] .card-ui-replacement-incoming > div { flex: 0 0 auto; }
    #game-root .card-ui-dialog[data-kind="replace"] .card-ui-replacement-incoming strong { font-size: 9px; }
    #game-root .card-ui-dialog[data-kind="replace"] .card-ui-replacement-incoming .card-ui-quality-badge { justify-content: center; font-size: 7px; }
    #game-root .card-ui-dialog[data-kind="replace"] .card-ui-replacement-incoming .card-ui-face-stats { width: 100%; }
    #game-root .card-ui-dialog[data-kind="replace"] .card-ui-replacement-arrow { grid-column: 2; grid-row: 2; margin: auto; transform: none; }
    #game-root .card-ui-dialog[data-kind="replace"] .card-ui-replacement-targets { grid-column: 3; grid-row: 2; }
    #game-root .card-ui-dialog[data-kind="replace"] .card-ui-card { min-height: 0; }
    #game-root .card-ui-dialog[data-kind="replace"] .card-ui-art { height: 22px; }
    #game-root .card-ui-dialog[data-kind="replace"] .card-ui-symbol { width: 20px; height: 20px; }
    #game-root .card-ui-dialog[data-kind="replace"] .card-ui-card-title { min-height: 20px; }
    #game-root .card-ui-dialog[data-kind="replace"] .card-ui-swap { grid-column: 1 / -1; margin-bottom: 0; }
    #game-root .card-ui-dialog[data-kind="replace"] .card-ui-replacement-actions { grid-column: 1 / -1; margin-top: 0; }
    #game-root .card-ui-dialog[data-kind="replace"] .card-ui-info-panel { grid-column: 1 / -1; }
}
@media (prefers-reduced-motion: reduce) {
    #game-root .card-ui-deal, #game-root .card-ui-reward-flash { animation: none; transform: none; }
    #game-root .card-ui-card-frame:has(> .card-ui-card[aria-pressed="true"]) { transform: none; }
    #game-root .card-ui-selection-spark { animation: none; opacity: 1; }
}

/* Inspect a physical card: its own modal above the preserved deck. */
#game-root .card-ui-card.card-ui-inspected { visibility: hidden; }
#game-root .card-ui-detail-dialog { box-sizing: border-box; position: fixed; inset: 0; width: 100vw; max-width: none; height: 100dvh; max-height: none; margin: 0; padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); border: 0; background: transparent; overflow: hidden; overscroll-behavior: contain; perspective: 1400px; color: #e8f0e9; }
#game-root .card-ui-detail-dialog[open] { display: flex; align-items: center; justify-content: center; }
#game-root .card-ui-detail-dialog::backdrop { background: #020b19e8; }
#game-root .card-ui-detail-dialog * { box-sizing: border-box; }
#game-root .card-ui-detail-stage { position: relative; flex: 0 0 auto; width: min(440px, 100%, calc((100dvh - 32px - env(safe-area-inset-top) - env(safe-area-inset-bottom)) * 5 / 6.6)); aspect-ratio: 5 / 6.6; height: auto; min-height: 0; transform-origin: center; }
#game-root .card-ui-detail-flip { position: absolute; inset: 0; transform-style: preserve-3d; transform: rotateY(180deg); }
#game-root .card-ui-detail-front, #game-root .card-ui-detail-back { position: absolute; inset: 0; backface-visibility: hidden; }
#game-root .card-ui-detail-front > .card-ui-card { position: absolute; inset: 0 auto auto 0; transform-origin: top left; cursor: default; }
#game-root .card-ui-detail-front .card-ui-selection-sparks { display: none; }
#game-root .card-ui-detail-back.card-ui-info-panel { display: flex; flex-direction: column; align-items: stretch; gap: 0; margin: 0; padding: 10px 16px; min-width: 0; height: 100%; overflow: hidden; transform: rotateY(180deg); border: 2px solid var(--quality-color); background: #142f43; box-shadow: inset 0 4px #3c5666, inset 0 -6px #091b2f, 4px 4px #020a17; touch-action: pan-y; }
#game-root .card-ui-detail-header, #game-root .card-ui-detail-seal, #game-root .card-ui-detail-footer { touch-action: none; }
#game-root .card-ui-detail-back > .card-ui-border-art { inset: 0; }
#game-root .card-ui-detail-back > .card-ui-rank-tabs { inset: 8px; }
#game-root .card-ui-detail-back::before { content: ''; position: absolute; inset: 6px; border: 1px solid #3e5967; pointer-events: none; }
#game-root .card-ui-detail-back[data-quality="fine"]::before, #game-root .card-ui-detail-back[data-quality="rare"]::before { border-color: var(--quality-color); opacity: .55; }
#game-root .card-ui-detail-back[data-quality="prism"]::before { border: 2px solid var(--quality-color); box-shadow: inset 0 0 0 3px #182d45; }
#game-root .card-ui-detail-ready .card-ui-detail-flip { transform: none; transform-style: flat; }
#game-root .card-ui-detail-ready .card-ui-detail-front { display: none; }
#game-root .card-ui-detail-ready .card-ui-detail-back { transform: none; }
#game-root .card-ui-detail-header { position: relative; flex: 0 0 auto; display: grid; grid-template-columns: minmax(0, 1fr) 44px; align-items: center; gap: 8px; padding: 4px 8px; z-index: 2; cursor: grab; }
#game-root .card-ui-detail-header .card-ui-close { width: 44px; height: 44px; border: 1px solid #426578; box-shadow: inset 0 -2px #07172c; background: #102b3e; }
#game-root .card-ui-detail-header .card-ui-close:hover { border-color: var(--quality-color); }
#game-root .card-ui-detail-identity { min-width: 0; }
#game-root .card-ui-detail-identity h2 { margin: 0; color: #eff5d9; font: 18px/1.25 var(--font); text-shadow: 2px 2px #061225; }
#game-root .card-ui-detail-identity .card-ui-detail-meta { justify-content: flex-start; gap: 6px; margin: 4px 0 0; }
#game-root .card-ui-detail-grip { position: absolute; top: 0; left: 50%; width: 24px; height: 3px; transform: translateX(-50%); cursor: grab; }
#game-root .card-ui-detail-grip > span { display: block; width: 24px; height: 3px; background: var(--quality-color); }
#game-root .card-ui-detail-dialog button:focus-visible { outline: 2px solid #fff1a8; outline-offset: 0; }
#game-root .card-ui-detail-seal { flex: 0 0 auto; display: flex; align-items: center; justify-content: center; gap: 12px; text-align: center; padding-bottom: 8px; user-select: none; cursor: grab; }
#game-root .card-ui-detail-type { display: block; color: var(--quality-color); font: 9px/1.6 var(--font); text-transform: uppercase; letter-spacing: 2px; margin: 0; }
#game-root .card-ui-reverse-art { position: relative; isolation: isolate; width: 72px; height: 48px; flex: 0 0 auto; max-width: 100%; margin: 0; overflow: hidden; border: 2px solid #365567; background: #0a1c31; }
#game-root .card-ui-reverse-pattern { position: absolute; width: 100%; height: 100%; inset: 0; image-rendering: pixelated; }
#game-root .card-ui-reverse-symbol { position: absolute; left: calc(50% - 16px); top: calc(50% - 16px); width: 32px; height: 32px; }
#game-root .card-ui-reverse-foil { position: absolute; inset: -50% -100%; pointer-events: none; opacity: 0; background: linear-gradient(115deg, transparent 44%, #ccead829 44% 48%, #effad244 48% 49%, #ccead829 49% 52%, transparent 52%); transform: translateX(-24%); }
#game-root .card-ui-detail-ready [data-quality="fine"] .card-ui-reverse-foil { animation: card-ui-foil 9s linear infinite; }
#game-root .card-ui-detail-ready [data-quality="rare"] .card-ui-reverse-foil { background: repeating-linear-gradient(115deg, transparent 0 48px, #a7dfff29 48px 60px, #effaff35 60px 63px, transparent 63px 100px); animation: card-ui-foil 7s linear infinite; }
#game-root .card-ui-detail-ready [data-quality="prism"] .card-ui-reverse-foil { background: repeating-linear-gradient(115deg, transparent 0 36px, #87e8df42 36px 48px, #cda6ef55 48px 60px, #f3db8d44 60px 72px, transparent 72px 108px); animation: card-ui-foil 6s linear infinite; }
#game-root .card-ui-reverse-sparks { position: absolute; inset: 0; pointer-events: none; }
#game-root .card-ui-reverse-sparks > span { position: absolute; width: 3px; height: 9px; background: #f7f4cf; box-shadow: -3px 3px #f7f4cf, 3px 3px #f7f4cf; opacity: 0; }
#game-root .card-ui-reverse-sparks > span:nth-child(1) { top: 22%; left: 15%; }
#game-root .card-ui-reverse-sparks > span:nth-child(2) { top: 68%; left: 74%; animation-delay: 1.1s; }
#game-root .card-ui-reverse-sparks > span:nth-child(3) { top: 14%; left: 82%; animation-delay: 2.6s; }
#game-root .card-ui-reverse-sparks > span:nth-child(4) { top: 78%; left: 22%; animation-delay: 3.7s; }
#game-root .card-ui-detail-ready [data-quality="rare"] .card-ui-reverse-sparks > span, #game-root .card-ui-detail-ready [data-quality="prism"] .card-ui-reverse-sparks > span { animation-name: card-ui-selection-twinkle; animation-duration: 5s; animation-timing-function: steps(1, end); animation-iteration-count: infinite; }
#game-root .card-ui-detail-scroll { flex: 1 1 auto; min-height: 0; min-width: 0; overflow: auto; overscroll-behavior: contain; touch-action: pan-y; padding: 2px 8px 8px; scrollbar-width: thin; scrollbar-color: var(--quality-color) #0b1d30; }
#game-root .card-ui-detail-scroll h2 { font: 18px/1.5 var(--font); color: #eff5d9; text-shadow: 2px 2px #061225; text-align: center; margin: 0 0 6px; }
#game-root .card-ui-detail-scroll > .card-ui-quality-badge { justify-content: center; margin: 0 0 14px; font-size: 9px; }
#game-root .card-ui-detail-scroll p { font: 14px/1.6 system-ui, sans-serif; color: #cfdddd; margin: 12px 0; }
#game-root .card-ui-ability-preview { display: block; width: 100%; height: auto; margin: 12px 0; overflow: hidden; background: #081b2e; border: 1px solid #3e5f70; box-shadow: inset 0 -3px #061225; }
#game-root .card-ui-ability-preview canvas { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; image-rendering: pixelated; pointer-events: none; }
#game-root .card-ui-detail-scroll .card-ui-info-stat { padding: 10px; margin-top: 6px; gap: 8px; background: #0a2034; border-left: 2px solid var(--card-color); font-size: 10px; }
#game-root .card-ui-detail-scroll .card-ui-stat-label { flex: 1; min-width: 62px; color: #b4c9cd; }
#game-root .card-ui-stat-explanation { flex: 0 0 100%; font: 12px/1.5 system-ui, sans-serif; color: #b1c5ca; }
#game-root .card-ui-detail-combo { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 6px; margin-top: 14px; padding: 8px 4px; border-top: 1px solid #496061; border-bottom: 1px solid #496061; color: #e8d595; font: 8px var(--font); }
#game-root .card-ui-detail-combo .card-ui-icon { width: 20px; height: 20px; }
#game-root .card-ui-detail-scroll p.card-ui-detail-rule, #game-root .card-ui-detail-scroll p.card-ui-keep-reset { font-size: 12px; }
#game-root .card-ui-detail-footer { position: relative; display: flex; justify-content: center; align-items: center; gap: 8px; flex: 0 0 32px; padding: 8px 0 4px; border-top: 1px solid #385265; color: var(--quality-color); font: 8px/1.5 var(--font); user-select: none; }
#game-root .card-ui-detail-footer .card-ui-quality-marks { width: 24px; height: 5px; }
#game-root .card-ui-detail-timer { display: flex; gap: 6px; align-items: center; margin-left: auto; color: #f4d18b; font-size: 12px; }
#game-root .card-ui-detail-timer .card-ui-icon { width: 20px; height: 20px; }
#game-root .card-ui-keep-cards[data-count="1"], #game-root .card-ui-keep-cards[data-count="2"] { grid-template-columns: repeat(var(--keep-count, 1), minmax(0, 180px)); justify-content: center; }
#game-root .card-ui-keep-cards[data-count="2"] { --keep-count: 2; }
@keyframes card-ui-foil { 0%, 100% { opacity: 0; transform: translateX(-24%); } 18% { opacity: .6; } 55% { opacity: .6; transform: translateX(24%); } 70% { opacity: 0; transform: translateX(24%); } }
@media (max-width: 520px) {
    #game-root .card-ui-dialog { width: calc(100vw - 28px - env(safe-area-inset-left) - env(safe-area-inset-right)); padding: 12px; }
    #game-root .card-ui-card .card-ui-face-stats { min-height: 28px; gap: 3px; }
    #game-root .card-ui-card .card-ui-face-stat .card-ui-icon { width: 10px; height: 10px; }
    #game-root .card-ui-detail-back.card-ui-info-panel { padding: 6px 10px; }
    #game-root .card-ui-reverse-art { width: 60px; height: 40px; }
    #game-root .card-ui-detail-type { font-size: 8px; }
    #game-root .card-ui-ability-preview { margin: 10px 0; }
    #game-root .card-ui-detail-scroll h2 { font-size: 16px; }
    #game-root .card-ui-detail-scroll .card-ui-info-stat { font-size: 9px; padding: 9px; }
    #game-root .card-ui-detail-scroll .card-ui-info-stat .card-ui-stat-label { flex: 1; }
    #game-root .card-ui-detail-scroll .card-ui-quality-comparison { justify-content: center; }
}
@media (max-height: 500px) and (orientation: landscape) {
    #game-root .card-ui-detail-stage { width: min(600px, 100%); height: calc(100dvh - 32px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); aspect-ratio: auto; }
    #game-root .card-ui-detail-back.card-ui-info-panel { padding: 4px 10px 8px; }
    #game-root .card-ui-detail-header { padding-block: 3px; }
    #game-root .card-ui-detail-seal { position: absolute; z-index: 1; top: 10px; left: 18px; padding: 0; }
    #game-root .card-ui-detail-type { font-size: 7px; }
    #game-root .card-ui-reverse-art { width: 48px; height: 32px; }
    #game-root .card-ui-reverse-symbol { width: 24px; height: 24px; left: calc(50% - 12px); top: calc(50% - 12px); }
    #game-root .card-ui-detail-ability { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: 'preview stats' 'description description'; column-gap: 12px; align-items: start; }
    #game-root .card-ui-ability-preview { grid-area: preview; margin: 0; }
    #game-root .card-ui-detail-ability > p { grid-area: description; }
    #game-root .card-ui-detail-ability > .card-ui-stat-list { grid-area: stats; }
    #game-root .card-ui-detail-ability > :is(.card-ui-quality-comparison, .card-ui-best-retained) { grid-column: 1 / -1; }
    #game-root .card-ui-detail-scroll { padding-inline: 2px; }
    #game-root .card-ui-detail-scroll h2 { font-size: 12px; }
    #game-root .card-ui-detail-scroll > .card-ui-quality-badge { margin-bottom: 8px; }
    #game-root .card-ui-detail-scroll p { margin: 8px 0; font-size: 12px; }
}
@media (max-width: 350px) {
    #game-root :is(.card-ui-collection, .card-ui-offers, .card-ui-keep-cards, .card-ui-replacement-targets) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    #game-root .card-ui-offers > .card-ui-card-frame:last-child, #game-root :is(.card-ui-collection, .card-ui-keep-cards)[data-count="3"] > .card-ui-card-frame:last-child, #game-root .card-ui-collection[data-count="5"] > .card-ui-card-frame:last-child { grid-column: 1 / -1; width: calc(50% - 4px); justify-self: center; }
    #game-root .card-ui-victory .card-ui-offer { aspect-ratio: auto; height: clamp(160px, calc((100dvh - 250px) / 2), 180px); }
}
@media (max-height: 500px) and (orientation: landscape) {
    #game-root .card-ui-victory .card-ui-offer { aspect-ratio: auto; height: clamp(160px, calc(100dvh - 180px), 220px); }
}
@media (prefers-reduced-motion: reduce) {
    #game-root .card-ui-detail-ready [data-quality] .card-ui-reverse-foil, #game-root .card-ui-detail-ready [data-quality] .card-ui-reverse-sparks > span { animation: none; }
    #game-root .card-ui-detail-ready [data-quality="prism"] .card-ui-reverse-foil { opacity: .5; transform: none; }
    #game-root .card-ui-detail-ready [data-quality="rare"] .card-ui-reverse-sparks > span, #game-root .card-ui-detail-ready [data-quality="prism"] .card-ui-reverse-sparks > span { opacity: .65; }
}

/* Artwork and the exact useful stats share the front of an expanded card. */
#game-root .card-ui-detail-dialog [hidden] { display: none !important; }
#game-root .card-ui-detail-scroll { display: flex; flex-direction: column; }
#game-root .card-ui-detail-scroll > :is(.card-ui-detail-cover, .card-ui-power-panel) { flex: 0 0 auto; }
#game-root .card-ui-detail-meta { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 8px; margin: 0 0 6px; color: var(--quality-color); font: 8px/1.5 var(--font); }
#game-root .card-ui-detail-meta .card-ui-detail-type { font-size: 8px; letter-spacing: 1px; }
#game-root .card-ui-detail-meta .card-ui-quality-marks { width: 48px; height: 10px; }
#game-root .card-ui-detail-meta .card-ui-detail-effective-quality { padding: 2px 5px; border: 1px solid #3e5c6e; background: #0e2338; font: 10px/1.4 var(--font); }
#game-root .card-ui-detail-roll { color: #b9ced2; font: 10px/1.4 var(--font); }
#game-root .card-ui-detail-cover { width: 100%; border: 2px solid var(--quality-color); background: #0a1c31; box-shadow: 3px 3px #061225; }
#game-root .card-ui-detail-scroll p.card-ui-detail-benefit { min-width: 0; align-self: center; margin: 0; padding: 6px 8px; text-align: left; color: #eef3dc; font: 9px/1.5 var(--font); }
#game-root .card-ui-detail-art-button { display: block; width: 100%; min-height: 44px; padding: 0; border: 0; color: #edf4dc; background: #0a1c31; cursor: pointer; touch-action: manipulation; }
#game-root .card-ui-detail-art-button:disabled { opacity: 1; cursor: default; }
#game-root .card-ui-detail-art-button:hover .card-ui-trading-art { box-shadow: inset 0 0 0 1px #f5e6ac; }
#game-root .card-ui-detail-art-button .card-ui-trading-art { flex: 0 0 auto; width: 100%; max-width: none; height: auto; aspect-ratio: 3 / 2; min-height: 0; margin: 0; border: 0; }
#game-root .card-ui-trading-art .card-ui-reverse-pattern { height: auto; top: 50%; bottom: auto; transform: translateY(-50%); }
#game-root .card-ui-trading-art .card-ui-reverse-symbol { width: 240px; height: 240px; max-width: 80%; max-height: 80%; object-fit: contain; left: 50%; top: 50%; transform: translate(-50%, -50%); }
#game-root .card-ui-example-strip { display: grid; grid-template-columns: minmax(0, 1fr) 84px; align-items: stretch; min-height: 44px; border-top: 1px solid #426374; background: #1d3b4b; }
#game-root .card-ui-example-label { display: flex; align-items: center; justify-content: center; gap: 6px; min-width: 44px; min-height: 44px; padding: 6px; border: 0; border-left: 1px solid #426374; background: #264d58; color: #eef3dc; font: 9px/1.4 var(--font); cursor: pointer; touch-action: manipulation; }
#game-root .card-ui-example-label:disabled { opacity: 1; cursor: default; }
#game-root .card-ui-play-symbol { width: 0; height: 0; border-top: 6px solid transparent; border-bottom: 6px solid transparent; border-left: 10px solid #f0e7b3; }
#game-root .card-ui-detail-example { flex: 0 0 auto; display: flex; flex-direction: column; justify-content: center; }
#game-root .card-ui-detail-example .card-ui-ability-preview { margin: 0; }
#game-root .card-ui-example-return { width: 100%; min-height: 44px; padding: 6px 12px; border: 1px solid #577a85; background: #19364b; color: #e6efdc; font: 11px/1.4 var(--font); cursor: pointer; touch-action: manipulation; }
#game-root .card-ui-power-panel { position: relative; margin-top: 10px; padding: 0 10px; background: #0d263b; box-shadow: inset 0 1px #3c596d, inset 0 -1px #3c596d; }
#game-root .card-ui-power-panel::before, #game-root .card-ui-power-panel::after { content: ''; position: absolute; width: 8px; height: 8px; border-color: var(--card-color); border-style: solid; pointer-events: none; }
#game-root .card-ui-power-panel::before { left: 0; top: 0; border-width: 2px 0 0 2px; }
#game-root .card-ui-power-panel::after { right: 0; bottom: 0; border-width: 0 2px 2px 0; }
#game-root .card-ui-detail-rules { margin: 0; padding: 0; border: 0; border-top: 1px solid #355366; background: transparent; }
#game-root .card-ui-detail-rules > summary { position: relative; display: flex; align-items: center; min-height: 44px; padding: 8px 26px 8px 0; color: #b5cbd0; font: 10px/1.4 var(--font); list-style: none; cursor: pointer; touch-action: manipulation; }
#game-root .card-ui-detail-rules > summary::-webkit-details-marker { display: none; }
#game-root .card-ui-detail-rules > summary::before, #game-root .card-ui-detail-rules > summary::after { content: ''; position: absolute; background: var(--quality-color); }
#game-root .card-ui-detail-rules > summary::before { right: 6px; top: calc(50% - 1px); width: 10px; height: 2px; }
#game-root .card-ui-detail-rules > summary::after { right: 10px; top: calc(50% - 5px); width: 2px; height: 10px; }
#game-root .card-ui-detail-rules[open] > summary::after { display: none; }
#game-root .card-ui-detail-rules[open] > summary, #game-root .card-ui-detail-rules > summary:hover { color: #eef3dc; }
#game-root .card-ui-detail-rules > summary:focus-visible { outline: 2px solid #fff1a8; outline-offset: -2px; }
#game-root .card-ui-detail-rules-body { padding: 2px 0 12px; border-top: 1px solid #2c475b; }
#game-root .card-ui-detail-scroll .card-ui-detail-rules-body p { margin: 8px 0; color: #c4d8d4; font: 11px/1.6 var(--font); text-transform: none; }
#game-root .card-ui-detail-rules-body > .card-ui-quality-badge { justify-content: flex-start; font-size: 10px; margin: 4px 0; }
#game-root .card-ui-detail-scroll .card-ui-detail-rules-body p.card-ui-stat-explanation { color: #9dbbc4; }
#game-root .card-ui-detail-rules-body .card-ui-detail-combo { justify-content: flex-start; gap: 6px; margin-top: 12px; padding: 8px; border: 0; border-left: 2px solid #a4cdb1; background: #14364a; }
#game-root .card-ui-detail-rules-body .card-ui-detail-combo strong { margin-left: auto; font: 10px/1.4 var(--font); color: #e5d797; }
#game-root .card-ui-core-stats { display: grid; gap: 0; margin: 0; padding: 0; border: 0; background: transparent; box-shadow: none; }
#game-root .card-ui-detail-scroll .card-ui-core-stats > .card-ui-info-stat { display: grid; grid-template-columns: 20px minmax(0, 1fr) auto; align-items: center; gap: 6px; margin: 0; padding: 8px 0; border: 0; background: transparent; }
#game-root .card-ui-detail-scroll .card-ui-core-stats > .card-ui-info-stat + .card-ui-info-stat { border-top: 1px solid #314c5d; }
#game-root .card-ui-core-stats .card-ui-icon { width: 20px; height: 20px; }
#game-root .card-ui-detail-scroll .card-ui-core-stats .card-ui-stat-label { min-width: 0; font: 12px/1.3 var(--font); }
#game-root .card-ui-detail-scroll .card-ui-core-stats .card-ui-stat-value { font: 24px/1.2 var(--font); font-variant-numeric: tabular-nums; white-space: nowrap; }
#game-root .card-ui-stat-unit { margin-left: 2px; font-size: 14px; color: #b8d0d0; }
#game-root .card-ui-stat-operator { font-size: 14px; color: #a5c2ca; }
#game-root .card-ui-face-benefit { display: block; color: #c5d9d8; font: 9px/1.4 var(--font); }
#game-root .card-ui-offer .card-ui-art { flex: 1 1 auto; width: 100%; max-width: none; height: auto; min-height: 44px; overflow: hidden; }
#game-root .card-ui-offer .card-ui-symbol { position: absolute; width: min(100px, 100%); height: 100%; max-width: none; max-height: none; object-fit: contain; top: 50%; left: 50%; transform: translate(-50%, -50%); }
#game-root .card-ui-offer > :is(.card-ui-card-title, .card-ui-face-benefit, .card-ui-choice-stats, .card-ui-quality-row) { flex: 0 0 auto; }
#game-root .card-ui-offer .card-ui-choice-stats { display: grid; gap: 4px; width: 100%; min-height: 62px; align-content: start; }
#game-root .card-ui-offer .card-ui-choice-stats .card-ui-face-stat { display: grid; grid-template-columns: 14px auto; justify-content: center; gap: 0 4px; font: 16px/1.15 var(--font); }
#game-root .card-ui-offer .card-ui-choice-stats .card-ui-icon { width: 14px; height: 14px; }
#game-root .card-ui-offer .card-ui-choice-stats:has(> .card-ui-face-stat:only-child) { align-content: center; }
#game-root .card-ui-face-unit { margin-left: 1px; font-size: 10px; color: #c0d5d0; }
#game-root .card-ui-face-label { grid-column: 1 / -1; font: 8px/1.4 var(--font); color: #b9ced2; }
@media (max-width: 520px) {
    #game-root .card-ui-detail-stage { width: min(440px, 100%); height: min(588px, calc((100vw - 32px) * 2 / 3 + 338px), calc(100dvh - 60px - env(safe-area-inset-top) - env(safe-area-inset-bottom))); aspect-ratio: auto; }
    #game-root .card-ui-detail-identity h2 { font-size: 16px; }
    #game-root .card-ui-face-benefit { font-size: 8px; }
    #game-root .card-ui-offer .card-ui-card-title { font-size: 9px; line-height: 1.5; min-height: 28px; }
    #game-root .card-ui-offer .card-ui-face-quality { font: 8px/1.3 var(--font); }
    #game-root .card-ui-offer .card-ui-choice-stats .card-ui-face-stat { font-size: 14px; }
}
@media (min-width: 351px) and (max-width: 520px) {
    #game-root .card-ui-offer { aspect-ratio: auto; height: 230px; }
}
@media (min-width: 521px) and (min-height: 501px) {
    #game-root .card-ui-detail-art-button .card-ui-trading-art { aspect-ratio: 16 / 9; }
}
@media (max-width: 350px) {
    #game-root .card-ui-detail-identity h2 { font-size: 14px; }
    #game-root .card-ui-detail-meta .card-ui-quality-marks { width: 24px; height: 5px; }
    #game-root .card-ui-detail-scroll .card-ui-core-stats .card-ui-stat-value { font-size: 20px; }
    #game-root .card-ui-offer { gap: 2px; padding-top: 10px; padding-bottom: 8px; }
    #game-root .card-ui-offer .card-ui-art { min-height: 28px; }
    #game-root .card-ui-offer .card-ui-card-title { min-height: 24px; }
    #game-root .card-ui-offer .card-ui-choice-stats { gap: 2px; min-height: 56px; }
    #game-root .card-ui-offer .card-ui-choice-stats .card-ui-face-stat { font-size: 14px; }
    #game-root .card-ui-face-label { font-size: 8px; }
}
@media (max-height: 500px) and (orientation: landscape) {
    #game-root .card-ui-detail-identity { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 12px; }
    #game-root .card-ui-detail-identity h2 { font-size: 16px; }
    #game-root .card-ui-detail-identity .card-ui-detail-meta { margin: 0; }
    #game-root .card-ui-detail-scroll { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: auto 1fr; column-gap: 16px; }
    #game-root .card-ui-detail-cover, #game-root .card-ui-detail-example { grid-column: 1; grid-row: 1 / 3; min-height: 0; align-self: center; }
    #game-root .card-ui-power-panel { grid-column: 2; grid-row: 1 / 3; align-self: start; margin-top: 0; }
    #game-root .card-ui-trading-art .card-ui-reverse-symbol { width: 200px; height: 200px; }
}

/* Fit the keep panel to its cards; only the choices scroll. */
#game-root .card-ui-dialog[data-kind="keep"] {
    --keep-columns: 3; --keep-card-width: 180px; --keep-gap: 14px; --keep-padding: 18px;
    width: min(calc(var(--keep-columns) * var(--keep-card-width) + (var(--keep-columns) - 1) * var(--keep-gap) + 2 * var(--keep-padding) + 8px), calc(100vw - 48px - env(safe-area-inset-left) - env(safe-area-inset-right)));
    padding: var(--keep-padding); overflow: hidden;
    grid-template-rows: auto minmax(0, 1fr) auto; gap: var(--keep-gap);
}
#game-root .card-ui-dialog[data-kind="keep"][open] { display: grid; }
#game-root .card-ui-dialog[data-kind="keep"]:has(.card-ui-keep-cards[data-count="1"]) { --keep-columns: 1; }
#game-root .card-ui-dialog[data-kind="keep"]:has(.card-ui-keep-cards[data-count="2"]) { --keep-columns: 2; }
#game-root .card-ui-dialog[data-kind="keep"] .card-ui-heading { margin: 0; min-height: 28px; }
#game-root .card-ui-dialog[data-kind="keep"] .card-ui-heading .card-ui-icon { width: 20px; height: 20px; }
#game-root .card-ui-dialog[data-kind="keep"] .card-ui-heading h2 { font-size: 14px; }
#game-root .card-ui-dialog[data-kind="keep"] .card-ui-keep-cards {
    min-height: 0; padding: 4px; margin: 0;
    grid-template-columns: repeat(var(--keep-columns), minmax(0, 1fr));
    grid-auto-rows: max-content; gap: var(--keep-gap); align-content: start;
    overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: #517787 #0b2035;
}
#game-root .card-ui-dialog[data-kind="keep"] .card-ui-keep-finish { margin: 0; min-height: 44px; }
@media (min-width: 581px) {
    #game-root .card-ui-dialog[data-kind="keep"] .card-ui-keep-cards:not([data-count="1"]) > .card-ui-card-frame:last-child:nth-child(3n + 1) { grid-column: 2; }
}
@media (max-width: 580px) {
    #game-root .card-ui-dialog[data-kind="keep"] { --keep-columns: 2; --keep-gap: 12px; --keep-padding: 14px; }
    #game-root .card-ui-dialog[data-kind="keep"] .card-ui-keep-cards:not([data-count="1"]) > .card-ui-card-frame:last-child:nth-child(odd) { grid-column: 1 / -1; width: calc((100% - var(--keep-gap)) / 2); justify-self: center; }
}
@media (max-height: 500px) and (orientation: landscape) {
    #game-root .card-ui-dialog[data-kind="keep"] { --keep-card-width: clamp(110px, calc((100dvh - 210px) / 1.4), 160px); --keep-gap: 12px; --keep-padding: 12px; }
}
#game-root .card-ui-saved-dismissal { border-color: #668391; background: #132a3c; color: #a4bec3; font: 7px/1 var(--font); }
#game-root .card-ui-saved-dismissal > .card-ui-icon { width: 32px; height: 32px; }
