:root {
	--blue: #2f66c8; --blue-d: #1a3c84; --blue-l: #5a9cff; --gold: #ffcf3a; --gold-d: #e89a10; --ink: #10182a; --red: #e8443a; --green: #4cc44a;
	--font: 'Barlow SC', Arial, sans-serif; --head: 'Russo One', 'Barlow SC', Arial, sans-serif;
	--st: env(safe-area-inset-top); --sb: env(safe-area-inset-bottom);
}
#ui { position: fixed; inset: 0; pointer-events: none; font-family: var(--font); color: #fff; z-index: 10; }
#ui > * { pointer-events: auto; }
#ui .hud { pointer-events: none; }
#ui button, .btn { font-family: var(--font); }
.ico { display: inline-block; width: 1.2em; height: 1.2em; vertical-align: -0.25em; }
.ico svg, .crown svg, .lock svg { width: 100%; height: 100%; display: block; }
.prank svg, .arange svg, .avg svg, .damt svg, .price svg, .frank svg { width: 1.1em; height: 1.1em; vertical-align: -0.2em; }
.outline { text-shadow: 0 2px 0 #0008, 1px 1px 0 #0008, -1px 1px 0 #0008; }

/* Buttons */
.btn { position: relative; border: 3px solid var(--ink); border-radius: 12px; padding: 10px 20px; font-size: 18px; font-weight: 800; color: #fff; cursor: pointer;
	text-shadow: 0 2px 0 #0009, 1px 0 0 #0006, -1px 0 0 #0006; box-shadow: inset 0 -5px 0 #0003, inset 0 3px 0 #fff5, 0 4px 0 var(--ink); transition: transform 0.08s, filter 0.1s; touch-action: manipulation; }
.btn:active { transform: translateY(3px); box-shadow: inset 0 -3px 0 #0003, inset 0 3px 0 #fff5, 0 1px 0 var(--ink); }
.btn.gold { background: linear-gradient(#ffe066, var(--gold) 45%, var(--gold-d)); }
.btn.blue { background: linear-gradient(#7ab8ff, var(--blue) 50%, var(--blue-d)); }
.btn.green { background: linear-gradient(#8ae87a, var(--green) 50%, #2a8a2a); }
.btn.red { background: linear-gradient(#ff8a7a, var(--red) 50%, #a0201a); }
.btn.grey { background: linear-gradient(#c8ccd8, #8a90a0 50%, #5a6070); }
.btn.off { filter: grayscale(1) brightness(0.75); cursor: default; }
.btn.poor .price { color: #ffb0b0; }
.btn.big { font-size: 24px; padding: 12px 40px; }
.btn.huge { font-size: 30px; padding: 14px 56px; font-family: var(--head); font-weight: 400; letter-spacing: 0.03em; }
.btn.round { width: 44px; height: 44px; padding: 0; border-radius: 50%; background: linear-gradient(#7ab8ff, var(--blue) 55%, var(--blue-d)); display: grid; place-items: center; }
.btn.round svg { width: 60%; height: 60%; }
.price { display: block; font-size: 14px; margin-top: 2px; }
.deny { animation: deny 0.38s; }
@keyframes deny { 0%, 100% { transform: translateX(0); } 15% { transform: translateX(-9px) rotate(-3deg); } 35% { transform: translateX(8px) rotate(3deg); } 55% { transform: translateX(-6px); } 75% { transform: translateX(4px); } }

/* Cards */
.card { position: relative; width: 100%; aspect-ratio: 4 / 5; border-radius: 10px; border: 3px solid #1a2238; box-sizing: border-box; overflow: hidden;
	background: linear-gradient(#5a6ad0, #2a2a6a); box-shadow: 0 3px 0 #0006, inset 0 0 0 2px #fff6; }
.card.r-rare { background: linear-gradient(#ffb04a, #b8501a); }
.card.r-epic { background: linear-gradient(#b070e8, #3a1a6a); }
.card .art { position: absolute; inset: 4% 4% 18% 4%; background: center 40% / contain no-repeat; filter: drop-shadow(0 3px 2px #0006); }
.card .cost { position: absolute; left: -2px; top: -2px; width: 34%; aspect-ratio: 24 / 28; }
.card .cost svg { width: 100%; height: 100%; display: block; }
.card .cost b { position: absolute; inset: 18% 0 0 0; display: grid; place-items: center; font-size: clamp(12px, 2.4vmin, 20px); font-weight: 800; text-shadow: 0 2px 0 #000a; }
.card .name { position: absolute; left: 0; right: 0; bottom: 3%; text-align: center; font-size: clamp(9px, 1.7vmin, 13px); font-weight: 800; text-shadow: 0 1px 0 #000a, 0 0 4px #0008; white-space: nowrap; overflow: hidden; }
.card.k-building .name { background: linear-gradient(#0000, #6a4a2acc); }
.card.k-strike .name { background: linear-gradient(#0000, #a02020cc); }
.card.k-area .name { background: linear-gradient(#0000, #208a5acc); }
.card .lvl { position: absolute; right: 4px; top: 4px; background: #000a; border-radius: 6px; padding: 1px 5px; font-size: clamp(9px, 1.6vmin, 12px); font-weight: 800; }
.card.locked { filter: grayscale(1) brightness(0.7); }
.card .lock { position: absolute; left: 50%; top: 45%; width: 40%; transform: translate(-50%, -50%); filter: drop-shadow(0 2px 2px #000); }
.card.empty { background: #0003; border: 3px dashed #fff4; box-shadow: none; }
.card .canup { position: absolute; right: 4px; bottom: 18%; background: var(--green); border: 2px solid var(--ink); border-radius: 50%; width: 22px; height: 22px; display: grid; place-items: center; font-size: 12px; animation: bob 1s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-3px); } }
.card.flying { position: fixed; z-index: 50; pointer-events: none; }

/* Menu */
.menu { position: absolute; inset: 0; display: flex; flex-direction: column; background: linear-gradient(#1a2c5acc, #0e1a38ee 30%, #0e1a38ee 70%, #1a2c5add); }
.topbar { display: flex; align-items: center; gap: 10px; padding: calc(8px + var(--st)) 12px 8px; background: linear-gradient(#2f66c8, #1a3c84); border-bottom: 3px solid var(--ink); box-shadow: 0 3px 0 #0005; }
.topbar .who { flex: 1; min-width: 0; padding-left: max(0px, var(--pokiback, 0px)); }
.pname { font-family: var(--head); font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-shadow: 0 2px 0 #0008; }
.prank { font-size: 15px; font-weight: 800; color: var(--gold); }
.xpbox { display: flex; align-items: center; gap: 6px; background: #0007; border: 2px solid #0009; border-radius: 20px; padding: 4px 14px 4px 6px; font-size: 18px; font-weight: 800; }
.xpbox .ico { width: 26px; height: 26px; }
.pages { flex: 1; display: flex; min-height: 0; transition: transform 0.3s cubic-bezier(0.3, 0.9, 0.4, 1); }
.page { position: relative; flex: 0 0 100%; min-width: 0; display: flex; flex-direction: column; align-items: center; padding: 12px 12px calc(var(--tabh, 64px) + 8px); box-sizing: border-box; overflow: hidden; }
.page > * { width: 100%; max-width: 520px; }
.scroll { overflow-y: auto; touch-action: pan-y; -webkit-overflow-scrolling: touch; scrollbar-width: thin; }
.ptitle { font-family: var(--head); font-size: 22px; text-align: center; margin: 4px 0 10px; text-shadow: 0 3px 0 #0008; }
.tabs { position: absolute; left: 0; right: 0; bottom: 0; z-index: 3; display: flex; background: linear-gradient(#24427e, #13254d); border-top: 3px solid var(--ink); padding-bottom: var(--sb); }
.tab { flex: 1; background: none; border: 0; border-right: 2px solid #0005; color: #cfe0ff; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 6px; font-size: 13px; font-weight: 800; cursor: pointer; transition: flex 0.2s, background 0.2s; position: relative; }
.tab .ico { width: 30px; height: 30px; transition: transform 0.2s; }
.tab span { text-shadow: 0 2px 0 #0008; }
.tab.on { flex: 1.5; background: linear-gradient(#4a86e8, #2a5ab8); color: #fff; }
.tab.on .ico { transform: translateY(-8px) scale(1.3); }
.tab.alert::after { content: '!'; position: absolute; top: 4px; right: 18%; width: 18px; height: 18px; border-radius: 50%; background: var(--red); border: 2px solid var(--ink); font-size: 12px; display: grid; place-items: center; }

/* Play */
/* The league list runs the full page height, under the deck and Battle buttons and the tab bar; its padding lets the last league scroll clear of them. */
.p-play { padding-bottom: 0; }
.p-play > .ptitle { position: absolute; left: 0; right: 0; top: 0; max-width: none; z-index: 2; margin: 0; padding: 14px 0 18px; pointer-events: none; background: linear-gradient(#0e1a38e0 55%, #0e1a3800); }
.p-play .arenas { position: absolute; left: 0; right: 0; top: 0; bottom: 0; max-width: none; display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 56px 12px calc(var(--tabh, 64px) + var(--footh, 150px) + 12px); box-sizing: border-box; }
.p-play .arenas > * { width: 100%; max-width: 520px; }
.arena { position: relative; flex: 0 0 auto; height: 120px; border-radius: 16px; border: 3px solid var(--ink); display: flex; align-items: center; gap: 14px; padding: 0 16px; overflow: hidden; cursor: pointer; box-shadow: 0 4px 0 #0007; }
.arena::before { content: ''; position: absolute; inset: 0; background: repeating-linear-gradient(45deg, #fff1 0 12px, #0000 12px 24px); }
.a-greenkeep { background: linear-gradient(135deg, #7fc44a, #3f8a2a 60%, #2a6ab0); }
.a-frostmarch { background: linear-gradient(135deg, #e8f2ff, #8ab0d8 60%, #3a6aa0); }
.a-ashfall { background: linear-gradient(135deg, #ff7a2a, #7a2a1a 55%, #2a1414); }
.arena.cur { outline: 4px solid var(--gold); outline-offset: -1px; box-shadow: 0 0 24px #ffcf3a88, 0 4px 0 #0007; }
.arena.locked { filter: grayscale(0.8) brightness(0.6); }
.anum { position: relative; font-family: var(--head); font-size: 44px; color: #fff; text-shadow: 0 3px 0 #0009; width: 40px; text-align: center; }
.atext { position: relative; flex: 1; }
.aname { font-family: var(--head); font-size: 24px; text-shadow: 0 3px 0 #0009; }
.arange { font-weight: 800; font-size: 16px; text-shadow: 0 2px 0 #0009; }
.alock { position: relative; width: 36px; height: 36px; }
.aneed { position: absolute; right: 12px; bottom: 8px; font-size: 13px; font-weight: 800; text-shadow: 0 2px 0 #000; }
.abadge { position: relative; background: var(--gold); color: var(--ink); border: 2px solid var(--ink); border-radius: 8px; padding: 2px 8px; font-weight: 800; font-size: 13px; }
.playfoot { position: absolute; left: 0; right: 0; bottom: var(--tabh, 64px); max-width: none; z-index: 2; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 26px 0 10px; pointer-events: none; background: linear-gradient(#0e1a3800, #0e1a38c0 45%); }
.playfoot > * { pointer-events: auto; }
.deckpick { display: flex; align-items: center; gap: 10px; padding: 6px 12px; background: linear-gradient(#5a7ab8, #2a4a88); }
.deckpick .mini, .deckrow .mini { display: flex; gap: 4px; }
.deckpick .card, .deckrow .card { width: 34px; border-width: 2px; border-radius: 6px; }
.deckpick .card .cost, .deckrow .card .cost { display: none; }
.dlabel { font-weight: 800; font-size: 16px; }

/* Cards page */
.decktabs { display: flex; gap: 6px; }
.decktab { flex: 1; padding: 6px 0; font-size: 15px; background: linear-gradient(#5a6a90, #3a4a70); }
.decktab.on { background: linear-gradient(#ffe066, var(--gold) 50%, var(--gold-d)); color: #fff; }
.deckcol { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.decktab { width: 100%; padding-left: 4px; padding-right: 4px; }
.decktab .dname { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.decktab.partial::after { content: ''; position: absolute; top: -7px; left: 50%; margin-left: -6px; width: 12px; height: 12px; border-radius: 50%; background: #b04aff; border: 2px solid var(--ink); box-shadow: 0 0 6px #b04aff; }
.btn.deckedit { width: 30px; height: 30px; }
.rename { position: relative; }
.deckgrid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-top: 10px; padding: 8px; background: #0005; border-radius: 12px; border: 2px solid #0008; box-sizing: border-box; }
.deckinfo { display: flex; justify-content: space-between; align-items: center; margin: 8px 0 4px; }
.ctitle { font-family: var(--head); font-size: 18px; text-shadow: 0 2px 0 #0008; }
.avg { font-weight: 800; font-size: 15px; }
.collection { flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; align-content: start; padding: 4px 2px 12px; }
.cell { cursor: pointer; }
.cell .card:active { transform: scale(0.95); }

/* Popups */
.backdrop { position: absolute; inset: 0; background: #0009; display: grid; place-items: center; z-index: 30; animation: fade 0.18s; }
.backdrop.out { opacity: 0; transition: opacity 0.18s; }
@keyframes fade { from { opacity: 0; } }
.popup { width: min(92vw, 400px); max-height: 88vh; overflow-y: auto; background: linear-gradient(#3a72d8, #1e428e); border: 4px solid var(--ink); border-radius: 18px; padding: 16px; box-sizing: border-box; box-shadow: 0 8px 0 #0008, inset 0 2px 0 #fff4; animation: pop 0.22s cubic-bezier(0.3, 1.5, 0.5, 1); }
@keyframes pop { from { transform: scale(0.6); opacity: 0; } }
.btnrow { display: flex; gap: 10px; justify-content: center; margin-top: 14px; flex-wrap: wrap; }
.btnrow .btn { flex: 1; min-width: 110px; }
.deckrow { display: flex; align-items: center; gap: 10px; padding: 8px; margin: 6px 0; border-radius: 12px; background: #0004; border: 2px solid #0008; cursor: pointer; }
.deckrow.on { background: #ffcf3a44; border-color: var(--gold); }
.deckrow.partial { opacity: 0.5; filter: grayscale(0.6); cursor: not-allowed; }
.deckrow .avg { margin-left: auto; }
.cardpop { position: relative; }
.btn.closex { position: absolute; top: 8px; right: 8px; width: 40px; height: 40px; z-index: 2; background: linear-gradient(#ff8a7a, var(--red) 55%, #a0201a); }
.cardpop .bigcard { width: 46%; margin: 0 auto 10px; }
.cardpop .bigcard .card .cost b { font-size: 24px; }
.cardpop .bigcard .card .name { font-size: 16px; }
.cardpop .bigcard .card .lvl { font-size: 14px; }
.cdesc { text-align: center; font-size: 15px; font-weight: 600; margin-bottom: 10px; color: #dfeaff; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.stat { background: #0004; border-radius: 8px; padding: 5px 8px; display: flex; flex-direction: column; }
.stat .sk { font-size: 12px; color: #bcd0f0; font-weight: 600; }
.stat b { font-size: 16px; }
.plus { color: #8aff7a; font-style: normal; }
.maxed { font-family: var(--head); color: var(--gold); padding: 10px; }
input.text { width: 100%; box-sizing: border-box; font: 800 22px var(--font); padding: 10px 12px; border-radius: 10px; border: 3px solid var(--ink); text-align: center; color: var(--ink); }
.slider { display: flex; align-items: center; gap: 12px; margin: 10px 0; font-weight: 800; font-size: 17px; }
.slider span { width: 80px; }
.slider input[type=range] { flex: 1; accent-color: var(--gold); }

/* Rewards */
.daily { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 8px; padding-bottom: 12px; }
.day { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 14px; background: linear-gradient(#3a5a9a, #23407a); border: 3px solid var(--ink); box-shadow: 0 3px 0 #0006; min-height: 44px; }
.day .ico { width: 34px; height: 34px; }
.dname { font-family: var(--head); font-size: 17px; width: 70px; }
.damt { flex: 1; font-weight: 800; font-size: 18px; }
.day.done { filter: brightness(0.6); }
.day.today { background: linear-gradient(#ffd96a, #e8a020); color: var(--ink); animation: glow 1.4s ease-in-out infinite; }
.day.today .dname, .day.today .damt { color: #fff; text-shadow: 0 2px 0 #0008; }
.day.big .ico { width: 44px; height: 44px; }
@keyframes glow { 50% { box-shadow: 0 0 22px #ffcf3a, 0 3px 0 #0006; } }
.check { font-size: 26px; color: #8aff7a; text-shadow: 0 2px 0 #000; }
.later { font-weight: 800; color: #cfe0ff; }
.soon { margin: auto; font-family: var(--head); font-size: 34px; text-align: center; color: var(--gold); text-shadow: 0 4px 0 #6b4a00, 0 8px 18px #000a; animation: bob 2s ease-in-out infinite; }

/* Friends */
.me { display: flex; flex-direction: column; align-items: center; gap: 6px; background: #0004; border: 3px solid #0008; border-radius: 16px; padding: 12px; box-sizing: border-box; }
.namerow { display: flex; align-items: center; gap: 10px; }
.namerow .fname { font-family: var(--head); font-size: 24px; text-shadow: 0 3px 0 #0008; }
.btn.edit { width: 36px; height: 36px; }
.frank { font-weight: 800; color: var(--gold); }
.fid { font-size: 14px; color: #bcd0f0; font-weight: 600; }
.loginname { font-size: 14px; font-weight: 700; color: #8aff7a; }
.fhead { display: flex; justify-content: space-between; align-items: center; margin: 12px 0 6px; }
.fhead .btn { padding: 6px 14px; font-size: 15px; }
.friends { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 6px; padding-bottom: 12px; }
.friend { display: grid; grid-template-columns: 1fr auto auto; grid-template-rows: auto auto; column-gap: 10px; align-items: center; padding: 8px 10px; border-radius: 12px; background: #2a4a8a; border: 2px solid var(--ink); }
.friend .fname { font-weight: 800; font-size: 17px; }
.friend .fid { grid-row: 2; }
.friend .fstatus { grid-row: 1 / 3; grid-column: 2; font-size: 13px; color: #9aaccc; font-weight: 700; }
.friend .xbtn { grid-row: 1 / 3; grid-column: 3; width: 36px; height: 36px; background: linear-gradient(#ff8a7a, var(--red) 55%, #a0201a); }
.friends .empty { text-align: center; color: #9aaccc; font-weight: 700; padding: 18px; }

/* Matchmaking and VS */
.search { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; background: radial-gradient(#2f5fb3ee, #0e1a38f5); }
.stitle { font-family: var(--head); font-size: 24px; text-align: center; text-shadow: 0 3px 0 #0008; padding: 0 16px; }
.sstatus { font-weight: 700; color: #cfe0ff; min-height: 20px; }
.ssecs { font-family: var(--head); font-size: 40px; color: var(--gold); }
.spinner { width: 70px; height: 70px; border-radius: 50%; border: 8px solid #fff3; border-top-color: var(--gold); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.vs { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px; background: linear-gradient(170deg, #c8303acc 0 49.5%, #1a1a1a 49.5% 50.5%, #2f66c8cc 50.5%); transition: opacity 0.4s; z-index: 25; }
.vs.out { opacity: 0; }
.vsname { font-family: var(--head); font-size: 32px; text-shadow: 0 4px 0 #0009; animation: slide-l 0.4s cubic-bezier(0.3, 1.4, 0.5, 1) both; }
.vsname.blue { animation-name: slide-r; }
.vsmid { font-family: var(--head); font-size: 72px; color: var(--gold); text-shadow: 0 5px 0 #6b4a00, 0 10px 20px #000; animation: pop 0.5s 0.2s cubic-bezier(0.3, 1.6, 0.5, 1) both; }
@keyframes slide-l { from { transform: translateX(-120vw); } }
@keyframes slide-r { from { transform: translateX(120vw); } }

/* Battle HUD */
.hud { position: absolute; inset: 0; }
.hud-top { position: absolute; left: 0; right: 0; top: 0; display: flex; align-items: flex-start; gap: 8px; padding: calc(6px + var(--st)) 8px 0; pointer-events: none; }
.hud-top .btn { pointer-events: auto; }
.plate { background: linear-gradient(#0009, #0006); border: 2px solid #0008; border-radius: 12px; padding: 4px 10px; }
.plate.foe { flex: 1; max-width: 260px; margin-left: var(--pokiback, 0px); }
.plate.foe .pname { color: #ffb0a8; font-size: 15px; }
.plate.foe .prank { font-size: 13px; }
.crowns { display: flex; gap: 2px; }
.crown { width: 24px; height: 20px; color: #0006; transition: color 0.2s; }
.crowns.red .crown.on { color: #ff4a3a; filter: drop-shadow(0 0 4px #ff4a3a); }
.crowns.blue .crown.on { color: #3aa0ff; filter: drop-shadow(0 0 4px #3aa0ff); }
.crown.pop { animation: crownpop 0.4s cubic-bezier(0.3, 1.8, 0.5, 1); }
@keyframes crownpop { from { transform: scale(2.6); } }
.clock { position: relative; width: 74px; height: 74px; margin-left: auto; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.clock .ring { position: absolute; inset: 0; border-radius: 50%; background: conic-gradient(#ffcf3a calc(var(--p, 1) * 360deg), #0007 0); -webkit-mask: radial-gradient(circle, #0000 60%, #000 61%); mask: radial-gradient(circle, #0000 60%, #000 61%); }
.clock::before { content: ''; position: absolute; inset: 6px; border-radius: 50%; background: #000a; }
.clabel { position: relative; font-size: 10px; font-weight: 700; color: #cfe0ff; text-transform: uppercase; }
.ctime { position: relative; font-family: var(--head); font-size: 20px; text-shadow: 0 2px 0 #000; }
.clock.boost .ring { background: conic-gradient(#e83cd8 calc(var(--p, 1) * 360deg), #0007 0); }
.clock.ot .ring { background: conic-gradient(#ff7a1a calc(var(--p, 1) * 360deg), #0007 0); }
.clock.ot .ctime { color: #ffb070; }
.clock.final .ctime { color: #ff5a4a; animation: tick 1s infinite; }
@keyframes tick { 0% { transform: scale(1.25); } 30% { transform: scale(1); } }
.btn.menu { width: 40px; height: 40px; display: flex; flex-direction: column; gap: 4px; justify-content: center; align-items: center; }
.btn.menu span { display: block; width: 18px; height: 3px; border-radius: 2px; background: #fff; box-shadow: 0 1px 0 #0008; }
.hud-bottom { position: absolute; left: 50%; bottom: 0; transform: translateX(-50%); width: min(100%, 520px); padding: 0 6px calc(6px + var(--sb)); box-sizing: border-box; pointer-events: none; }
.plate.mine { display: inline-flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.plate.mine .pname { font-size: 14px; color: #a8d0ff; }
.handrow { display: flex; align-items: flex-end; gap: 6px; background: linear-gradient(#1d3466ee, #0e1a38f0); border: 3px solid var(--ink); border-bottom: 0; border-radius: 16px 16px 0 0; padding: 8px 8px 4px; }
.next { width: 13%; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.nlabel { font-size: 12px; font-weight: 800; color: #cfe0ff; }
.nslot { width: 100%; }
.nslot .card .cost b { font-size: 11px; }
.hand { flex: 1; display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.slot { position: relative; pointer-events: auto; cursor: grab; touch-action: none; transition: transform 0.12s; }
.slot.sel { transform: translateY(-14px) scale(1.06); }
.slot.sel .card { box-shadow: 0 0 0 3px #fff, 0 0 18px #8fd0ff, 0 3px 0 #0006; }
.slot.poor .card { filter: saturate(0.25) brightness(0.75); }
.slot.poor .card::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: calc((1 - var(--fill, 0)) * 100%); background: #0005; }
.energy { pointer-events: auto; position: relative; display: flex; align-items: center; gap: 6px; background: #0e1a38f0; border: 3px solid var(--ink); border-top: 0; border-radius: 0 0 14px 14px; padding: 2px 10px 8px; }
.edrop { position: relative; width: 34px; height: 40px; flex: none; }
.edrop svg { width: 100%; height: 100%; }
.edrop b { position: absolute; inset: 22% 0 0; display: grid; place-items: center; font-size: 18px; font-weight: 800; text-shadow: 0 2px 0 #000; }
.etrack { position: relative; flex: 1; height: 22px; border-radius: 8px; background: #2a1438; border: 2px solid #000; overflow: hidden; }
.efill { position: absolute; left: 0; top: 0; bottom: 0; background: linear-gradient(#ff8af0, #d22cc2 60%, #9a1a8a); transition: width 0.1s linear; }
.eneed { position: absolute; top: 0; bottom: 0; background: repeating-linear-gradient(-45deg, #ff3a3a88 0 6px, #ff3a3a33 6px 12px); }
.eseg { position: absolute; inset: 0; background: repeating-linear-gradient(90deg, #0000 0 calc(10% - 2px), #000a calc(10% - 2px) 10%); }
.energy.boost .efill { background: linear-gradient(#ffd0ff, #ff5af0 50%, #c41ab4); box-shadow: 0 0 12px #ff5af0; }
.energy.deny .etrack { animation: redflash 0.4s 2; }
@keyframes redflash { 50% { box-shadow: 0 0 0 3px #ff3a3a, 0 0 16px #ff3a3a; } }
.rate { position: absolute; right: 18px; top: 0; font-family: var(--head); font-size: 18px; line-height: 26px; color: #fff; text-shadow: 0 2px 0 #000, 0 0 6px #ff5af0; opacity: 0; transform: scale(0.5); transition: 0.2s; pointer-events: none; }
.rate.on { opacity: 1; transform: scale(1); animation: pulse 0.8s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.15); } }
.rate.x3 { color: #ffb070; }
.tlabel { position: absolute; left: 0; top: 0; margin: -12px 0 0 -26px; width: 52px; text-align: center; font-weight: 800; font-size: 13px; text-shadow: 0 1px 0 #000, 0 0 3px #000; pointer-events: none; }
.tlabel.blue { color: #b8dcff; } .tlabel.red { color: #ffc0b8; }
.tlabel .kc { display: inline-block; width: 14px; height: 12px; margin-right: 2px; vertical-align: -1px; color: var(--gold); }
.countdown { position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%); font-family: var(--head); font-size: clamp(60px, 18vmin, 140px); color: #ffffffcc; text-shadow: 0 6px 0 #0009; opacity: 0; pointer-events: none; }
.countdown.show { animation: count 0.95s ease-out both; }
@keyframes count { 0% { opacity: 0; transform: translate(-50%, -50%) scale(2); } 20% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 100% { opacity: 0; transform: translate(-50%, -50%) scale(0.8); } }

/* End screen */
.endscreen { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; background: radial-gradient(#0006, #000b); animation: fade 0.4s; padding: var(--st) 12px var(--sb); }
.endscreen .xpbox { position: absolute; top: calc(10px + var(--st)); right: 12px; }
.endbanner { position: relative; padding: 16px 60px; border: 4px solid var(--ink); border-radius: 14px; box-shadow: 0 8px 0 #0008; animation: drop 0.7s cubic-bezier(0.3, 1.5, 0.5, 1) both; }
.endbanner::before, .endbanner::after { content: ''; position: absolute; top: 14px; width: 40px; height: 100%; background: inherit; border: 4px solid var(--ink); z-index: -1; filter: brightness(0.75); }
.endbanner::before { left: -34px; clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%, 30% 50%); }
.endbanner::after { right: -34px; clip-path: polygon(0 0, 100% 0, 70% 50%, 100% 100%, 0 100%); }
.endtitle { font-family: var(--head); font-size: clamp(40px, 11vmin, 72px); text-shadow: 0 5px 0 #0009; }
.won .endbanner { background: linear-gradient(#ffe066, var(--gold) 50%, var(--gold-d)); }
.lost .endbanner { background: linear-gradient(#8a9ab8, #5a6a88 50%, #3a4a68); animation: sag 1.1s cubic-bezier(0.3, 1.5, 0.5, 1) both; }
.draw .endbanner { background: linear-gradient(90deg, #d8dce8, #9aa2b8 50%, #d8dce8); }
@keyframes drop { from { transform: translateY(-60vh) rotate(-6deg); } }
@keyframes sag { 0% { transform: translateY(-60vh); } 60% { transform: translateY(0) rotate(0); } 100% { transform: translateY(8px) rotate(-3deg); } }
.endrows { display: flex; flex-direction: column; gap: 10px; width: min(92vw, 380px); }
.endrow { display: flex; align-items: center; justify-content: space-between; padding: 8px 14px; border-radius: 12px; border: 3px solid var(--ink); }
.endrow.red { background: #8a2a2acc; } .endrow.blue { background: #2a4a9acc; }
.endrow .crown { width: 34px; height: 28px; }
.rewards { display: flex; gap: 14px; }
.reward { display: flex; align-items: center; gap: 6px; background: #0008; border-radius: 12px; padding: 8px 14px; font-size: 22px; font-weight: 800; border: 2px solid #000; }
.reward .ico { width: 30px; height: 30px; }
.reward .neg { color: #ff8a7a; }
.flygem { position: fixed; left: 0; top: 0; width: 28px; height: 28px; z-index: 60; pointer-events: none; filter: drop-shadow(0 0 6px #7ee0ff); }
.flygem svg { width: 100%; height: 100%; }
.note { position: fixed; z-index: 70; pointer-events: none; font-family: var(--font); font-weight: 800; font-size: 18px; white-space: nowrap; text-shadow: 0 2px 0 #000, 0 0 6px #000; }
.note.bad { color: #ff7a6a; }

/* Upgrade / unlock */
.celebrate { position: absolute; inset: 0; z-index: 40; background: radial-gradient(#1a2a5aee, #050a18f8); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px; overflow: hidden; animation: fade 0.25s; perspective: 900px; }
.celebrate.out { opacity: 0; transition: opacity 0.3s; }
.celebrate .rays { position: absolute; left: 50%; top: 42%; width: 200vmax; height: 200vmax; margin: -100vmax 0 0 -100vmax; background: repeating-conic-gradient(#ffcf3a22 0 8deg, #0000 8deg 20deg); animation: spin 14s linear infinite; mask: radial-gradient(circle, #000 0, #0000 45%); -webkit-mask: radial-gradient(circle, #000 0, #0000 45%); }
.celebrate.unlock .rays { background: repeating-conic-gradient(#c070ff33 0 8deg, #0000 8deg 20deg); }
.celebrate .stage { position: relative; width: min(46vw, 210px); transform-style: preserve-3d; }
.celebrate .stage .card .cost b { font-size: 24px; }
.celebrate .stage .card .name { font-size: 16px; }
.celebrate .stage .card .lvl { font-size: 15px; }
.sparks { position: absolute; left: 50%; top: 42%; }
.spark { position: absolute; width: 12px; height: 12px; margin: -6px; border-radius: 50%; background: radial-gradient(#fff, #ffcf3a 50%, #0000 70%); }
.confetti { position: absolute; left: 50%; top: 42%; width: 10px; height: 16px; border-radius: 2px; }
.shard { position: absolute; width: 14px; height: 10px; background: #c9c9d6; border: 2px solid #333; clip-path: polygon(0 0, 100% 30%, 70% 100%, 10% 80%); }
.shock { position: absolute; left: 50%; top: 42%; width: 40px; height: 40px; margin: -20px; border-radius: 50%; border: 6px solid #fff; animation: shock 0.6s ease-out forwards; }
@keyframes shock { to { transform: scale(14); opacity: 0; border-width: 1px; } }
.stamp { position: absolute; z-index: 3; left: 50%; top: 52%; font-family: var(--head); font-size: 44px; color: #ff5a4a; border: 5px solid #ff5a4a; border-radius: 10px; padding: 2px 18px; background: #0006; }
.grow { display: flex; flex-direction: column; gap: 8px; width: min(80vw, 320px); animation: fade 0.3s; }
.gbar { display: grid; grid-template-columns: 90px 1fr 80px; gap: 8px; align-items: center; font-weight: 800; }
.gtrack { height: 14px; background: #0008; border-radius: 7px; overflow: hidden; border: 2px solid #000; }
.gfill { height: 100%; background: linear-gradient(#8aff7a, #2aa02a); }

@media (orientation: landscape) and (max-height: 560px) {
	.arena { height: 90px; }
	.btn.huge { font-size: 24px; padding: 10px 44px; }
	.tab { padding: 4px 0 3px; }
	.tab .ico { width: 24px; height: 24px; }
	.hud-bottom { width: min(100%, 440px); }
}
@media (min-aspect-ratio: 5/4) {
	.hud-bottom { left: auto; right: 16px; bottom: 50%; transform: translateY(50%); width: min(380px, 34vw); padding: 0; }
	.hud-bottom .handrow { border-radius: 16px 16px 0 0; }
}

/* Name wheels */
.who { cursor: pointer; }
.namepick { width: min(92vw, 420px); }
.wheels { display: flex; gap: 10px; padding: 8px; background: #0006; border: 3px solid var(--ink); border-radius: 14px; box-shadow: inset 0 3px 8px #000a; }
.wheel { position: relative; flex: 1; height: 308px; overflow: hidden; touch-action: none; cursor: grab; border-radius: 10px; background: linear-gradient(#0008, #0000 30%, #0000 70%, #0008); }
.wband { position: absolute; left: 2px; right: 2px; top: 132px; height: 44px; border-radius: 9px; background: #ffffff22; border: 2px solid #ffcf3a88; }
.wrow { position: absolute; left: 0; right: 0; top: 0; height: 44px; line-height: 44px; text-align: center; font-weight: 800; font-size: 21px; color: #f0f4ff; text-shadow: 0 2px 0 #0008; white-space: nowrap; pointer-events: none; will-change: transform; }
.wrow.on { color: var(--gold); font-size: 23px; }
.npreview { text-align: center; font-family: var(--head); font-size: 24px; color: var(--gold); margin-top: 10px; text-shadow: 0 3px 0 #0008; }
.btnrow.col { flex-direction: column; align-items: stretch; }
@media (max-height: 640px) { .wheel { height: 220px; } .wband { top: 88px; } }

/* Phase announcements and widgets */
.clockcol { margin-left: auto; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.phasepill { display: flex; align-items: center; gap: 4px; padding: 2px 10px 2px 6px; border-radius: 12px; border: 2px solid var(--ink); font-weight: 800; font-size: 12px; white-space: nowrap; text-shadow: 0 1px 0 #000; }
.phasepill:empty { display: none; }
.phasepill svg, .phasepill .ico { width: 16px; height: 16px; }
[data-phase=x2] .phasepill { background: linear-gradient(#ff8af0, #c41ab4); animation: pulse 1.2s ease-in-out infinite; }
[data-phase=x3] .phasepill { background: linear-gradient(#ffc070, #ff4ab0); animation: pulse 0.8s ease-in-out infinite; }
[data-phase=ot] .phasepill { background: linear-gradient(#ffb040, #d0400a); color: #fff; animation: pulse 0.9s ease-in-out infinite; }
[data-phase=ot] .phasepill .ico { color: var(--gold); }
.edgeglow { position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity 1s; }
[data-phase=x2] .edgeglow { opacity: 1; background: radial-gradient(ellipse at center, #0000 62%, #ff4af04d 100%); }
[data-phase=x3] .edgeglow { opacity: 1; background: radial-gradient(ellipse at center, #0000 58%, #ff7a4a66 100%); animation: edge 1s ease-in-out infinite; }
[data-phase=ot] .edgeglow { opacity: 1; background: radial-gradient(ellipse at center, #0000 55%, #ff5a0a77 100%); animation: edge 1.4s ease-in-out infinite; }
@keyframes edge { 50% { opacity: 0.45; } }
[data-phase=x3] .efill, [data-phase=ot] .efill { background: linear-gradient(#ffe0a0, #ff8a3a 50%, #e8402a); box-shadow: 0 0 14px #ff8a3a; }
.announce { position: absolute; inset: 0; pointer-events: none; overflow: hidden; display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 5; }
.announce::before { content: ''; position: absolute; inset: 0; animation: aflash 2.8s ease-out both; }
.announce.x2::before { background: radial-gradient(#ff4af055, #0000 70%); }
.announce.x3::before { background: radial-gradient(#ff8a3a66, #0000 70%); }
.announce.ot::before { background: radial-gradient(#ff5a0a66, #000a 80%); }
@keyframes aflash { 0% { opacity: 0; } 10% { opacity: 1; } 75% { opacity: 1; } 100% { opacity: 0; } }
.streak { position: absolute; left: -20%; right: -20%; height: 90px; top: 40%; transform: rotate(-8deg) translateX(-140%); animation: streak 2.6s cubic-bezier(0.2, 0.9, 0.3, 1) both; }
.streak.s2 { top: 50%; height: 40px; animation-delay: 0.08s; opacity: 0.7; }
.x2 .streak { background: linear-gradient(90deg, #0000, #ff5af0 20%, #ffb0f8 50%, #ff5af0 80%, #0000); }
.x3 .streak { background: linear-gradient(90deg, #0000, #ff8a3a 20%, #ffe0a0 50%, #ff4ab0 80%, #0000); }
.ot .streak { background: linear-gradient(90deg, #0000, #d0400a 20%, #ffb040 50%, #d0400a 80%, #0000); }
@keyframes streak { 0% { transform: rotate(-8deg) translateX(-140%); } 25% { transform: rotate(-8deg) translateX(0); } 75% { transform: rotate(-8deg) translateX(0); opacity: 1; } 100% { transform: rotate(-8deg) translateX(140%); opacity: 0; } }

.annbadge { position: relative; width: 110px; height: 120px; display: grid; place-items: center; animation: slam 2.8s cubic-bezier(0.3, 1.6, 0.5, 1) both; filter: drop-shadow(0 6px 0 #0008); }
.annbadge svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.annbadge b { position: relative; margin-top: 26px; font-family: var(--head); font-size: 40px; text-shadow: 0 3px 0 #000; }
.annbadge .acrown { width: 110px; height: 92px; color: var(--gold); }
@keyframes slam { 0% { transform: scale(4) rotate(-20deg); opacity: 0; } 12% { transform: scale(1) rotate(0); opacity: 1; } 80% { transform: scale(1); opacity: 1; } 100% { transform: scale(0.4) translate(120px, -60vh); opacity: 0; } }
.atitle { position: relative; font-family: var(--head); font-size: clamp(32px, 9vmin, 60px); text-shadow: 0 4px 0 #0009, 0 0 20px #000; animation: atitle 2.8s cubic-bezier(0.3, 1.4, 0.5, 1) both; margin-top: 6px; }
.x2 .atitle { color: #ffb0f8; } .x3 .atitle { color: #ffd090; } .ot .atitle { color: var(--gold); }
.asub { position: relative; font-weight: 800; font-size: clamp(14px, 3.6vmin, 20px); text-shadow: 0 2px 0 #000, 0 0 8px #000; animation: atitle 2.8s 0.15s ease-out both; padding: 0 16px; text-align: center; }
@keyframes atitle { 0% { transform: scale(0.3); opacity: 0; } 14% { transform: scale(1.08); opacity: 1; } 22% { transform: scale(1); } 82% { opacity: 1; } 100% { opacity: 0; transform: scale(1.15); } }
.rain { position: absolute; top: 0; width: 24px; height: 28px; }
.rain svg { width: 100%; height: 100%; }

/* League popup */
.arenapop { position: relative; width: min(94vw, 440px); }
.arenapop .preview { border: 3px solid var(--ink); border-radius: 12px; overflow: hidden; aspect-ratio: 480 / 300; margin-bottom: 8px; box-shadow: 0 4px 0 #0007; }
.arenapop .preview img { display: block; width: 100%; height: 100%; object-fit: cover; }
.arenapop .arange { text-align: center; margin-bottom: 8px; }
.arenapop .ctitle { text-align: center; font-size: 16px; margin: 4px 0 6px; }
.leaguecards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.lprice { text-align: center; font-weight: 800; font-size: 13px; margin-top: 2px; }
.lprice svg { width: 14px; height: 14px; vertical-align: -2px; }
