/* Goal Brawl — chunky, volumetric game UI.
 *
 * Every control is built the same way: a thick dark outline, a lit body with
 * a gloss band on top, and a solid "lip" under it that collapses when pressed.
 * Generated textures (assets/ui/*.webp) are applied as 9-slice border images,
 * so the painted corners and rims keep their size at any button width and
 * only the flat middle stretches.
 */

:root{
  --ink:#fff; --ink2:#cfc6ff; --ink3:#8f86c4;
  --bg0:#0e0824; --bg1:#1c1145; --bg2:#2a1b63;
  --line:#0b0618;
  --me:#3fd8ff; --them:#ff4f6d; --gold:#ffd23f; --green:#58e04a;
  --tap:52px;
  --font:"Segoe UI Black","Arial Black","Segoe UI",system-ui,sans-serif;
  --body:"Segoe UI",system-ui,sans-serif;
  --f-sm:14px; --f-md:16px; --f-lg:20px; --f-xl:28px;
}
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
html,body{margin:0;height:100%;background:var(--bg0);color:var(--ink);overflow:hidden;
  font-family:var(--font);font-size:var(--f-md);user-select:none;-webkit-user-select:none}
#app{position:fixed;inset:0;max-width:560px;margin:0 auto;overflow:hidden;
  background:radial-gradient(120% 70% at 50% 0%,#3a2490 0%,var(--bg1) 45%,var(--bg0) 100%)}
.screen{position:absolute;inset:0;display:flex;flex-direction:column}
.hidden{display:none!important}
img{-webkit-user-drag:none}

/* text with a heavy outline, like game titles */
h1,h2,h3,.btn span,.score-plate b,#turn,.res-score,.flash,.topbar h2{
  text-shadow:0 2px 0 var(--line),2px 0 0 var(--line),-2px 0 0 var(--line),0 -2px 0 var(--line),
              2px 2px 0 var(--line),-2px 2px 0 var(--line),2px -2px 0 var(--line),-2px -2px 0 var(--line),0 4px 0 rgba(0,0,0,.35)}

/* ------------------------------------------------------------------ buttons */
.btn{
  --c1:#6d7cff; --c2:#3f3fd6; --lip:#22197a;
  position:relative;appearance:none;border:3px solid var(--line);border-radius:18px;
  min-height:var(--tap);padding:0 22px;color:#fff;cursor:pointer;font-family:var(--font);
  font-size:var(--f-lg);letter-spacing:.02em;line-height:1;
  background:linear-gradient(180deg,var(--c1) 0%,var(--c2) 100%);
  box-shadow:0 6px 0 var(--lip),0 9px 0 var(--line),inset 0 -5px 0 rgba(0,0,0,.18),inset 0 2px 0 rgba(255,255,255,.45);
  transition:transform .06s,box-shadow .06s,filter .15s;
  display:inline-flex;align-items:center;justify-content:center;gap:8px;margin-bottom:9px;
}
.btn::before{ /* gloss band */
  content:"";position:absolute;left:8px;right:8px;top:4px;height:42%;
  border-radius:12px 12px 40% 40%/12px 12px 18px 18px;
  background:linear-gradient(180deg,rgba(255,255,255,.55),rgba(255,255,255,.06));pointer-events:none}
.btn span{position:relative;z-index:1}
.btn:active:not(:disabled){transform:translateY(6px);
  box-shadow:0 0 0 var(--lip),0 3px 0 var(--line),inset 0 -3px 0 rgba(0,0,0,.18),inset 0 2px 0 rgba(255,255,255,.45)}
