/* Engine stylesheet. Every colour, font, radius and size comes from CSS variables set by
   config.applyTheme() from game.json "theme"; grid areas/rows/columns come from "layout". */
:root {
  --c-bg: #1b1029; --c-ink: #2a1838; --c-panel: rgba(255,255,255,.9); --c-panel-edge: rgba(255,255,255,.55);
  --c-accent: #ff7a29; --c-accent-ink: #fff; --c-accent2: #8b4dff; --c-accent2-ink: #fff;
  --c-card: #fff; --c-card-edge: #efe6f7; --c-card-active: #fff1e6; --c-card-active-edge: #ff7a29;
  --c-tab: #f4ecfb; --c-tab-ink: #6d4f8a; --c-tab-active: #8b4dff; --c-tab-active-ink: #fff;
  --c-muted: #8a7a99; --c-star: #ffc93c; --c-coin: #ffb800; --c-title: #fff; --c-title-shadow: #5b1f8a;
  --f-title: 'Fredoka', system-ui, sans-serif; --f-display: 'Fredoka', system-ui, sans-serif; --f-body: 'Nunito', system-ui, sans-serif;
  --radius: 22px; --card: 96px; --blur: 16px; --grid-cols: 4; --panel-inset: 0;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--c-bg); color: var(--c-ink); font: 600 15px/1.35 var(--f-body); overflow: hidden; overscroll-behavior: none; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; padding: 0; }
button:focus-visible { outline: 3px solid var(--c-accent2); outline-offset: 2px; }
.ico { display: block; flex: none; }

.app { position: fixed; inset: 0; display: grid; overflow: hidden; user-select: none; -webkit-user-select: none; }
.stage-area { grid-area: stage; position: relative; min-width: 0; min-height: 0; overflow: hidden; }
.stage-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.stage-overlay { position: absolute; inset: 0; pointer-events: none; }
.stage-overlay > * { pointer-events: auto; }
.panel-area { grid-area: panel; min-width: 0; min-height: 0; padding: var(--panel-inset); display: flex; }
.app[data-mode="full"] .panel-area { display: none; }
.screens { position: absolute; inset: 0; pointer-events: none; z-index: 5; }
.screens > * { pointer-events: auto; }

