/* Trainer Card (js/trainercard.js): hero with live 3D avatar, level ring, stat tiles, party strip, badge case, achievements.
   Uses the shared panel theme (style.css :root) — navy surfaces, cyan accents, gold highlights; Nunito + Lilita One. */
.tcx-panel.modal.size-md { width: min(760px, calc(100vw - 32px)); }
.tcx { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.tcx > * { animation: tcx-up 420ms var(--ease) both; }
.tcx > :nth-child(2) { animation-delay: 50ms; } .tcx > :nth-child(3) { animation-delay: 100ms; }
.tcx > :nth-child(4) { animation-delay: 150ms; } .tcx > :nth-child(5) { animation-delay: 200ms; } .tcx > :nth-child(6) { animation-delay: 250ms; }
@keyframes tcx-up { from { opacity: 0; transform: translateY(10px); } }

/* ---------------------------------------------------------------- hero */
.tcx-hero {
  position: relative; display: grid; grid-template-columns: minmax(0, 236px) minmax(0, 1fr); gap: 16px; padding: 14px; border-radius: 24px; overflow: hidden; isolation: isolate;
  background:
    radial-gradient(120% 90% at 100% 0%, rgba(76, 200, 255, .28), transparent 55%),
    radial-gradient(90% 80% at 0% 100%, rgba(255, 207, 74, .16), transparent 60%),
    linear-gradient(135deg, #2a3f8f 0%, #1a2a63 48%, #101a40 100%);
  border: 1px solid rgba(140, 200, 255, .32);
  box-shadow: 0 14px 34px rgba(2, 6, 20, .45), inset 0 1px 0 rgba(255, 255, 255, .14);
}
.tcx-hero::before { /* card sheen */
  content: ''; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: linear-gradient(115deg, transparent 30%, rgba(255, 255, 255, .09) 45%, transparent 60%) no-repeat;
  background-size: 260% 100%; animation: tcx-sheen 7s ease-in-out infinite;
}
.tcx-hero::after { /* concentric rings */
  content: ''; position: absolute; right: -80px; top: -90px; width: 280px; height: 280px; border-radius: 50%; z-index: -1; pointer-events: none;
  border: 30px solid rgba(255, 255, 255, .05); box-shadow: 0 0 0 46px rgba(255, 255, 255, .025);
}
@keyframes tcx-sheen { 0%, 60% { background-position: 130% 0; } 100% { background-position: -130% 0; } }

.tcx-stage.stage { min-height: 270px; border-radius: 18px; --t: #5fc8ff;
  background: radial-gradient(ellipse 70% 55% at 50% 38%, rgba(120, 200, 255, .45), transparent 70%), radial-gradient(ellipse at 50% 30%, #2d4c9c, #0e1838 74%);
  border: 1px solid rgba(160, 210, 255, .28); box-shadow: inset 0 -30px 40px rgba(5, 10, 30, .35); }
.tcx-wardrobe { position: absolute; right: 8px; top: 8px; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 14px; z-index: 1;
  color: #fff; background: rgba(10, 20, 50, .55); border: 1px solid rgba(255, 255, 255, .22); backdrop-filter: blur(6px); transition: background var(--t), transform var(--t) var(--ease); }
.tcx-wardrobe .ic { width: 22px; height: 22px; }
.tcx-wardrobe:hover { background: rgba(255, 207, 74, .3); }
.tcx-wardrobe:active { transform: scale(.94); }

.tcx-id { display: flex; flex-direction: column; gap: 8px; min-width: 0; padding-top: 2px; }
.tcx-kicker { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 900; letter-spacing: 1.4px; text-transform: uppercase; color: #9fdcff; }
.tcx-kicker .ic { width: 15px; height: 15px; }
.tcx-name { display: flex; align-items: center; gap: 4px; min-width: 0; cursor: text; }
html .tcx .tcx-name input { flex: 1; min-width: 0; width: 100%; font: 400 clamp(24px, 4.6vw, 32px)/1.1 'Lilita One', Nunito, sans-serif; letter-spacing: .5px; color: #fff;
  background: transparent; border: 1px solid transparent; border-radius: 10px; padding: 4px 6px; margin-left: -6px; min-height: 44px;
  text-shadow: 0 2px 0 rgba(5, 10, 30, .45); }
.tcx-name input:hover, .tcx-name input:focus { border-color: rgba(255, 255, 255, .35); background: rgba(0, 0, 0, .22); outline: none; }
.tcx-edit { display: grid; place-items: center; width: 28px; color: rgba(255, 255, 255, .55); flex: none; }
.tcx-edit .ic { width: 18px; height: 18px; }
.tcx-user { margin-top: -6px; font-weight: 800; font-size: 13.5px; color: #cfe0ff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tcx-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.tcx-title { font-size: 12px; font-weight: 900; color: #3a2400; background: linear-gradient(#ffe07a, #f0a51c); padding: 4px 11px; border-radius: 999px;
  box-shadow: 0 2px 8px rgba(240, 165, 28, .35), inset 0 1px 0 rgba(255, 255, 255, .6); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tcx-chip { --c: #9fdcff; display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 900; padding: 3px 10px 3px 7px; border-radius: 999px;
  color: #fff; background: color-mix(in srgb, var(--c) 22%, rgba(10, 20, 50, .6)); border: 1px solid color-mix(in srgb, var(--c) 60%, transparent); }
.tcx-chip .ic { width: 15px; height: 15px; color: var(--c); }
.tcx-chip i { font-style: normal; opacity: .75; }
.tcx-chip.tier-bronze { --c: #e09a62; } .tcx-chip.tier-silver { --c: #d8e2f2; } .tcx-chip.tier-gold { --c: #ffcf4a; }
.tcx-chip.tier-platinum { --c: #6fe3d0; } .tcx-chip.tier-diamond { --c: #7cc8ff; } .tcx-chip.tier-master { --c: #d08cff; }
.tcx-chip.guild { --c: var(--g); }

.tcx-level { display: flex; align-items: center; gap: 12px; margin-top: auto; padding: 10px 12px; border-radius: 16px;
  background: rgba(5, 12, 34, .42); border: 1px solid rgba(255, 255, 255, .1); }
.tcx-lvring { position: relative; display: grid; place-items: center; flex: none; width: 64px; height: 64px; }
.tcx-lvring > span { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; line-height: 1; }
.tcx-lvring small { font-size: 9.5px; font-weight: 900; letter-spacing: 1px; color: #ffe7a0; }
.tcx-lvring b { font: 400 24px 'Lilita One', Nunito, sans-serif; color: #fff; text-shadow: 0 2px 0 rgba(0, 0, 0, .35); }
.tcx-xp { display: flex; flex-direction: column; gap: 5px; min-width: 0; flex: 1; }
.tcx-xp > b { font-size: 14px; }
.tcx-xp > small { font-size: 11.5px; font-weight: 800; color: var(--muted); }

/* rings + bars */
.tcx-ring { display: block; }
.tcx-ring .trk { fill: none; stroke: rgba(255, 255, 255, .12); }
.tcx-ring .val { fill: none; stroke-linecap: round; stroke-dashoffset: var(--off); animation: tcx-ring 1s var(--ease) both 200ms; }
.tcx-ring.gold .val { stroke: #ffcf4a; filter: drop-shadow(0 0 4px rgba(255, 207, 74, .65)); }
.tcx-ring.red .val { stroke: #ff6b6b; filter: drop-shadow(0 0 3px rgba(255, 95, 107, .55)); }
@keyframes tcx-ring { from { stroke-dashoffset: var(--len); } }
.tcx-bar { position: relative; height: 8px; border-radius: 999px; background: rgba(255, 255, 255, .1); overflow: hidden; }
.tcx-bar i { position: absolute; inset: 0 auto 0 0; width: var(--w); border-radius: inherit; background: linear-gradient(90deg, #4cc8ff, #7aa8ff);
  box-shadow: 0 0 8px rgba(76, 200, 255, .55); animation: tcx-bar 900ms var(--ease) both 250ms; }
.tcx-bar.xp i { background: linear-gradient(90deg, #f3a51e, #ffe07a); box-shadow: 0 0 8px rgba(255, 207, 74, .55); }
@keyframes tcx-bar { from { width: 0; } }

/* ---------------------------------------------------------------- stat tiles */
.tcx-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(160px, 100%), 1fr)); gap: 10px; }
.tcx-tile { display: flex; align-items: center; gap: 12px; min-width: 0; padding: 12px 14px; border-radius: 18px;
  background: linear-gradient(160deg, rgba(255, 255, 255, .085), rgba(255, 255, 255, .03)); border: 1px solid var(--line);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06); transition: transform var(--t) var(--ease), border-color var(--t); }
.tcx-tile:hover { border-color: var(--line-2); transform: translateY(-1px); }
.tcx-tile .ic-tile { width: 42px; height: 42px; flex: none; }
.tcx-tv { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; }
.tcx-tv b { font: 400 22px 'Lilita One', Nunito, sans-serif; letter-spacing: .3px; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tcx-tv b small.of { font: 800 13px Nunito, sans-serif; color: var(--muted); }
.tcx-tv > small { order: -1; font-size: 11px; font-weight: 900; letter-spacing: .6px; text-transform: uppercase; color: var(--muted); }
.tcx-tv em { font-style: normal; font-size: 11.5px; font-weight: 700; color: #9fb3dc; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tcx-tile.dex { grid-column: 1 / -1; }
.tcx-dexring { position: relative; width: 52px; height: 52px; flex: none; display: grid; place-items: center; }
.tcx-dexring > span { position: absolute; inset: 0; display: grid; place-items: center; font-size: 12px; font-weight: 900; }

/* ---------------------------------------------------------------- cards (party, badges, achievements) */
.tcx-card { padding: 14px; border-radius: 20px; background: linear-gradient(180deg, rgba(255, 255, 255, .06), rgba(255, 255, 255, .025)); border: 1px solid var(--line); min-width: 0; }
.tcx-card > header { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; min-height: 28px; }
.tcx-card h3 { display: flex; align-items: center; gap: 8px; margin: 0; font: 400 18px 'Lilita One', Nunito, sans-serif; letter-spacing: .4px; }
.tcx-card h3 .ic { width: 20px; height: 20px; color: var(--gold); }
.tcx-count { font-size: 12.5px; font-weight: 900; color: var(--muted); padding: 3px 10px; border-radius: 999px; background: rgba(0, 0, 0, .22); white-space: nowrap; }
.tcx-link { display: inline-flex; align-items: center; gap: 2px; min-height: 44px; padding: 0 4px 0 10px; margin: -8px -4px -8px 0; border-radius: 12px;
  font-weight: 900; font-size: 13px; color: #9fdcff; background: transparent; border: 0; }
.tcx-link .ic { width: 18px; height: 18px; }
.tcx-link:hover { background: var(--surface); }

/* party */
.tcx-party { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
.tcx-mon { --t: #6fa6ff; position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; min-height: 44px; padding: 8px 6px 9px;
  border-radius: 16px; text-align: center; color: #fff;
  background: linear-gradient(180deg, color-mix(in srgb, var(--t) 26%, rgba(255, 255, 255, .04)), rgba(255, 255, 255, .03));
  border: 1px solid color-mix(in srgb, var(--t) 40%, transparent); transition: transform var(--t) var(--ease), box-shadow var(--t); }
.tcx-mon:hover:not(.empty) { transform: translateY(-2px); box-shadow: 0 8px 18px color-mix(in srgb, var(--t) 30%, transparent); }
.tcx-mon:active:not(.empty) { transform: scale(.97); }
.tcx-mon.lead { box-shadow: 0 0 0 2px var(--gold); }
.tcx-mon.fnt .tcx-mon-pic img { filter: grayscale(1) brightness(.7); }
.tcx-mon.empty { border-style: dashed; border-color: var(--line); background: rgba(255, 255, 255, .02); justify-content: center; }
.tcx-mon.empty .tcx-mon-pic { color: rgba(255, 255, 255, .14); }
.tcx-mon-pic { position: relative; display: grid; place-items: center; width: 100%; aspect-ratio: 1; max-width: 84px; border-radius: 50%;
  background: radial-gradient(circle at 50% 40%, color-mix(in srgb, var(--t) 45%, #2a3f8f), #121c3a 72%); }
.tcx-mon.empty .tcx-mon-pic { background: transparent; }
.tcx-mon-pic .ic { width: 50%; height: 50%; }
.tcx-mon-pic img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 3px 3px rgba(0, 0, 0, .4)); }
.tcx-shiny { position: absolute; top: 0; right: 2px; font-style: normal; color: #ffe07a; text-shadow: 0 0 6px rgba(255, 207, 74, .8); }
.tcx-lv { position: absolute; bottom: -4px; left: 50%; transform: translateX(-50%); font-size: 10.5px; font-weight: 900; padding: 1px 7px; border-radius: 999px;
  color: #13204a; background: #fff; white-space: nowrap; box-shadow: 0 2px 5px rgba(0, 0, 0, .3); }
.tcx-mon > b { margin-top: 4px; font-size: 12.5px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tcx-mon > small { font-size: 11px; color: var(--muted); font-weight: 800; }
.tcx-types { display: flex; gap: 3px; justify-content: center; flex-wrap: wrap; }
.tcx-types i { font-style: normal; font-size: 9px; font-weight: 900; letter-spacing: .3px; text-transform: uppercase; padding: 1px 6px; border-radius: 999px;
  background: var(--c); color: #10183a; }
.tcx-hp { width: 80%; height: 4px; border-radius: 999px; background: rgba(0, 0, 0, .35); overflow: hidden; }
.tcx-hp i { display: block; height: 100%; background: var(--hp); border-radius: inherit; }
.tcx-hp i.mid { background: #ffd23f; } .tcx-hp i.low { background: var(--danger); }

/* badges */
.tcx-badges { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 8px; }
.tcx-badge { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; }
.tcx-badge-art { position: relative; display: grid; place-items: center; width: 100%; max-width: 64px; aspect-ratio: 1; border-radius: 50%;
  background: radial-gradient(circle at 50% 40%, rgba(255, 255, 255, .08), rgba(0, 0, 0, .25)); border: 1px solid rgba(255, 255, 255, .06); }
.tcx-badge-art .badge-svg { width: 74%; height: 74%; }
.tcx-badge.on .tcx-badge-art { background: radial-gradient(circle at 50% 40%, rgba(255, 220, 120, .35), rgba(40, 60, 130, .4) 70%);
  border-color: rgba(255, 207, 74, .55); box-shadow: 0 0 16px rgba(255, 207, 74, .35), inset 0 0 12px rgba(255, 207, 74, .2); animation: tcx-glow 3.2s ease-in-out infinite; }
.tcx-badge:not(.on) .tcx-badge-art { filter: saturate(0); opacity: .55; }
.tcx-badge small { font-size: 10.5px; font-weight: 800; color: var(--muted); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tcx-badge.on small { color: #ffe7a0; }
@keyframes tcx-glow { 50% { box-shadow: 0 0 24px rgba(255, 207, 74, .55), inset 0 0 14px rgba(255, 207, 74, .3); } }

/* achievements */
.tcx-achs { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); gap: 8px; }
.tcx-ach { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 16px;
  background: var(--surface); border: 1px solid var(--line); min-width: 0; }
.tcx-ach.tier-gold { border-color: rgba(255, 207, 74, .4); background: linear-gradient(110deg, rgba(255, 207, 74, .12), var(--surface) 60%); }
.tcx-ach-main { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.tcx-ach-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tcx-ach-top b { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tcx-ach-main > small { font-size: 12px; font-weight: 700; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tcx-ach.max .tcx-bar i { background: linear-gradient(90deg, #f3a51e, #ffe07a); }
.tcx-ach-n { font-size: 14px; font-weight: 900; text-align: right; white-space: nowrap; }
.tcx-ach-n small { font-size: 11px; color: var(--muted); }
.tcx-ach-n .ic { width: 22px; height: 22px; color: var(--ok); }
.tcx-pips { display: flex; gap: 4px; flex: none; }
.tcx-pips i { width: 9px; height: 9px; border-radius: 50%; background: rgba(255, 255, 255, .14); }
.tcx-pips i.bronze { background: #d98a4e; } .tcx-pips i.silver { background: #dfe6f2; } .tcx-pips i.gold { background: #ffcf4a; box-shadow: 0 0 6px rgba(255, 207, 74, .7); }
.tcx-more { display: flex; align-items: center; justify-content: center; gap: 6px; width: 100%; min-height: 44px; margin-top: 8px; border-radius: 14px;
  font-weight: 900; font-size: 13px; color: #9fdcff; background: rgba(0, 0, 0, .18); border: 1px dashed var(--line-2); }
.tcx-more .ic { width: 18px; height: 18px; }
.tcx-more:hover { background: var(--surface); }

/* actions */
.tcx-actions { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.tcx-actions .btn { min-height: 48px; border-radius: 14px; }
.tcx-actions .btn .ic { width: 20px; height: 20px; }

/* ---------------------------------------------------------------- narrow: portrait phones, small windows */
@media (max-width: 640px) {
  .tcx-hero { grid-template-columns: minmax(0, 44%) minmax(0, 1fr); gap: 10px; padding: 10px; border-radius: 20px; }
  .tcx-stage.stage { min-height: 230px; }
  .tcx-id { gap: 6px; }
  html .tcx .tcx-name input { font-size: 23px; }
  .tcx-level { flex-direction: column; align-items: stretch; gap: 6px; padding: 8px; }
  .tcx-level .tcx-lvring { align-self: center; }
  .tcx-xp > b { display: none; }
  .tcx-xp > small { text-align: center; font-size: 11px; }
  .tcx-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .tcx-tile { padding: 10px; gap: 9px; border-radius: 16px; }
  .tcx-tile .ic-tile { width: 36px; height: 36px; }
  .tcx-tv b { font-size: 19px; }
  .tcx-party { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .tcx-badges { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px 8px; }
  .tcx-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tcx-card { padding: 12px; }
}
@media (max-width: 360px) {
  .tcx-hero { grid-template-columns: 1fr; }
  .tcx-tile.dex { grid-column: auto; }
  .tcx-tiles { grid-template-columns: 1fr; }
}
/* landscape phones: short viewport — keep the hero compact */
@media (orientation: landscape) and (max-height: 500px) {
  .tcx-hero { grid-template-columns: minmax(0, 200px) minmax(0, 1fr); }
  .tcx-stage.stage { min-height: 200px; }
  .tcx-level { flex-direction: row; }
  .tcx-xp > b { display: block; }
  .tcx-xp > small { text-align: left; }
  .tcx-tiles { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
  .tcx-party { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .tcx-badges { grid-template-columns: repeat(8, minmax(0, 1fr)); }
  .tcx-actions { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  .tcx > *, .tcx-hero::before, .tcx-ring .val, .tcx-bar i, .tcx-badge.on .tcx-badge-art { animation: none !important; }
}
html.reduce-motion .tcx > *, html.reduce-motion .tcx-hero::before, html.reduce-motion .tcx-ring .val,
html.reduce-motion .tcx-bar i, html.reduce-motion .tcx-badge.on .tcx-badge-art { animation: none !important; }
