/* Poké Tactics — "tournament playmat" world.
   Dark neoprene mat, cream silkscreen print, cream card-stock shop tray,
   type colour only where it carries meaning. */

:root {
  --ink: #0d1118;
  --ink-2: #131924;
  --mat: #19212e;
  --mat-hi: #202a3a;
  --silk: #efe6d2;
  --silk-2: rgba(239, 230, 210, .62);
  --silk-3: rgba(239, 230, 210, .34);
  --silk-line: rgba(239, 230, 210, .16);
  --card: #f2ead8;
  --card-2: #e6dcc6;
  --card-ink: #1d1b18;
  --card-ink-2: #5d564b;
  --red: #e3350d;
  --red-hi: #ff4a1f;
  --gold: #f2c14e;
  --ally: #5fd38d;
  --foe: #ff5d4f;
  --mana: #5aa8ff;
  --shield: #e8eef7;
  --hexW: 80px;
  --hexH: 92px;
  --display: 'Barlow Condensed', system-ui, sans-serif;
  --pixel: 'Pixelify Sans', 'Barlow Condensed', sans-serif;
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--ink);
  color: var(--silk);
  font-family: var(--display);
  font-size: 16px;
  overflow: hidden;
  user-select: none;
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--gold); color: var(--ink); }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
svg { display: block; }

/* ---------- layout ---------- */
#app {
  height: 100vh;
  display: grid;
  grid-template-rows: 58px minmax(0, 1fr) 92px 172px;
  /* neoprene: fine noise over ink */
  background:
    radial-gradient(120% 80% at 50% 38%, #1a2230 0%, var(--ink) 70%),
    var(--ink);
}
#app::before {
  content: ''; position: fixed; inset: 0; pointer-events: none; opacity: .35; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .55 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- top bar ---------- */
.topbar {
  display: grid; grid-template-columns: 240px 1fr auto auto auto; align-items: center; gap: 22px;
  padding: 0 22px; border-bottom: 1px solid var(--silk-line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 22px; letter-spacing: .02em; text-transform: uppercase; }
.brand-mark { width: 24px; height: 24px; color: var(--red-hi); }
.round-info { display: flex; align-items: baseline; gap: 14px; justify-content: center; }
.round-stage { font-weight: 700; font-size: 15px; color: var(--silk-2); text-transform: uppercase; letter-spacing: .08em; }
.round-label { font-weight: 800; font-size: 22px; text-transform: uppercase; letter-spacing: .02em; }
.round-pips { display: flex; gap: 6px; align-self: center; }
.round-pips i { width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid var(--silk-3); }
.round-pips i.done { background: var(--silk-2); border-color: var(--silk-2); }
.round-pips i.lost { background: var(--foe); border-color: var(--foe); }
.round-pips i.now { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(242, 193, 78, .18); }
.round-pips i.gym { border-radius: 2px; transform: rotate(45deg) scale(.9); }

.badges { display: flex; gap: 6px; }
.badge { width: 22px; height: 22px; opacity: .22; filter: grayscale(1); transition: opacity .4s, filter .4s, transform .5s var(--ease-out); }
.badge.earned { opacity: 1; filter: none; }
.badge.earned.fresh { animation: badge-pop .9s var(--ease-out); }
@keyframes badge-pop { 0% { transform: scale(2.2) rotate(-30deg); } 100% { transform: none; } }

.player-hp { display: flex; align-items: center; gap: 7px; font-family: var(--pixel); font-size: 24px; font-weight: 700; }
.player-hp svg { width: 22px; height: 22px; color: var(--foe); }
.player-hp.hit { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-4px); } 40%, 80% { transform: translateX(4px); } }

/* ---------- table ---------- */
.table { display: grid; grid-template-columns: 240px minmax(0, 1fr) 280px; min-height: 0; }
.panel-title { margin: 0 0 12px; font-size: 13px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--silk-3); }

