/* TimFOTF Card Simulator styles. Sections are marked with ==== for quick navigation (see docs/ui-and-css.md). */
:root {
  --bg: #07050d; --panel: #130d1f; --panel2: #1b1230; --line: #3a2a5c;
  --gold: #ffd76a; --gold2: #b8860b; --crimson: #d1142f; --purple: #7c3aed; --blue: #38bdf8;
  --text: #efe8ff; --dim: #a79cc4;
  --head: 'Metal Mania', 'Cinzel Decorative', 'Impact', 'Georgia', serif;
  --title: 'Cinzel', 'Georgia', 'Times New Roman', serif;
  --body: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--body); font-size: 15px; overflow-x: hidden; }
body { background: radial-gradient(1200px 700px at 70% -10%, #2a1050 0%, transparent 60%), radial-gradient(900px 600px at 0% 100%, #3a0612 0%, transparent 55%), var(--bg); background-attachment: fixed; }
button { font: inherit; color: inherit; cursor: pointer; }
h1, h2, h3 { margin: 0; font-family: var(--title); letter-spacing: .03em; }
.hide { display: none !important; }

/* ==== layout ==== */
#app { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
#nav { position: sticky; top: 0; height: 100vh; padding: 18px 12px; background: linear-gradient(180deg, #0e0818, #0a0612); border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; z-index: 20; }
.logo { font-family: var(--head); font-size: 25px; line-height: 1; color: var(--gold); text-shadow: 0 0 14px #ff9a1f66, 0 2px 0 #000; padding: 4px 8px 16px; cursor: pointer; }
.logo small { display: block; font-family: var(--title); font-size: 10px; letter-spacing: .3em; color: var(--dim); margin-top: 6px; text-shadow: none; }
.nav-btn { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid transparent; background: none; border-radius: 10px; text-align: left; color: var(--dim); font-family: var(--title); font-weight: 600; transition: .18s; }
.nav-btn .ic { font-size: 18px; width: 24px; text-align: center; }
.nav-btn:hover { background: #1d1233; color: var(--text); }
.nav-btn.on { background: linear-gradient(90deg, #3b1f6e, #1d1233); border-color: var(--purple); color: var(--gold); box-shadow: 0 0 18px #7c3aed44; }
.nav-btn .dot { margin-left: auto; background: var(--crimson); color: #fff; border-radius: 99px; font-size: 11px; padding: 1px 7px; }
.nav-foot { margin-top: auto; font-size: 11px; color: #6b5f8a; padding: 8px; line-height: 1.4; }
main { min-width: 0; padding-bottom: 40px; }
#topbar { position: sticky; top: 0; z-index: 15; display: flex; gap: 14px; align-items: center; padding: 10px 22px; background: #0a0612dd; backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.pill { display: flex; align-items: center; gap: 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 99px; padding: 6px 14px; font-weight: 700; white-space: nowrap; }
.pill.coins { color: var(--gold); box-shadow: inset 0 0 12px #ffd76a22; }
.pill.coins.bump { animation: bump .5s; }
@keyframes bump { 40% { transform: scale(1.14); box-shadow: 0 0 18px #ffd76a88; } }
.lvl { flex: 1; max-width: 300px; display: flex; flex-direction: column; gap: 4px; min-width: 120px; }
.lvl .t { font-size: 12px; color: var(--dim); display: flex; justify-content: space-between; }
.bar { height: 8px; border-radius: 9px; background: #1d1433; overflow: hidden; border: 1px solid #2c2050; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--purple), var(--blue)); border-radius: 9px; transition: width .6s; }
.bar.gold > i { background: linear-gradient(90deg, var(--gold2), var(--gold)); }
.icon-btn { background: var(--panel); border: 1px solid var(--line); border-radius: 50%; width: 38px; height: 38px; font-size: 17px; margin-left: auto; }
.icon-btn:hover { border-color: var(--gold); }
#screen { padding: 22px; max-width: 1280px; margin: 0 auto; animation: fadein .35s; }
@keyframes fadein { from { opacity: 0; transform: translateY(8px); } }
.h-row { display: flex; align-items: end; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.h-row h2 { font-size: 28px; color: var(--gold); text-shadow: 0 0 16px #ff9a1f44; }
.sub { color: var(--dim); font-size: 14px; margin-top: 4px; }

/* ==== generic ui ==== */
.panel { background: linear-gradient(180deg, var(--panel2), var(--panel)); border: 1px solid var(--line); border-radius: 16px; padding: 18px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.g3 { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.btn { border: 1px solid #5a3fa0; background: linear-gradient(180deg, #4a2a8c, #2c1760); border-radius: 10px; padding: 9px 16px; font-weight: 700; font-family: var(--title); color: #fff; transition: .15s; position: relative; }
.btn:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 6px 18px #7c3aed55; border-color: var(--gold); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .4; cursor: not-allowed; filter: grayscale(.6); }
.btn.gold { background: linear-gradient(180deg, #ffd76a, #b8860b); color: #2a1800; border-color: #ffe9a8; text-shadow: 0 1px 0 #fff6; }
.btn.red { background: linear-gradient(180deg, #e01a38, #8a0a1f); border-color: #ff6b81; }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--dim); }
.btn.big { padding: 14px 28px; font-size: 18px; }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.chip { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 99px; background: #241a3d; color: var(--dim); border: 1px solid var(--line); margin: 2px 3px 0 0; text-transform: uppercase; letter-spacing: .06em; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.tile .k { font-size: 12px; color: var(--dim); text-transform: uppercase; letter-spacing: .08em; }
.tile .v { font-family: var(--title); font-size: 26px; font-weight: 800; color: var(--gold); margin-top: 2px; }
input[type=text], input[type=search], select, textarea { background: #0d0816; border: 1px solid var(--line); border-radius: 10px; color: var(--text); padding: 9px 12px; font: inherit; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--purple); }
textarea { width: 100%; min-height: 90px; font-family: monospace; font-size: 12px; }
input[type=range] { accent-color: var(--gold); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.muted { color: var(--dim); }
.coin { color: var(--gold); font-weight: 700; }
.coin::before { content: '\1FA99'; margin-right: 4px; font-size: .9em; }

/* ==== toasts, modal ==== */
#toasts { position: fixed; right: 16px; top: 70px; z-index: 300; display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
.toast { pointer-events: auto; background: #120a22f2; border: 1px solid var(--gold2); border-left: 5px solid var(--gold); border-radius: 12px; padding: 10px 16px; max-width: 330px; box-shadow: 0 10px 30px #000a; animation: toastin .4s cubic-bezier(.2, 1.4, .4, 1); }
.toast.bad { border-color: #8a0a1f; border-left-color: var(--crimson); }
.toast.ach { border-left-color: #4ade80; }
.toast b { font-family: var(--title); color: var(--gold); display: block; }
.toast.out { opacity: 0; transform: translateX(40px); transition: .4s; }
@keyframes toastin { from { transform: translateX(80px) scale(.9); opacity: 0; } }
#modal { position: fixed; inset: 0; z-index: 200; background: #05030bcc; backdrop-filter: blur(6px); display: flex; align-items: center; justify-content: center; padding: 16px; animation: fadein .2s; overflow-y: auto; }
.modal-box { background: linear-gradient(180deg, #1d1232, #120a22); border: 1px solid var(--gold2); border-radius: 18px; padding: 22px; max-width: 880px; width: 100%; max-height: 92vh; overflow-y: auto; position: relative; box-shadow: 0 0 60px #7c3aed44; margin: auto; }
.modal-x { position: absolute; right: 12px; top: 10px; background: none; border: none; font-size: 24px; color: var(--dim); }

/* ==== splash / dashboard ==== */
#splash { position: fixed; inset: 0; z-index: 400; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; text-align: center; padding: 24px; background: radial-gradient(800px 500px at 50% 35%, #3d1170 0%, #0a0612 70%); }
#splash.out { opacity: 0; transition: opacity .6s; pointer-events: none; }
.splash-title { font-family: var(--head); font-size: clamp(44px, 9vw, 108px); line-height: .95; color: var(--gold); text-shadow: 0 0 40px #ff9a1faa, 0 4px 0 #000, 0 0 90px #d1142f99; animation: pulse 3s infinite; }
.splash-title span { display: block; font-family: var(--title); font-size: .22em; letter-spacing: .5em; color: #fff; text-shadow: none; margin-top: 12px; }
@keyframes pulse { 50% { filter: brightness(1.25); } }
.slogan { font-family: var(--title); font-style: italic; font-size: clamp(16px, 2.6vw, 24px); color: #ffe9b5; max-width: 780px; }
.splash-cards { display: flex; gap: 14px; justify-content: center; perspective: 900px; }
.splash-cards .card { width: clamp(70px, 14vw, 150px); }
.splash-cards .card:nth-child(1) { transform: rotate(-9deg) translateY(10px); } .splash-cards .card:nth-child(3) { transform: rotate(9deg) translateY(10px); }
.hero { position: relative; overflow: hidden; padding: 28px; border-radius: 20px; border: 1px solid var(--gold2); background: radial-gradient(600px 300px at 80% 0, #5b1fa855, transparent), linear-gradient(135deg, #1e0b36, #2a0710); margin-bottom: 18px; display: flex; gap: 24px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.hero h1 { font-family: var(--head); font-size: clamp(34px, 5vw, 58px); color: var(--gold); text-shadow: 0 0 24px #ff9a1f77; line-height: 1; }
.hero .slogan { margin: 10px 0 18px; font-size: 18px; }
.showcase { display: flex; gap: 10px; }
.showcase .card { width: 120px; }
.recent { display: flex; gap: 10px; flex-wrap: wrap; }
.recent .card { width: 82px; }
.tip { font-style: italic; color: var(--dim); }

/* ==== cards ==== */
.card { position: relative; width: 100%; aspect-ratio: var(--ar, .75); container-type: inline-size; perspective: 800px; user-select: none; -webkit-user-select: none; }
.card-inner { position: absolute; inset: 0; border-radius: 4.6cqw; overflow: hidden; background: #0b0710; transform-style: preserve-3d; transition: transform .25s ease-out, box-shadow .3s; box-shadow: 0 0 0 1px #000, 0 6px 18px #000a, 0 0 calc(var(--glow, 8) * 1px) var(--rc); }
.card.tilt .card-inner { transform: rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)); }
.card.tilt.hot .card-inner { transition: transform .06s linear, box-shadow .3s; }
.card.r-uncommon { --glow: 10; } .card.r-rare { --glow: 16; } .card.r-epic { --glow: 22; } .card.r-legendary { --glow: 30; } .card.r-mythic { --glow: 36; } .card.r-ultra { --glow: 44; } .card.r-secret { --glow: 52; }
.card.r-secret .card-inner { animation: rainbowglow 4s linear infinite; }
@keyframes rainbowglow { 0% { box-shadow: 0 0 0 1px #000, 0 0 50px #ff2d4d; } 25% { box-shadow: 0 0 0 1px #000, 0 0 50px #ffe14a; } 50% { box-shadow: 0 0 0 1px #000, 0 0 50px #4ade80; } 75% { box-shadow: 0 0 0 1px #000, 0 0 50px #38bdf8; } 100% { box-shadow: 0 0 0 1px #000, 0 0 50px #ff2d4d; } }
.card.r-legendary .card-inner, .card.r-mythic .card-inner, .card.r-ultra .card-inner { animation: glowpulse 2.6s ease-in-out infinite; }
@keyframes glowpulse { 50% { box-shadow: 0 0 0 1px #000, 0 6px 18px #000a, 0 0 60px var(--rc); } }
.card img.orig { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; pointer-events: none; }
.frame { position: absolute; inset: 0; background: linear-gradient(160deg, #3a2a0a, #120a02 40%, #2c1f06); border: 2.4cqw solid transparent; border-image: linear-gradient(135deg, #fff1b0, #b8860b 40%, #ffe27a 60%, #8a5d08) 1; box-shadow: inset 0 0 0 .6cqw #000; }
.frame .art { position: absolute; left: 2.2cqw; right: 2.2cqw; top: 2.2cqw; height: 61%; border: .8cqw solid #000; border-radius: 2cqw; overflow: hidden; box-shadow: 0 0 0 .5cqw var(--rc); }
.frame .art svg { width: 100%; height: 100%; display: block; }
.nameplate { position: absolute; left: 1.4cqw; right: 1.4cqw; top: 59%; height: 14%; display: flex; align-items: center; justify-content: center; text-align: center; background: linear-gradient(180deg, #00000000, #000000cc 35%, #000000cc 80%, #00000000); padding: 0 3cqw; }
.nameplate span { font-family: var(--head); font-size: 8.4cqw; line-height: .95; color: #ffe9a8; text-shadow: 0 .5cqw 0 #000, 0 0 3cqw #ff9a1f88; text-wrap: balance; letter-spacing: .02em; }
.nameplate.ln span { font-size: 6.4cqw; }
.badge { position: absolute; left: 50%; top: 72.5%; transform: translateX(-50%); padding: .4cqw 6cqw; font-family: var(--title); font-weight: 800; font-size: 4cqw; letter-spacing: .15em; text-transform: uppercase; color: #fff; background: linear-gradient(180deg, color-mix(in srgb, var(--rc) 70%, #fff 0%), color-mix(in srgb, var(--rc) 35%, #000)); border: .5cqw solid #fff8; border-radius: 1.5cqw; text-shadow: 0 .3cqw 0 #000a; white-space: nowrap; }
.r-secret .badge { background: linear-gradient(90deg, #ff2d4d, #ffb020, #4ade80, #38bdf8, #b05cff); }
.r-common .badge, .r-secret .badge { color: #111; text-shadow: none; }
.textbox { position: absolute; left: 4cqw; right: 4cqw; bottom: 3.4cqw; height: 17%; display: flex; align-items: center; justify-content: center; text-align: center; background: linear-gradient(180deg, #f1e0b4, #d9c08a); border: .6cqw solid #6b4a12; border-radius: 3cqw; padding: 0 3cqw; }
.textbox span { font-family: 'Georgia', serif; font-size: 5cqw; line-height: 1.12; color: #2a1a05; font-weight: 600; text-wrap: balance; }
.locked-face .nameplate span { color: #5b4f7a; font-size: 9cqw; } .locked-face .textbox { background: #1a1428; border-color: #2c2050; } .locked-face .textbox { color: #5b4f7a; font-size: 4.5cqw; }
.card.locked .card-inner { box-shadow: 0 0 0 1px #000; animation: none; filter: saturate(.6); }
.count { position: absolute; right: 2.5cqw; top: 2.5cqw; background: #000c; color: var(--gold); border: 1px solid var(--gold2); border-radius: 99px; padding: .4cqw 3cqw; font-weight: 800; font-size: 5.5cqw; z-index: 6; }
.vtag { position: absolute; left: 2.5cqw; top: 2.5cqw; z-index: 6; font-size: 3.6cqw; font-weight: 800; letter-spacing: .12em; padding: .5cqw 2.4cqw; border-radius: 1.5cqw; color: #000; background: #fff; }
.v-shiny .vtag { background: linear-gradient(90deg, #fff1a8, #ffd76a); } .v-holo .vtag { background: linear-gradient(90deg, #ff9ae8, #8ee7ff, #b6ff9a); } .v-corrupted .vtag { background: #ff2d4d; color: #fff; animation: flick 1.2s steps(2) infinite; }
@keyframes flick { 50% { opacity: .6; transform: translateX(.6cqw); } }
.fx-holo, .fx-shine, .fx-glitch { position: absolute; inset: 0; pointer-events: none; opacity: 0; z-index: 4; border-radius: inherit; }
.v-holo .fx-holo, .r-ultra .fx-holo, .r-secret .fx-holo { opacity: .5; mix-blend-mode: color-dodge; background: repeating-linear-gradient(115deg, #ff5ce1 0%, #38bdf8 12%, #4ade80 24%, #ffe14a 36%, #ff5ce1 48%); background-size: 260% 260%; background-position: calc(var(--mx, 50) * 1%) calc(var(--my, 50) * 1%); filter: saturate(1.3); }
.r-ultra:not(.v-holo) .fx-holo, .r-secret:not(.v-holo) .fx-holo { opacity: .22; }
.v-holo .fx-shine { opacity: .5; background: radial-gradient(circle at calc(var(--mx, 50) * 1%) calc(var(--my, 50) * 1%), #fff9, transparent 45%); mix-blend-mode: overlay; }
.v-shiny .fx-shine { opacity: 1; background: linear-gradient(115deg, transparent 35%, #fff9 48%, #ffe9a899 52%, transparent 65%), radial-gradient(circle at 20% 30%, #fff 0 1px, transparent 2px), radial-gradient(circle at 70% 60%, #fff 0 1px, transparent 2px), radial-gradient(circle at 40% 80%, #fff 0 1.5px, transparent 3px), radial-gradient(circle at 85% 20%, #fff 0 1.5px, transparent 3px); background-size: 250% 100%, 100% 100%, 100% 100%, 100% 100%, 100% 100%; background-position: 160% 0, 0 0, 0 0, 0 0, 0 0; mix-blend-mode: screen; animation: sweep 3.2s ease-in-out infinite; }
@keyframes sweep { 0% { background-position: 160% 0, 0 0, 0 0, 0 0, 0 0; } 60%, 100% { background-position: -60% 0, 0 0, 0 0, 0 0, 0 0; } }
.v-shiny .card-inner { filter: saturate(1.15) brightness(1.06); }
.v-corrupted .fx-glitch { opacity: 1; background: repeating-linear-gradient(0deg, #0000 0 2px, #00000055 2px 3px), linear-gradient(90deg, #ff005533, transparent 30%, #00ffff22 70%, transparent); mix-blend-mode: multiply; animation: glitchbar 2.2s steps(1) infinite; }
.v-corrupted .card-inner { animation: corrupt 3.1s steps(1) infinite; filter: contrast(1.15) saturate(1.2); }
@keyframes corrupt { 0%, 90%, 100% { transform: none; filter: contrast(1.15) saturate(1.2); } 91% { filter: hue-rotate(90deg) contrast(1.5); clip-path: inset(0 0 55% 0); } 93% { filter: hue-rotate(-60deg) invert(.15); clip-path: inset(40% 0 0 0); } 95% { filter: none; clip-path: inset(0); } 97% { filter: hue-rotate(180deg); clip-path: inset(20% 0 40% 0); } }
@keyframes glitchbar { 0%, 100% { background-position: 0 0, 0 0; } 50% { background-position: 0 3px, 30px 0; } }

/* card grids */
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; align-items: start; }
.cell { cursor: pointer; display: flex; flex-direction: column; gap: 6px; }
.cell .cn { font-size: 12px; text-align: center; color: var(--dim); min-height: 1.3em; }
.cell:hover .cn { color: var(--gold); }

/* ==== shop ==== */
.pack { position: relative; width: 190px; aspect-ratio: 190 / 290; filter: drop-shadow(0 12px 18px #000c); }
.pack-body { position: absolute; inset: 14px 0; border-radius: 6px; background: linear-gradient(160deg, var(--p2), var(--p1) 70%); border: 3px solid #ffffff55; overflow: hidden; }
.pack-art { position: absolute; inset: 0; width: 100%; height: 100%; opacity: .85; mix-blend-mode: screen; }
.pack-top, .pack-bottom { position: absolute; left: 0; right: 0; height: 18px; background: repeating-linear-gradient(90deg, var(--p2) 0 6px, var(--p1) 6px 12px); border-radius: 3px; box-shadow: 0 0 0 2px #0008; z-index: 3; }
.pack-top { top: 0; } .pack-bottom { bottom: 0; }
.pack-label { position: absolute; left: 0; right: 0; bottom: 10%; text-align: center; padding: 8px; background: linear-gradient(180deg, #0000, #000c 30%, #000c 70%, #0000); z-index: 2; }
.pack-label b { display: block; font-family: var(--head); font-size: 28px; color: var(--gold); text-shadow: 0 2px 0 #000, 0 0 12px #ff9a1f; letter-spacing: .06em; }
.pack-label span { font-family: var(--title); font-size: 12px; font-weight: 700; color: #fff; text-transform: uppercase; letter-spacing: .08em; }
.pack-shine { position: absolute; inset: 0; z-index: 4; pointer-events: none; background: linear-gradient(115deg, transparent 40%, #fff5 50%, transparent 60%); background-size: 250% 100%; animation: sweep2 4s ease-in-out infinite; mix-blend-mode: overlay; border-radius: 6px; }
@keyframes sweep2 { 0% { background-position: 160% 0; } 60%, 100% { background-position: -60% 0; } }
.pack-card { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.pack-card .info { flex: 1; min-width: 220px; }
.odds { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; font-size: 12px; margin: 8px 0; }
.odds b { font-weight: 600; text-align: right; }
.pack.sm { width: 110px; }
.pack.sm .pack-label b { font-size: 15px; } .pack.sm .pack-label span { font-size: 7px; }
.pack.hover:hover { transform: translateY(-6px) rotate(-1.5deg); transition: .2s; }

/* ==== pack opening ==== */
.stage { position: relative; min-height: 560px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; border-radius: 22px; padding: 24px 10px; overflow: hidden; background: radial-gradient(700px 400px at 50% 40%, #2b1250, #0a0612 75%); border: 1px solid var(--line); transition: background 1s; }
.stage.dramatic { background: radial-gradient(500px 500px at 50% 45%, color-mix(in srgb, var(--stage-c) 55%, #000), #000 75%); }
.stage .spot { position: absolute; inset: 0; pointer-events: none; opacity: 0; background: conic-gradient(from 0deg at 50% 45%, transparent, var(--stage-c, #fff) 5%, transparent 10%, transparent 20%, var(--stage-c, #fff) 25%, transparent 30%, transparent 45%, var(--stage-c, #fff) 50%, transparent 55%, transparent 70%, var(--stage-c, #fff) 75%, transparent 80%); mix-blend-mode: screen; }
.stage.dramatic .spot { opacity: .28; animation: spin 6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.pack-wrap { display: flex; flex-direction: column; align-items: center; gap: 20px; z-index: 2; }
.pack-wrap .pack { width: min(250px, 60vw); animation: floaty 3s ease-in-out infinite; cursor: pointer; }
@keyframes floaty { 50% { transform: translateY(-10px) rotate(1deg); } }
.pack.shaking { animation: pshake .08s linear infinite !important; filter: drop-shadow(0 0 40px #ffd76a); }
@keyframes pshake { 25% { transform: translate(-6px, 2px) rotate(-3deg); } 75% { transform: translate(6px, -2px) rotate(3deg); } }
.pack.tearing .pack-top { transition: transform .6s cubic-bezier(.3, 0, .8, 1), opacity .6s; transform: translateY(-160px) rotate(-28deg); opacity: 0; }
.pack.tearing .pack-body { transition: opacity .5s .2s, transform .6s .2s; opacity: 0; transform: scale(1.3); }
.pack.tearing .pack-bottom { transition: transform .6s, opacity .6s; transform: translateY(120px) rotate(18deg); opacity: 0; }
#flash { position: fixed; inset: 0; background: #fff; opacity: 0; pointer-events: none; z-index: 150; }
#flash.go { animation: flash .7s ease-out; }
@keyframes flash { 0% { opacity: .95; } 100% { opacity: 0; } }
body.shake #app { animation: shake .6s; }
@keyframes shake { 10%, 90% { transform: translate(-2px, 1px); } 20%, 80% { transform: translate(4px, -3px); } 30%, 50%, 70% { transform: translate(-8px, 4px); } 40%, 60% { transform: translate(8px, -4px); } }
.reveal-row { display: flex; flex-wrap: wrap; gap: 16px; justify-content: center; z-index: 2; perspective: 1200px; }
.flipcard { width: clamp(118px, 17vw, 176px); aspect-ratio: .745; cursor: pointer; position: relative; animation: dealin .55s cubic-bezier(.2, 1.2, .4, 1) backwards; }
@keyframes dealin { from { transform: translateY(-120px) scale(.4) rotate(-12deg); opacity: 0; } }
.flip-inner { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform .6s cubic-bezier(.3, 1.3, .5, 1); }
.flipcard.flipped .flip-inner { transform: rotateY(180deg); }
.flipcard .ff { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; display: flex; align-items: center; justify-content: center; }
.flipcard .ff.front { transform: rotateY(180deg); }
.flipcard .ff.front .card { width: 100%; max-height: 100%; }
.flipcard .ff.front .card .card-inner { position: absolute; }
.flipcard.charging .flip-inner { animation: charge .12s linear infinite; }
@keyframes charge { 25% { transform: translate(-3px, 1px) rotate(-1deg); } 75% { transform: translate(3px, -1px) rotate(1deg); } }
.flipcard.charging::after { content: ''; position: absolute; inset: -20px; background: radial-gradient(closest-side, var(--hint, #fff) 0, transparent 100%); opacity: .6; z-index: -1; animation: grow .9s ease-in; }
@keyframes grow { from { transform: scale(.2); opacity: 0; } }
.flipcard .new { position: absolute; top: -10px; left: 50%; transform: translateX(-50%); background: var(--crimson); color: #fff; font-weight: 800; font-size: 11px; padding: 2px 10px; border-radius: 99px; z-index: 10; letter-spacing: .1em; box-shadow: 0 0 14px var(--crimson); }
.card-back { width: 100%; height: 100%; border-radius: 12px; padding: 7px; background: linear-gradient(135deg, #fff1b0, #b8860b 50%, #8a5d08); box-shadow: 0 8px 20px #000a; }
.cb-inner { width: 100%; height: 100%; border-radius: 7px; background: radial-gradient(circle at 50% 40%, #4a1b8c, #12061f); display: flex; align-items: center; justify-content: center; border: 2px solid #000; }
.cb-inner svg { width: 82%; }
.card-back.hint-epic, .card-back.hint-legendary, .card-back.hint-mythic, .card-back.hint-ultra, .card-back.hint-secret { animation: hint 1s ease-in-out infinite; }
@keyframes hint { 50% { box-shadow: 0 0 30px var(--hint, #fff), 0 8px 20px #000a; } }
.banner { position: absolute; top: 14px; left: 0; right: 0; text-align: center; z-index: 5; font-family: var(--head); font-size: clamp(34px, 7vw, 76px); color: var(--bc, #fff); text-shadow: 0 0 30px var(--bc), 0 4px 0 #000; animation: bannerin 1.8s ease-out forwards; pointer-events: none; }
@keyframes bannerin { 0% { transform: scale(2.4); opacity: 0; } 15% { transform: scale(1); opacity: 1; } 80% { opacity: 1; } 100% { transform: scale(1.1); opacity: 0; } }
.stage-ctl { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; z-index: 2; min-height: 48px; }
.summary { z-index: 2; text-align: center; }

/* ==== binder ==== */
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.filters input[type=search] { flex: 1; min-width: 180px; }
.rar-chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.rchip { border: 1px solid var(--line); border-left: 4px solid var(--rc); border-radius: 8px; background: var(--panel); padding: 4px 10px; font-size: 12px; }
.modal-card { display: grid; grid-template-columns: minmax(200px, 340px) 1fr; gap: 24px; align-items: start; }
.modal-card .card { max-width: 340px; width: 100%; }
@media (max-width: 700px) { .modal-card { grid-template-columns: 1fr; justify-items: center; } }
.vrow { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.vbtn { border: 1px solid var(--line); background: var(--panel); border-radius: 9px; padding: 6px 10px; font-size: 13px; }
.vbtn.on { border-color: var(--gold); color: var(--gold); box-shadow: 0 0 12px #ffd76a44; }
.vbtn.none { opacity: .35; }

/* ==== market ==== */
.npc-say { display: flex; gap: 14px; align-items: center; padding: 14px 18px; margin-bottom: 16px; border-left: 5px solid var(--nc, var(--gold)); }
.npc-say .av { font-size: 40px; }
.npc-say .q { font-style: italic; font-size: 17px; }
.offer { display: flex; flex-direction: column; gap: 10px; border-top: 4px solid var(--nc); }
.offer .who { display: flex; gap: 10px; align-items: center; }
.offer .who .av { font-size: 32px; }
.offer .who b { font-family: var(--title); font-size: 17px; }
.sides { display: grid; grid-template-columns: 1fr 24px 1fr; gap: 8px; align-items: center; }
.side { background: #0d0816; border: 1px solid var(--line); border-radius: 12px; padding: 8px; min-height: 120px; display: flex; flex-direction: column; gap: 6px; align-items: center; justify-content: center; text-align: center; }
.side .lab { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--dim); }
.side .card { width: 84px; }
.warn { color: #ff8a8a; font-size: 12px; }
.wait { text-align: center; padding: 30px 10px; color: var(--dim); }
.npc-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; }
.npc-list .tile { border-left: 4px solid var(--nc); }

/* ==== achievements, stats ==== */
.ach { display: flex; gap: 12px; align-items: center; opacity: .5; filter: grayscale(.8); }
.ach.done { opacity: 1; filter: none; border-color: #3a7a4f; background: linear-gradient(90deg, #12301f, var(--panel)); }
.ach .ic { font-size: 30px; width: 46px; text-align: center; }
.ach b { font-family: var(--title); display: block; }
.ach small { color: var(--dim); }
.ach .rw { margin-left: auto; text-align: right; white-space: nowrap; font-size: 13px; }
.barrow { display: grid; grid-template-columns: 110px 1fr 70px; gap: 10px; align-items: center; margin: 6px 0; font-size: 13px; }
.barrow .bar > i { background: var(--rc); }

/* ==== mobile ==== */
@media (max-width: 900px) {
  #app { grid-template-columns: 1fr; }
  #nav { position: fixed; top: auto; bottom: 0; left: 0; right: 0; height: auto; flex-direction: row; overflow-x: auto; padding: 6px; border-right: none; border-top: 1px solid var(--line); gap: 2px; }
  .logo, .nav-foot { display: none; }
  .nav-btn { flex-direction: column; gap: 2px; padding: 6px 10px; font-size: 10px; min-width: 62px; text-align: center; }
  main { padding-bottom: 80px; }
  #topbar { padding: 8px 12px; gap: 8px; flex-wrap: wrap; } .lvl { order: 5; max-width: none; flex-basis: 100%; }
  #screen { padding: 14px; } .h-row h2 { font-size: 22px; }
  #toasts { top: 56px; right: 8px; left: 8px; } .toast { max-width: none; }
  .sides { grid-template-columns: 1fr; } .sides .arrow { transform: rotate(90deg); text-align: center; }
  .stage { min-height: 480px; }
  .nav-btn .dot { position: absolute; margin: 0; transform: translate(14px, -10px); }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; } }
body.nomotion .card.tilt .card-inner { transform: none !important; }
#fx { position: fixed; inset: 0; pointer-events: none; z-index: 250; }
@media (max-width: 600px) { .showcase { flex-wrap: wrap; } .showcase .card { width: 74px; } .hero { padding: 18px; } }
/* ==== easter eggs and calls ==== */
.canrain { position: fixed; top: -60px; z-index: 260; pointer-events: none; animation: canfall 3.2s linear forwards; }
@keyframes canfall { to { transform: translateY(115vh) rotate(540deg); } }
@keyframes ring { 25% { transform: rotate(-18deg); } 75% { transform: rotate(18deg); } }
a.btn { text-decoration: none; display: inline-block; }
.panel a { color: var(--gold); }
a.nav-btn { text-decoration: none; }
/* ==== chat with tim ==== */
.chat-wrap { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(260px, 1fr); gap: 16px; align-items: start; }
@media (max-width: 900px) { .chat-wrap { grid-template-columns: 1fr; } }
.chat { display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.chat-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); background: #150d26; }
.av.big { width: 42px; height: 42px; font-size: 24px; }
.av { width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg, #4a2a8c, #d1142f); display: flex; align-items: center; justify-content: center; flex: none; font-size: 18px; }
.chatlog { height: 420px; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; background: #0d0816; }
.msg { display: flex; gap: 8px; align-items: flex-end; max-width: 85%; animation: fadein .25s; }
.msg.me { align-self: flex-end; flex-direction: row-reverse; }
.bub { padding: 8px 13px; border-radius: 16px; background: #2a1d4a; line-height: 1.35; word-break: break-word; }
.msg.me .bub { background: linear-gradient(180deg, #5b34b5, #3c2180); border-bottom-right-radius: 4px; }
.msg.tim .bub { border-bottom-left-radius: 4px; }
.bub.act { background: transparent; border: 1px dashed var(--line); color: var(--dim); font-style: italic; }
.typing { padding: 2px 16px 8px; font-size: 13px; color: var(--dim); background: #0d0816; }
.typing span { animation: blink 1.2s infinite; } .typing span:nth-child(2) { animation-delay: .2s; } .typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 50% { opacity: .15; } }
.chips { display: flex; gap: 6px; flex-wrap: wrap; padding: 8px 12px; border-top: 1px solid var(--line); background: #110a1e; }
.btn-chip { cursor: pointer; } .btn-chip:hover { border-color: var(--gold); color: var(--gold); }
.chat-in { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); background: #150d26; }
.chat-in input { flex: 1; min-width: 0; }
.lore .tl { border-left: 3px solid var(--purple); padding-left: 10px; margin: 10px 0; }

/* ==== polish: themes, background, volume, graphics ==== */
#bg { position: fixed; inset: 0; z-index: 0; pointer-events: none; }
#app { position: relative; z-index: 1; }
body[data-theme=crimson] { --gold: #ff7a8a; --gold2: #a30f2d; --purple: #d1142f; --line: #5c2230; --panel2: #231018; --panel: #170a10; }
body[data-theme=purple] { --gold: #d9b3ff; --gold2: #6d28d9; --purple: #a855f7; --line: #4a2f7a; }
body[data-theme=blue] { --gold: #8fe3ff; --gold2: #0b7bb5; --purple: #2aa7e0; --line: #1f4a6e; --panel2: #0f1c30; --panel: #0a1424; }
body[data-theme=rogue] { --gold: #7dff6a; --gold2: #1f9d2f; --purple: #22c55e; --line: #1f5a32; --panel2: #0f2418; --panel: #0a1a10; }
body[data-theme=crimson] .btn.gold, body[data-theme=purple] .btn.gold, body[data-theme=blue] .btn.gold, body[data-theme=rogue] .btn.gold { background: linear-gradient(180deg, var(--gold), var(--gold2)); color: #12091f; }
.card-inner { box-shadow: 0 0 0 1px #000, 0 6px 18px #000a, 0 0 calc(var(--glow, 8) * var(--glowm, 1) * 1px) var(--rc); }
body.noholo .fx-holo, body.noholo .fx-shine { display: none !important; }
body.noflash #flash { display: none !important; }
body.q-low * { animation-duration: 0.01ms !important; }
body.q-low .card.r-legendary .card-inner, body.q-low .card.r-mythic .card-inner, body.q-low .card.r-ultra .card-inner, body.q-low .card.r-secret .card-inner { animation: none; }
body.q-low .pack-shine, body.q-low .fx-glitch { display: none; }
.volbox { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.volbox .icon-btn { margin-left: 0; width: 34px; height: 34px; }
input.vol { -webkit-appearance: none; appearance: none; width: 110px; height: 6px; border-radius: 6px; background: linear-gradient(90deg, var(--gold), #3a2a5c); outline-offset: 4px; cursor: pointer; }
input.vol::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: var(--gold); border: 2px solid #12091f; box-shadow: 0 0 8px var(--gold); }
input.vol::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--gold); border: 2px solid #12091f; }
.setgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.setgrid label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--dim); }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 6px; }
::selection { background: var(--purple); color: #fff; }
* { scrollbar-width: thin; scrollbar-color: #3a2a5c transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; } ::-webkit-scrollbar-thumb { background: #3a2a5c; border-radius: 8px; } ::-webkit-scrollbar-track { background: transparent; }
.cell { transition: transform .2s ease; } .cell:hover { transform: translateY(-4px); }
.btn { text-shadow: 0 1px 0 #0006; }
@media (max-width: 900px) { input.vol { width: 80px; } .volbox { margin-left: 0; } }
/* ==== logo ==== */
.logo { display: flex; align-items: center; gap: 10px; }
.logo-img { width: 44px; height: 44px; flex: none; image-rendering: auto; filter: drop-shadow(0 0 8px #7c3aed88); }
.logo span { display: block; }
.av img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.splash-logo { width: 70px; height: 70px; filter: drop-shadow(0 0 18px #7c3aedaa); margin-bottom: -6px; }
/* ==== shame ==== */
.pill.shame { background: #3a0a17; border-color: #ff2d4d; color: #ff8a9b; animation: shamepulse 2s infinite; }
@keyframes shamepulse { 50% { box-shadow: 0 0 14px #ff2d4d99; } }
.shame-banner { background: repeating-linear-gradient(135deg, #3a0a17, #3a0a17 14px, #2a0711 14px, #2a0711 28px); border: 1px solid #ff2d4d; color: #ffb3bf; border-radius: 12px; padding: 10px 16px; margin-bottom: 14px; text-align: center; font-family: var(--title); font-weight: 700; }
/* ==== music player (top bar) ==== */
.musicbox { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.musicbox + .volbox { margin-left: 0; }
#songsel { max-width: 165px; font-size: 12px; padding: 6px 8px; border-radius: 9px; }
.icon-btn.sm { width: 32px; height: 32px; font-size: 13px; margin-left: 0; line-height: 1; }
.icon-btn.on { border-color: var(--gold); color: var(--gold); box-shadow: 0 0 10px #ffd76a44; }
.np { font-size: 12px; color: var(--dim); max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 1100px) { .np { display: none; } }
@media (max-width: 900px) { .musicbox { margin-left: 0; } #songsel { max-width: 120px; } }
/* ==== tim's town ==== */
.town-wrap { max-width: 980px; margin: 0 auto; }
#town { width: 100%; display: block; image-rendering: pixelated; image-rendering: crisp-edges; border: 2px solid var(--line); border-radius: 12px; background: #000; touch-action: none; outline: none; box-shadow: 0 0 40px #7c3aed33; }
.town-hud { display: flex; gap: 14px; flex-wrap: wrap; align-items: end; margin-bottom: 8px; }
.town-hud .tb { min-width: 150px; flex: 1; font-size: 13px; display: flex; flex-direction: column; gap: 3px; }
.town-hud .tb:last-child { flex-direction: row; justify-content: space-between; align-items: center; flex: 1.2; }
.bar.low > i { background: linear-gradient(90deg, #ff2d4d, #ff8a3d); }
.town-prompt { margin: 8px 0; text-align: center; font-family: var(--title); color: var(--gold); min-height: 1.4em; }
.town-pad { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin: 6px 0 12px; }
.dpad { display: grid; grid-template-columns: repeat(3, 46px); grid-template-rows: repeat(3, 46px); gap: 4px; }
.dpad button { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; color: var(--text); font-size: 18px; touch-action: none; user-select: none; }
.dpad button:active { background: var(--purple); }
.dpad [data-dir=up] { grid-column: 2; grid-row: 1; } .dpad [data-dir=left] { grid-column: 1; grid-row: 2; } .dpad [data-dir=down] { grid-column: 2; grid-row: 3; } .dpad [data-dir=right] { grid-column: 3; grid-row: 2; }
@media (hover: hover) and (pointer: fine) { .dpad { opacity: .45; } }
/* ==== quests, wardrobe ==== */
.quest { display: flex; gap: 12px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin: 8px 0; }
.quest.claimed { opacity: .55; border-color: #3a7a4f; }
.swatch { height: 22px; border-radius: 6px; margin: 8px 0 2px; background: linear-gradient(90deg, var(--s) 0 70%, var(--a) 70% 100%); border: 1px solid #0006; }
.hudic { width: 16px; height: 16px; image-rendering: pixelated; vertical-align: -3px; }
/* wardrobe previews: frame 0 (facing down) of the walk sheet at 2x */
.outfit-prev { width: 64px; height: 96px; margin: 8px auto 4px; background-repeat: no-repeat; background-size: 256px 384px; background-position: 0 0; image-rendering: pixelated; }
.outfit-prev.locked { filter: brightness(0) opacity(.5); }
/* wardrobe previews: frame 0 (facing down) of the walk sheet at 2x */
.outfit-prev { width: 64px; height: 96px; margin: 8px auto 4px; background-repeat: no-repeat; background-size: 256px 384px; background-position: 0 0; image-rendering: pixelated; }
.outfit-prev.locked { filter: brightness(0) opacity(.5); }

/* ---- Accessibility ---- */
.sr-only { position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: -999px; top: 8px; z-index: 1000; background: #fff; color: #000; padding: 12px 18px; border-radius: 8px; font-weight: 700; }
.skip:focus { left: 8px; }
#captions { position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 400; display: grid; gap: 6px; justify-items: center; width: min(92vw, 640px); pointer-events: none; }
#captions .cap { background: #000e; color: #fff; border: 1px solid #fff6; border-radius: 8px; padding: 8px 14px; font-size: 16px; font-weight: 600; text-align: center; }
.icon-btn.cc { font-size: 12px; font-weight: 800; letter-spacing: .04em; min-width: 40px; }
.icon-btn.cc[aria-pressed="true"] { background: var(--gold); color: #000; }
button, [role="button"], .nav-btn, .btn { min-height: 40px; }
:focus-visible { outline: 3px solid #fff; outline-offset: 2px; box-shadow: 0 0 0 5px #000; }
body.a11y-hc { --bg: #000; --text: #fff; --dim: #e6e6e6; --muted: #e0e0e0; --gold: #ffe14d; }
body.a11y-hc .muted, body.a11y-hc .sub, body.a11y-hc small { color: #e6e6e6 !important; }
body.a11y-hc .panel, body.a11y-hc .tile, body.a11y-hc .toast, body.a11y-hc .modal-box, body.a11y-hc .pill, body.a11y-hc .btn, body.a11y-hc .nav-btn { background: #000 !important; border: 2px solid #fff !important; color: #fff !important; box-shadow: none !important; }
body.a11y-hc .btn.gold, body.a11y-hc [aria-pressed="true"] { background: #ffe14d !important; color: #000 !important; }
body.a11y-hc #bg, body.a11y-hc #fx { display: none; }
body.a11y-hc * { text-shadow: none !important; }
@media (forced-colors: active) { .panel, .tile, .btn, .nav-btn, .toast, .pill { border: 1px solid CanvasText; } #bg, #fx { display: none; } }