.btn:disabled{filter:grayscale(.85) brightness(.75);cursor:default}
.btn.primary{--c1:#ffe14d;--c2:#ff9d1a;--lip:#a8510a}
.btn.secondary{--c1:#59c7ff;--c2:#2a73e8;--lip:#163f8f}
.btn.huge{min-height:72px;font-size:var(--f-xl);border-radius:22px;width:100%}
.btn.small{min-height:44px;font-size:var(--f-sm);padding:0 14px;border-radius:14px}
.btn.round{width:var(--tap);padding:0;border-radius:50%;font-size:26px;--c1:#9a84ff;--c2:#5a3fd6;--lip:#2c1a7d}
.btn.round.tiny{width:44px;min-height:44px;font-size:18px}
.btn.pulse{animation:pulse .9s ease-in-out infinite}
@keyframes pulse{50%{filter:brightness(1.18) saturate(1.2)}}

/* generated texture skins (body.tex is set once assets/ui loads) */
body.tex .btn.primary,body.tex .btn.secondary{
  background:none;border-color:transparent;box-shadow:none;margin-bottom:4px}
body.tex .btn::before{display:none}
/* slices in source pixels: the 640px-wide button art has ~100px rounded ends */
body.tex .btn.primary{border-style:solid;border-width:18px 22px 22px;border-image:url(assets/ui/btn_primary.webp) 90 110 110 110 fill / 18px 22px 22px stretch;padding:0 4px}
body.tex .btn.secondary{border-style:solid;border-width:18px 22px 22px;border-image:url(assets/ui/btn_secondary.webp) 90 110 110 110 fill / 18px 22px 22px stretch;padding:0 4px}
body.tex .btn.huge{border-width:22px 28px 28px;border-image-width:22px 28px 28px}
body.tex .btn.round{background:url(assets/ui/btn_round.webp) center/100% 100% no-repeat;border-color:transparent;box-shadow:none;margin-bottom:4px}
body.tex .btn.round::before{display:none}
body.tex .btn:active:not(:disabled){transform:translateY(3px) scale(.97);box-shadow:none}
/* the panel art is 900x609 with ~150px ornamented corners */
body.tex .panel{background:none;border-color:transparent;box-shadow:none;border-style:solid;border-width:34px;
  border-image:url(assets/ui/panel.webp) 150 fill / 34px stretch;padding:0;border-radius:0}

/* small framed pieces use the same panel art with a thin frame; a chosen
   piece takes the button art of its colour */
body.tex .btn.round{font-size:30px}
body.tex .hero-tile,body.tex .slot,body.tex .hcard,body.tex .score-plate,body.tex .seg-btn{
  background:none;border-color:transparent;box-shadow:0 4px 0 rgba(0,0,0,.35);border-style:solid;border-radius:0;
  border-width:12px;border-image:url(assets/ui/panel.webp) 150 fill / 12px stretch;padding:0}
body.tex .score-plate{border-width:16px;border-image-width:16px;padding:0 4px}
body.tex .hero-tile.picked,body.tex .seg-btn.on{border-image:url(assets/ui/btn_primary.webp) 90 110 110 110 fill / 12px 14px 14px stretch;color:#fff}
body.tex .slot.full,body.tex .hcard.ready{border-image:url(assets/ui/btn_secondary.webp) 90 110 110 110 fill / 12px 14px 14px stretch}
body.tex .hcard.ball{box-shadow:0 0 0 3px var(--gold),0 4px 0 rgba(0,0,0,.35)}
body.tex .hero-tile span,body.tex .hcard .nm{text-shadow:0 1px 0 #000,1px 0 0 #000,-1px 0 0 #000,0 -1px 0 #000}

/* --------------------------------------------------------------------- panels */
.panel{
  position:relative;border:3px solid var(--line);border-radius:22px;
  background:linear-gradient(180deg,#3b2a8f 0%,#24186a 60%,#1b1150 100%);
  box-shadow:0 6px 0 #120a3a,0 9px 0 var(--line),inset 0 0 0 3px rgba(141,120,255,.55),inset 0 3px 0 6px rgba(255,255,255,.06);
  padding:14px;
}
.panel h3{margin:0 0 10px;font-size:var(--f-xl);text-align:center;color:var(--gold)}
.panel label{display:block;margin:10px 0 6px;font-size:var(--f-sm);color:var(--ink2);text-transform:uppercase;letter-spacing:.06em}

/* ---------------------------------------------------------------------- title */
.title-bg{position:absolute;inset:0;
  background:url(assets/ui/title_bg.webp) center/cover no-repeat,
    radial-gradient(80% 50% at 50% 30%,rgba(255,180,60,.25),transparent 70%)}
.title-wrap{position:relative;flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:14px;padding:24px 20px 28px}
.logo{text-align:center}
.logo h1{margin:0;font-size:58px;line-height:.9;color:#fff;transform:rotate(-3deg);filter:drop-shadow(0 6px 0 rgba(0,0,0,.4))}
.logo h1 span{display:block;font-size:64px;color:var(--gold)}
.tagline{margin:0;color:#fff;font-size:var(--f-md);text-align:center;font-family:var(--body);font-weight:800;
  text-shadow:0 2px 0 rgba(0,0,0,.6)}
.arena-pick{display:flex;align-items:center;gap:10px;width:100%;padding:10px}
.arena-pick .btn{margin:0 0 9px;flex:none}
.arena-card{flex:1;display:flex;gap:12px;align-items:center;min-width:0}
.arena-thumb{flex:none;width:64px;height:100px;border-radius:12px;border:3px solid var(--line);
  background:#2e6b45 center/cover no-repeat;box-shadow:inset 0 0 0 2px rgba(255,255,255,.25)}
.arena-text{min-width:0}
.arena-text small{color:var(--ink3);font-size:var(--f-sm)}
.arena-text b{display:block;font-size:var(--f-lg);color:var(--gold);margin:2px 0}
.arena-text p{margin:0;font-family:var(--body);font-weight:700;font-size:var(--f-sm);color:var(--ink2);line-height:1.3}
.row{display:flex;gap:12px;width:100%}
.row .btn{flex:1;font-size:var(--f-md)}

/* ----------------------------------------------------------------------- team */
.topbar{display:flex;align-items:center;gap:10px;padding:12px 14px 4px}
.topbar h2{flex:1;margin:0;font-size:var(--f-xl);text-align:center}
.topbar .btn{margin-bottom:9px}
.slots{display:flex;justify-content:center;gap:12px;padding:6px 14px 0}
.slot{appearance:none;width:96px;height:104px;border-radius:18px;border:3px solid var(--line);
  background:linear-gradient(180deg,#2c1f72,#1a1150);box-shadow:inset 0 0 0 3px rgba(141,120,255,.35),0 5px 0 var(--line);
  display:flex;flex-direction:column;align-items:center;justify-content:center;color:var(--ink3);font-family:var(--font);cursor:pointer;padding:4px}
.slot b{font-size:40px;color:#5d4fae}
.slot.full{background:linear-gradient(180deg,#3fb7ff,#2459d6);box-shadow:inset 0 0 0 3px rgba(255,255,255,.4),0 5px 0 var(--line)}
.slot img{width:66px;height:66px;object-fit:contain;filter:drop-shadow(0 3px 0 rgba(0,0,0,.35))}
.slot span{font-size:var(--f-sm);color:#fff}
.note{margin:8px 0 4px;text-align:center;color:var(--ink2);font-size:var(--f-sm)}
.roster{flex:1;overflow-y:auto;display:grid;grid-template-columns:repeat(5,1fr);gap:8px;padding:6px 14px 10px;align-content:start}
.hero-tile{appearance:none;position:relative;border:3px solid var(--line);border-radius:14px;padding:4px 2px 6px;cursor:pointer;
  background:linear-gradient(180deg,#43339c,#271a6c);box-shadow:inset 0 2px 0 rgba(255,255,255,.25),0 4px 0 var(--line);
  display:flex;flex-direction:column;align-items:center;gap:2px;color:#fff;font-family:var(--font);font-size:12px;min-height:84px}
.hero-tile img{width:100%;max-width:58px;aspect-ratio:1;object-fit:contain}
.hero-tile.picked{background:linear-gradient(180deg,#ffe14d,#ff9d1a);color:#3a1c00}
.hero-tile.focus{outline:3px solid #fff;outline-offset:1px}
.hero-tile i{position:absolute;top:-6px;right:-6px;width:24px;height:24px;border-radius:50%;background:var(--green);border:3px solid var(--line);
  font-style:normal;font-size:13px;display:flex;align-items:center;justify-content:center;color:#fff}
.info{margin:0 14px;display:flex;gap:12px;align-items:center;min-height:96px}
.info img{width:80px;height:80px;object-fit:contain;flex:none}
.info b{display:block;font-size:var(--f-lg)}
.info em{display:inline-block;font-style:normal;font-size:12px;color:#2b1700;background:var(--gold);border:2px solid var(--line);border-radius:8px;padding:2px 8px;margin:4px 0}
.info p{margin:2px 0 0;font-family:var(--body);font-weight:700;font-size:var(--f-sm);line-height:1.35;color:var(--ink2)}
.team-foot{padding:12px 14px 16px}

/* --------------------------------------------------------------------- battle */
#pitch{position:absolute;inset:0;width:100%;height:100%;touch-action:none}
.hud-top{position:absolute;left:0;right:0;top:0;padding:8px 10px 0;pointer-events:none}
.hud-top .btn{pointer-events:auto;position:absolute;right:8px;top:8px;margin:0}
.score-plate{margin:0 52px 0 0;display:flex;align-items:center;justify-content:space-between;gap:6px;
  border:3px solid var(--line);border-radius:18px;padding:6px 10px;
  background:linear-gradient(180deg,#3a2a8c,#1d1356);box-shadow:inset 0 2px 0 rgba(255,255,255,.2),0 5px 0 var(--line)}
.team{display:flex;align-items:center;gap:6px}
.team b{font-size:34px;min-width:34px;text-align:center}
.team.me b{color:var(--me)} .team.them b{color:var(--them)}
.heads{display:flex;gap:2px}
.heads span{position:relative;width:28px;height:32px}
.heads img{width:28px;height:28px;object-fit:contain}
.heads i{position:absolute;left:3px;bottom:0;height:4px;width:0;background:var(--green);border-radius:2px;max-width:22px}
.heads span.dead{opacity:.3;filter:grayscale(1)}
.mid{display:flex;flex-direction:column;align-items:center;gap:3px;flex:1;min-width:0}
#turn{font-size:var(--f-sm);color:var(--gold)}
.timer{position:relative;width:100%;max-width:120px;height:20px;border-radius:10px;border:3px solid var(--line);background:#0d0828;overflow:hidden}
.timer i{position:absolute;left:0;top:0;bottom:0;background:linear-gradient(180deg,#9cff6b,#2fb53a);transition:width .2s linear}
.timer.low i{background:linear-gradient(180deg,#ff9d6b,#e8332a)}
.timer b{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;font-size:13px;
  text-shadow:0 1px 0 #000,1px 0 0 #000,-1px 0 0 #000,0 -1px 0 #000}
.hint{margin:6px auto 0;max-width:420px;text-align:center;font-family:var(--body);font-weight:800;font-size:var(--f-sm);
  color:#fff;background:rgba(12,8,32,.82);border:2px solid rgba(141,120,255,.6);border-radius:12px;padding:6px 10px}
.arena-banner{display:none}
.flash{position:absolute;left:50%;top:38%;transform:translate(-50%,-50%) scale(.6);opacity:0;pointer-events:none;
  font-size:30px;white-space:nowrap;color:#fff;transition:transform .18s,opacity .18s}
.flash.show{opacity:1;transform:translate(-50%,-50%) scale(1)}
.flash.good{color:var(--gold)}
.flash.note{top:auto;bottom:120px;transform:translate(-50%,0);width:86%;white-space:normal;text-align:center;
  font-family:var(--body);font-weight:800;font-size:var(--f-md);line-height:1.35;text-shadow:none;
  background:rgba(12,8,32,.92);border:3px solid var(--gold);border-radius:16px;padding:10px 14px}

.hud-bottom{position:absolute;left:0;right:0;bottom:0;padding:6px 10px 10px;display:flex;gap:8px;align-items:stretch}
.cards{flex:1;display:flex;gap:6px;min-width:0}
.hcard{flex:1;min-width:0;position:relative;border:3px solid var(--line);border-radius:14px;padding:4px 4px 6px;
  background:linear-gradient(180deg,#3a2a8c,#1d1356);box-shadow:inset 0 2px 0 rgba(255,255,255,.2),0 4px 0 var(--line);
  display:flex;flex-direction:column;align-items:center;gap:2px}
.hcard img{width:40px;height:40px;object-fit:contain}
.hcard .nm{font-size:12px;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.hcard .hp{display:block;width:90%;height:7px;border-radius:4px;background:#0d0828;overflow:hidden}
.hcard .hp b{display:block;height:100%;background:linear-gradient(180deg,#9cff6b,#2fb53a)}
.hcard .st{font-size:12px;color:var(--ink2);font-family:var(--body);font-weight:900}
.hcard.ready{background:linear-gradient(180deg,#3fb7ff,#2459d6)}
.hcard.ready .st{color:#fff}
.hcard.ball{box-shadow:inset 0 0 0 3px var(--gold),0 4px 0 var(--line)}
.hcard.ball .st{color:var(--gold)}
.hcard.dead{filter:grayscale(1) brightness(.6)}
.btn.go{flex:none;width:118px;min-height:auto;font-size:var(--f-lg);margin:0 0 9px;padding:0 8px;border-radius:18px}

/* --------------------------------------------------------------------- result */
.result{position:relative;margin:auto 20px;display:flex;flex-direction:column;align-items:center;gap:12px;padding:22px 18px}
.result h2{margin:0;font-size:46px}
.result h2.win{color:var(--gold)} .result h2.lose{color:var(--them)}
.res-heads{display:flex;gap:8px}
.res-heads img{width:84px;height:84px;object-fit:contain}
.res-score{margin:0;font-size:44px}
.result .btn{width:100%}

/* --------------------------------------------------------------------- sheets */
.sheet{position:absolute;inset:0;background:rgba(6,3,18,.7);display:flex;align-items:center;justify-content:center;padding:18px;z-index:10}
.sheet .panel{width:100%;max-width:440px;max-height:92%;overflow:auto}
.sheet .panel>.btn{width:100%;margin-top:14px}
.seg{display:flex;gap:8px}
.seg-btn{flex:1;appearance:none;min-height:48px;border:3px solid var(--line);border-radius:14px;cursor:pointer;font-family:var(--font);font-size:var(--f-md);color:#fff;
  background:linear-gradient(180deg,#43339c,#271a6c);box-shadow:inset 0 2px 0 rgba(255,255,255,.25),0 4px 0 var(--line)}
.seg-btn.on{background:linear-gradient(180deg,#ffe14d,#ff9d1a)}
.steps{margin:0;padding-left:22px;font-family:var(--body);font-weight:700;font-size:var(--f-md);line-height:1.4;color:var(--ink2)}
.steps li{margin:0 0 10px}
.steps b{color:#fff}

@media (min-height:820px){ .hcard img{width:48px;height:48px} }

/* the echo bar on a battle portrait: fills from the ball and hits; full, it glows and waits for a tap */
.hcard .eb{position:relative;display:block;width:90%;height:6px;border-radius:4px;background:#160b33;overflow:visible;margin-top:1px}
.hcard .eb b{display:block;height:100%;border-radius:4px;background:linear-gradient(90deg,#7b3cff,#d9a2ff);transition:width .4s}
.hcard .eb-ic{position:absolute;right:-8px;top:50%;width:16px;height:16px;transform:translateY(-50%);opacity:.55;filter:grayscale(.6)}
.hcard.charged{box-shadow:0 0 0 3px #b77bff,0 0 18px #9b5cff,0 4px 0 var(--line);animation:charged 1.1s ease-in-out infinite}
.hcard.charged .eb-ic,.hcard.echo-on .eb-ic{opacity:1;filter:none}
.hcard.charged .st,.hcard.echo-on .st{color:#e3ccff}
.hcard.echo-on{background:linear-gradient(180deg,#7b3cff,#3a1592)}
.hcard.echo-on .eb b{background:linear-gradient(90deg,#d9a2ff,#fff)}
@keyframes charged{50%{transform:translateY(-2px);box-shadow:0 0 0 3px #d9a2ff,0 0 26px #b77bff,0 6px 0 var(--line)}}
@media (prefers-reduced-motion:reduce){.hcard.charged{animation:none}}

/* no system scrollbars anywhere: everything scrolls by touch and wheel, the frames stay clean */
*{scrollbar-width:none}
*::-webkit-scrollbar{display:none;width:0;height:0}

/* "Ready" is exactly as tall as the hero cards beside it, with the same frame thickness */
.hud-bottom .btn.go,body.tex .hud-bottom .btn.go{align-self:stretch;height:auto;margin:0;border-width:12px 14px 14px;border-image-width:12px 14px 14px;box-sizing:border-box}

/* the placement toggle sits just above the hero cards on a kick-off turn */
.hud-bottom .place-btn{position:absolute;left:10px;top:-46px;min-height:38px;padding:4px 14px;font-size:14px;z-index:3}
.hud-bottom .place-btn.on{filter:hue-rotate(160deg) saturate(1.3)}
.hud-bottom .place-btn.hidden{display:none}

/* the active skill on a battle card: a round badge in the corner, its cooldown on it */
.hcard .sk{position:absolute;top:-10px;right:-8px;width:38px;height:38px;padding:0;border:0;border-radius:50%;background:none;cursor:pointer;z-index:2}
.hcard .sk img{width:100%;height:100%;object-fit:contain;filter:grayscale(.85) brightness(.7);transition:filter .2s,transform .2s}
.hcard .sk.ready img{filter:none;animation:skReady 1.2s ease-in-out infinite}
.hcard .sk.on img{filter:none;transform:scale(1.15)}
.hcard .sk.on{box-shadow:0 0 0 3px #fff,0 0 16px #ffd23f}
.hcard .sk em{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;font-style:normal;font-size:16px;color:#fff;text-shadow:0 0 3px #000,0 0 3px #000;pointer-events:none}
@keyframes skReady{50%{transform:scale(1.08)}}
@media (prefers-reduced-motion:reduce){.hcard .sk.ready img{animation:none}}