/* ---------- boot */
.boot { position: fixed; inset: 0; display: grid; place-items: center; background: var(--c-bg); z-index: 50; }
.boot { transition: opacity .5s ease; background: radial-gradient(ellipse at 50% 40%, color-mix(in srgb, var(--c-accent2) 30%, var(--c-bg)), var(--c-bg) 70%); align-content: center; gap: 22px; }
.boot-title { font: 400 clamp(36px, 7vw, 72px)/1 var(--f-title); color: var(--c-title); text-align: center; padding: 0 20px; text-shadow: 0 4px 0 var(--c-title-shadow), 0 12px 30px rgba(0,0,0,.5); animation: popIn .6s cubic-bezier(.2,1.4,.4,1) both; }
.boot-bar { justify-self: center; width: min(260px, 60vw); height: 10px; border-radius: 999px; background: rgba(255,255,255,.12); overflow: hidden; box-shadow: inset 0 0 0 1.5px rgba(255,255,255,.18); }
.boot-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--c-accent2), var(--c-accent)); transform: scaleX(.08); transform-origin: left; transition: transform .35s ease; }
.boot.done { opacity: 0; pointer-events: none; }
.boot-ring { width: 46px; height: 46px; border-radius: 50%; border: 5px solid rgba(255,255,255,.15); border-top-color: var(--c-accent); animation: spin .8s linear infinite; }
.boot-error { color: #fff; padding: 24px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 20px; border-radius: 999px; font: 700 17px/1 var(--f-display); letter-spacing: .01em; transition: transform .12s ease, filter .12s ease, box-shadow .12s ease; white-space: nowrap; }
.btn:active { transform: translateY(2px) scale(.97); }
.btn-primary { color: var(--c-accent-ink); background: linear-gradient(180deg, color-mix(in srgb, var(--c-accent) 82%, #fff) 0%, var(--c-accent) 55%, color-mix(in srgb, var(--c-accent) 80%, #000) 100%); box-shadow: 0 5px 0 color-mix(in srgb, var(--c-accent) 62%, #000), 0 10px 22px color-mix(in srgb, var(--c-accent) 40%, transparent), inset 0 2px 0 rgba(255,255,255,.45); }
.btn-primary:active { box-shadow: 0 2px 0 color-mix(in srgb, var(--c-accent) 62%, #000), inset 0 2px 0 rgba(255,255,255,.4); }
.btn-secondary { color: var(--c-accent2-ink); background: linear-gradient(180deg, color-mix(in srgb, var(--c-accent2) 80%, #fff), var(--c-accent2)); box-shadow: 0 4px 0 color-mix(in srgb, var(--c-accent2) 60%, #000), inset 0 2px 0 rgba(255,255,255,.35); }
.btn-coin { color: #4a2a00; background: linear-gradient(180deg, #ffe58a, var(--c-coin)); box-shadow: 0 4px 0 #b77d00, inset 0 2px 0 rgba(255,255,255,.6); }
.btn-lg { min-height: 54px; padding: 0 28px; font-size: 20px; }
.btn-xl { min-height: 66px; padding: 0 40px; font-size: 26px; }
.btn-pulse { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.06); } }
.btn.on { filter: brightness(1.15) saturate(1.2); }
.icon-btn { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 50%; color: var(--c-ink); background: var(--c-panel); backdrop-filter: blur(var(--blur)); -webkit-backdrop-filter: blur(var(--blur)); box-shadow: 0 4px 14px rgba(0,0,0,.25), inset 0 0 0 2px var(--c-panel-edge); transition: transform .12s; }
.icon-btn:hover { transform: scale(1.08); }
.icon-btn.on { background: var(--c-accent2); color: #fff; }
.ib-undo.spin .ico { animation: spinBack .45s cubic-bezier(.3,1.3,.5,1); }
.ib-reset.spin .ico { animation: spinFwd .5s cubic-bezier(.3,1.3,.5,1); }
.ib-shuffle.spin .ico { animation: wiggle .5s ease; }
@keyframes spinBack { from { transform: rotate(0); } to { transform: rotate(-360deg); } }
@keyframes spinFwd { from { transform: rotate(0); } to { transform: rotate(360deg); } }
@keyframes wiggle { 20% { transform: rotate(-18deg) scale(1.1); } 50% { transform: rotate(14deg); } 80% { transform: rotate(-6deg); } }
.icon-btn:active { transform: scale(.92); }

/* ---------- stage HUD */
.hud { position: absolute; top: max(12px, env(safe-area-inset-top)); display: flex; flex-direction: column; gap: 10px; z-index: 3; }
.hud-left { left: 12px; } .hud-right { right: 12px; }
.app[data-orient="portrait"] .hud { gap: 8px; top: 10px; }
.app[data-orient="portrait"] .icon-btn { width: 44px; height: 44px; }

/* ---------- themed shell: line-art wallpaper + corner ornaments (theme.decor) */
.screens .card, .modal-card { background-image: var(--panel-pattern, none); position: relative; }
:root:not([data-decor="none"]) .panel-card::before, :root:not([data-decor="none"]) .panel-card::after,
:root:not([data-decor="none"]) .screens .card::before, :root:not([data-decor="none"]) .modal-card::before {
  content: ''; position: absolute; top: 0; left: 0; width: 76px; height: 99px; background: var(--corner-art) no-repeat 0 0 / 76px auto; pointer-events: none; z-index: 0; border-top-left-radius: var(--radius); }
:root:not([data-decor="none"]) .panel-card::after { left: auto; right: 0; transform: scaleX(-1); }
.panel-card > *, .screens .card > *, .modal-card > * { position: relative; z-index: 1; }

/* ---------- equip flight, praise, new dots, shine */
.fly-trail { position: fixed; z-index: 99; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%; pointer-events: none; background: radial-gradient(circle, #fff 0 22%, color-mix(in srgb, var(--c-star) 85%, #fff) 38%, transparent 70%); will-change: transform, opacity; opacity: 0; }
.fly-ghost { position: fixed; z-index: 100; pointer-events: none; object-fit: contain; filter: drop-shadow(0 0 10px rgba(255,255,255,.9)) drop-shadow(0 0 22px color-mix(in srgb, var(--c-star) 70%, transparent)) drop-shadow(0 8px 14px rgba(0,0,0,.3)); will-change: transform; }
.praise { position: absolute; z-index: 4; transform: translate(-50%, -50%); font: 400 clamp(30px, 4vw, 46px)/1 var(--f-title); color: #fff; -webkit-text-stroke: 2px color-mix(in srgb, var(--c-title-shadow) 70%, #000); paint-order: stroke fill; text-shadow: 0 4px 0 var(--c-title-shadow), 0 10px 24px rgba(0,0,0,.45); white-space: nowrap; pointer-events: none; animation: praise 1.5s cubic-bezier(.2,1.4,.4,1) forwards; }
.praise.praise-out { animation: praiseOut .22s ease forwards; }
@keyframes praiseOut { to { opacity: 0; transform: translate(-50%, -80%) scale(.8) rotate(var(--rot)); } }
@keyframes praise { 0% { opacity: 0; transform: translate(-50%, -30%) scale(.3) rotate(var(--rot)); } 18% { opacity: 1; transform: translate(-50%, -50%) scale(1.12) rotate(var(--rot)); } 30% { transform: translate(-50%, -50%) scale(1) rotate(var(--rot)); } 75% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -130%) scale(.95) rotate(var(--rot)); } }
.new-dot { position: absolute; top: 6px; left: 6px; width: 10px; height: 10px; border-radius: 50%; background: #ff3b5c; box-shadow: 0 0 0 2px #fff; display: none; transition: transform .3s cubic-bezier(.4,0,.6,1), opacity .3s; }
.tile .new-dot { display: block; }
.tab .new-dot { top: 4px; left: auto; right: 8px; }
.tab.fresh .new-dot { display: block; }
.new-dot.gone { transform: scale(0); opacity: 0; }
.btn-primary { position: relative; overflow: hidden; isolation: isolate; }
.btn-primary::after { content: ''; position: absolute; inset: -20% auto -20% -60%; width: 40%; background: linear-gradient(100deg, transparent, rgba(255,255,255,.55), transparent); transform: skewX(-18deg); animation: shine 3.2s ease-in-out infinite; z-index: -1; pointer-events: none; }
@keyframes shine { 0%, 62% { left: -60%; } 100% { left: 130%; } }
.btn-done:not(.ready)::after { display: none; }

/* ---------- first-run hint */
.tap-hint { position: absolute; left: 52%; top: 46%; z-index: 3; pointer-events: none; display: grid; justify-items: start; color: #fff; filter: drop-shadow(0 4px 6px rgba(0,0,0,.45)); animation: hintIn .4s cubic-bezier(.2,1.4,.4,1) both; }
.tap-hint .ico { animation: tap 1.1s ease-in-out infinite; transform-origin: 30% 20%; fill: var(--c-accent); stroke: #fff; }
.tap-hint span { margin-top: 2px; padding: 4px 10px; border-radius: 999px; background: rgba(20,8,32,.85); font: 700 12px var(--f-display); white-space: nowrap; }
.tap-hint.gone { animation: fadeOut .3s ease forwards; }
@keyframes tap { 0%, 100% { transform: translate(0, 0) scale(1); } 45% { transform: translate(-6px, -8px) scale(1.05); } 60% { transform: translate(0, 0) scale(.92); } }
@keyframes hintIn { from { opacity: 0; transform: translateY(10px); } }
.tile:has(.tap-hint) { overflow: visible; z-index: 2; }

/* ---------- panel */
.panel-card { position: relative; background-image: var(--panel-pattern, none); flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; gap: 10px; padding: 14px; background-color: var(--c-panel); backdrop-filter: blur(var(--blur)); -webkit-backdrop-filter: blur(var(--blur)); border-radius: var(--radius); box-shadow: 0 18px 40px rgba(0,0,0,.35), inset 0 0 0 2px var(--c-panel-edge); animation: panelIn .5s cubic-bezier(.2,1.2,.3,1) both; }
.app[data-orient="portrait"] .panel-card { padding: 10px 10px 8px; gap: 8px; border-radius: var(--radius) var(--radius) calc(var(--radius) * .6) calc(var(--radius) * .6); }
@keyframes panelIn { from { transform: translateY(24px); opacity: 0; } }
.panel-body { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 8px; }
/* tabs as a vertical rail beside the grid: layout.<orientation>.tabs = "rail" */
.panel-card.tabs-rail { display: grid; grid-template-columns: 84px 1fr; grid-template-rows: auto 1fr auto; }
.tabs-rail .panel-head, .tabs-rail .panel-foot { grid-column: 1 / -1; }
.tabs-rail .tabs { flex-direction: column; overflow-y: auto; overflow-x: hidden; flex-wrap: nowrap; padding: 2px 4px 2px 0; scroll-snap-type: y proximity; }
.tabs-rail .tab { width: 76px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 34px; }
.panel-title { font: 700 20px var(--f-display); color: var(--c-ink); }
.challenge-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; background: color-mix(in srgb, var(--c-accent2) 14%, transparent); color: var(--c-accent2); font: 700 14px var(--f-display); min-width: 0; }
.challenge-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.coin-chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px 5px 6px; border-radius: 999px; background: color-mix(in srgb, var(--c-coin) 22%, #fff); color: #7a4b00; font: 700 15px var(--f-display); box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--c-coin) 50%, transparent); flex: none; }
.coin-chip .ico { color: var(--c-coin); }

.tabs { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px 2px 4px; scroll-snap-type: x proximity; flex: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs:not(.tabs-wrap) { -webkit-mask-image: linear-gradient(90deg, #000 82%, transparent); mask-image: linear-gradient(90deg, #000 82%, transparent); }
.tabs-rail .tabs { -webkit-mask-image: linear-gradient(180deg, #000 86%, transparent); mask-image: linear-gradient(180deg, #000 86%, transparent); padding-bottom: 24px; }
.tabs-wrap { display: grid; grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); gap: 6px; overflow: visible; }
.tabs-wrap .tab { width: auto; padding: 5px 2px 4px; border-radius: 15px; }
.tabs-wrap .tab-ico { width: 38px; height: 38px; border-radius: 12px; }
.tabs-wrap .tab-label { font-size: max(11px, calc(11.5px / var(--ui, 1))); max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.tab { position: relative; flex: none; display: flex; flex-direction: column; align-items: center; gap: 2px; width: 70px; padding: 6px 4px 6px; border-radius: 18px; background: var(--c-tab); color: var(--c-tab-ink); scroll-snap-align: center; transition: transform .15s, background .2s, color .2s; }
.tab:hover { transform: translateY(-2px); }
.tab-ico { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; background: rgba(255,255,255,.75); overflow: hidden; }
.tab-ico img { width: 100%; height: 100%; object-fit: contain; }
.tab-label { font: 700 13px var(--f-display); white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.tab[aria-selected="true"] { background: var(--c-tab-active); color: var(--c-tab-active-ink); box-shadow: 0 6px 14px color-mix(in srgb, var(--c-tab-active) 45%, transparent); transform: translateY(-2px); }
.tab-dot { position: absolute; top: 5px; right: 7px; width: 9px; height: 9px; border-radius: 50%; background: var(--c-accent); box-shadow: 0 0 0 2px #fff; transform: scale(0); transition: transform .2s cubic-bezier(.3,1.6,.5,1); }
.tab-dot { display: none; }
.tab.has .tab-ico { box-shadow: 0 0 0 2.5px var(--c-accent); }
.tab-ico img { transition: transform .3s cubic-bezier(.3,1.6,.5,1); }
.tab-ico img.swap { animation: iconSwap .35s cubic-bezier(.3,1.6,.5,1); }
@keyframes iconSwap { from { transform: scale(.4) rotate(-12deg); opacity: .3; } }
.app[data-orient="portrait"] .tab { width: 60px; } .app[data-orient="portrait"] .tab-ico { width: 38px; height: 38px; }

.swatches { display: flex; align-items: center; gap: 8px; padding: 4px 6px; flex: none; overflow-x: auto; scrollbar-width: none; animation: fadeUp .25s ease both; }
.sw-label { color: var(--c-muted); }
.sw { flex: none; width: 30px; height: 30px; border-radius: 50%; box-shadow: inset 0 0 0 2px rgba(0,0,0,.12), 0 2px 5px rgba(0,0,0,.15); transition: transform .15s; }
.sw:hover { transform: scale(1.12); }
.sw.on { box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--c-accent); }
.sw-orig { background: conic-gradient(#ff7a7a, #ffd36e, #7affb2, #7ac8ff, #c38bff, #ff7a7a); }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } }

.grid-scroll { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 8px 4px 10px; -webkit-mask-image: linear-gradient(180deg, transparent, #000 10px, #000 calc(100% - 10px), transparent); mask-image: linear-gradient(180deg, transparent, #000 10px, #000 calc(100% - 10px), transparent); margin: 0 -4px; scrollbar-width: thin; }
.grid { display: grid; grid-template-columns: repeat(var(--grid-cols), minmax(0, 1fr)); gap: 10px; }
.tile { position: relative; aspect-ratio: 1; border-radius: calc(var(--radius) * .8); background: radial-gradient(circle at 50% 38%, var(--c-card) 45%, color-mix(in srgb, var(--c-card-edge) 70%, var(--c-card)) 100%); box-shadow: 0 4px 0 var(--c-card-edge), 0 6px 14px rgba(60,20,90,.08), inset 0 0 0 2px var(--c-card-edge); display: grid; place-items: center; overflow: hidden; transition: transform .15s ease, box-shadow .15s ease; }
.tile img { width: 100%; height: 100%; object-fit: contain; padding: 6%; transition: transform .25s cubic-bezier(.3,1.5,.5,1); pointer-events: none; }
.tile:hover img { transform: scale(1.08); }
.tile:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--c-card-edge), inset 0 0 0 2px var(--c-card-edge); }
.tile.on { background: var(--c-card-active); box-shadow: 0 4px 0 var(--c-card-active-edge), 0 8px 18px color-mix(in srgb, var(--c-card-active-edge) 35%, transparent), inset 0 0 0 3px var(--c-card-active-edge); }
.tile .check { position: absolute; top: 6px; right: 6px; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--c-card-active-edge); color: #fff; transform: scale(0); transition: transform .2s cubic-bezier(.3,1.7,.5,1); }
.tile.on .check { transform: scale(1); }
/* the moment an item goes on: a light sweep across its tile */
.tile.just-on::before { content: ''; position: absolute; inset: 0; z-index: 1; pointer-events: none; background: linear-gradient(115deg, transparent 35%, rgba(255,255,255,.85) 50%, transparent 65%) -150% 0 / 220% 100% no-repeat; animation: tileSheen .6s ease-out forwards; }
@keyframes tileSheen { to { background-position: 150% 0; } }
.tile.on .check { animation: checkIn .4s cubic-bezier(.3,1.8,.5,1); }
@keyframes checkIn { from { transform: scale(0) rotate(-90deg); } }
.tile-none { color: var(--c-muted); }
.tile-name { position: absolute; left: 0; right: 0; bottom: 4px; font: 700 11px var(--f-display); color: var(--c-muted); text-align: center; }
.tile .lock { position: absolute; left: 6px; bottom: 6px; display: inline-flex; align-items: center; gap: 3px; padding: 3px 7px 3px 4px; border-radius: 999px; background: rgba(30,12,48,.82); color: #fff; font: 700 11px var(--f-display); }
.tile .lock .ico { color: var(--c-coin); }
.tile:not(.locked) .lock { display: none; }
.tile.locked img { filter: saturate(.55) brightness(.92); }
.tile .badge { position: absolute; top: 6px; left: 6px; padding: 2px 7px; border-radius: 999px; background: var(--c-accent2); color: #fff; font: 700 10px var(--f-display); text-transform: uppercase; letter-spacing: .04em; }
.grid-wait .tile { opacity: 0; }
.grid-in .tile { animation: cardIn .32s cubic-bezier(.2,1.3,.4,1) both; animation-delay: calc(min(var(--d), 8) * 18ms); }
.sw-hint { font-size: 12px; color: var(--c-muted); white-space: nowrap; }
.swatches.idle .sw-label { opacity: .45; }
@keyframes cardIn { from { opacity: 0; transform: translate(var(--dx, 0px), 10px) scale(.92); } }
.fx-bounce { animation: bounce .45s cubic-bezier(.3,1.6,.5,1) !important; }
@keyframes bounce { 0% { transform: scale(.88); } 60% { transform: scale(1.07); } 100% { transform: scale(1); } }
.fx-pulse { animation: pulseOnce .4s ease !important; }
@keyframes pulseOnce { 50% { transform: scale(1.06); filter: brightness(1.1); } }
.fx-shake { animation: shake .4s ease; }
@keyframes shake { 20%,60% { transform: translateX(-6px); } 40%,80% { transform: translateX(6px); } }

.panel-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex: none; }
.progress { font-size: 12px; color: var(--c-muted); line-height: 1.2; }
.progress:empty { display: none; }
.foot-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
/* live style meter: bar with star marks that light (and pop) as the predicted score crosses them */
.meter { max-width: 260px; padding: 0 12px 0 2px; }
.meter-bar { position: relative; height: 22px; display: flex; align-items: center; }
.meter-track { position: relative; flex: 1; height: 10px; border-radius: 999px; overflow: hidden; background: color-mix(in srgb, var(--c-card-edge) 70%, transparent); box-shadow: inset 0 1px 2px rgba(0,0,0,.18); }
.meter-fill { position: absolute; inset: 0; transform-origin: left; transform: scaleX(.02); border-radius: inherit; background: linear-gradient(90deg, var(--c-accent2), var(--c-accent)); transition: transform .7s cubic-bezier(.3,1.25,.5,1); }
.meter-fill::after { content: ''; position: absolute; inset: 0; background: linear-gradient(100deg, transparent 30%, rgba(255,255,255,.55) 50%, transparent 70%) -200% 0 / 50% 100% no-repeat; animation: meterShine 2.6s ease-in-out infinite; }
@keyframes meterShine { 60%, 100% { background-position: 300% 0; } }
.meter-star { position: absolute; top: 50%; width: 24px; height: 24px; margin: -12px 0 0 -12px; display: grid; place-items: center; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2), inset 0 0 0 2px var(--c-card-edge); color: #cfc4da; transition: color .25s, box-shadow .25s; }
.meter-star .ico { width: 16px; height: 16px; }
.meter-star.on { color: var(--c-star); box-shadow: 0 1px 3px rgba(0,0,0,.2), inset 0 0 0 2px var(--c-star), 0 0 10px color-mix(in srgb, var(--c-star) 70%, transparent); }
.meter-star.pop { animation: meterStarPop .6s cubic-bezier(.2,1.8,.4,1) .25s both; }
@keyframes meterStarPop { 0% { transform: scale(1) rotate(0); } 45% { transform: scale(1.8) rotate(72deg); } 100% { transform: scale(1) rotate(144deg); } }
.meter.max .meter-fill { background: linear-gradient(90deg, var(--c-accent), var(--c-coin)); }
.coin-chip.spend { animation: spend .35s ease; }
@keyframes spend { 30% { transform: scale(.88); filter: saturate(.4); } }
.btn-done { margin-left: auto; opacity: .55; filter: saturate(.6); }
.btn-done { transition: opacity .3s, filter .3s; }
.btn-done.ready { opacity: 1; filter: none; animation: pulse 1.8s ease-in-out infinite; }
.btn-done.just-ready { animation: readyPop .6s cubic-bezier(.2,1.8,.4,1), pulse 1.8s .6s ease-in-out infinite; box-shadow: 0 5px 0 color-mix(in srgb, var(--c-accent) 62%, #000), 0 0 0 6px color-mix(in srgb, var(--c-accent) 30%, transparent), 0 10px 26px color-mix(in srgb, var(--c-accent) 55%, transparent); }
@keyframes readyPop { 0% { transform: scale(.9); } 50% { transform: scale(1.14); } 100% { transform: scale(1); } }

/* ---------- screens shared */
.screen { position: absolute; inset: 0; display: flex; padding: 20px; }
.card.pop-in, .pop-in { animation: popIn .5s cubic-bezier(.2,1.4,.4,1) both; }
@keyframes popIn { from { opacity: 0; transform: translateY(18px) scale(.94); } }
.eyebrow { font: 700 12px var(--f-display); letter-spacing: .14em; text-transform: uppercase; color: var(--c-accent2); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; justify-content: center; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.tag { padding: 5px 11px; border-radius: 999px; background: color-mix(in srgb, var(--c-accent) 14%, #fff); color: color-mix(in srgb, var(--c-accent) 75%, #000); font: 700 13px var(--f-display); }
.screens .card { background-color: var(--c-panel); backdrop-filter: blur(var(--blur)); -webkit-backdrop-filter: blur(var(--blur)); border-radius: var(--radius); box-shadow: 0 24px 60px rgba(0,0,0,.45), inset 0 0 0 2px var(--c-panel-edge); padding: 22px; display: grid; gap: 12px; justify-items: center; text-align: center; max-width: 440px; width: 100%; }
.avatar { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; color: #fff; font: 700 17px var(--f-display); box-shadow: 0 0 0 3px #fff, 0 4px 10px rgba(0,0,0,.2); object-fit: cover; flex: none; }

/* ---------- title */
.title { align-items: center; }
.title.logo-left { justify-content: flex-start; padding-left: 6vw; }
.title.logo-center { justify-content: center; align-items: flex-end; padding-bottom: 8vh; }
.title.logo-top { justify-content: center; align-items: flex-start; padding-top: 6vh; }
.app[data-orient="portrait"] .title { justify-content: center; align-items: flex-end; padding: 0 16px 7vh; }
/* portrait: the logo sits over the character's legs, so give it a stage-light scrim to read as intentional */
.app[data-orient="portrait"] .title::before { content: ''; position: absolute; inset: 45% 0 0; background: linear-gradient(180deg, transparent, color-mix(in srgb, var(--c-title-shadow) 55%, rgba(0,0,0,.55)) 55%); pointer-events: none; animation: fadeIn .8s both; }
.app[data-orient="portrait"] .title-block { position: relative; }
.title-block { display: grid; gap: 14px; justify-items: start; max-width: min(560px, 46vw); }
.title.logo-center .title-block, .title.logo-top .title-block, .app[data-orient="portrait"] .title-block { justify-items: center; text-align: center; max-width: 92vw; }
.title-badge { padding: 6px 14px; border-radius: 999px; background: var(--c-accent2); color: #fff; font: 700 14px var(--f-display); letter-spacing: .08em; text-transform: uppercase; box-shadow: 0 4px 0 color-mix(in srgb, var(--c-accent2) 60%, #000); animation: popIn .6s .1s both; }
.title-text { margin: 0; font: 400 calc(clamp(44px, 7.4vw, 104px) * var(--title-scale, 1))/var(--title-lh, .95) var(--f-title); color: var(--c-title); text-shadow: 0 4px 0 var(--c-title-shadow), 0 8px 0 color-mix(in srgb, var(--c-title-shadow) 70%, #000), 0 14px 30px rgba(0,0,0,.5); -webkit-text-stroke: 2px color-mix(in srgb, var(--c-title-shadow) 60%, #000); paint-order: stroke fill; letter-spacing: .01em; padding-bottom: calc((var(--title-lh, .95) - .95) * 1em); }
.app[data-orient="portrait"] .title-text { font-size: clamp(42px, 13vw, 84px); }
.ttl-word { display: inline-block; white-space: nowrap; margin-right: .22em; }
.ttl-word:last-child { margin-right: 0; }
.ttl-ch { display: inline-block; animation: letterIn .7s cubic-bezier(.2,1.6,.4,1) both, wave 3.2s ease-in-out infinite; animation-delay: calc(var(--i) * 45ms), calc(.8s + var(--i) * 90ms); }
@keyframes letterIn { from { opacity: 0; transform: translateY(-40px) rotate(-12deg) scale(.6); } }
@keyframes wave { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
.title-sub { font: 700 clamp(18px, 2.4vw, 28px) var(--f-display); color: #fff; text-shadow: 0 3px 10px rgba(0,0,0,.5); animation: popIn .6s .4s both; }
.title-block .btn { margin-top: 10px; animation: popIn .6s .6s both, pulse 1.6s 1.3s ease-in-out infinite; }
.title-foot { margin: 0; color: rgba(255,255,255,.75); font-size: 13px; }
.title-corner { position: absolute; top: 14px; right: 14px; }

/* ---------- brief */
.brief { align-items: center; justify-content: center; background: radial-gradient(ellipse at center, rgba(0,0,0,.15), rgba(0,0,0,.45)); }
.app[data-orient="portrait"] .brief { align-items: flex-end; padding-bottom: 3vh; }
.app[data-orient="landscape"] .brief { justify-content: flex-end; padding-right: 9vw; background: linear-gradient(90deg, rgba(0,0,0,0) 35%, rgba(0,0,0,.4)); }
.brief-title { margin: 0; font: 400 36px/1.1 var(--f-title); color: var(--c-ink); }
.brief-text { margin: 0; color: var(--c-muted); font-size: 16px; max-width: 34ch; }
.brief-judges { display: grid; gap: 8px; }
.brief-judge { display: grid; justify-items: center; gap: 4px; font-size: 12px; color: var(--c-muted); }

/* ---------- coins, result card header, veil emblem */
.judge-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; }
.coin-fly { position: fixed; z-index: 95; color: var(--c-coin); pointer-events: none; filter: drop-shadow(0 3px 4px rgba(0,0,0,.3)); }
.coin-chip.bump { animation: bump .3s cubic-bezier(.3,1.8,.5,1); }
@keyframes bump { 40% { transform: scale(1.18); } }
.veil .ico { position: absolute; left: 50%; top: 50%; width: 54px; height: 54px; margin: -27px 0 0 -27px; color: var(--c-star); opacity: 0; }
.veil.in .ico { animation: emblemIn var(--ms) ease forwards; }
.veil.out .ico { animation: emblemOut var(--ms) ease forwards; }
@keyframes emblemIn { from { opacity: 0; transform: scale(.4) rotate(-90deg); } to { opacity: 1; transform: scale(1) rotate(0); } }
@keyframes emblemOut { from { opacity: 1; transform: scale(1) rotate(0); } to { opacity: 0; transform: scale(1.6) rotate(90deg); } }

/* ---------- theme select */
.select { align-items: center; justify-content: center; }
.app[data-orient="landscape"] .select { padding-left: 22vw; }
.select-wrap { display: grid; gap: 14px; justify-items: center; width: min(760px, 100%); }
.select-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; flex-wrap: wrap; }
.select-title { margin: 0; font: 400 clamp(30px, 4vw, 46px)/1 var(--f-title); color: var(--c-title); -webkit-text-stroke: 1.5px color-mix(in srgb, var(--c-title-shadow) 60%, #000); paint-order: stroke fill; text-shadow: 0 3px 0 var(--c-title-shadow), 0 10px 24px rgba(0,0,0,.45); }
.star-chip { display: inline-flex; align-items: center; gap: 5px; padding: 5px 12px 5px 8px; border-radius: 999px; background: rgba(20,8,32,.6); color: #fff; font: 700 15px var(--f-display); box-shadow: inset 0 0 0 1.5px rgba(255,255,255,.25); }
.star-chip .ico { color: var(--c-star); } .star-chip span { opacity: .6; font-size: 13px; }
.star-chip em { font-style: normal; font-size: 11px; opacity: .7; text-transform: uppercase; letter-spacing: .05em; margin-left: 2px; }
.app[data-orient="portrait"] .star-chip em { display: none; }
.sel-grid { display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); gap: 14px; width: 100%; }
.sel-card { position: relative; aspect-ratio: 16 / 8; border-radius: var(--radius); background-size: cover; background-position: center 60%; overflow: hidden; text-align: left; box-shadow: 0 12px 28px rgba(0,0,0,.4), inset 0 0 0 3px rgba(255,255,255,.75); animation: selIn .55s cubic-bezier(.2,1.3,.4,1) both; animation-delay: calc(var(--i) * 70ms + 120ms); transition: transform .25s cubic-bezier(.3,1.5,.5,1), box-shadow .25s; }
@keyframes selIn { from { opacity: 0; transform: translateY(26px) scale(.92) rotate(-2deg); } }
.sel-card:hover { transform: translateY(-5px) rotate(-.6deg) scale(1.02); box-shadow: 0 20px 36px rgba(0,0,0,.45), inset 0 0 0 3px var(--c-accent); }
.sel-card:active { transform: scale(.97); }
.sel-shade { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(10,4,20,0) 30%, rgba(10,4,20,.82)); }
.sel-name { position: absolute; left: 16px; bottom: 30px; font: 400 clamp(22px, 2.6vw, 32px)/1 var(--f-title); color: #fff; text-shadow: 0 3px 0 rgba(0,0,0,.4); }
.sel-tags { position: absolute; left: 17px; right: 76px; bottom: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font: 700 12px var(--f-display); color: rgba(255,255,255,.8); }
.sel-stars { position: absolute; right: 12px; bottom: 10px; display: flex; gap: 2px; }
.sel-stars .star { color: rgba(255,255,255,.35); } .sel-stars .star.on { color: var(--c-star); animation: none; }
.sel-card.locked { filter: grayscale(.85) brightness(.75); cursor: not-allowed; }
.sel-lock { position: absolute; right: 12px; bottom: 10px; display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 999px; background: rgba(0,0,0,.6); color: #fff; font: 700 13px var(--f-display); }
.app[data-orient="portrait"] .sel-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
.app[data-orient="portrait"] .sel-card { aspect-ratio: 4 / 3; }
.app[data-orient="portrait"] .sel-name { bottom: 30px; left: 12px; }
.app[data-orient="portrait"] .sel-tags { left: 13px; right: 12px; bottom: 34px; display: none; }
.app[data-orient="portrait"] .sel-stars { left: 10px; right: auto; }
.app[data-orient="portrait"] .select { align-items: flex-start; padding-top: 7vh; }

/* ---------- judge */
.judging { align-items: center; }
.judge-landscape { justify-content: flex-end; padding-right: 5vw; }
.judge-portrait { justify-content: center; align-items: flex-end; padding-bottom: 12px; }
.judge-card { max-width: 420px; }
.judges { display: grid; gap: 10px; width: 100%; }
.judges .judge { display: flex; align-items: center; gap: 12px; padding: 8px 12px; border-radius: 16px; background: rgba(255,255,255,.65); opacity: .25; transform: translateX(16px); transition: all .4s cubic-bezier(.2,1.3,.4,1); text-align: left; }
.judges .judge.in { opacity: 1; transform: none; }
.j-body { flex: 1; min-width: 0; }
.j-name { font: 700 15px var(--f-display); }
.j-quote { margin: 0; font-size: max(13px, calc(12px / var(--ui, 1))); color: var(--c-muted); min-height: 1.3em; }
.j-score.landed { animation: scoreLand .4s cubic-bezier(.2,1.8,.4,1); }
@keyframes scoreLand { 40% { transform: scale(1.35); } }
.j-score { display: inline-block; font: 700 28px var(--f-display); color: var(--c-accent); min-width: 2.2em; text-align: right; font-variant-numeric: tabular-nums; }
.total { display: flex; align-items: baseline; gap: 10px; font: 700 16px var(--f-display); color: var(--c-muted); }
.total b { font-size: 40px; color: var(--c-ink); font-variant-numeric: tabular-nums; }
.stars { position: relative; display: flex; gap: 6px; }
.j-score.hi { color: #149a5a; } .j-score.mid { color: var(--c-ink); } .j-score.lo { color: color-mix(in srgb, #d9534f 75%, var(--c-ink)); }
/* rating stamp that slams onto the star row */
.total { position: relative; }
.rating-stamp { z-index: 2; position: absolute; left: calc(100% + 12px); top: 50%; margin-top: -16px; padding: 4px 12px; border-radius: 10px; white-space: nowrap; font: 400 18px var(--f-title); color: #fff; background: var(--c-accent2); box-shadow: 0 3px 0 color-mix(in srgb, var(--c-accent2) 60%, #000); transform: rotate(-8deg); animation: stampIn .45s cubic-bezier(.2,1.6,.4,1) both; }
.rating-stamp.r3 { background: linear-gradient(135deg, var(--c-accent), var(--c-star)); box-shadow: 0 3px 0 color-mix(in srgb, var(--c-accent) 60%, #000), 0 0 18px color-mix(in srgb, var(--c-star) 70%, transparent); }
.rating-stamp.r0 { background: var(--c-muted); box-shadow: 0 3px 0 color-mix(in srgb, var(--c-muted) 60%, #000); }
@keyframes stampIn { from { opacity: 0; transform: rotate(-24deg) scale(2.4); } 70% { opacity: 1; transform: rotate(-6deg) scale(.92); } }
.skip-hint { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); padding: 6px 14px; border-radius: 999px; background: rgba(0,0,0,.45); color: rgba(255,255,255,.85); font: 700 12px var(--f-display); letter-spacing: .04em; pointer-events: none; animation: fadeIn .4s 1.2s both, breathe 1.6s 1.6s ease-in-out infinite; }
@keyframes breathe { 50% { opacity: .55; } }
.star { color: rgba(0,0,0,.12); transition: color .2s; }
.star.on { color: var(--c-star); animation: starPop .5s cubic-bezier(.2,1.8,.4,1); filter: drop-shadow(0 4px 8px color-mix(in srgb, var(--c-star) 60%, transparent)); }
@keyframes starPop { from { transform: scale(.2) rotate(-40deg); } }
.reward { display: inline-flex; align-items: center; gap: 8px; padding: 8px 16px; border-radius: 999px; background: color-mix(in srgb, var(--c-coin) 25%, #fff); color: #7a4b00; font: 700 20px var(--f-display); }
.reward .ico { color: var(--c-coin); }
.actions { margin-top: 4px; }
.app[data-orient="portrait"] .judge-card { padding: 14px; gap: 8px; }
.app[data-orient="portrait"] .judges { grid-template-columns: repeat(3, 1fr); }
.app[data-orient="portrait"] .judges .judge { flex-direction: column; text-align: center; padding: 6px; }
.app[data-orient="portrait"] .j-quote { display: none; }

/* ---------- photo */
.photo { align-items: flex-end; justify-content: center; padding-bottom: 14px; }
.photo-dock { max-width: 640px !important; padding: 12px !important; grid-template-columns: minmax(0, 1fr); min-width: 0; }
.photo-dock > * { min-width: 0; max-width: 100%; }
.app[data-orient="landscape"] .photo { justify-content: flex-end; align-items: center; padding: 16px 4vw 16px 16px; }
.app[data-orient="landscape"] .photo-dock { max-width: 420px !important; }
.app[data-orient="landscape"] .photo-dock .row { flex-wrap: wrap; justify-content: center; }
.bg-strip { display: flex; gap: 8px; overflow-x: auto; max-width: 100%; padding: 4px; scrollbar-width: none; }
.bg-thumb { flex: none; width: 92px; height: 54px; border-radius: 12px; background-size: cover; background-position: center; box-shadow: inset 0 0 0 2px rgba(255,255,255,.6), 0 3px 8px rgba(0,0,0,.2); transition: transform .15s; }
.bg-thumb:hover { transform: translateY(-2px); }
.bg-thumb.on { box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--c-accent); }
.wipe-handle { position: absolute; top: 50%; width: 46px; height: 46px; margin: -23px 0 0 -23px; border-radius: 50%; background: #fff; box-shadow: 0 6px 18px rgba(0,0,0,.35); cursor: ew-resize; touch-action: none; }
.wipe-handle::before, .wipe-handle::after { content: ''; position: absolute; top: 50%; width: 0; height: 0; border: 7px solid transparent; margin-top: -7px; }
.wipe-handle::before { left: 6px; border-right-color: var(--c-accent2); }
.wipe-handle::after { right: 6px; border-left-color: var(--c-accent2); }
.wipe-labels { position: absolute; top: 14px; left: 14px; right: 14px; display: flex; justify-content: space-between; pointer-events: none; }
.wipe-labels span { padding: 6px 14px; border-radius: 999px; background: rgba(20,8,32,.7); color: #fff; font: 700 14px var(--f-display); }

/* ---------- versus, reactions, timer */
.name-tag { position: absolute; top: 14px; transform: translateX(-50%); padding: 6px 16px; border-radius: 999px; font: 700 15px var(--f-display); color: #fff; box-shadow: 0 4px 0 rgba(0,0,0,.25); animation: popIn .5s both; }
.name-tag.me { background: var(--c-accent); }
.name-tag.rival { background: var(--c-accent2); }
.timer { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); width: min(46%, 360px); height: 16px; border-radius: 999px; background: rgba(0,0,0,.35); box-shadow: inset 0 0 0 2px rgba(255,255,255,.5); overflow: hidden; }
.timer i { position: absolute; inset: 0; background: linear-gradient(90deg, var(--c-accent2), var(--c-accent)); transform-origin: left; }
.timer b { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); font: 700 11px var(--f-display); color: #fff; }
.timer.hurry i { animation: hurry .5s ease-in-out infinite alternate; }
@keyframes hurry { to { filter: brightness(1.4); } }
.app:has(.timer) .name-tag { top: 40px; }
.reactions { position: absolute; bottom: 8%; width: 84px; height: 80%; pointer-events: none; z-index: 2; }
.reactions-right { right: 10px; } .reactions-left { left: 64px; }
.react { position: absolute; bottom: 0; left: 50%; animation: floatUp 2.2s cubic-bezier(.2,.6,.4,1) forwards; filter: drop-shadow(0 3px 4px rgba(0,0,0,.3)); }
@keyframes floatUp { 0% { transform: translate(calc(-50% + var(--x)), 0) scale(.2) rotate(var(--r)); opacity: 0; } 12% { transform: translate(calc(-50% + var(--x)), -20px) scale(var(--s)) rotate(var(--r)); opacity: 1; } 100% { transform: translate(calc(-50% - var(--x)), -52vh) scale(calc(var(--s) * .8)) rotate(calc(var(--r) * -1)); opacity: 0; } }
.vs-head { display: flex; align-items: center; gap: 12px; font: 700 16px var(--f-display); }
.vs-head span:first-child { color: var(--c-accent); } .vs-head span:last-child { color: var(--c-accent2); }
.vs-head i { font-style: normal; font: 400 26px var(--f-title); color: var(--c-ink); }
.j-rival { color: var(--c-accent2); font-size: 20px; min-width: 2em; opacity: .85; }
.rival-total { font-style: normal; font-size: 16px; color: var(--c-accent2); }
.banner { font: 400 34px/1 var(--f-title); padding: 4px 18px 8px; border-radius: 14px; color: #fff; }
.banner.win { background: linear-gradient(180deg, color-mix(in srgb, var(--c-star) 80%, #fff), var(--c-accent)); text-shadow: 0 2px 0 rgba(0,0,0,.25); }
.banner.lose { background: var(--c-muted); }
.versus.judge-landscape { justify-content: center; padding-right: 20px; }
.versus .judge-card { max-width: 400px; }

/* ---------- photo: filters, flash, polaroid */
.filter-row { display: flex; gap: 6px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; max-width: 100%; padding: 2px; -webkit-mask-image: linear-gradient(90deg, #000 88%, transparent); mask-image: linear-gradient(90deg, #000 88%, transparent); }
.filter-row .chip { flex: none; }
.chip { min-height: 44px; padding: 8px 14px; border-radius: 999px; background: var(--c-tab); color: var(--c-tab-ink); font: 700 13px var(--f-display); transition: transform .15s, background .2s; }
.chip:hover { transform: translateY(-1px); }
.chip.on { background: var(--c-tab-active); color: var(--c-tab-active-ink); }
.stage-canvas { transition: filter .35s ease; }
.sticker-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(44px, 1fr)); gap: 6px; width: 100%; justify-items: center; }
.sticker-btn { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px; background: color-mix(in srgb, var(--c-accent2) 14%, #fff); transition: transform .15s cubic-bezier(.3,1.6,.5,1); }
.sticker-btn:hover { transform: rotate(-8deg) scale(1.12); }
.sticker-btn:active { transform: scale(.9); }
.flash { position: fixed; inset: 0; z-index: 90; background: #fff; pointer-events: none; animation: flash .65s ease-out forwards; }
@keyframes flash { 0% { opacity: 0; } 8% { opacity: .95; } 100% { opacity: 0; } }
.polaroid-modal { gap: 18px; align-content: center; background: rgba(8,3,16,.78); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); animation: fadeIn .25s ease both; }
.polaroid-modal.out { animation: fadeOut .25s ease forwards; }
@keyframes fadeIn { from { opacity: 0; } } @keyframes fadeOut { to { opacity: 0; } }
.polaroid { margin: 0; background: #fffdf8; padding: 14px 14px 0; border-radius: 6px; box-shadow: 0 30px 70px rgba(0,0,0,.55), 0 2px 0 rgba(0,0,0,.08); width: min(78vw, 46vh, 380px); transform: rotate(-3deg); animation: polaroidIn .8s cubic-bezier(.2,1.25,.35,1) both; }
@keyframes polaroidIn { 0% { transform: translateY(-60vh) rotate(-14deg); } 70% { transform: translateY(8px) rotate(-2deg); } 100% { transform: rotate(-3deg); } }
.polaroid img { display: block; width: 100%; aspect-ratio: 4 / 5; object-fit: cover; border-radius: 2px; background: #222; animation: develop 1.6s .4s ease both; }
@keyframes develop { from { filter: brightness(1.8) saturate(0) blur(2px); } }
.polaroid figcaption { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 2px 10px; padding: 12px 4px 16px; color: #2b2233; }
.polaroid figcaption b { font: 400 26px/1 var(--f-title); color: var(--c-ink); }
.polaroid figcaption span { font: 700 12px var(--f-display); color: var(--c-muted); grid-column: 1; }
.pol-stars { grid-row: 1 / span 2; grid-column: 2; display: flex; gap: 2px; font-size: 22px; }
.pol-stars .star { color: #ddd; } .pol-stars .star.on { color: var(--c-star); animation: none; filter: none; }
.btn-snap .ico { animation: none; }

/* ---------- modal, toast, ad stub */
.modal { position: absolute; inset: 0; z-index: 20; display: grid; place-items: center; background: rgba(10,4,20,.55); padding: 20px; }
.modal-card { position: relative; background-color: var(--c-panel); border-radius: var(--radius); padding: 22px; display: grid; gap: 12px; justify-items: center; min-width: 260px; box-shadow: 0 24px 60px rgba(0,0,0,.45); }
.modal-card h3 { margin: 0; font: 700 22px var(--f-display); }
.modal-thumb { width: 140px; height: 140px; border-radius: 20px; background: var(--c-card-active); display: grid; place-items: center; }
.modal-thumb img { width: 100%; height: 100%; object-fit: contain; }
.modal-x { position: absolute; top: 6px; right: 6px; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; font-size: 28px; line-height: 1; color: var(--c-muted); }
.modal-x:hover { background: color-mix(in srgb, var(--c-muted) 14%, transparent); }
.toast { position: absolute; left: 50%; top: 72px; zoom: var(--ui, 1); transform: translate(-50%, 20px); opacity: 0; padding: 10px 18px; border-radius: 999px; background: rgba(20,8,32,.88); color: #fff; font: 700 15px var(--f-display); transition: all .25s; z-index: 30; pointer-events: none; }
.toast { transform: translate(-50%, -20px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.ad-stub { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; background: rgba(0,0,0,.8); color: #fff; }
.ad-stub-card { display: grid; gap: 10px; justify-items: center; font: 700 18px var(--f-display); }
.ad-stub-bar { width: 220px; height: 8px; border-radius: 4px; background: rgba(255,255,255,.2); overflow: hidden; }
.ad-stub-bar i { display: block; height: 100%; background: var(--c-accent); animation: adbar 1.6s linear forwards; }
@keyframes adbar { from { width: 0; } to { width: 100%; } }

/* ---------- transitions (veil) */
.veil { position: absolute; inset: 0; z-index: 40; pointer-events: none; background: var(--veil, #000); opacity: 0; }
.veil.in { pointer-events: auto; }  /* opening never swallows a tap */
.veil[data-type="fade"].in { animation: vFadeIn var(--ms) ease forwards; }
.veil[data-type="fade"].out { animation: vFadeOut var(--ms) ease forwards; }
@keyframes vFadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes vFadeOut { from { opacity: 1; } to { opacity: 0; } }
.veil[data-type="iris"] { opacity: 1; clip-path: circle(0% at 50% 50%); }
.veil[data-type="iris"].in { animation: irisIn var(--ms) cubic-bezier(.6,0,.4,1) forwards; }
.veil[data-type="iris"].out { animation: irisOut var(--ms) cubic-bezier(.6,0,.4,1) forwards; }
@keyframes irisIn { from { clip-path: circle(0% at 50% 50%); } to { clip-path: circle(80% at 50% 50%); } }
@keyframes irisOut { from { clip-path: circle(80% at 50% 50%); } to { clip-path: circle(0% at 50% 50%); } }
.veil[data-type="curtain"] { opacity: 1; background: linear-gradient(90deg, var(--veil) 50%, transparent 50%), linear-gradient(270deg, var(--veil) 50%, transparent 50%); background-size: 0% 100%, 0% 100%; background-repeat: no-repeat; background-position: left, right; }
.veil[data-type="curtain"].in { animation: curtIn var(--ms) cubic-bezier(.6,0,.4,1) forwards; }
.veil[data-type="curtain"].out { animation: curtOut var(--ms) cubic-bezier(.6,0,.4,1) forwards; }
@keyframes curtIn { from { background-size: 0% 100%, 0% 100%; } to { background-size: 100% 100%, 100% 100%; } }
@keyframes curtOut { from { background-size: 100% 100%, 100% 100%; } to { background-size: 0% 100%, 0% 100%; } }
.veil[data-type="slide"] { opacity: 1; transform: translateX(-100%); }
.veil[data-type="slide"].in { animation: slideIn var(--ms) cubic-bezier(.6,0,.4,1) forwards; }
.veil[data-type="slide"].out { animation: slideOut var(--ms) cubic-bezier(.6,0,.4,1) forwards; }
@keyframes slideIn { from { transform: translateX(-100%); } to { transform: none; } }
@keyframes slideOut { from { transform: none; } to { transform: translateX(100%); } }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; } }

/* ---------- viewport scaling (--ui set by Game.applyLayout) */
.panel-area > *, .screens > *, .hud, .modal-card, .stage-overlay > .timer { zoom: var(--ui, 1); }
/* phones on their side: tabs move into a side rail so the grid keeps its height */
.app[data-short="1"] .panel-card { display: grid; grid-template-columns: 74px 1fr; grid-template-rows: auto 1fr auto; padding: 10px; gap: 8px; }
.app[data-short="1"] .panel-head, .app[data-short="1"] .panel-foot { grid-column: 1 / -1; }
.app[data-short="1"] .tabs, .app[data-short="1"] .tabs-wrap { display: flex; flex-direction: column; flex-wrap: nowrap; overflow-y: auto; overflow-x: hidden; gap: 6px; padding: 2px 2px 8px 0; -webkit-mask-image: linear-gradient(180deg, #000 85%, transparent); mask-image: linear-gradient(180deg, #000 85%, transparent); }
.app[data-short="1"] .tab { width: 66px; flex: none; }
.app[data-short="1"] .panel-head { min-height: 28px; }
/* small portrait phones: keep the grid tall enough to browse */
.app[data-tiny="1"] .panel-card .progress { display: none; }
.app[data-tiny="1"] .panel-head { min-height: 26px; }
.app[data-tiny="1"] .challenge-chip { font-size: 12px; }
.app[data-tiny="1"] .sw { width: 26px; height: 26px; }
.app[data-tiny="1"] .tab-ico { width: 32px; height: 32px; }
.app[data-tiny="1"] .tab { width: 54px; padding: 4px 2px; }

/* phones: every control at least 44px */
.app[data-orient="portrait"] .btn { min-height: 44px; }
.app[data-orient="portrait"] .tab { width: 56px; }
/* small phones: a compact photo dock so the figure keeps most of the screen */
.app[data-tiny="1"] .photo-dock { gap: 8px !important; padding: 8px !important; }
.app[data-orient="portrait"] .photo-dock .row { flex-wrap: nowrap; gap: 6px; }
.app[data-orient="portrait"] .photo-dock .btn { padding-left: 12px; padding-right: 12px; font-size: 14px; }
.app[data-orient="portrait"] .photo-dock .btn-lg { font-size: 15px; }
.app[data-orient="portrait"] .sticker-row { display: flex; overflow-x: auto; scrollbar-width: none; -webkit-mask-image: linear-gradient(90deg, #000 88%, transparent); mask-image: linear-gradient(90deg, #000 88%, transparent); }
.app[data-orient="portrait"] .sticker-btn { flex: none; }
.app[data-tiny="1"] .bg-thumb { height: 48px; }
.app[data-orient="portrait"] .photo-dock .row .btn-secondary:last-child span { display: none; }
.app[data-orient="portrait"] .photo-dock .row .btn-secondary:last-child { padding-left: 14px; padding-right: 14px; }

/* challenge brief over the dress-up stage */
.brief-pop { position: absolute; left: 50%; top: max(14px, env(safe-area-inset-top)); transform: translateX(-50%); z-index: 6; width: min(420px, calc(100% - 32px)); padding: 14px 18px; border-radius: var(--radius); background: color-mix(in srgb, var(--c-card) 94%, transparent); box-shadow: 0 10px 30px rgba(0,0,0,.25), inset 0 0 0 2px var(--c-card-edge); color: var(--c-ink); text-align: center; pointer-events: auto; animation: briefIn .5s cubic-bezier(.2,1.3,.4,1) both; }
.brief-pop p { margin: 4px 0 6px; font: 600 14px/1.35 var(--f-body); color: var(--c-muted); }
.brief-pop .tags { justify-content: center; }
.brief-pop-title { display: block; font: 700 22px var(--f-display); }
.brief-pop.gone { animation: briefOut .35s ease-in forwards; }
@keyframes briefIn { from { opacity: 0; transform: translate(-50%, 24px) scale(.92); } }
@keyframes briefOut { to { opacity: 0; transform: translate(-50%, 18px) scale(.96); } }
/* after an ad break the game resumes only on player input */
.ad-resume { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; border: 0; background: rgba(0,0,0,.55); color: #fff; font: 700 26px var(--f-display); cursor: pointer; }
.ad-resume span { padding: 16px 30px; border-radius: 999px; background: var(--c-accent); box-shadow: 0 8px 24px rgba(0,0,0,.35); animation: pulse 1.4s ease-in-out infinite; }

/* the theme picker with more than four themes */
.select-wrap:has(.sel-grid.many) { width: min(900px, 100%); max-height: 100%; }
/* landscape: the character stands at the left, so the grid takes the space to her right */
.app[data-orient="landscape"] .select:has(.sel-grid.many) { padding-left: 24vw; padding-right: 2vw; }
.sel-grid.many { gap: 12px; }
.sel-grid.many .sel-card { aspect-ratio: 4 / 3.2; }
.sel-grid.many .sel-name { font-size: clamp(17px, 1.9vw, 24px); }
.sel-grid.many .sel-tags { font-size: 10px; }
.app[data-orient="portrait"] .sel-grid.many { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.app[data-orient="portrait"] .sel-grid.many .sel-card { aspect-ratio: 1 / 1.05; }
.app[data-orient="portrait"] .sel-grid.many .sel-name { left: 8px; bottom: 24px; font-size: 15px; }
.app[data-orient="portrait"] .sel-grid.many .sel-tags { display: none; }
.app[data-orient="portrait"] .sel-grid.many .sel-stars { right: 6px; bottom: 6px; transform: scale(.8); transform-origin: right bottom; }
/* the corner sound/music buttons never sit on the header chips */
.select-head { padding-right: 56px; }

/* touch: small controls keep their look but get a 44px hit area (the UI scale shrinks them on small phones) */
.sw, .icon-btn, .chip, .sticker-btn, .bg-thumb, .tab { position: relative; }
.sw::after, .icon-btn::after, .chip::after, .sticker-btn::after, .bg-thumb::after { content: ''; position: absolute; left: 50%; top: 50%; width: max(100%, 44px); height: max(100%, 44px); transform: translate(-50%, -50%); }
.btn-done { min-height: 44px; }
/* the theme brief sits at the foot of the stage: her face and the HUD stay visible */
.brief-pop { top: auto; bottom: max(14px, env(safe-area-inset-bottom)); padding: 10px 16px; }
.brief-pop p { font-size: 13px; }
body { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }

/* items that suit the current theme */
.tile .fit-mark { position: absolute; right: 6px; bottom: 6px; width: 20px; height: 20px; display: grid; place-items: center; border-radius: 50%; background: var(--c-star); color: #fff; box-shadow: 0 2px 5px rgba(0,0,0,.2); }
.tile .fit-mark .ico { width: 12px; height: 12px; }
.judge-tip { display: flex; align-items: center; gap: 6px; margin-top: 6px; padding: 6px 10px; border-radius: 12px; background: color-mix(in srgb, var(--c-star) 18%, transparent); color: var(--c-ink); font: 700 max(13px, calc(12px / var(--ui, 1))) var(--f-display); animation: popIn .4s both; }

/* short landscape screens (phones sideways, 800x450 portal frames): the verdict card shrinks to fit */
@media (orientation: landscape) and (max-height: 500px) { .judge-card { zoom: .8; } .judging { align-items: center; }
  .judge-card .j-quote, .judge-card .judge-tip { font-size: max(13px, calc(12px / (var(--ui, 1) * .8))); }
  .judge-card .j-name { font-size: max(15px, calc(12px / (var(--ui, 1) * .8))); } }

.ib-music.off { opacity: .55; }
.ib-music.off::before { content: ''; position: absolute; left: 22%; right: 22%; top: 50%; height: 2.5px; border-radius: 2px; background: currentColor; transform: rotate(-45deg); }

/* short stages: the brief is just the theme name and its tags */
@media (max-height: 500px) { .brief-pop { width: min(300px, calc(100% - 32px)); padding: 7px 12px; } .brief-pop p, .brief-pop .eyebrow { display: none; } .brief-pop-title { font-size: 18px; } }

/* skin-tone picker */
.tile-skin .skin-dot { width: 62%; aspect-ratio: 1; border-radius: 50%; background: var(--tone); box-shadow: inset 0 -6px 12px rgba(0,0,0,.12), 0 3px 8px rgba(0,0,0,.15); }
.tile-skin .skin-dot.orig { background: conic-gradient(#ffe6d5, #e3a97f, #94603c, #ffe6d5); opacity: .55; }

/* the theme picker never traps its last row (Random) below a short landscape phone: it scrolls, and centres only
   while it fits ("safe" keeps the top reachable when it does not) */
.screen.select { overflow-y: auto; align-items: safe center; }
@media (orientation: landscape) and (max-height: 480px) {
  .sel-grid.many .sel-card { aspect-ratio: 16 / 9; }
  .sel-grid.many { gap: 8px; }
  .select-wrap { gap: 8px; }
}