.traits { padding: 20px 14px 20px 22px; overflow-y: auto; }
.traits ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.trait { display: grid; grid-template-columns: 30px 1fr auto; align-items: center; gap: 10px; padding: 7px 10px 7px 7px; border-radius: 8px; background: rgba(239, 230, 210, .035); border: 1px solid transparent; transition: background .2s; }
.trait.active { background: rgba(239, 230, 210, .08); border-color: var(--silk-line); }
.trait-hex { width: 30px; height: 30px; display: grid; place-items: center; clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%); background: #2a3343; color: var(--silk-3); font-family: var(--pixel); font-weight: 700; font-size: 15px; }
.trait.active .trait-hex { background: var(--tc); color: #111; }
.trait-name { font-weight: 700; font-size: 17px; letter-spacing: .01em; color: var(--silk-2); line-height: 1.05; }
.trait.active .trait-name { color: var(--silk); }
.trait-tiers { font-family: var(--pixel); font-size: 13px; color: var(--silk-3); letter-spacing: .02em; }
.trait-tiers b { color: var(--silk); font-weight: 700; }
.trait-tiers .on { color: var(--gold); }
.traits-empty { color: var(--silk-3); font-size: 15px; line-height: 1.35; margin: 4px 0 0; max-width: 24ch; }

.arena { position: relative; display: grid; place-items: center; min-height: 0; min-width: 0; padding: 10px 6px; }
.mat {
  position: relative; isolation: isolate;
  border-radius: 26px;
  background:
    radial-gradient(90% 60% at 50% 50%, var(--mat-hi), var(--mat) 75%);
  box-shadow: 0 30px 60px -20px rgba(0, 0, 0, .65), 0 2px 0 rgba(255, 255, 255, .03) inset, 0 0 0 1px #0a0e14;
}
/* stitched edge */
.mat::after { content: ''; position: absolute; inset: 8px; border-radius: 20px; border: 1.5px dashed rgba(239, 230, 210, .14); pointer-events: none; }
.mat-grid { position: absolute; left: 0; top: 0; overflow: visible; }
.hex { fill: rgba(239, 230, 210, .025); stroke: var(--silk-line); stroke-width: 1.2; transition: fill .15s; }
.hex.foe-zone { fill: rgba(255, 93, 79, .025); }
.hex.drop-ok { fill: rgba(242, 193, 78, .14); stroke: rgba(242, 193, 78, .6); }
.hex.drop-bad { fill: rgba(255, 93, 79, .12); }
.mid-line { stroke: rgba(239, 230, 210, .22); stroke-width: 1.5; stroke-dasharray: 2 7; stroke-linecap: round; }
.mat-print { position: absolute; left: 28px; font-weight: 700; font-size: 13px; letter-spacing: .22em; text-transform: uppercase; color: rgba(239, 230, 210, .26); pointer-events: none; writing-mode: vertical-rl; transform: rotate(180deg); }
.mat-print-top { top: 34px; }
.mat-print-bottom { bottom: 34px; }

/* ---------- units ---------- */
.units, .fx { position: absolute; inset: 0; pointer-events: none; }
.units { z-index: 1; }
.fx { z-index: 2; }
.unit {
  position: absolute; left: 0; top: 0; width: var(--hexW); height: var(--hexH);
  pointer-events: auto; cursor: grab; will-change: transform;
}
.unit.foe { cursor: default; }
.unit .shadow { position: absolute; left: 50%; top: 62%; width: 62%; height: 18%; transform: translate(-50%, -50%); border-radius: 50%; background: radial-gradient(closest-side, rgba(0, 0, 0, .55), transparent); }
.unit .ring { position: absolute; left: 50%; top: 62%; width: 70%; height: 22%; transform: translate(-50%, -50%); border-radius: 50%; border: 2px solid var(--ally); opacity: .55; }
.unit.foe .ring { border-color: var(--foe); }
.unit img {
  position: absolute; left: 50%; bottom: 36%;
  transform: translateX(-50%) scale(var(--s, 1)); transform-origin: 50% 100%;
  image-rendering: pixelated; pointer-events: none;
  filter: drop-shadow(0 1px 0 rgba(0, 0, 0, .35));
}
.unit.hurt img { filter: brightness(2.4) saturate(0); }
.unit.dead { transition: opacity .45s, transform .45s; opacity: 0 !important; }
.unit.stunned img { filter: saturate(.3) brightness(.85); }
.unit .bars { position: absolute; left: 50%; top: calc(var(--hexH) * .64 - var(--nh, 56) * var(--s) * 1px - 13px); width: 74%; transform: translateX(-50%); display: none; z-index: 2; }
.unit.in-combat .bars { display: block; }
.unit .hpbar { position: relative; height: 7px; background: rgba(10, 13, 19, .85); border-radius: 2px; overflow: hidden; box-shadow: 0 0 0 1px rgba(0, 0, 0, .6); }
.unit .hpfill { position: absolute; inset: 0; transform-origin: left; background: var(--ally); transition: transform .12s linear; }
.unit.foe .hpfill { background: var(--foe); }
.unit .shieldfill { position: absolute; top: 0; bottom: 0; left: 0; background: var(--shield); opacity: .85; transform-origin: left; transform: scaleX(0); }
.unit .manabar { height: 3px; margin-top: 2px; background: rgba(10, 13, 19, .85); border-radius: 2px; overflow: hidden; }
.unit .manafill { height: 100%; background: var(--mana); transform-origin: left; transform: scaleX(0); }
.unit .stars { position: absolute; left: 50%; top: calc(var(--hexH) * .64 - var(--nh, 56) * var(--s) * 1px - 26px); transform: translateX(-50%); display: flex; gap: 1px; z-index: 2; }
.unit:not(.in-combat) .stars { top: 73%; }
.star { width: 11px; height: 11px; color: var(--silk-2); }
.star.s2 { color: #c9d4e6; }
.star.s3 { color: var(--gold); }
.unit.dragging { opacity: .25; }

.drag-ghost { position: fixed; left: 0; top: 0; pointer-events: none; z-index: 50; width: 96px; height: 96px; transform: translate(-50%, -70%); }
.drag-ghost img { position: absolute; left: 50%; bottom: 0; transform: translateX(-50%) scale(1.15); transform-origin: 50% 100%; image-rendering: pixelated; filter: drop-shadow(0 10px 8px rgba(0, 0, 0, .5)); }

/* ---------- fx ---------- */
.dmg {
  position: absolute; font-family: var(--pixel); font-weight: 700; font-size: 17px; color: #fff;
  text-shadow: 0 2px 0 rgba(0, 0, 0, .7), 0 0 6px rgba(0, 0, 0, .5);
  animation: dmg-rise .8s var(--ease-out) forwards; white-space: nowrap; transform: translate(-50%, -50%);
}
.dmg.se { color: var(--gold); font-size: 22px; }
.dmg.nve { color: #aab3c2; font-size: 14px; }
.dmg.heal { color: var(--ally); }
.dmg.miss { color: var(--silk-2); font-size: 14px; letter-spacing: .06em; }
.dmg.crit { font-size: 24px; }
@keyframes dmg-rise { 0% { opacity: 0; translate: 0 6px; scale: .7; } 15% { opacity: 1; scale: 1.15; } 30% { scale: 1; } 100% { opacity: 0; translate: 0 -34px; } }
.callout {
  position: absolute; transform: translate(-50%, -100%); padding: 3px 9px 4px; border-radius: 4px;
  background: var(--card); color: var(--card-ink); font-weight: 800; font-size: 15px; letter-spacing: .02em; text-transform: uppercase; white-space: nowrap;
  box-shadow: 0 6px 14px -4px rgba(0, 0, 0, .6); display: flex; align-items: center; gap: 6px;
  animation: callout 1.1s var(--ease-out) forwards;
}
.callout::before { content: ''; width: 9px; height: 9px; border-radius: 50%; background: var(--tc, var(--gold)); box-shadow: 0 0 0 1.5px rgba(0, 0, 0, .25); }
@keyframes callout { 0% { opacity: 0; translate: 0 8px; } 12% { opacity: 1; translate: 0 0; } 80% { opacity: 1; } 100% { opacity: 0; translate: 0 -10px; } }
.proj { position: absolute; width: 12px; height: 12px; margin: -6px 0 0 -6px; border-radius: 50%; background: var(--tc); box-shadow: 0 0 10px 2px var(--tc), 0 0 0 2px rgba(255, 255, 255, .5) inset; }
.burst { position: absolute; border-radius: 50%; border: 3px solid var(--tc); transform: translate(-50%, -50%); animation: burst .5s var(--ease-out) forwards; box-shadow: 0 0 18px var(--tc); }
@keyframes burst { 0% { width: 10px; height: 10px; opacity: 1; } 100% { width: var(--r); height: var(--r); opacity: 0; border-width: 1px; } }
.slash { position: absolute; width: 34px; height: 4px; border-radius: 2px; background: #fff; transform: translate(-50%, -50%) rotate(-35deg); animation: slash .25s ease-out forwards; box-shadow: 0 0 8px #fff; }
@keyframes slash { 0% { opacity: 1; width: 6px; } 100% { opacity: 0; width: 40px; } }
.evolve-flash { position: absolute; width: 120px; height: 120px; transform: translate(-50%, -50%); border-radius: 50%; background: radial-gradient(closest-side, #fff, rgba(255, 255, 255, 0)); animation: evo 1s ease-out forwards; }
@keyframes evo { 0% { opacity: 0; scale: .2; } 30% { opacity: 1; scale: 1.2; } 100% { opacity: 0; scale: 1.8; } }

.banner {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  font-weight: 800; font-size: 64px; letter-spacing: .01em; text-transform: uppercase; color: var(--silk); white-space: nowrap;
  text-shadow: 0 4px 0 rgba(0, 0, 0, .45); pointer-events: none; animation: banner 1.3s var(--ease-out) forwards; z-index: 3;
}
.banner.win { color: var(--gold); }
.banner.loss { color: var(--foe); }
@keyframes banner { 0% { opacity: 0; letter-spacing: .3em; filter: blur(6px); } 25% { opacity: 1; letter-spacing: .01em; filter: none; } 80% { opacity: 1; } 100% { opacity: 0; } }

/* ---------- inspector ---------- */
.inspector { padding: 20px 22px 20px 14px; display: flex; flex-direction: column; gap: 26px; overflow-y: auto; }
.opp-name { font-weight: 800; font-size: 26px; line-height: 1; text-transform: uppercase; letter-spacing: .01em; }
.opp-meta { margin-top: 6px; color: var(--silk-2); font-size: 16px; }
.opp-meta .chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.detail-hint { color: var(--silk-3); font-size: 15px; margin: 0; line-height: 1.35; }
.detail-card { background: var(--card); color: var(--card-ink); border-radius: 12px; overflow: hidden; box-shadow: 0 14px 30px -12px rgba(0, 0, 0, .7); }
.detail-art { position: relative; height: 112px; display: grid; place-items: end center; padding-bottom: 8px; background: linear-gradient(160deg, var(--tc), color-mix(in oklab, var(--tc) 55%, #000)); }
.detail-art img { image-rendering: pixelated; transform: scale(1.25); transform-origin: 50% 100%; }
.detail-art .stars { position: absolute; right: 10px; top: 8px; display: flex; gap: 1px; }
.detail-body { padding: 12px 14px 14px; }
.detail-name { font-weight: 800; font-size: 24px; line-height: 1; text-transform: uppercase; }
.detail-traits { display: flex; gap: 4px; margin: 8px 0 10px; flex-wrap: wrap; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px 10px; margin-bottom: 12px; }
.stat { display: flex; flex-direction: column; }
.stat span { font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--card-ink-2); }
.stat b { font-family: var(--pixel); font-weight: 700; font-size: 17px; }
.move { border-top: 1px solid rgba(0, 0, 0, .12); padding-top: 10px; }
.move-name { font-weight: 800; font-size: 17px; text-transform: uppercase; display: flex; justify-content: space-between; }
.move-name small { font-family: var(--pixel); font-size: 13px; color: var(--card-ink-2); font-weight: 500; text-transform: none; }
.move p { margin: 4px 0 0; font-size: 15px; line-height: 1.3; color: var(--card-ink-2); font-weight: 500; }

.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px 2px 6px; border-radius: 99px; font-size: 13px; font-weight: 700; letter-spacing: .02em; background: rgba(0, 0, 0, .07); color: inherit; }
.chip i { width: 8px; height: 8px; border-radius: 50%; background: var(--tc); }
.inspector .chip { background: rgba(239, 230, 210, .08); }

/* ---------- bench ---------- */
.bench-row { display: flex; align-items: center; justify-content: center; gap: 18px; padding: 0 22px; position: relative; }
.bench { display: grid; grid-template-columns: repeat(9, 76px); gap: 8px; }
.slot { position: relative; height: 80px; border-radius: 12px; border: 1.5px dashed var(--silk-line); background: rgba(239, 230, 210, .02); transition: background .15s, border-color .15s; }
.slot.drop-ok { border-color: rgba(242, 193, 78, .7); background: rgba(242, 193, 78, .1); border-style: solid; }
.slot .unit { width: 100%; height: 100%; }
.slot .unit img { bottom: 18%; }
.slot .unit .shadow, .slot .unit .ring { top: 82%; }
.slot .unit .stars { top: auto; bottom: 1px; }
.board-cap { position: absolute; right: 22px; font-family: var(--pixel); font-size: 15px; color: var(--silk-2); text-align: right; line-height: 1.2; }
.board-cap b { font-size: 22px; color: var(--silk); }
.board-cap.full b { color: var(--gold); }
.board-cap small { display: block; font-family: var(--display); font-weight: 700; font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--silk-3); }

/* ---------- tray (the one cream panel) ---------- */
.tray {
  position: relative; margin: 0 14px 14px; border-radius: 18px; padding: 14px 18px;
  background: var(--card); color: var(--card-ink);
  display: grid; grid-template-columns: 190px 1fr 230px; gap: 18px; align-items: stretch;
  box-shadow: 0 -1px 0 rgba(255, 255, 255, .4) inset, 0 20px 40px -18px rgba(0, 0, 0, .8);
}
.tray-left { display: flex; flex-direction: column; justify-content: space-between; gap: 8px; }
.level { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 10px; align-items: center; }
.level-num { grid-row: span 2; font-weight: 800; font-size: 30px; line-height: 1; text-transform: uppercase; }
.level-num span { font-family: var(--pixel); }
.xp-bar { height: 7px; border-radius: 4px; background: rgba(0, 0, 0, .12); overflow: hidden; }
.xp-fill { height: 100%; background: #3d7be0; transform-origin: left; transition: transform .4s var(--ease-out); }
.xp-text { font-family: var(--pixel); font-size: 13px; color: var(--card-ink-2); }
.btn { display: inline-flex; align-items: center; gap: 8px; border: 0; cursor: pointer; border-radius: 10px; font-weight: 700; font-size: 17px; letter-spacing: .02em; text-transform: uppercase; transition: transform .12s var(--ease-out), background .15s, opacity .15s; }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn:active:not(:disabled) { transform: translateY(1px) scale(.98); }
.btn:disabled { opacity: .38; cursor: not-allowed; }
.btn-ghost { justify-content: flex-start; padding: 8px 10px; background: rgba(0, 0, 0, .06); color: var(--card-ink); }
.btn-ghost:hover:not(:disabled) { background: rgba(0, 0, 0, .11); }
.btn .cost { margin-left: auto; display: inline-flex; align-items: center; gap: 3px; font-family: var(--pixel); font-size: 15px; }
.btn .cost svg { width: 14px; height: 14px; color: #c9961f; }

.shop { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; min-width: 0; }
.card {
  position: relative; border: 0; padding: 0; cursor: pointer; border-radius: 11px; overflow: hidden; text-align: left;
  background: #fffaf0; color: var(--card-ink);
  box-shadow: 0 1px 0 rgba(0, 0, 0, .06), 0 6px 14px -8px rgba(0, 0, 0, .45);
  display: grid; grid-template-rows: 1fr auto;
  transition: transform .18s var(--ease-out), box-shadow .18s;
  outline: 2.5px solid var(--tier); outline-offset: -2.5px;
}
.card:hover:not(:disabled) { transform: translateY(-4px); box-shadow: 0 1px 0 rgba(0, 0, 0, .06), 0 14px 22px -10px rgba(0, 0, 0, .5); }
.card:disabled { cursor: not-allowed; }
.card.poor .card-cost { color: #b3261e; }
.card.empty { background: transparent; box-shadow: none; outline: 1.5px dashed rgba(0, 0, 0, .14); cursor: default; }
.card.owned::after { content: ''; position: absolute; inset: 0; border-radius: 11px; box-shadow: 0 0 0 3px var(--gold) inset; pointer-events: none; animation: owned 1.6s ease-in-out infinite; }
@keyframes owned { 50% { box-shadow: 0 0 0 3px rgba(242, 193, 78, .35) inset; } }
.card-art { position: relative; display: grid; place-items: end center; padding-bottom: 4px; overflow: hidden;
  background: linear-gradient(165deg, var(--tc), color-mix(in oklab, var(--tc2, var(--tc)) 60%, #000)); }
.card-art img { image-rendering: pixelated; max-height: 92%; }
.card-foot { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px; padding: 6px 9px 7px; }
.card-name { font-weight: 800; font-size: 17px; line-height: 1; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-traits { grid-column: 1 / -1; display: flex; gap: 8px; font-size: 13px; font-weight: 600; color: var(--card-ink-2); }
.card-traits span { display: inline-flex; align-items: center; gap: 4px; }
.card-traits i { width: 7px; height: 7px; border-radius: 50%; background: var(--tc); }
.card-cost { display: inline-flex; align-items: center; gap: 3px; font-family: var(--pixel); font-weight: 700; font-size: 17px; }
.card-cost svg { width: 15px; height: 15px; color: #c9961f; }
.card-have { position: absolute; left: 7px; top: 6px; font-family: var(--pixel); font-size: 12px; color: #fff; background: rgba(0, 0, 0, .45); padding: 1px 6px; border-radius: 99px; }

.sell-zone {
  position: absolute; inset: 8px; border-radius: 13px; display: grid; place-items: center;
  background: repeating-linear-gradient(-45deg, rgba(179, 38, 30, .08) 0 12px, rgba(179, 38, 30, .14) 12px 24px), var(--card);
  border: 2px dashed #b3261e; color: #8a1d17; font-weight: 800; font-size: 26px; text-transform: uppercase; letter-spacing: .02em;
}
.sell-zone.hot { background: repeating-linear-gradient(-45deg, rgba(179, 38, 30, .18) 0 12px, rgba(179, 38, 30, .26) 12px 24px), var(--card); }
.sell-zone span { font-family: var(--pixel); }

.tray-right { display: grid; grid-template-columns: 1fr auto auto; grid-template-rows: 1fr auto; gap: 8px; align-items: center; }
.gold { grid-column: 1; display: flex; align-items: center; gap: 7px; font-family: var(--pixel); font-weight: 700; font-size: 34px; line-height: 1; }
.gold svg { width: 28px; height: 28px; color: var(--gold); filter: drop-shadow(0 1px 0 rgba(0, 0, 0, .25)); }
.gold.bump { animation: bump .35s var(--ease-out); }
@keyframes bump { 40% { transform: scale(1.15); } }
.btn-icon { padding: 9px; background: rgba(0, 0, 0, .06); color: var(--card-ink); font-family: var(--pixel); font-size: 14px; gap: 4px; }
.btn-icon:hover { background: rgba(0, 0, 0, .11); }
.btn-icon.on { background: var(--card-ink); color: var(--gold); }
.btn-battle {
  grid-column: 1 / -1; justify-content: center; padding: 14px 16px; font-size: 24px; font-weight: 800; letter-spacing: .04em;
  background: var(--red); color: #fff; box-shadow: 0 3px 0 #9c2207, 0 10px 18px -8px rgba(227, 53, 13, .7);
}
.btn-battle svg { width: 22px; height: 22px; }
.btn-battle:hover:not(:disabled) { background: var(--red-hi); }
.btn-battle:active:not(:disabled) { box-shadow: 0 1px 0 #9c2207; transform: translateY(2px); }

/* ---------- overlay ---------- */
.overlay { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; background: rgba(6, 8, 12, .72); backdrop-filter: blur(3px); animation: fade .3s ease-out; }
.overlay[hidden], .toast[hidden], .banner[hidden], .sell-zone[hidden], .drag-ghost[hidden] { display: none; }
@keyframes fade { from { opacity: 0; } }
.overlay-card { background: var(--card); color: var(--card-ink); border-radius: 20px; padding: 30px 34px 32px; max-width: 760px; box-shadow: 0 40px 80px -30px #000; text-align: center; animation: rise .5s var(--ease-out); }
@keyframes rise { from { transform: translateY(16px) scale(.98); opacity: 0; } }
.overlay-card h1 { margin: 0; font-weight: 800; font-size: 44px; line-height: .95; text-transform: uppercase; letter-spacing: .01em; }
.overlay-card p { margin: 10px auto 0; font-size: 18px; color: var(--card-ink-2); max-width: 48ch; line-height: 1.35; font-weight: 500; }
.starters { display: grid; grid-template-columns: repeat(3, 190px); gap: 14px; margin-top: 24px; }
.starter { border: 0; cursor: pointer; border-radius: 14px; overflow: hidden; background: #fffaf0; padding: 0; box-shadow: 0 8px 18px -10px rgba(0, 0, 0, .5); transition: transform .2s var(--ease-out); outline: 2.5px solid transparent; outline-offset: -2.5px; }
.starter:hover { transform: translateY(-6px); outline-color: var(--tc); }
.starter .card-art { height: 140px; }
.starter .card-art img { transform: scale(1.6); transform-origin: 50% 100%; max-height: none; }
.starter div.name { padding: 10px 0 12px; font-weight: 800; font-size: 22px; text-transform: uppercase; }
.overlay-card .btn-battle { margin-top: 24px; display: inline-flex; padding: 13px 30px; }
.badge-big { width: 110px; height: 110px; margin: 0 auto 16px; animation: badge-pop 1s var(--ease-out); }

.toast { position: fixed; left: 50%; top: 72px; transform: translateX(-50%); z-index: 45; background: var(--card); color: var(--card-ink); padding: 9px 16px; border-radius: 10px; font-weight: 700; font-size: 17px; box-shadow: 0 14px 28px -12px #000; animation: toast 2.2s var(--ease-out) forwards; white-space: nowrap; }
@keyframes toast { 0% { opacity: 0; translate: 0 -8px; } 10%, 85% { opacity: 1; translate: 0 0; } 100% { opacity: 0; } }

body.combat .card, body.combat #btn-reroll, body.combat #btn-xp { opacity: .5; pointer-events: none; }

@media (max-width: 1280px) {
  .table { grid-template-columns: 200px minmax(0, 1fr) 240px; }
  .topbar { grid-template-columns: 200px 1fr auto auto auto; gap: 16px; }
  .bench { grid-template-columns: repeat(9, 64px); }
  .slot { height: 72px; }
  .tray { grid-template-columns: 170px 1fr 200px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------- held items ---------- */
.item-img { image-rendering: pixelated; width: 30px; height: 30px; display: block; }
.bag-wrap { position: absolute; left: 22px; top: 50%; transform: translateY(-50%); display: flex; align-items: flex-start; gap: 10px; }
.bag-label { writing-mode: vertical-rl; transform: rotate(180deg); font-size: 12px; font-weight: 700; letter-spacing: .18em; text-transform: uppercase; color: var(--silk-3); padding-top: 2px; }
.bag { display: grid; grid-template-columns: repeat(5, 36px); gap: 4px; max-height: 80px; overflow-y: auto; scrollbar-width: none; }
.bag-slot { width: 36px; height: 36px; border-radius: 8px; border: 1.5px dashed var(--silk-line); display: grid; place-items: center; }
.bag-slot.filled { border: 1px solid rgba(239, 230, 210, .22); background: rgba(239, 230, 210, .08); cursor: grab; transition: background .15s, transform .15s var(--ease-out); }
.bag-slot.filled:hover { background: rgba(239, 230, 210, .16); transform: translateY(-2px); }
.bag-slot.done { border-color: rgba(242, 193, 78, .55); background: rgba(242, 193, 78, .1); }
.bag-slot.lifted { opacity: .3; }
.drag-ghost.item { width: 44px; height: 44px; transform: translate(-50%, -50%); }
.drag-ghost.item .item-img { width: 44px; height: 44px; filter: drop-shadow(0 8px 6px rgba(0, 0, 0, .5)); }
.item-fly { position: fixed; z-index: 60; pointer-events: none; transform: translate(-50%, -50%) scale(1.5); transition: left .8s cubic-bezier(.45, 0, .2, 1), top .8s cubic-bezier(.3, 0, .2, 1), transform .8s var(--ease-out); filter: drop-shadow(0 0 8px rgba(242, 193, 78, .8)); }
.item-fly.land { transform: translate(-50%, -50%) scale(1); }

.unit .held { position: absolute; left: 50%; top: 82%; transform: translateX(-50%); display: flex; gap: 1px; z-index: 2; }
.unit .held .item-img { width: 18px; height: 18px; background: rgba(13, 17, 24, .78); border-radius: 4px; box-shadow: 0 0 0 1px rgba(239, 230, 210, .25); }
.unit:not(.in-combat) .stars { top: 70%; }
.unit:not(.in-combat) .held { top: 84%; }
.slot .unit .held { top: 3px; left: 3px; transform: none; flex-direction: column; }
.slot .unit .held .item-img { width: 16px; height: 16px; }
.unit.item-target .ring { opacity: 1; border-color: var(--gold); box-shadow: 0 0 12px rgba(242, 193, 78, .7); }

.detail-items { border-top: 1px solid rgba(0, 0, 0, .12); margin-top: 10px; padding-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.detail-item { display: grid; grid-template-columns: 30px 1fr; gap: 8px; align-items: start; }
.detail-item b { display: block; font-size: 15px; text-transform: uppercase; letter-spacing: .01em; }
.detail-item span { display: block; font-size: 14px; line-height: 1.25; color: var(--card-ink-2); font-weight: 500; }
.item-head { display: flex; align-items: center; gap: 12px; padding: 14px 14px 0; }
.item-img.big { width: 48px; height: 48px; background: var(--card-2); border-radius: 10px; padding: 4px; box-sizing: content-box; }
.item-kind { font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--card-ink-2); margin-top: 3px; }
.item-desc { margin: 0 0 10px; font-size: 15px; line-height: 1.3; font-weight: 600; }
.recipes { border-top: 1px solid rgba(0, 0, 0, .12); padding-top: 8px; display: flex; flex-direction: column; gap: 3px; }
.recipes-title { font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--card-ink-2); margin-bottom: 2px; }
.recipe { display: flex; align-items: center; gap: 5px; font-size: 14px; }
.recipe .item-img { width: 24px; height: 24px; }
.recipe b { margin-left: 4px; font-weight: 700; }
.recipe .arrow { width: 10px; height: 2px; background: var(--card-ink-2); position: relative; }
.recipe .arrow::after { content: ''; position: absolute; right: -1px; top: -3px; border: 4px solid transparent; border-left-color: var(--card-ink-2); border-right: 0; }
.recipe .plus { font-weight: 800; color: var(--card-ink-2); }
.item-hint { margin: 10px 0 0; font-size: 13px; line-height: 1.3; color: var(--card-ink-2); font-weight: 500; }

/* ---------- augments ---------- */
.augments-wrap { margin-top: 22px; }
.augments-wrap[hidden] { display: none; }
#augments { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.aug { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; color: var(--silk-2); }
.aug img { width: 26px; height: 26px; image-rendering: pixelated; }
.augs { display: grid; grid-template-columns: repeat(3, 200px); gap: 14px; margin-top: 24px; }
.aug-card { border: 0; cursor: pointer; border-radius: 14px; background: #fffaf0; padding: 18px 14px 18px; box-shadow: 0 8px 18px -10px rgba(0, 0, 0, .5); transition: transform .2s var(--ease-out), outline-color .2s; outline: 2.5px solid transparent; outline-offset: -2.5px; color: var(--card-ink); display: flex; flex-direction: column; align-items: center; gap: 8px; }
.aug-card:hover { transform: translateY(-6px); outline-color: var(--gold); }
.aug-icon { width: 76px; height: 76px; border-radius: 50%; background: var(--card-2); display: grid; place-items: center; }
.aug-icon img { width: 60px; height: 60px; image-rendering: pixelated; }
.aug-name { font-weight: 800; font-size: 22px; text-transform: uppercase; line-height: 1; }
.aug-desc { font-size: 15px; line-height: 1.3; color: var(--card-ink-2); font-weight: 500; }

@media (max-width: 1280px) {
  .bag { grid-template-columns: repeat(5, 32px); }
  .bag-slot { width: 32px; height: 32px; }
  .item-img { width: 26px; height: 26px; }
}

/* ---------- mute ---------- */
.btn-top { width: 34px; height: 34px; border: 0; border-radius: 9px; background: rgba(239, 230, 210, .06); color: var(--silk-2); display: grid; place-items: center; cursor: pointer; transition: background .15s, color .15s; }
.btn-top:hover { background: rgba(239, 230, 210, .12); color: var(--silk); }
.btn-top svg { width: 19px; height: 19px; }

/* ---------- shiny ---------- */
@keyframes shimmer { 0% { background-position: -120% 0; } 100% { background-position: 220% 0; } }
.card.shiny { outline-color: var(--gold); outline-width: 3px; }
.card.shiny .card-art::after, .safari-card.shiny .card-art::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(110deg, transparent 35%, rgba(255, 255, 255, .55) 48%, rgba(255, 246, 200, .2) 54%, transparent 65%) no-repeat;
  background-size: 60% 100%; animation: shimmer 2.4s ease-in-out infinite;
}
.card-shiny { position: absolute; right: 6px; top: 6px; z-index: 1; font-family: var(--pixel); font-size: 11px; color: #3a2a00; background: var(--gold); padding: 1px 6px; border-radius: 99px; box-shadow: 0 1px 0 rgba(0, 0, 0, .2); }
.unit.shiny .ring { border-color: var(--gold); opacity: .9; }
.unit.shiny::after { content: ''; position: absolute; left: 50%; top: 20%; width: 46%; height: 46%; transform: translateX(-50%); pointer-events: none;
  background: radial-gradient(circle, #fff 0 1.5px, transparent 2px) 10% 20% / 30% 30%, radial-gradient(circle, #fff6c8 0 1.2px, transparent 1.8px) 70% 60% / 26% 26%;
  animation: twinkle 1.8s ease-in-out infinite; opacity: .8; }
@keyframes twinkle { 50% { opacity: .1; } }
.shiny-tag { position: absolute; left: 10px; top: 9px; font-family: var(--pixel); font-size: 12px; color: #3a2a00; background: var(--gold); padding: 1px 7px; border-radius: 99px; }

/* ---------- safari / eevee / resume ---------- */
.safari, .eevees { display: grid; grid-template-columns: repeat(5, minmax(0, 150px)); gap: 12px; margin-top: 22px; justify-content: center; }
.overlay-card:has(.safari), .overlay-card:has(.eevees) { max-width: min(900px, calc(100vw - 32px)); }
.safari .card-art, .eevees .card-art { height: 110px; position: relative; }
.safari .card-art img, .eevees .card-art img { transform: scale(1.35); }
.safari .name, .eevees .name { font-size: 19px; padding: 8px 0 2px; }
.safari-item { display: flex; align-items: center; justify-content: center; gap: 4px; padding: 0 8px 12px; font-size: 14px; font-weight: 700; color: var(--card-ink-2); }
.safari-item .item-img { width: 26px; height: 26px; }
.eevee-meta { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 0 10px 14px; }
.eevee-meta b { font-size: 15px; text-transform: uppercase; }
.eevee-meta > span:last-child { font-size: 13px; line-height: 1.25; color: var(--card-ink-2); font-weight: 500; }
.resume-actions { display: flex; gap: 10px; justify-content: center; align-items: center; margin-top: 22px; }
.resume-actions .btn-battle { margin-top: 0; }
.resume-actions .btn-ghost { padding: 13px 22px; font-size: 18px; }

/* ---------- damage meter ---------- */
.meter[hidden] { display: none; }
#meter-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 7px; }
#meter-list li { display: grid; grid-template-columns: 34px 1fr; gap: 8px; align-items: center; }
#meter-list li.fainted { opacity: .5; }
#meter-list img { width: 34px; height: 34px; object-fit: contain; image-rendering: pixelated; }
.meter-top { display: flex; justify-content: space-between; font-size: 15px; font-weight: 700; line-height: 1; margin-bottom: 4px; }
.meter-top b { font-family: var(--pixel); font-weight: 500; color: var(--silk-2); }
.meter-bar { height: 6px; border-radius: 3px; background: rgba(239, 230, 210, .08); overflow: hidden; }
.meter-bar i { display: block; height: 100%; background: var(--gold); transform-origin: left; transition: transform .3s var(--ease-out); }
#meter-list li:first-child .meter-bar i { background: var(--red-hi); }

/* ---------- legendaries ---------- */
.card.legend { outline-width: 3px; }
.card.legend .card-art { background: radial-gradient(120% 90% at 50% 100%, color-mix(in oklab, var(--tc) 70%, #fff) 0%, var(--tc) 45%, color-mix(in oklab, var(--tc) 40%, #000) 100%); }
.card.legend .card-name { color: #7a4f00; }
.unit.legend .ring { border-color: #e0a526; opacity: .95; box-shadow: 0 0 10px rgba(224, 165, 38, .55); }
.unit.legend.foe .ring { border-color: #ff8a3d; }

/* ---------- lobby standings ---------- */
#standings-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
#standings-list li { display: grid; grid-template-columns: 28px 1fr auto 54px 26px; align-items: center; gap: 7px; padding: 2px 6px 2px 2px; border-radius: 7px; transition: background .15s; }
#standings-list li[data-id] { cursor: pointer; }
#standings-list li[data-id]:hover { background: rgba(239, 230, 210, .07); }
#standings-list li.you { background: rgba(242, 193, 78, .1); box-shadow: 0 0 0 1px rgba(242, 193, 78, .3) inset; }
#standings-list li.next { box-shadow: 0 0 0 1px rgba(255, 93, 79, .55) inset; background: rgba(255, 93, 79, .08); }
#standings-list li.out { opacity: .42; }
#standings-list li.out img { filter: grayscale(1); }
#standings-list img { width: 28px; height: 28px; object-fit: contain; image-rendering: pixelated; }
.st-name { font-weight: 700; font-size: 15px; line-height: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 5px; }
.st-name em { font-style: normal; font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: #fff; background: var(--foe); padding: 1px 4px; border-radius: 3px; }
.st-lv { font-family: var(--pixel); font-size: 11px; color: var(--silk-3); }
.st-bar { height: 5px; border-radius: 3px; background: rgba(239, 230, 210, .08); overflow: hidden; }
.st-bar i { display: block; height: 100%; background: var(--ally); transform-origin: left; transition: transform .5s var(--ease-out); }
#standings-list li:not(.you) .st-bar i { background: #8fb3c9; }
#standings-list b { font-family: var(--pixel); font-weight: 500; font-size: 13px; text-align: right; color: var(--silk-2); }
.st-place { color: var(--silk-3) !important; }
.inspector { gap: 20px; }
.round-pips i.rival { border-radius: 2px; }

/* ---------- scouting ---------- */
.scout .detail-body { padding-top: 14px; }
.scout-meta { font-size: 14px; font-weight: 600; color: var(--card-ink-2); margin: 4px 0 10px; }
.scout-units { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; margin-bottom: 8px; }
.scout-unit { position: relative; display: grid; place-items: center; padding: 4px 0 12px; background: var(--card-2); border-radius: 7px; }
.scout-unit img { width: 40px; height: 40px; object-fit: contain; image-rendering: pixelated; }
.scout-unit .stars { position: absolute; bottom: 1px; display: flex; }
.scout-unit .star { width: 8px; height: 8px; }
.scout-items { position: absolute; top: 1px; right: 1px; display: flex; flex-direction: column; gap: 1px; }
.scout-items .item-img { width: 12px; height: 12px; }

/* ---------- placement ---------- */
.placement { font-family: var(--pixel); font-weight: 700; font-size: 64px; line-height: 1; color: var(--card-ink); margin-bottom: 6px; }
.placement small { display: block; font-family: var(--display); font-size: 15px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--card-ink-2); margin-top: 4px; }
.placement.p1 { color: #b8860b; }
.placement.p2, .placement.p3, .placement.p4 { color: #3d7be0; }

/* ---------- floating detail card ---------- */
.detail-pop { position: fixed; z-index: 35; width: 272px; pointer-events: none; animation: pop-in .14s var(--ease-out); }
.detail-pop[hidden] { display: none; }
@keyframes pop-in { from { opacity: 0; transform: translateY(4px); } }
.detail-pop .detail-card { box-shadow: 0 22px 44px -14px rgba(0, 0, 0, .8), 0 0 0 1px rgba(0, 0, 0, .25); }
.detail-pop .detail-art { height: 92px; }
@media (max-width: 1280px) { .st-name em { display: none; } }

/* =====================================================================
   Touch + responsive
   Desktop keeps the three-column table. Phones (and portrait tablets) get
   a single column: board up top, synergies as a swipe strip, bench and shop
   at thumb height, and Lobby / Next up / damage in a pull-up sheet.
   Phone landscape puts the board on the left and the controls on the right.
   ===================================================================== */
html { touch-action: manipulation; -webkit-text-size-adjust: 100%; overflow: hidden; width: 100%; }
.mat { max-width: 100%; }
#app { height: 100vh; height: 100dvh; }
.unit, .bag-slot.filled { touch-action: none; -webkit-touch-callout: none; }
img { -webkit-user-drag: none; }
.btn-sheet, .sheet-head, .sheet-scrim { display: none; }

/* ---- shared compact rules: phone portrait, portrait tablet, phone landscape ---- */
@media (max-width: 760px), (max-width: 1024px) and (orientation: portrait), (orientation: landscape) and (max-height: 540px) {
  .table { display: contents; }

  .topbar { grid-area: top; grid-template-columns: auto minmax(0, 1fr) auto auto auto; gap: 8px; padding: max(6px, env(safe-area-inset-top)) 12px 6px; }
  .brand span { display: none; }
  .round-info { justify-content: flex-start; gap: 8px; min-width: 0; }
  .round-stage { font-size: 12px; white-space: nowrap; }
  .round-label { font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
  .btn-sheet { display: grid; }
  .btn-top { width: 40px; height: 40px; }
  .player-hp { font-size: 20px; }

  /* synergies: one swipeable strip */
  .traits { grid-area: traits; padding: 2px 12px 6px; overflow-x: auto; overflow-y: hidden; display: flex; gap: 6px; align-items: center; scrollbar-width: none; }
  .traits::-webkit-scrollbar { display: none; }
  .traits .panel-title { display: none; }
  .traits-empty { margin: 0; font-size: 13px; max-width: none; white-space: nowrap; }
  .traits-empty[hidden] { display: none; }
  .traits ul { flex-direction: row; gap: 6px; flex: none; }
  .trait { grid-template-columns: 22px auto; gap: 6px; padding: 3px 9px 3px 3px; }
  .trait-hex { width: 22px; height: 22px; font-size: 12px; }
  .trait-name { font-size: 14px; white-space: nowrap; }
  .trait-tiers { display: none; }
  .augments-wrap { margin: 0; flex: none; }
  .augments-wrap .panel-title { display: none; }
  #augments { flex-direction: row; gap: 2px; }
  .aug span { display: none; }
  .aug img { width: 26px; height: 26px; }

  .arena { grid-area: arena; padding: 2px 6px; }
  .mat-print { display: none; }
  .mat { border-radius: 18px; }
  .mat::after { inset: 5px; border-radius: 14px; }

  /* bench + bag */
  .bench-row { grid-area: bench; display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "bag cap" "bench bench"; gap: 4px 10px; padding: 4px 12px 6px; align-items: center; }
  .bag-wrap { grid-area: bag; position: static; transform: none; min-width: 0; }
  .bag-label { display: none; }
  .bag { display: flex; gap: 4px; max-height: none; overflow-x: auto; scrollbar-width: none; }
  .bag-slot { width: 34px; height: 34px; flex: none; }
  .bag-slot:not(.filled) { display: none; }
  .board-cap { grid-area: cap; position: static; display: flex; align-items: baseline; gap: 6px; font-size: 13px; }
  .board-cap b { font-size: 18px; }
  .bench { grid-area: bench; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 4px; width: 100%; }
  .slot { height: auto; aspect-ratio: 4 / 5; border-radius: 9px; }
  .slot .unit img { transform: translateX(-50%) scale(calc(var(--s) * .9)); }

  /* shop tray: level + gold, five cards, then the buttons */
  .tray { grid-area: tray; margin: 0 8px max(8px, env(safe-area-inset-bottom)); padding: 10px; gap: 8px; border-radius: 16px;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto auto minmax(0, 1.5fr);
    grid-template-areas: "lvl lvl lvl gold gold" "shop shop shop shop shop" "xp reroll lock speed battle"; }
  .tray-left, .tray-right { display: contents; }
  .level { grid-area: lvl; }
  .level-num { font-size: 24px; }
  .gold { grid-area: gold; justify-content: flex-end; font-size: 26px; }
  .gold svg { width: 22px; height: 22px; }
  .shop { grid-area: shop; gap: 6px; }
  #btn-xp { grid-area: xp; }
  #btn-reroll { grid-area: reroll; }
  #btn-lock { grid-area: lock; }
  #btn-speed { grid-area: speed; }
  .btn-battle { grid-area: battle; font-size: 20px; padding: 8px 10px; gap: 6px; }
  .tray .btn { min-height: 46px; }
  .btn-ghost { flex-direction: column; justify-content: center; gap: 1px; padding: 4px 6px; font-size: 13px; line-height: 1.1; }
  .btn-ghost > svg { display: none; }
  .btn .cost { margin-left: 0; font-size: 13px; }
  .btn-icon { padding: 8px 10px; }
  .sell-zone { font-size: 18px; text-align: center; padding: 0 12px; }

  .card { grid-template-rows: 60px auto; }
  .card-art img { max-height: 56px; }
  .card-foot { padding: 4px 6px 5px; grid-template-columns: 1fr; }
  .card-name { font-size: 13px; }
  .card-cost { position: absolute; top: 4px; right: 4px; gap: 2px; font-size: 12px; color: #fff; background: rgba(0, 0, 0, .5); padding: 1px 6px 1px 4px; border-radius: 99px; }
  .card-cost svg { width: 11px; height: 11px; }
  .card-traits { display: none; }
  .card-shiny { top: auto; bottom: 3px; right: auto; left: 4px; }
  .card:hover:not(:disabled) { transform: none; }

  /* Lobby / Next up / damage meter: pull-up sheet */
  .inspector {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    max-height: min(80dvh, 680px); overflow-y: auto; overscroll-behavior: contain;
    padding: 0 16px calc(18px + env(safe-area-inset-bottom)); gap: 18px;
    background: var(--ink-2); border-radius: 20px 20px 0 0;
    box-shadow: 0 -24px 60px rgba(0, 0, 0, .6), 0 -1px 0 var(--silk-line);
    transform: translateY(105%); visibility: hidden;
    transition: transform .34s var(--ease-out), visibility 0s .34s;
  }
  body.sheet-open .inspector { transform: none; visibility: visible; transition: transform .34s var(--ease-out); }
  .sheet-head { display: flex; flex-direction: column; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 1; background: var(--ink-2); padding: 10px 0 6px; }
  .sheet-grip { width: 40px; height: 4px; border-radius: 2px; background: var(--silk-3); }
  .sheet-head .badge { width: 24px; height: 24px; }
  .sheet-scrim { display: block; position: fixed; inset: 0; z-index: 29; background: rgba(6, 8, 12, .55); opacity: 0; pointer-events: none; transition: opacity .25s; }
  body.sheet-open .sheet-scrim { opacity: 1; pointer-events: auto; }
  body.sheet-open .btn-sheet { background: var(--silk); color: var(--ink); }
  #standings-list li { min-height: 42px; grid-template-columns: 32px 1fr auto 72px 32px; }
  #standings-list img { width: 32px; height: 32px; }
  .st-name { font-size: 16px; }
  .st-name em { display: inline; }

  /* dialogs */
  .overlay-card { width: calc(100vw - 24px); max-height: calc(100dvh - 24px); overflow-y: auto; padding: 22px 16px 20px; border-radius: 18px; }
  .overlay-card h1 { font-size: 30px; }
  .overlay-card p { font-size: 16px; }
  .starters { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 18px; }
  .starter .card-art { height: 96px; }
  .starter .card-art img { transform: scale(1.2); }
  .starter div.name { font-size: 16px; padding: 8px 0 10px; }
  .augs { grid-template-columns: 1fr; gap: 8px; margin-top: 18px; }
  .aug-card { display: grid; grid-template-columns: 56px 1fr; grid-template-rows: auto auto; column-gap: 12px; row-gap: 2px; text-align: left; padding: 12px; align-items: center; }
  .aug-icon { grid-row: span 2; width: 56px; height: 56px; }
  .aug-icon img { width: 44px; height: 44px; }
  .aug-name { font-size: 19px; align-self: end; }
  .aug-desc { align-self: start; }
  .safari, .eevees { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; margin-top: 18px; }
  .safari .card-art, .eevees .card-art { height: 80px; }
  .eevee-meta > span:last-child { display: none; }
  .resume-actions { flex-direction: column; align-items: stretch; }
  .resume-actions .btn { justify-content: center; }
  .placement { font-size: 48px; }

  .toast { top: calc(58px + env(safe-area-inset-top)); white-space: normal; text-align: center; width: max-content; max-width: calc(100vw - 32px); font-size: 15px; }
  .banner { font-size: 40px; }
  .detail-pop { width: min(300px, calc(100vw - 24px)); }
  .detail-pop .detail-art { height: 76px; }
}

/* ---- phone portrait & portrait tablet: one column ---- */
@media (max-width: 760px), (max-width: 1024px) and (orientation: portrait) {
  #app { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto minmax(0, 1fr) auto auto; grid-template-areas: "top" "traits" "arena" "bench" "tray"; }
  .topbar > .badges { display: none; }
}
@media (max-width: 400px) { .round-pips { display: none; } }

/* ---- portrait tablets: same column, roomier controls ---- */
@media (min-width: 600px) and (max-width: 1024px) and (orientation: portrait) {
  .card { grid-template-rows: 90px auto; }
  .card-art img { max-height: 84px; }
  .card-name { font-size: 16px; }
  .card-traits { display: flex; }
  .btn-ghost { flex-direction: row; font-size: 15px; gap: 6px; }
  .btn-ghost > svg { display: block; }
  .inspector { left: auto; width: min(460px, 100vw); right: 0; }
}

/* ---- phone landscape: board left, controls right ---- */
@media (orientation: landscape) and (max-height: 540px) {
  #app { grid-template-columns: minmax(0, 1fr) minmax(320px, 47vw); grid-template-rows: auto auto auto minmax(0, 1fr); grid-template-areas: "top top" "arena traits" "arena bench" "arena tray"; }
  .topbar { grid-template-columns: auto minmax(0, 1fr) auto auto auto auto; padding-top: max(4px, env(safe-area-inset-top)); padding-bottom: 4px; }
  .topbar > .badges { gap: 3px; }
  .topbar > .badges .badge { width: 15px; height: 15px; }
  .btn-top { width: 36px; height: 36px; }
  .tray { margin: 0 max(8px, env(safe-area-inset-right)) 8px 0; align-self: end; padding: 8px; gap: 6px; }
  .card { grid-template-rows: 46px auto; }
  .card-art img { max-height: 44px; }
  .tray .btn { min-height: 42px; }
  .level-num { font-size: 20px; }
  .gold { font-size: 22px; }
  .bench-row { padding-left: 0; padding-right: max(12px, env(safe-area-inset-right)); }
  .traits { padding-left: 0; }
  .arena { padding-left: max(6px, env(safe-area-inset-left)); }
  .inspector { left: auto; width: min(420px, 100vw); }
}

/* =====================================================================
   Multiplayer: title screen, room screens, timer, ready state
   ===================================================================== */
.title-mark { width: 54px; height: 54px; margin: 0 auto 10px; color: var(--red); }
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 24px; text-align: left; }
.mode-card { border: 0; cursor: pointer; border-radius: 14px; padding: 18px 18px 20px; background: #fffaf0; color: var(--card-ink); display: flex; flex-direction: column; gap: 6px; box-shadow: 0 8px 18px -10px rgba(0, 0, 0, .5); outline: 2.5px solid transparent; outline-offset: -2.5px; transition: transform .2s var(--ease-out), outline-color .2s; }
.mode-card:hover { transform: translateY(-4px); outline-color: var(--card-ink-2); }
.mode-card.hot { background: var(--red); color: #fff; box-shadow: 0 3px 0 #9c2207, 0 12px 22px -10px rgba(227, 53, 13, .7); }
.mode-card.hot:hover { outline-color: rgba(255, 255, 255, .6); }
.mode-card b { font-size: 24px; font-weight: 800; text-transform: uppercase; line-height: 1; }
.mode-card span { font-size: 15px; line-height: 1.3; font-weight: 500; opacity: .85; }

.field { display: flex; flex-direction: column; gap: 6px; text-align: left; margin: 22px 0 14px; }
.field span { font-size: 13px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--card-ink-2); }
.overlay-card input { font: inherit; font-size: 20px; font-weight: 700; padding: 12px 14px; border-radius: 10px; border: 2px solid var(--card-2); background: #fffaf0; color: var(--card-ink); outline: none; width: 100%; min-width: 0; user-select: text; }
.overlay-card input:focus { border-color: var(--card-ink); }
#mp-code { font-family: var(--pixel); letter-spacing: .2em; text-transform: uppercase; text-align: center; }
.btn.wide { width: 100%; justify-content: center; margin-top: 0; }
.or { display: flex; align-items: center; gap: 10px; margin: 14px 0; color: var(--card-ink-2); font-size: 14px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; }
.or::before, .or::after { content: ''; flex: 1; height: 1px; background: var(--card-2); }
.join-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.join-row .btn { padding: 0 22px; font-size: 20px; margin-top: 0; }
.form-error { color: #b3261e !important; font-weight: 700 !important; min-height: 1.3em; margin-top: 10px !important; }
.link-btn { border: 0; background: none; color: var(--card-ink-2); font-weight: 700; font-size: 16px; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; margin-top: 6px; padding: 8px; }

.room-label { margin: 0 !important; font-size: 13px !important; font-weight: 700 !important; letter-spacing: .14em; text-transform: uppercase; }
.room-code { font-family: var(--pixel); font-weight: 700; font-size: 64px; letter-spacing: .14em; line-height: 1.1; margin: 4px 0 10px; color: var(--card-ink); }
.share-btn { margin: 0 auto 18px; padding: 10px 16px; }
.room-list { list-style: none; margin: 0 0 18px; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; text-align: left; }
.room-list li { display: flex; align-items: center; gap: 8px; padding: 6px 10px 6px 6px; border-radius: 10px; background: #fffaf0; font-weight: 700; font-size: 16px; min-height: 46px; }
.room-list li img { width: 34px; height: 34px; object-fit: contain; image-rendering: pixelated; }
.room-list li.you { box-shadow: 0 0 0 2px var(--gold) inset; }
.room-list li.away { opacity: .5; }
.room-list li.empty { background: transparent; border: 1.5px dashed var(--card-2); color: var(--card-ink-2); font-weight: 600; font-size: 14px; padding-left: 12px; }
.room-list li em { margin-left: auto; font-style: normal; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; background: var(--card-ink); color: var(--gold); padding: 2px 6px; border-radius: 4px; }
.room-wait { font-weight: 700 !important; color: var(--card-ink) !important; }
.podium { list-style: none; margin: 16px auto 0; padding: 0; display: flex; flex-direction: column; gap: 6px; max-width: 320px; }
.podium li { display: grid; grid-template-columns: 36px 1fr auto; align-items: center; gap: 10px; background: #fffaf0; border-radius: 10px; padding: 4px 12px 4px 4px; font-weight: 700; font-size: 17px; text-align: left; }
.podium img { width: 36px; height: 36px; object-fit: contain; image-rendering: pixelated; }
.podium b { font-family: var(--pixel); }

body.mp .badges, body.mp .round-pips { display: none; }
.round-label.urgent { color: var(--foe); animation: tick-pulse 1s ease-in-out infinite; }
@keyframes tick-pulse { 50% { opacity: .55; } }
body.mp .round-label { font-family: var(--pixel); }
.btn-battle.is-ready { background: #2f7d4f; box-shadow: 0 3px 0 #1d5235, 0 10px 18px -8px rgba(47, 125, 79, .7); }
.btn-battle.is-ready:hover:not(:disabled) { background: #379a5f; }
#standings-list .st-name i.ai { font-style: normal; font-size: 10px; font-weight: 700; letter-spacing: .08em; color: var(--silk-3); border: 1px solid var(--silk-line); border-radius: 3px; padding: 0 3px; }
#standings-list .st-name em.ok { background: #2f7d4f; }

@media (max-width: 760px), (max-width: 1024px) and (orientation: portrait), (orientation: landscape) and (max-height: 540px) {
  .modes { grid-template-columns: 1fr; }
  .room-code { font-size: 48px; }
  .room-list { grid-template-columns: 1fr; }
  .room-list li.empty:nth-of-type(n+6) { display: none; }
  body.mp .round-label { font-size: 17px; }
}
