/* ===================================================================
   GRIDIRON LEGENDS — Full League Engine Styles v3
   =================================================================== */

/* ── Reset & Tokens ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0a0e1a;
  --bg2:       #111827;
  --bg3:       #1c2333;
  --border:    #1e2d45;
  --border2:   #2a3f5f;
  --accent:    #2563eb;
  --accent2:   #1d4ed8;
  --gold:      #f59e0b;
  --green:     #22c55e;
  --red:       #ef4444;
  --text:      #f1f5f9;
  --text2:     #94a3b8;
  --text3:     #64748b;
  --radius:    10px;
  --radius-lg: 16px;
  --shadow:    0 4px 24px rgba(0,0,0,.45);
  --shadow-sm: 0 2px 8px rgba(0,0,0,.3);
}

html {
  font-size: 14px;
  overflow-x: hidden;
}
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  min-height: 100vh;
  line-height: 1.5;
  display: flex;
  justify-content: center;
  align-items: stretch;
  overflow-x: hidden;
}

/* App shell — constrained, centered, fills viewport height */
#app-shell {
  width: 100%;
  max-width: 1280px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  position: relative;
}

button {
  cursor: pointer;
  font-family: inherit;
  font-size: .9rem;
  border: none;
  border-radius: var(--radius);
  transition: opacity .15s, background .15s, transform .1s;
}
button:active:not(:disabled) { transform: scale(.97); }
button:disabled { opacity: .4; cursor: not-allowed; }

select, input {
  font-family: inherit;
  font-size: .9rem;
  background: var(--bg3);
  color: var(--text);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: .5rem .75rem;
  outline: none;
}
select:focus, input:focus { border-color: var(--accent); }

.hidden { display: none !important; }

@keyframes screenFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.screen:not(.hidden) {
  animation: screenFadeIn .1s ease-out both;
}
.app-shell { min-height: 100vh; display: flex; flex-direction: column; }

/* ── Buttons ──────────────────────────────────────────────────── */
.primary-btn {
  background: var(--accent);
  color: #fff;
  padding: .55rem 1.2rem;
  font-weight: 600;
}
.primary-btn:hover:not(:disabled) { background: var(--accent2); }
.primary-btn.wide { width: 100%; padding: .7rem; }

.ghost-btn {
  background: transparent;
  color: var(--text2);
  border: 1px solid var(--border2);
  padding: .5rem 1rem;
}
.ghost-btn:hover:not(:disabled) { background: var(--bg3); color: var(--text); }

.sm-btn { font-size: .8rem; padding: .4rem .85rem; }
.cancel-btn { margin-top: .75rem; }

/* ── Global Header ────────────────────────────────────────────── */
.app-header {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  position: sticky; top: 0; z-index: 100;
}
.app-header-inner {
  max-width: 1600px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  height: 52px;
}
.app-logo-row { display: flex; align-items: center; gap: .5rem; }
.app-logo-icon { font-size: 1.3rem; }
.app-title { font-size: 1.05rem; font-weight: 800; letter-spacing: -.5px; color: var(--text); }

/* ── Screen Base ──────────────────────────────────────────────── */
.screen {
  flex: 1;
  padding: 2rem 1.5rem;
  max-width: 100%;
  overflow-x: hidden;
  overflow-y: auto;
}
.screen-center-wrap {
  max-width: 640px;
  margin: 0 auto;
}
.wide-wrap { max-width: 860px; }
.screen-title {
  font-size: 1.7rem;
  font-weight: 800;
  margin-bottom: 1.5rem;
  text-align: center;
}

/* ── Card Panel ───────────────────────────────────────────────── */
.card-panel {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}
.panel-section-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: .05em;
}

/* ── Field / Label ────────────────────────────────────────────── */
.field-label {
  display: block;
  font-size: .85rem;
  color: var(--text2);
  margin-bottom: .85rem;
}
.field-input, .field-select {
  display: block;
  width: 100%;
  margin-top: .3rem;
}

/* ═══════════════════════════════════════════════════════════════
   PROFILE SCREEN
═══════════════════════════════════════════════════════════════ */
.profile-hero {
  text-align: center;
  margin-bottom: 2rem;
}
.profile-hero-icon { font-size: 3rem; margin-bottom: .5rem; }
.profile-hero-title { font-size: 2rem; font-weight: 800; margin-bottom: .35rem; }
.profile-hero-sub   { color: var(--text2); font-size: .95rem; }

.profile-card {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.profile-logo-img {
  width: 56px; height: 56px;
  border-radius: var(--radius);
  border: 2px solid var(--border2);
  object-fit: cover;
}
.profile-coach-name { font-size: 1.1rem; font-weight: 700; }
.profile-team-name  { color: var(--text2); font-size: .9rem; margin-top: .15rem; }
.profile-stats      { color: var(--text3); font-size: .8rem; margin-top: .3rem; }
.profile-card-info  { flex: 1; }

.profile-actions {
  display: flex;
  gap: .75rem;
  justify-content: center;
  margin-top: 1rem;
}

/* ═══════════════════════════════════════════════════════════════
   SETUP SCREEN
═══════════════════════════════════════════════════════════════ */
.setup-grid {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}
@media (max-width: 640px) { .setup-grid { grid-template-columns: 1fr; } }

.mode-options {
  display: flex;
  flex-direction: column;
  gap: .75rem;
  margin-bottom: 1rem;
}
.mode-option { display: block; cursor: pointer; }
.mode-option input[type=radio] { position: absolute; opacity: 0; pointer-events: none; }
.mode-card {
  background: var(--bg3);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: .9rem 1rem;
  display: flex;
  align-items: center;
  gap: .75rem;
  transition: border-color .15s, background .15s;
}
.mode-option input:checked + .mode-card {
  border-color: var(--accent);
  background: rgba(37,99,235,.1);
}
.mode-icon  { font-size: 1.4rem; }
.mode-name  { font-weight: 700; font-size: .95rem; }
.mode-range { font-size: .75rem; color: var(--text3); margin-top: .1rem; }
.mode-desc  { font-size: .85rem; color: var(--text2); border-left: 3px solid var(--accent); padding-left: .75rem; }

.setup-hint { font-size: .82rem; color: var(--text3); margin-bottom: .85rem; }

.cpu-pick-list {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  max-height: 420px;
  overflow-y: auto;
}
.cpu-pick-row {
  display: flex;
  align-items: center;
  gap: .65rem;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .6rem .85rem;
  cursor: pointer;
  transition: border-color .15s;
}
.cpu-pick-row:has(input:checked) { border-color: var(--accent); }
.cpu-pick-row input { accent-color: var(--accent); width: 16px; height: 16px; flex-shrink: 0; }
.cpu-logo-sm { width: 28px; height: 28px; border-radius: 5px; object-fit: cover; }
.cpu-pick-info { flex: 1; }
.cpu-pick-name { font-weight: 600; font-size: .88rem; display: block; }
.cpu-pick-team { color: var(--text2); font-size: .78rem; }
.cpu-personality-badge {
  font-size: .7rem; font-weight: 700;
  padding: .2rem .5rem;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.p-aggressive { background: rgba(239,68,68,.15); color: #fca5a5; }
.p-builder    { background: rgba(34,197,94,.15);  color: #86efac; }
.p-tactician  { background: rgba(168,85,247,.15); color: #d8b4fe; }
.p-balanced   { background: rgba(245,158,11,.15); color: #fcd34d; }

.setup-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

/* ═══════════════════════════════════════════════════════════════
   SEASON SCREEN
═══════════════════════════════════════════════════════════════ */

#screen-season {
  padding: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  contain: style;
}

/* ── TOP NAV BAR ─────────────────────────────────────────────── */
.season-topbar {
  display: flex;
  align-items: stretch;
  gap: 0;
  padding: 0;
  background: #000;
  border-bottom: 2px solid rgba(255,160,60,.3);
  flex-shrink: 0;
  height: 200px;   /* full stadium reveal */
}
.season-title { display: none; }
.season-track-label { display: none; }
.season-track-wrap {
  display: flex;
  align-items: stretch;
  flex: 1;
  min-width: 0;
  height: 100%;
  width: 100%;
}

/* Win track */
.win-track {
  display: flex;
  flex: 1;
  align-items: flex-start;
  overflow-x: auto;
  min-width: 0;
}
.win-track::-webkit-scrollbar { height: 2px; }
.win-track::-webkit-scrollbar-thumb { background: var(--border2); }

/* ═══════════════════════════════════════════════════════════════
   WIN TRACK — FOOTBALL FIELD THEME
═══════════════════════════════════════════════════════════════ */

/* Outer wrapper stretches to fill .win-track */
.wt-field-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* SVG field — fills the full width, sits behind tokens */
.wt-field-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: 0;
  overflow: hidden;
}

/* SVG element classes — field bg now photo, keep overlays */
.wt-svg-field   { fill: #1a5c28; }         /* fallback if image fails */
.wt-svg-stripe  { fill: rgba(0,0,0,.0); }  /* hide stripes — photo has them */
.wt-svg-progress {
  fill: rgba(56,189,248,.22);
  transition: width .5s ease;
}
.wt-svg-hashmark { stroke: rgba(255,255,255,.5);  stroke-width: 1.5; }
.wt-svg-goalline { stroke: rgba(255,255,255,.85); stroke-width: 2.5; }
.wt-svg-tick     { stroke: rgba(255,255,255,.0);  stroke-width: 0; }  /* hide — photo has them */
.wt-svg-endzone  { fill: rgba(0,0,0,.0); }  /* hide — photo has them */
.wt-svg-label {
  font-family: inherit;
  font-size: 8px;
  font-weight: 800;
  fill: rgba(255,255,255,.0);   /* hide — photo already has yard numbers */
}

/* Center logo — team crest overlaid mid-field at full color */
.wt-center-logo {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 56px;
  height: 56px;
  object-fit: contain;
  pointer-events: none;
  z-index: 1;
}

/* Token row — positioned on top of SVG field */
.wt-token-row {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: flex-start;
  height: 100%;
  padding: 0 2px;
}

/* Each positional slot */
.wt-slot {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  padding: 2px 0;
  gap: 1px;
}
.wt-slot-lbl {
  font-size: .62rem;
  line-height: 1;
  color: rgba(255,255,255,.55);
  font-weight: 700;
}
.wt-slot-start .wt-slot-lbl { font-size: .75rem; color: rgba(255,255,255,.7); }
.wt-slot-finish .wt-slot-lbl {
  font-size: 1rem;
  color: #fbbf24;
  filter: drop-shadow(0 0 4px rgba(251,191,36,.6));
  animation: trophyPulse 2s ease-in-out infinite;
}

@keyframes trophyPulse {
  0%,100% { filter: drop-shadow(0 0 4px rgba(251,191,36,.5)); transform: scale(1); }
  50%     { filter: drop-shadow(0 0 8px rgba(251,191,36,.9)); transform: scale(1.15); }
}

/* Token column — vertical stack, up to 6 visible, rest wrap */
.wt-toks {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  max-height: 100%;
  overflow: visible;
}

/* Individual token — vertical layout, compact size */
.wt-tok {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1.5px solid;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .45rem;
  font-weight: 800;
  color: #fff;
  overflow: hidden;
  flex-shrink: 0;
  transition: transform .2s, box-shadow .2s;
}
.wt-tok:hover { transform: scale(1.2); z-index: 5; }

/* Human player token — slightly larger with glow */
.wt-tok-human {
  width: 20px;
  height: 20px;
  border-width: 2px;
  box-shadow: 0 0 0 2px rgba(56,189,248,.5), 0 0 8px rgba(56,189,248,.4);
  z-index: 3;
}

/* Active-turn pulse already defined globally as .active-token — still applies */

/* Overflow badge when >6 teams share a position */
.wt-tok-overflow {
  background: rgba(255,255,255,.15) !important;
  border-color: rgba(255,255,255,.3) !important;
  font-size: .42rem;
  letter-spacing: -.02em;
}
.track-space {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 32px;
  position: relative;
}
.track-space::before {
  content: "";
  position: absolute;
  top: 12px; left: 0; right: 0;
  height: 2px;
  background: var(--border2);
  z-index: 0;
}
.track-space:first-child::before { left: 50%; }
.track-space:last-child::before  { right: 50%; }
.track-space-label {
  font-size: .6rem; font-weight: 700; color: var(--text3);
  background: var(--bg2); padding: 0 .1rem;
  position: relative; z-index: 1; line-height: 1;
}
.track-finish .track-space-label { color: var(--gold); font-size: .8rem; }
.track-tokens {
  display: flex; flex-wrap: wrap; gap: 2px;
  justify-content: center; margin-top: .2rem; min-height: 18px;
}
.track-token {
  width: 20px; height: 20px; border-radius: 50%; border: 2px solid;
  display: flex; align-items: stretch; justify-content: center;
  font-size: .55rem; font-weight: 800; color: #fff;
}
.track-token.active-token {
  box-shadow: 0 0 0 3px rgba(37,99,235,.5);
  animation: pulse 1.8s ease-in-out infinite;
}
@keyframes pulse {
  0%,100% { box-shadow: 0 0 0 3px rgba(37,99,235,.5); }
  50%      { box-shadow: 0 0 0 5px rgba(37,99,235,.15); }
}

/* ── BODY: sidebar + main ────────────────────────────────────── */
.season-body {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0;
  max-height: 100%;
}

/* ── SIDEBAR ─────────────────────────────────────────────────── */
.season-sidebar {
  width: 165px;
  flex-shrink: 0;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  padding: .5rem .6rem;
  gap: .25rem;
}
.season-sidebar::-webkit-scrollbar { width: 3px; }
.season-sidebar::-webkit-scrollbar-thumb { background: var(--border2); }

.sb-section-label {
  font-size: .6rem; font-weight: 700; letter-spacing: .08em;
  color: var(--text3); margin-bottom: .35rem;
}
.season-team-list { display: flex; flex-direction: column; gap: .18rem; }
.team-sidebar-card {
  display: flex; align-items: center; gap: .35rem;
  padding: .3rem .35rem; border-radius: 6px;
  border: 1px solid transparent; cursor: default;
  transition: background .12s, border-color .12s;
}
.team-sidebar-card:hover { background: var(--bg3); border-color: var(--border2); }
.team-sidebar-card.current-turn { background: rgba(37,99,235,.12); border-color: var(--accent); }
.tsb-rank  { font-size: .62rem; font-weight: 800; color: var(--text3); width: 10px; flex-shrink: 0; }
.tsb-logo  { width: 20px; height: 20px; border-radius: 3px; object-fit: cover; flex-shrink: 0; }
.tsb-info  { flex: 1; min-width: 0; }
.tsb-name-row { display: flex; align-items: baseline; gap: .25rem; justify-content: space-between; }
.tsb-name  { font-size: .7rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tsb-wins  { font-size: .72rem; font-weight: 900; color: var(--text); flex-shrink: 0; }
.tsb-record{ font-size: .58rem; color: var(--text3); }
.tsb-prog-wrap { width: 100%; height: 2px; background: var(--bg3); border-radius: 2px; overflow: hidden; margin-top: .18rem; }
.tsb-prog-fill { height: 100%; border-radius: 2px; transition: width .4s; min-width: 2px; opacity: .8; }
.tsb-badge { flex-shrink: 0; }
.cpu-badge   { font-size: .5rem; font-weight: 700; background: rgba(100,116,139,.2); color: var(--text3); padding: .05rem .22rem; border-radius: 5px; text-transform: uppercase; }
.human-badge { font-size: .5rem; font-weight: 700; background: rgba(37,99,235,.2);   color: #93c5fd;       padding: .05rem .22rem; border-radius: 5px; text-transform: uppercase; }

.sb-spacer { flex: 1; }

/* Match log */
.sb-log-block { border-top: 1px solid var(--border); padding-top: .5rem; margin-top: .3rem; }
.sb-log-toggle {
  display: flex; align-items: center; gap: .35rem; width: 100%;
  background: none; border: none; font-size: .68rem; font-weight: 700;
  color: var(--text2); padding: 0; cursor: pointer; text-align: left;
}
.sb-log-toggle:hover { color: var(--text); }
.log-count-badge {
  background: rgba(37,99,235,.25); color: #93c5fd;
  font-size: .58rem; font-weight: 800;
  padding: .04rem .28rem; border-radius: 5px; min-width: 14px; text-align: center;
}
.log-chevron { margin-left: auto; font-size: .6rem; color: var(--text3); transition: transform .2s; }
.log-chevron.open { transform: rotate(90deg); }
.sb-log-body { margin-top: .4rem; max-height: 220px; overflow-y: auto; }
.sb-log-body::-webkit-scrollbar { width: 3px; }
.sb-log-body::-webkit-scrollbar-thumb { background: var(--border2); }
.sb-play-log { display: flex; flex-direction: column; gap: .12rem; }
.log-entry {
  font-size: .67rem; color: var(--text2);
  padding: .2rem .35rem; border-radius: 4px;
  background: var(--bg3); line-height: 1.4;
}
.log-entry strong { color: var(--text); }

/* ── MAIN COLUMN ─────────────────────────────────────────────── */
.season-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  min-width: 0;
}
.season-main::-webkit-scrollbar { width: 4px; }
.season-main::-webkit-scrollbar-thumb { background: var(--border2); }

/* Turn bar */
.turn-bar {
  display: flex;
  align-items: center;
  gap: .85rem;
  padding: .48rem .9rem;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
}
.turn-bar-identity { flex-shrink: 0; }
.turn-bar-team  { font-size: 1rem; font-weight: 900; line-height: 1.1; }
.turn-bar-coach { font-size: .72rem; color: var(--text2); margin-top: .05rem; }
.turn-bar-hint  { flex: 1; font-size: .75rem; color: var(--text3); text-align: center; min-width: 80px; }
.turn-bar-actions { display: flex; align-items: center; gap: .4rem; flex-shrink: 0; }
.cpu-tag {
  font-size: .6rem; font-weight: 700; background: rgba(100,116,139,.2); color: var(--text2);
  padding: .12rem .38rem; border-radius: 10px; text-transform: uppercase; letter-spacing: .05em;
}
.tb-btn {
  font-size: .8rem; font-weight: 700; padding: .42rem .9rem;
  border-radius: 8px; border: none; cursor: pointer;
  display: flex; align-items: center; gap: .3rem;
  transition: filter .15s, transform .1s;
}
.tb-btn:active:not(:disabled) { transform: scale(.96); }
.tb-btn:disabled { opacity: .32; cursor: not-allowed; }
.tb-play  { background: var(--accent); color: #fff; }
.tb-play:hover:not(:disabled)  { filter: brightness(1.15); }
.tb-draft { background: rgba(56,189,248,.15); color: #38bdf8; border: 1px solid rgba(56,189,248,.3); }
.tb-draft:hover:not(:disabled) { background: rgba(56,189,248,.25); }
.tb-trade { background: rgba(168,85,247,.15); color: #c084fc; border: 1px solid rgba(168,85,247,.3); }
.tb-trade:hover:not(:disabled) { background: rgba(168,85,247,.25); }
.trade-count-badge {
  background: rgba(168,85,247,.35); color: #e9d5ff;
  font-size: .62rem; font-weight: 800;
  padding: .03rem .28rem; border-radius: 6px;
}



/* Opponent picker */
.opp-picker {
  padding: .65rem .9rem;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.picker-label {
  font-size: .62rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .07em; color: var(--text3); margin-bottom: .5rem;
}
.opponent-grid { display: flex; flex-wrap: wrap; gap: .45rem; }
.opponent-btn {
  display: flex; align-items: center; gap: .45rem;
  background: var(--bg3); border: 1px solid var(--border2);
  border-radius: 8px; padding: .5rem .85rem;
  color: var(--text); transition: border-color .15s, background .15s;
  min-width: 140px;
}
.opponent-btn:hover:not(:disabled) { background: rgba(37,99,235,.1); border-color: var(--accent); }
.opponent-btn img { width: 26px; height: 26px; border-radius: 4px; object-fit: cover; }
.opp-btn-info { text-align: left; }
.opp-btn-name   { font-size: .82rem; font-weight: 600; display: block; }
.opp-btn-record { font-size: .65rem; color: var(--text3); }
.opp-lock-icon  { font-size: .8rem; margin-left: auto; }
.opp-locked     { opacity: .38; }

/* Action panels (draft / trade) */
.action-panel {
  padding: .75rem .9rem;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.action-panel-header { font-size: .85rem; font-weight: 700; margin-bottom: .7rem; }
.action-mini-grid { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .45rem; }
.mini-card-tile {
  display: flex; gap: .45rem; background: var(--bg3); border: 1px solid var(--border2);
  border-radius: 8px; padding: .4rem .55rem; cursor: pointer;
  transition: border-color .15s, background .15s; min-width: 155px; max-width: 220px;
}
.mini-card-tile:hover { background: rgba(37,99,235,.1); border-color: var(--accent); }
.mini-card-art  { width: 32px; height: 32px; border-radius: 4px; object-fit: cover; flex-shrink: 0; }
.mini-card-info { min-width: 0; }
.mini-card-name { font-size: .77rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-card-meta { font-size: .68rem; color: var(--text2); margin-top: .06rem; }
.mini-card-attrs{ font-size: .61rem; color: var(--text3); margin-top: .08rem; }
.facedown-grid { display: flex; flex-wrap: wrap; gap: .55rem; margin-bottom: .55rem; }
.facedown-card {
  width: 82px; height: 112px;
  background: linear-gradient(135deg, #1e2d45, #0f1929);
  border: 2px solid var(--border2); border-radius: 10px;
  display: flex; align-items: stretch; justify-content: center;
  cursor: pointer; font-size: 2rem;
  transition: transform .15s, border-color .15s, box-shadow .15s;
}
.facedown-card:hover { transform: translateY(-4px) scale(1.04); border-color: var(--accent); box-shadow: 0 6px 18px rgba(37,99,235,.3); }
.revealed-trade-card {
  display: inline-flex; flex-direction: column;
  background: var(--bg2); border: 2px solid var(--accent);
  border-radius: 10px; overflow: hidden; width: 86px;
  box-shadow: 0 0 14px rgba(37,99,235,.35);
  animation: revealPop .25s ease-out;
}
@keyframes revealPop {
  from { transform: scale(.8) rotateY(90deg); opacity: 0; }
  to   { transform: scale(1) rotateY(0deg); opacity: 1; }
}

/* Match wrapper */
.match-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
/* match-panel — contains all match UI, hidden by default, shown only during a match */
.match-panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.match-panel.hidden { display: none; }
.match-header {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  padding: .38rem .9rem; background: var(--bg2); border-bottom: 1px solid var(--border);
  flex-shrink: 0; flex-wrap: wrap;
}
.match-status-text { font-size: .8rem; font-weight: 600; color: var(--text2); }
.match-controls-row { display: flex; gap: .3rem; flex-wrap: wrap; align-items: center; }
.format-select-sm {
  font-size: .7rem; padding: .22rem .45rem;
  background: var(--bg3); border: 1px solid var(--border2);
  color: var(--text2); border-radius: 6px;
}
.ghost-btn {
  background: var(--bg3); border: 1px solid var(--border2);
  color: var(--text2); padding: .3rem .7rem; font-size: .78rem;
  border-radius: 7px;
}
.ghost-btn:hover:not(:disabled) { border-color: var(--border2); background: var(--bg2); color: var(--text); }
.sm-btn { font-size: .74rem; padding: .26rem .6rem; }
.primary-btn {
  background: var(--accent); color: #fff;
  padding: .3rem .75rem; font-size: .78rem; border-radius: 7px;
}
.primary-btn:hover:not(:disabled) { filter: brightness(1.12); }

.scorebar {
  display: flex; align-items: center; gap: .75rem;
  padding: .55rem .9rem; flex-shrink: 0;
  background: linear-gradient(135deg, #0c1520, #0f1e2e);
  border-bottom: 1px solid var(--border);
}
.score-team-box { flex: 1; display: flex; align-items: center; gap: .5rem; min-width: 0; }
.score-team-box img { width: 32px; height: 32px; border-radius: 5px; object-fit: cover; flex-shrink: 0; }
.score-team-box .team-name { font-size: .85rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.score-team-box .team-meta { font-size: .65rem; color: var(--text3); }
.score-team-box.empty { opacity: .28; }
.score-center-block  { text-align: center; flex-shrink: 0; }
.round-label-text    { font-size: .62rem; color: var(--text3); margin-bottom: .15rem; }
.main-score-display  { font-size: 2.1rem; font-weight: 900; line-height: 1; letter-spacing: -.02em; }
.score-dash          { margin: 0 .28rem; color: var(--text3); }
.series-score-display{ font-size: .7rem; color: var(--text2); margin-top: .15rem; }

/* ═══════════════════════════════════════════════════════
   ARENA — layered 3D battle field
═══════════════════════════════════════════════════════ */

/* Arena breath — subtle pulse on field container */
@keyframes arenaBreath {
  0%,100% { opacity: .92; }
  50%      { opacity: 1; }
}

/* ── Winner: victorious hold ── */
@keyframes cardWin {
  0%   { transform: translateY(0) scale(1); }
  30%  { transform: translateY(-12px) scale(1.05); }
  60%  { transform: translateY(-8px) scale(1.03); }
  100% { transform: translateY(-8px) scale(1.03); }
}

/* ── Loser: impact flash then burns to ash ── */
@keyframes cardDust {
  /* 0% must exactly match normal card state — NO changes, perfectly clean hold */
  0%   {
    transform: scale(1);
    opacity: 1;
    visibility: visible;
    filter: none;
    box-shadow: none;
  }
  /* Violent shudder — sudden impact */
  6%  { transform: scale(1.02) rotate(-3deg) translateX(-5px); }
  10% { transform: scale(.99)  rotate(3deg)  translateX(6px);  }
  14% { transform: scale(1.03) rotate(-2deg) translateX(-4px); }
  18% { transform: scale(1)    rotate(0deg)  translateX(0);    }
  /* FLASH — pure white overexposure, single frame burst */
  22% {
    transform: scale(1.12);
    opacity: 1;
    filter: brightness(12) saturate(0);
    box-shadow:
      0 0 0   8px rgba(255,255,255,1),
      0 0 40px 20px rgba(255,220,120,.95),
      0 0 100px 50px rgba(255,100,0,.7);
  }
  /* Afterburn — orange-hot, starting to dissolve upward */
  30% {
    transform: scale(1.08) translateY(-8px);
    opacity: .95;
    filter: brightness(3) saturate(4) hue-rotate(-20deg) sepia(.2);
    box-shadow: 0 0 60px 28px rgba(255,120,0,.65);
  }
  /* Card scorches — heat distortion, going sepia */
  42% {
    transform: scale(.95) translateY(-18px) skewX(2deg);
    opacity: .82;
    filter: brightness(1.8) saturate(2) sepia(.5) hue-rotate(-10deg);
    box-shadow: 0 0 30px 12px rgba(255,80,0,.4);
  }
  /* Burning up — curling, fading fast */
  56% {
    transform: scale(.72) translateY(-30px) skewX(5deg) rotate(3deg);
    opacity: .55;
    filter: brightness(.9) saturate(.5) sepia(.9);
    box-shadow: 0 0 12px 4px rgba(200,60,0,.25);
  }
  /* Ash rising — very light, drifting up */
  70% {
    transform: scale(.45) translateY(-44px) skewX(8deg) rotate(5deg);
    opacity: .28;
    filter: brightness(.5) saturate(.1) sepia(1) blur(.5px);
    box-shadow: none;
  }
  /* Particles dispersing */
  84% {
    transform: scale(.22) translateY(-58px) skewX(10deg) rotate(7deg);
    opacity: .1;
    filter: brightness(.2) saturate(0) blur(1.5px);
  }
  /* Gone — ash has dissipated into arena smoke */
  100% {
    transform: scale(.05) translateY(-70px);
    opacity: 0;
    visibility: hidden;
    filter: brightness(0) blur(3px);
    box-shadow: none;
  }
}

/* ── Injured: twist and shake ── */
@keyframes cardInjury {
  0%   { transform: rotate(0deg)   skewX(0deg); }
  15%  { transform: rotate(-6deg)  skewX(-4deg); filter: hue-rotate(0deg); }
  30%  { transform: rotate(5deg)   skewX(3deg);  filter: hue-rotate(20deg); }
  45%  { transform: rotate(-4deg)  skewX(-2deg); }
  60%  { transform: rotate(3deg)   skewX(2deg); }
  75%  { transform: rotate(-2deg)  skewX(-1deg); }
  100% { transform: rotate(0deg)   skewX(0deg)  perspective(400px) rotateY(8deg); }
}

/* ── Tie: tremor ── */
@keyframes cardTie {
  0%,100% { transform: translateX(0); }
  20%  { transform: translateX(-4px); }
  40%  { transform: translateX(4px); }
  60%  { transform: translateX(-3px); }
  80%  { transform: translateX(3px); }
}

/* ── Card appear: slam in ── */
@keyframes cardReveal {
  0%   { transform: perspective(600px) scale(.78) translateY(-20px) rotateX(12deg); opacity: 0; filter: brightness(.6); }
  60%  { transform: perspective(600px) scale(1.04) translateY(3px)  rotateX(-2deg); opacity: 1; filter: brightness(1.1); }
  100% { transform: perspective(600px) scale(1)   translateY(0)     rotateX(0deg);  opacity: 1; filter: brightness(1); }
}

/* Continuous 3D float — card hovers above the arena */
@keyframes cardFloat {
  0%   { transform: perspective(600px) translateY(0px)   rotateX(2deg)  rotateY(-1deg); }
  25%  { transform: perspective(600px) translateY(-5px)  rotateX(0deg)  rotateY(1deg);  }
  50%  { transform: perspective(600px) translateY(-8px)  rotateX(-2deg) rotateY(0deg);  }
  75%  { transform: perspective(600px) translateY(-4px)  rotateX(0deg)  rotateY(-1deg); }
  100% { transform: perspective(600px) translateY(0px)   rotateX(2deg)  rotateY(-1deg); }
}

/* Away card floats with a slight opposing tilt */
@keyframes cardFloatAway {
  0%   { transform: perspective(600px) translateY(0px)   rotateX(2deg)  rotateY(1deg);  }
  25%  { transform: perspective(600px) translateY(-5px)  rotateX(0deg)  rotateY(-1deg); }
  50%  { transform: perspective(600px) translateY(-8px)  rotateX(-2deg) rotateY(0deg);  }
  75%  { transform: perspective(600px) translateY(-4px)  rotateX(0deg)  rotateY(1deg);  }
  100% { transform: perspective(600px) translateY(0px)   rotateX(2deg)  rotateY(1deg);  }
}

/* ── Arena idle state — roster preview when no match active ── */
.arena-idle {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: .75rem 1rem;
  min-height: 240px;
  background:
    linear-gradient(to bottom, rgba(0,0,0,.45) 0%, rgba(0,0,0,.15) 40%, rgba(0,0,0,.55) 100%),
    url("assets/arena_bg.png") center/cover no-repeat;
  gap: .55rem;
  overflow: hidden;
}
.arena-idle.hidden { display: none; }

.ai-label {
  font-size: .6rem;
  font-weight: 700;
  letter-spacing: .1em;
  color: rgba(255,255,255,.45);
  text-transform: uppercase;
  flex-shrink: 0;
}

/* 3+2 grid — top row 3 cards, bottom row 2 centered */
.ai-cards {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .55rem;
  width: 100%;
}
.ai-row {
  display: flex;
  gap: .55rem;
  justify-content: center;
}

.ai-card {
  position: relative;
  width: 175px;
  height: 235px;
  flex-shrink: 0;
  border-radius: 14px;
  overflow: hidden;
  border: 1.5px solid rgba(255,160,60,.4);
  box-shadow:
    0 4px 16px rgba(0,0,0,.8),
    0 0 20px rgba(255,120,30,.18);
  background: #060a10;
  animation: cardFloat 4.5s ease-in-out infinite;
  animation-delay: calc(var(--i, 0) * 0.35s);
}
.ai-card img {
  position: absolute;
  inset: 0; width: 100%; height: 100%;
  object-fit: cover;
  object-position: center top;
}
.ai-card .ai-value {
  position: absolute; top: 8px; left: 8px;
  font-size: 1.4rem; font-weight: 900; line-height: 1;
  padding: .15rem .42rem; border-radius: 8px;
  background: rgba(0,0,0,.75);
  border: 1px solid rgba(255,255,255,.15);
  z-index: 4;
}
.ai-card .ai-type {
  position: absolute; top: 8px; right: 8px;
  font-size: .55rem; font-weight: 800; letter-spacing: .08em;
  padding: .18rem .38rem; border-radius: 5px;
  background: rgba(0,0,0,.7); z-index: 4;
}
.ai-card .ai-overlay {
  position: absolute; bottom: 0; left: 0; right: 0;
  padding: 1.5rem .65rem .55rem;
  background: linear-gradient(to top, rgba(0,0,0,.92) 0%, rgba(0,0,0,.55) 40%, transparent 100%);
  z-index: 3;
}
.ai-card .ai-name {
  font-size: .82rem; font-weight: 800; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ai-card .ai-attrs {
  font-size: .62rem; color: rgba(200,225,255,.55);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-top: .08rem;
}
/* Type color accents */
.ai-card.ai-leg { border-color: rgba(245,158,11,.5); }
.ai-card.ai-off { border-color: rgba(56,189,248,.45); }
.ai-card.ai-def { border-color: rgba(74,222,128,.45); }
.ai-card.ai-leg .ai-value { color: #f59e0b; }
.ai-card.ai-off .ai-value { color: #38bdf8; }
.ai-card.ai-def .ai-value { color: #4ade80; }
.ai-card.ai-leg .ai-type  { color: #f59e0b; }
.ai-card.ai-off .ai-type  { color: #38bdf8; }
.ai-card.ai-def .ai-type  { color: #4ade80; }


/* ── Arena action panel — trade/draft flows in arena space ── */
.arena-action {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  min-height: 240px;
  background:
    linear-gradient(to bottom, rgba(0,0,0,.55) 0%, rgba(0,0,0,.2) 40%, rgba(0,0,0,.65) 100%),
    url("assets/arena_bg.png") center/cover no-repeat;
  overflow-y: auto;
  position: relative;
}
.arena-action.hidden { display: none; }

/* Header bar inside action panel */
.aa-header {
  padding: .65rem 1rem .5rem;
  font-size: .72rem; font-weight: 800; letter-spacing: .06em;
  color: rgba(255,255,255,.6); text-transform: uppercase;
  border-bottom: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
  display: flex; align-items: center; gap: .5rem;
}
.aa-header .aa-title { flex: 1; }
.aa-header .aa-cancel {
  background: none; border: 1px solid rgba(255,255,255,.2);
  color: rgba(255,255,255,.5); font-size: .65rem; font-weight: 700;
  padding: .18rem .5rem; border-radius: 5px; cursor: pointer;
}
.aa-header .aa-cancel:hover { border-color: rgba(255,255,255,.5); color: #fff; }

/* Body area */
.aa-body {
  flex: 1;
  padding: .65rem 1rem;
  display: flex;
  flex-direction: column;
  gap: .6rem;
}

/* Team picker grid for trade */
.aa-team-grid {
  display: flex; gap: .6rem; flex-wrap: wrap; justify-content: center;
  padding: .4rem 0;
}
.aa-team-btn {
  display: flex; flex-direction: column; align-items: center; gap: .3rem;
  background: rgba(255,255,255,.06); border: 1.5px solid rgba(255,255,255,.15);
  border-radius: 12px; padding: .6rem .8rem; cursor: pointer; min-width: 90px;
  transition: background .15s, border-color .15s, transform .15s;
}
.aa-team-btn:hover { background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.35); transform: translateY(-2px); }
.aa-team-btn img { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; }
.aa-team-btn .aa-team-name { font-size: .68rem; font-weight: 700; color: #fff; text-align: center; }
.aa-team-btn .aa-team-record { font-size: .58rem; color: rgba(255,255,255,.45); }

/* Card grid for face-down/face-up cards */
.aa-card-grid {
  display: flex; gap: .55rem; flex-wrap: wrap; justify-content: center;
  padding: .2rem 0;
}

/* Face-down card */
.aa-facedown {
  width: 80px; height: 110px;
  background: linear-gradient(135deg, #1a2a3a 0%, #0d1520 100%);
  border: 2px solid rgba(56,189,248,.3);
  border-radius: 10px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.8rem; transition: transform .15s, border-color .15s, box-shadow .15s;
  flex-shrink: 0;
}
.aa-facedown:hover { transform: translateY(-4px) scale(1.04); border-color: rgba(56,189,248,.7); box-shadow: 0 8px 20px rgba(0,0,0,.5); }
.aa-facedown:disabled { opacity: .3; cursor: default; transform: none; }

/* Revealed card in trade */
.aa-revealed {
  display: flex; align-items: center; gap: .65rem;
  background: rgba(0,0,0,.6); border: 2px solid;
  border-radius: 12px; padding: .55rem .7rem;
  max-width: 340px;
}
.aa-revealed img { width: 54px; height: 68px; object-fit: cover; object-position: top; border-radius: 7px; flex-shrink: 0; }
.aa-revealed .aa-rev-info { min-width: 0; flex: 1; }
.aa-revealed .aa-rev-type { font-size: .55rem; font-weight: 800; letter-spacing: .08em; margin-bottom: .15rem; }
.aa-revealed .aa-rev-name { font-size: .92rem; font-weight: 800; color: #fff; }
.aa-revealed .aa-rev-attrs { font-size: .6rem; color: rgba(200,225,255,.5); margin-top: .1rem; }
.aa-revealed .aa-rev-val { font-size: 2rem; font-weight: 900; flex-shrink: 0; margin-left: auto; padding-left: .5rem; }

/* Accept strip */
.aa-accept-strip {
  display: flex; gap: .6rem; align-items: center; flex-wrap: wrap;
  padding: .55rem .7rem;
  background: rgba(0,0,0,.5); border: 1px solid rgba(255,255,255,.1);
  border-radius: 9px;
}
.aa-accept-strip .aa-strip-text { flex: 1; font-size: .78rem; color: rgba(255,255,255,.75); }
.aa-accept-strip .aa-strip-btn {
  background: var(--accent); color: #fff;
  border: none; border-radius: 7px; padding: .32rem .75rem;
  font-size: .75rem; font-weight: 700; cursor: pointer;
}
.aa-accept-strip .aa-strip-btn:hover { filter: brightness(1.15); }

/* Return card picker (mini cards in arena) */
.aa-return-grid {
  display: flex; gap: .55rem; flex-wrap: wrap; justify-content: center;
}
.aa-return-card {
  display: flex; flex-direction: column; align-items: center;
  background: rgba(0,0,0,.55); border: 1.5px solid rgba(255,255,255,.15);
  border-radius: 10px; overflow: hidden; width: 90px; cursor: pointer;
  transition: transform .15s, border-color .15s;
}
.aa-return-card:hover { transform: translateY(-3px); border-color: rgba(255,255,255,.45); }
.aa-return-card img { width: 100%; height: 80px; object-fit: cover; object-position: top; }
.aa-return-card .aa-rc-info { padding: .25rem .3rem; width: 100%; }
.aa-return-card .aa-rc-name { font-size: .55rem; font-weight: 800; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.aa-return-card .aa-rc-val { font-size: .62rem; font-weight: 900; margin-top: .08rem; }

/* Trade complete confirmation */
.aa-trade-complete {
  display: flex; flex-direction: column; align-items: center;
  gap: .6rem; padding: .8rem; text-align: center;
}
.aa-trade-complete .aa-tc-label {
  font-size: 1.1rem; font-weight: 900; color: #fff;
  letter-spacing: .05em; text-shadow: 0 0 20px rgba(56,189,248,.6);
}
.aa-trade-complete .aa-tc-cards {
  display: flex; align-items: center; gap: .8rem;
}
.aa-trade-complete .aa-tc-arrow { font-size: 1.4rem; color: rgba(255,255,255,.5); }

/* Draft card grid */
/* Draft grid — tall card style matching arena idle display */
.aa-draft-grid {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .6rem;
  width: 100%;
}
.aa-draft-row {
  display: flex;
  gap: .6rem;
  justify-content: center;
}
.aa-body-draft {
  justify-content: center;
  align-items: center;
  padding: .5rem .75rem;
}
/* aa-draft-card inherits ai-card — just add cursor + hover lift */
.aa-draft-card {
  cursor: pointer;
  animation: none !important;
}
.aa-draft-card:hover {
  transform: translateY(-6px) scale(1.04);
  box-shadow: 0 12px 32px rgba(0,0,0,.8), 0 0 24px rgba(255,120,30,.25);
}

/* CPU idle variant */
.arena-idle.arena-idle-cpu .ai-label { color: rgba(255,200,100,.5); }
.arena-idle.arena-idle-cpu .ai-card { border-color: rgba(255,160,60,.25); opacity: .85; }


.field-surface {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex; align-items: stretch; justify-content: center;
  padding: .75rem 1rem;
  min-height: 240px;
  height: 100%;
  perspective: 800px;
  background:
    linear-gradient(to bottom, rgba(0,0,0,.45) 0%, rgba(0,0,0,.15) 40%, rgba(0,0,0,.55) 100%),
    url("assets/arena_bg.png") center/cover no-repeat;
  animation: arenaBreath 4s ease-in-out infinite;
}

/* Center energy clash line — subtle vertical glow */
.field-surface::after {
  content: "";
  position: absolute;
  left: 50%; top: 10%; bottom: 10%;
  width: 1px;
  background: linear-gradient(to bottom,
    transparent,
    rgba(255,160,60,.25) 30%,
    rgba(255,200,80,.45)  50%,
    rgba(255,160,60,.25) 70%,
    transparent);
  transform: translateX(-50%);
  animation: arenaBreath 2.5s ease-in-out infinite;
  pointer-events: none;
  z-index: 2;
}

/* Arena canvas — full-bleed particle system */
.arena-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

.battle-lane {
  display: flex; align-items: stretch; justify-content: center; gap: 1.2rem;
  position: relative; z-index: 2;
  width: 100%; height: 100%;
  padding: .5rem 0;
}
.battle-card-wrap {
  display: flex; flex-direction: column; align-items: center; gap: .35rem;
  transform-style: preserve-3d;
  height: 100%;
  flex: 0 0 auto;
}
.side-label {
  font-size: .6rem; font-weight: 700;
  color: rgba(255,255,255,.5); letter-spacing: .1em;
  text-shadow: 0 0 6px rgba(56,189,248,.5);
  flex-shrink: 0;
}

/* ── Base flip card — tall, image-first ── */
.flip-card {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  border: 1.5px solid rgba(255,160,60,.5);
  /* Layered shadow: tight contact shadow + wide atmospheric glow */
  box-shadow:
    0 2px 4px rgba(0,0,0,.9),
    0 8px 20px rgba(0,0,0,.75),
    0 20px 50px rgba(0,0,0,.55),
    0 0 30px rgba(255,120,30,.3),
    0 0 8px  rgba(255,160,60,.2);
  transform-style: preserve-3d;
  /* Reveal first, then hand off to the float loop */
  animation:
    cardReveal .55s cubic-bezier(.22,.68,0,1.2) both,
    cardFloat  4.5s ease-in-out 0.6s infinite;
  width: 220px;
  height: 100%;
  min-height: 200px;
  background: #060a10;
  display: flex; flex-direction: column;
  will-change: transform, opacity;
  backface-visibility: hidden;
  isolation: isolate;
}

/* Player image — fills entire card as background */
.flip-card .fc-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  display: block;
  z-index: 0;
}

/* Value badge — top left */
.flip-card .fc-value {
  position: absolute;
  top: 8px; left: 8px;
  font-size: 1.6rem; font-weight: 900; line-height: 1;
  padding: .18rem .45rem;
  border-radius: 8px;
  background: rgba(0,0,0,.7);
  border: 1px solid rgba(255,255,255,.15);
  z-index: 4;
}

/* Card type strip — top right */
.flip-card .fc-type {
  position: absolute;
  top: 8px; right: 8px;
  font-size: .58rem; font-weight: 800; letter-spacing: .1em;
  padding: .22rem .45rem;
  border-radius: 6px;
  background: rgba(0,0,0,.65);
  z-index: 4;
}

/* Bottom overlay — name top-right within overlay, attrs bottom */
.flip-card .fc-overlay {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 1.6rem .65rem .55rem;
  background: linear-gradient(to top,
    rgba(0,0,0,.92) 0%,
    rgba(0,0,0,.65) 40%,
    transparent     100%);
  z-index: 3;
  display: flex;
  flex-direction: column;
  gap: .2rem;
}
.flip-card .fc-name {
  font-size: .82rem; font-weight: 800;
  color: #fff; line-height: 1.2;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.flip-card .fc-attrs {
  font-size: .62rem; color: rgba(200,225,255,.6);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Ghost state */
.flip-card.ghost {
  background: rgba(6,10,16,.7);
  border-style: dashed; border-color: rgba(255,160,60,.18);
  animation: none; box-shadow: none;
  align-items: center; justify-content: center;
  color: rgba(148,163,184,.35); font-size: .8rem;
}

/* Type colors */
.flip-card.fc-leg .fc-value { color: #f59e0b; border-color: rgba(245,158,11,.35); }
.flip-card.fc-off .fc-value { color: #38bdf8; border-color: rgba(56,189,248,.35); }
.flip-card.fc-def .fc-value { color: #4ade80; border-color: rgba(74,222,128,.35); }
.flip-card.fc-leg .fc-type  { color: #f59e0b; }
.flip-card.fc-off .fc-type  { color: #38bdf8; }
.flip-card.fc-def .fc-type  { color: #4ade80; }
.flip-card.fc-leg { border-color: rgba(245,158,11,.35); }
.flip-card.fc-off { border-color: rgba(56,189,248,.35); }
.flip-card.fc-def { border-color: rgba(74,222,128,.35); }

/* ── Winner card ── */
.flip-card.winner {
  border-color: var(--green);
  box-shadow:
    0 2px 4px rgba(0,0,0,.9),
    0 16px 40px rgba(0,0,0,.6),
    0 0 50px rgba(34,197,94,.45),
    0 0 100px rgba(34,197,94,.18),
    inset 0 0 24px rgba(34,197,94,.07);
  animation: cardWin .6s cubic-bezier(.22,.68,0,1.2) both;
}

/* ── Loser card — impact flash then burns to ash ── */
.flip-card.loser {
  border-color: rgba(255,160,60,.4);   /* barely visible — won't look pre-lit */
  animation: cardDust 2.2s ease-in-out 1.3s both;
  pointer-events: none;
  z-index: 2;
}

/* ── Injured card — twisted ── */
/* Only plays injury animation if NOT also a loser or winner */
.flip-card.injured:not(.loser):not(.winner) {
  border-color: #f59e0b;
  box-shadow: 0 0 20px rgba(245,158,11,.3);
  animation: cardInjury .9s ease-out forwards;
}
/* Injured loser: dust wins, just add the amber border hint */
.flip-card.injured.loser {
  border-color: rgba(245,158,11,.5);
}
/* Injured winner: win animation plays, then a subtle injury glow remains */
.flip-card.injured.winner {
  box-shadow:
    0 2px 4px rgba(0,0,0,.9),
    0 16px 40px rgba(0,0,0,.6),
    0 0 50px rgba(34,197,94,.45),
    0 0 100px rgba(34,197,94,.18),
    0 0 20px rgba(245,158,11,.3),
    inset 0 0 24px rgba(34,197,94,.07);
}
.flip-card.injured::after {
  content: "🚑";
  position: absolute; top: 5px; right: 7px; font-size: .9rem;
  z-index: 10;
}

/* ── Tie card — tremor ── */
.flip-card.tie {
  border-color: var(--gold);
  box-shadow: 0 0 22px rgba(245,158,11,.25);
  animation: cardTie .5s ease-in-out 2;
}

/* VS center badge */
.battle-vs {
  font-size: 1rem; font-weight: 900;
  color: rgba(56,189,248,.55);
  text-shadow: 0 0 10px rgba(56,189,248,.7), 0 0 20px rgba(56,189,248,.3);
  letter-spacing: .12em;
  align-self: center;
  margin-bottom: 24px;
}

.drive-strip {
  flex-shrink: 0;
  padding: .42rem .9rem; border-top: 1px solid var(--border);
  background: var(--bg2);
}
.drive-markers { display: flex; gap: .32rem; flex-wrap: wrap; justify-content: center; }
.drive-marker button {
  display: flex; flex-direction: column; align-items: center; gap: .1rem;
  background: var(--bg3); border: 1px solid var(--border2); border-radius: 7px;
  padding: .28rem .42rem; min-width: 52px; color: var(--text2);
  font-size: .63rem; cursor: not-allowed; opacity: .45;
}
.drive-marker.current button { border-color: var(--accent); color: var(--text); cursor: pointer; opacity: 1; background: rgba(37,99,235,.1); }
.drive-marker.current button:hover { background: rgba(37,99,235,.2); }
.drive-marker.win-a button { border-color: var(--green); opacity: .78; }
.drive-marker.win-b button { border-color: var(--red);   opacity: .78; }
.drive-marker.tie   button { border-color: var(--gold);  opacity: .78; }
.drive-ball { font-size: .85rem; }
.drive-text { font-size: .6rem; }

/* Roster popover */
.roster-popover {
  position: fixed; z-index: 1000;
  background: var(--bg2); border: 1px solid var(--border2);
  border-radius: 14px; padding: .85rem;
  box-shadow: 0 8px 40px rgba(0,0,0,.7), 0 0 0 1px rgba(255,160,60,.15);
  pointer-events: none;
}
.popover-header { display: flex; align-items: center; gap: .6rem; margin-bottom: .75rem; padding-bottom: .5rem; border-bottom: 1px solid var(--border); }
.popover-logo  { width: 32px; height: 32px; border-radius: 6px; object-fit: cover; }
.popover-team  { font-size: .88rem; font-weight: 800; color: var(--text); }
.popover-coach { font-size: .68rem; color: var(--text3); margin-top: .08rem; }

/* Full-size flip card grid inside the popover */
.pop-flip-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: .55rem;
}
/* Inherit all flip-card styles, just fix the dimensions */
.pop-flip-card {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  border: 1.5px solid rgba(255,160,60,.3);
  box-shadow: 0 4px 16px rgba(0,0,0,.75), 0 0 12px rgba(255,120,30,.12);
  background: #060a10;
  display: flex; flex-direction: column;
  height: 155px;
}
.pop-flip-card .fc-img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover; object-position: center top;
  z-index: 0;
}
.pop-flip-card .fc-value {
  position: absolute; top: 4px; left: 5px;
  font-size: 1rem; font-weight: 900; line-height: 1;
  padding: .1rem .3rem; border-radius: 5px;
  background: rgba(0,0,0,.75);
  border: 1px solid rgba(255,255,255,.12); z-index: 4;
}
.pop-flip-card .fc-type {
  position: absolute; top: 4px; right: 4px;
  font-size: .48rem; font-weight: 800; letter-spacing: .08em;
  padding: .15rem .3rem; border-radius: 4px;
  background: rgba(0,0,0,.7); z-index: 4;
}
.pop-flip-card .fc-overlay {
  position: absolute; bottom: 0; left: 0; right: 0;
  padding: .8rem .4rem .3rem;
  background: linear-gradient(to top, rgba(0,0,0,.95) 0%, rgba(0,0,0,.6) 55%, transparent 100%);
  z-index: 3;
}
.pop-flip-card .fc-name {
  font-size: .72rem; font-weight: 800; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pop-flip-card .fc-attrs {
  font-size: .6rem; color: rgba(200,225,255,.55);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-top: .08rem;
}
/* Type colors inherited */
.pop-flip-card.fc-leg { border-color: rgba(245,158,11,.4); }
.pop-flip-card.fc-off { border-color: rgba(56,189,248,.4); }
.pop-flip-card.fc-def { border-color: rgba(74,222,128,.4); }
.pop-flip-card.fc-leg .fc-value { color: #f59e0b; }
.pop-flip-card.fc-off .fc-value { color: #38bdf8; }
.pop-flip-card.fc-def .fc-value { color: #4ade80; }
.pop-flip-card.fc-leg .fc-type  { color: #f59e0b; }
.pop-flip-card.fc-off .fc-type  { color: #38bdf8; }
.pop-flip-card.fc-def .fc-type  { color: #4ade80; }

/* ═══════════════════════════════════════════════════════════════
   PLAYOFFS SCREEN
═══════════════════════════════════════════════════════════════ */
.playoffs-layout {
  max-width: 1100px;
  margin: 0 auto;
}
.playoffs-header { text-align: center; margin-bottom: 2rem; }
.playoffs-title { font-size: 2rem; font-weight: 900; }
.playoffs-sub   { color: var(--text2); font-size: .95rem; margin-top: .3rem; }

/* Tiebreaker */
.tiebreaker-box {
  background: var(--bg2);
  border: 2px solid var(--gold);
  border-radius: var(--radius-lg);
  padding: 2rem;
  text-align: center;
  max-width: 480px;
  margin: 0 auto 2rem;
}
.tb-title    { font-size: 1.4rem; font-weight: 800; margin-bottom: .5rem; color: var(--gold); }
.tb-subtitle { color: var(--text2); font-size: .9rem; margin-bottom: 1.5rem; }
.tb-matchup  { display: flex; align-items: stretch; justify-content: center; gap: 1.5rem; margin-bottom: 1.5rem; }
.tb-team     { text-align: center; }
.tb-team img { width: 48px; height: 48px; border-radius: 8px; object-fit: cover; margin-bottom: .4rem; }
.tb-team div:not(.tb-rec) { font-weight: 700; font-size: .95rem; }
.tb-rec      { font-size: .78rem; color: var(--text3); margin-top: .15rem; }
.tb-vs       { font-size: 1.1rem; font-weight: 900; color: var(--text3); }

/* Bracket */
.bracket-wrap { overflow-x: auto; }
.bracket-container {
  display: flex;
  align-items: flex-start;
  gap: 1.5rem;
  min-width: fit-content;
  padding: 1rem;
}
.bracket-col { display: flex; flex-direction: column; gap: .75rem; min-width: 200px; }
.bracket-round-label {
  font-size: .72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .07em; color: var(--text3);
  text-align: center; margin-bottom: .25rem;
}
.bracket-matchup {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.bracket-matchup.done { border-color: var(--green); }
.bm-team {
  display: flex; align-items: center; gap: .5rem;
  padding: .65rem .85rem;
  font-size: .85rem; font-weight: 500;
}
.bm-team img { width: 24px; height: 24px; border-radius: 4px; object-fit: cover; }
.bm-team.bm-winner { background: rgba(34,197,94,.08); font-weight: 800; }
.bm-tbd { color: var(--text3); font-style: italic; }
.bm-score { margin-left: auto; font-weight: 800; color: var(--gold); }
.bm-divider { height: 1px; background: var(--border); }
.bm-play-btn { width: calc(100% - 1.5rem); margin: .5rem .75rem; }

.bracket-champion-col {
  display: flex;
  align-items: center;
  justify-content: center;
}
.bracket-champ-wrap {
  background: linear-gradient(135deg, rgba(245,158,11,.15), rgba(37,99,235,.1));
  border: 2px solid var(--gold);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  text-align: center;
  min-width: 160px;
}
.champ-trophy-big { font-size: 2.5rem; margin-bottom: .5rem; }
.champ-label     { font-size: .7rem; color: var(--gold); font-weight: 800; text-transform: uppercase; letter-spacing: .08em; margin-bottom: .6rem; }
.champ-logo-lg   { width: 56px; height: 56px; border-radius: 10px; object-fit: cover; margin-bottom: .6rem; }
.champ-name-lg   { font-size: 1rem; font-weight: 800; }
.champ-coach-lg  { font-size: .8rem; color: var(--text2); margin-top: .2rem; }

.playoffs-log-section { margin-top: 1.5rem; }

/* ═══════════════════════════════════════════════════════════════
   CHAMPION SCREEN
═══════════════════════════════════════════════════════════════ */
.champion-layout { max-width: 760px; margin: 0 auto; }
.champion-hero { text-align: center; padding: 2.5rem 1rem 1.5rem; }
.champ-screen-trophy { font-size: 4rem; margin-bottom: .75rem; }
.champ-screen-logo   { width: 72px; height: 72px; border-radius: 12px; object-fit: cover; margin: .5rem auto; display: block; }
.champ-screen-team   { font-size: 2rem; font-weight: 900; margin-top: .5rem; }
.champ-screen-coach  { font-size: 1rem; color: var(--text2); margin-top: .3rem; }
.champ-screen-stats  { font-size: .85rem; color: var(--text3); margin-top: .25rem; }
.champion-confetti   { font-size: 1.5rem; margin-top: 1rem; letter-spacing: .5rem; }
.champion-stats-wrap { margin-bottom: 1.5rem; }
.champion-stats-title { font-size: 1rem; font-weight: 700; margin-bottom: .85rem; color: var(--text2); text-transform: uppercase; letter-spacing: .05em; }

.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .82rem;
}
.stats-table th {
  text-align: left;
  padding: .5rem .65rem;
  color: var(--text3);
  font-weight: 600;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  border-bottom: 1px solid var(--border);
}
.stats-table td {
  padding: .5rem .65rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.stats-table tr:last-child td { border-bottom: none; }
.champ-row td { color: var(--gold); font-weight: 700; }

.champion-actions { text-align: center; padding: 1rem 0 2rem; }

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE
═══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .season-sidebar { width: 180px; }
  .flip-card      { width: 140px; }
  .turn-banner    { gap: .5rem; }
  .turn-banner-right { gap: .3rem; }
  .bracket-container { gap: .75rem; }
  .bracket-col { min-width: 160px; }
}

@media (max-width: 520px) {
  .season-sidebar { width: 130px; }
  .tsb-info       { display: none; }
  .flip-card      { width: 110px; }
  .main-score-display { font-size: 1.6rem; }
}

/* ── Team Count Selector ──────────────────────────────────────── */
.team-count-section { margin-top: 1.25rem; }
.team-count-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: .75rem 0 .4rem;
}
.count-btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--bg3);
  border: 1px solid var(--border2);
  color: var(--text);
  font-size: 1.2rem;
  font-weight: 700;
  display: flex; align-items: stretch; justify-content: center;
  flex-shrink: 0;
}
.count-btn:hover:not(:disabled) { background: var(--accent); border-color: var(--accent); }
.team-count-display {
  display: flex; align-items: baseline; gap: .35rem;
}
.team-count-num {
  font-size: 2rem;
  font-weight: 900;
  color: var(--text);
  min-width: 2ch;
  text-align: center;
}
.team-count-label { font-size: .85rem; color: var(--text2); }
.team-count-note  { font-size: .78rem; color: var(--text3); }

/* ── Active Roster Section ────────────────────────────────────── */
.active-roster-section {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: .85rem 1rem;
}
.active-roster-header {
  display: flex;
  align-items: baseline;
  gap: .75rem;
  margin-bottom: .75rem;
  flex-wrap: wrap;
}
.active-roster-title {
  font-size: .9rem;
  font-weight: 700;
  color: var(--text);
}
.active-roster-sub {
  font-size: .78rem;
  color: var(--text3);
}
.active-roster-cards {
  display: flex;
  gap: .6rem;
  flex-wrap: wrap;
}
.roster-card-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  width: 110px;
  overflow: hidden;
  position: relative;
  transition: border-color .15s, transform .15s;
}
.roster-card-tile:hover {
  border-color: var(--border2);
  transform: translateY(-2px);
}
.rt-legendary { border-color: var(--gold); }
.rt-legendary:hover { border-color: var(--gold); box-shadow: 0 4px 14px rgba(245,158,11,.25); }
.rt-offense:hover  { border-color: #38bdf8; }
.rt-defense:hover  { border-color: #4ade80; }

.rct-type-bar {
  width: 100%;
  text-align: center;
  font-size: .62rem;
  font-weight: 800;
  letter-spacing: .08em;
  padding: .2rem 0;
  background: var(--bg);
  color: var(--text3);
}
.rt-legendary .rct-type-bar { background: rgba(245,158,11,.15); color: var(--gold); }
.rt-offense   .rct-type-bar { background: rgba(56,189,248,.1);  color: #38bdf8; }
.rt-defense   .rct-type-bar { background: rgba(74,222,128,.1);  color: #4ade80; }

.rct-art {
  width: 100%;
  height: 80px;
  object-fit: cover;
  display: block;
}
.rct-info {
  padding: .45rem .5rem .5rem;
  width: 100%;
  text-align: center;
}
.rct-name {
  font-size: .72rem;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: .2rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rct-pos {
  font-size: .65rem;
  color: var(--text3);
  margin-bottom: .25rem;
}
.rct-value {
  font-size: 1.3rem;
  font-weight: 900;
  color: var(--text);
  line-height: 1;
  margin-bottom: .2rem;
}
.rt-legendary .rct-value { color: var(--gold); }
.rct-attrs {
  font-size: .6rem;
  color: var(--text3);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Revealed trade card ──────────────────────────────────────── */
.revealed-trade-card {
  display: inline-flex;
  flex-direction: column;
  background: var(--bg2);
  border: 2px solid var(--accent);
  border-radius: var(--radius-lg);
  overflow: hidden;
  width: 88px;
  box-shadow: 0 0 14px rgba(37,99,235,.35);
  animation: revealPop .25s ease-out;
}
@keyframes revealPop {
  from { transform: scale(.8) rotateY(90deg); opacity: 0; }
  to   { transform: scale(1) rotateY(0deg);   opacity: 1; }
}

/* ── Round badge in action hint ───────────────────────────────── */
.round-badge {
  display: inline-block;
  background: rgba(37,99,235,.2);
  color: #93c5fd;
  font-size: .68rem;
  font-weight: 800;
  padding: .12rem .45rem;
  border-radius: 8px;
  letter-spacing: .04em;
  margin-right: .35rem;
}

/* ── Standings card tweaks ───────────────────────────────────── */
.tsb-name-row {
  display: flex; align-items: baseline; gap: .35rem;
  justify-content: space-between;
}
.tsb-wins {
  font-size: .75rem; font-weight: 900;
  color: var(--text); flex-shrink: 0;
}
.tsb-prog-wrap {
  width: 100%; height: 3px; background: var(--bg3);
  border-radius: 3px; overflow: hidden; margin-top: .2rem;
}
.tsb-prog-fill {
  height: 100%; border-radius: 3px;
  transition: width .4s ease;
  min-width: 2px;
  opacity: .85;
}
.tsb-badge { flex-shrink: 0; }

/* Win track label background fix — sits in win-track-bar */
.win-track-bar .track-space-label { background: var(--bg2); }

/* App shell flex behavior */
#app-shell .screen { flex: 1; }


/* ── Coach Profile Card ──────────────────────────────────────── */
.profile-card {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.profile-card-header {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.profile-logo-img {
  width: 64px; height: 64px;
  border-radius: 12px;
  object-fit: cover;
  border: 2px solid var(--border2);
  flex-shrink: 0;
}
.profile-card-identity { flex: 1; min-width: 0; }
.profile-coach-name {
  font-size: 1.3rem; font-weight: 900; color: var(--text);
  line-height: 1.1; margin-bottom: .2rem;
}
.profile-team-name {
  font-size: .85rem; color: var(--text2); margin-bottom: .4rem;
}
.profile-level-badge {
  display: inline-flex; align-items: center; gap: .4rem;
}
.plb-level {
  background: var(--accent); color: #fff;
  font-size: .72rem; font-weight: 800;
  padding: .15rem .45rem; border-radius: 6px;
}
.plb-title {
  font-size: .78rem; font-weight: 700; color: var(--gold);
}

/* XP bar */
.profile-xp-section { display: flex; flex-direction: column; gap: .35rem; }
.profile-xp-label {
  display: flex; justify-content: space-between;
  font-size: .72rem; color: var(--text3);
}
.profile-xp-bar-wrap {
  width: 100%; height: 8px;
  background: var(--bg3); border-radius: 4px; overflow: hidden;
}
.profile-xp-bar-fill {
  height: 100%; border-radius: 4px;
  background: linear-gradient(90deg, var(--accent), var(--gold));
  transition: width .6s ease;
  min-width: 4px;
}

/* Stats grid */
.profile-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .5rem;
}
.psg-stat {
  background: var(--bg3);
  border-radius: 8px;
  padding: .6rem .5rem;
  text-align: center;
}
.psg-num {
  font-size: 1.4rem; font-weight: 900; color: var(--text);
  line-height: 1;
}
.psg-lbl {
  font-size: .62rem; color: var(--text3);
  text-transform: uppercase; letter-spacing: .06em;
  margin-top: .2rem;
}

/* Next level hint */
.profile-next-level {
  display: flex; align-items: center; gap: .5rem;
  padding: .5rem .65rem;
  background: var(--bg3); border-radius: 8px;
  flex-wrap: wrap;
}

/* ═══════════════════════════════════════════════════════════════
   LOGIN SCREEN
═══════════════════════════════════════════════════════════════ */
.login-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 1rem 2rem;
  gap: 1.25rem;
  margin-top: -1rem;
}
.login-hero { text-align: center; }
.login-logo { font-size: 3rem; margin-bottom: .5rem; }
.login-title {
  font-size: 2rem; font-weight: 900; color: var(--text);
  margin-bottom: .35rem;
}
.login-sub { font-size: .9rem; color: var(--text3); }

.login-card {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  width: 100%; max-width: 400px;
  display: flex; flex-direction: column; gap: .85rem;
}
.login-card-title {
  font-size: 1.1rem; font-weight: 800; color: var(--text);
  margin-bottom: .25rem;
}
.login-error {
  font-size: .8rem; color: #ef4444;
  background: rgba(239,68,68,.1);
  border: 1px solid rgba(239,68,68,.25);
  border-radius: 7px; padding: .45rem .65rem;
}
.login-divider {
  display: flex; align-items: center; gap: .75rem;
  color: var(--text3); font-size: .78rem;
}
.login-divider::before, .login-divider::after {
  content: ""; flex: 1; height: 1px; background: var(--border);
}
.login-register-hint {
  text-align: center; font-size: .8rem; color: var(--text3);
}
.link-btn {
  background: none; border: none; color: var(--accent);
  font-size: inherit; font-weight: 600; cursor: pointer;
  padding: 0; text-decoration: underline;
}
.link-btn:hover { color: #60a5fa; }

/* ═══════════════════════════════════════════════════════════════
   DASHBOARD SCREEN
═══════════════════════════════════════════════════════════════ */
.dashboard-wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* Dashboard profile card */
.dash-profile-card {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.25rem;
  display: flex; align-items: center; gap: 1rem;
}
.dash-profile-logo {
  width: 56px; height: 56px; border-radius: 10px;
  object-fit: cover; flex-shrink: 0;
  border: 2px solid var(--border2);
}
.dash-profile-info { flex: 1; min-width: 0; }
.dash-profile-name { font-size: 1.1rem; font-weight: 900; color: var(--text); }
.dash-profile-team { font-size: .8rem; color: var(--text2); margin-top: .1rem; }
.dash-profile-meta {
  display: flex; align-items: center; gap: .5rem; margin-top: .35rem; flex-wrap: wrap;
}
.dash-level-pill {
  background: var(--accent); color: #fff;
  font-size: .65rem; font-weight: 800;
  padding: .12rem .4rem; border-radius: 5px;
}
.dash-rank-label { font-size: .72rem; color: var(--gold); font-weight: 700; }
.dash-xp-text { font-size: .68rem; color: var(--text3); }
.dash-profile-xp-bar {
  width: 100%; height: 5px; background: var(--bg3);
  border-radius: 3px; overflow: hidden; margin-top: .4rem;
}
.dash-profile-xp-fill {
  height: 100%; border-radius: 3px;
  background: linear-gradient(90deg, var(--accent), var(--gold));
  transition: width .5s ease;
}
.dash-signout-btn {
  background: none; border: none; color: var(--text3);
  font-size: .72rem; cursor: pointer; flex-shrink: 0;
  padding: .25rem .5rem; border-radius: 6px;
}
.dash-signout-btn:hover { color: var(--text); background: var(--bg3); }

/* Action cards */
.dash-actions { display: flex; flex-direction: column; gap: .6rem; }
.dash-action-card {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg);
  padding: .9rem 1.1rem;
  display: flex; align-items: center; gap: .85rem;
  cursor: pointer;
  transition: border-color .15s, background .15s, transform .1s;
  position: relative;
}
.dash-action-card:hover {
  border-color: var(--accent);
  background: rgba(37,99,235,.06);
  transform: translateX(2px);
}
.dash-action-card:active { transform: scale(.99); }
.dash-action-secondary { opacity: .75; }
.dash-action-secondary:hover { opacity: 1; }
.dac-icon {
  font-size: 1.4rem; width: 40px; height: 40px;
  background: var(--bg3); border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.dac-content { flex: 1; min-width: 0; }
.dac-title { font-size: .9rem; font-weight: 700; color: var(--text); }
.dac-desc  { font-size: .75rem; color: var(--text3); margin-top: .1rem; }
.dac-arrow { font-size: .9rem; color: var(--text3); flex-shrink: 0; }
.dac-badge {
  position: absolute; top: .6rem; right: 2.2rem;
  background: #ef4444; color: #fff;
  font-size: .65rem; font-weight: 800;
  padding: .1rem .35rem; border-radius: 8px; min-width: 18px; text-align: center;
}

/* Recent matches */
.dash-section { display: flex; flex-direction: column; gap: .5rem; }
.dash-section-title {
  font-size: .68rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .07em; color: var(--text3);
}
.dash-recent-list { display: flex; flex-direction: column; gap: .4rem; }
.dash-empty {
  font-size: .82rem; color: var(--text3);
  padding: .75rem; text-align: center;
  background: var(--bg2); border-radius: 8px;
  border: 1px dashed var(--border);
}
.dash-match-row {
  display: flex; align-items: center; gap: .75rem;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 8px; padding: .5rem .75rem;
}
.dmr-result {
  font-size: .7rem; font-weight: 800; padding: .15rem .4rem;
  border-radius: 5px; flex-shrink: 0;
}
.dmr-win  { background: rgba(34,197,94,.15);  color: #4ade80; }
.dmr-loss { background: rgba(239,68,68,.15);  color: #f87171; }
.dmr-info { flex: 1; min-width: 0; }
.dmr-opponent { font-size: .8rem; font-weight: 600; color: var(--text); }
.dmr-detail   { font-size: .68rem; color: var(--text3); margin-top: .05rem; }
.dmr-xp { font-size: .7rem; color: var(--gold); font-weight: 700; flex-shrink: 0; }

/* ═══════════════════════════════════════════════════════════════
   FIND PLAYERS SCREEN
═══════════════════════════════════════════════════════════════ */
.players-header {
  display: flex; align-items: center; gap: 1rem;
  margin-bottom: 1.25rem;
}
.players-search-bar {
  display: flex; gap: .5rem; margin-bottom: 1.25rem;
}
.players-search-bar .field-input { flex: 1; }
.players-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: .75rem;
}
.player-card {
  background: var(--bg2); border: 1px solid var(--border2);
  border-radius: var(--radius-lg); padding: .85rem 1rem;
  display: flex; align-items: center; gap: .75rem;
}
.player-card-logo {
  width: 44px; height: 44px; border-radius: 8px;
  object-fit: cover; flex-shrink: 0;
}
.player-card-info { flex: 1; min-width: 0; }
.player-card-name { font-size: .85rem; font-weight: 700; color: var(--text); }
.player-card-team { font-size: .72rem; color: var(--text3); }
.player-card-stats {
  display: flex; gap: .4rem; margin-top: .25rem; flex-wrap: wrap;
}
.pcs-pill {
  font-size: .6rem; font-weight: 700;
  padding: .08rem .3rem; border-radius: 4px;
  background: var(--bg3); color: var(--text3);
}
.player-invite-btn {
  background: var(--accent); color: #fff;
  border: none; border-radius: 7px;
  padding: .38rem .75rem; font-size: .78rem; font-weight: 700;
  cursor: pointer; flex-shrink: 0;
  transition: filter .15s;
}
.player-invite-btn:hover { filter: brightness(1.15); }
.player-invite-btn:disabled {
  background: var(--bg3); color: var(--text3); cursor: not-allowed;
}

/* Invite toast */
.invite-toast {
  position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%);
  background: var(--bg2); border: 1px solid var(--accent);
  border-radius: 10px; padding: .75rem 1.25rem;
  font-size: .85rem; font-weight: 600; color: var(--text);
  box-shadow: 0 4px 20px rgba(0,0,0,.5);
  z-index: 500; opacity: 0; transition: opacity .3s;
  white-space: nowrap;
}
.invite-toast.show { opacity: 1; }

/* ============================================================
   COACH ABILITY SLOTS
   ============================================================ */
.coach-ability-slots {
  margin-top: 1.25rem;
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}
.cas-title {
  font-size: .95rem; font-weight: 800; color: var(--text); margin-bottom: .15rem;
}
.cas-subtitle {
  font-size: .72rem; color: var(--text3); margin-bottom: .85rem;
}
.cas-slot {
  background: var(--bg2); border: 1px solid var(--border2);
  border-radius: 10px; padding: .7rem .85rem; margin-bottom: .6rem;
}
.cas-slot.cas-locked {
  opacity: .5;
}
.cas-slot-name {
  font-size: .82rem; font-weight: 700; color: var(--text);
}
.cas-slot-hint {
  font-size: .72rem; color: var(--text3); margin-top: .15rem;
}
.cas-slot-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: .2rem; gap: .5rem; flex-wrap: wrap;
}
.cas-slot-desc {
  font-size: .7rem; color: var(--text3); margin-bottom: .55rem;
}
.cas-equipped-badge {
  font-size: .65rem; font-weight: 800; background: var(--accent);
  color: #000; padding: .1rem .42rem; border-radius: 4px; white-space: nowrap;
}
.cas-empty-badge {
  font-size: .65rem; color: var(--text3); font-style: italic;
}
.cas-controls {
  display: flex; gap: .5rem; align-items: center; flex-wrap: wrap;
}
.cas-select {
  flex: 1; min-width: 0; background: var(--bg3); border: 1px solid var(--border2);
  color: var(--text); border-radius: 7px; padding: .38rem .5rem;
  font-size: .75rem; cursor: pointer;
}
.cas-equip-btn {
  background: var(--accent); color: #000;
  border: none; border-radius: 7px;
  padding: .38rem .9rem; font-size: .75rem; font-weight: 700;
  cursor: pointer; flex-shrink: 0; transition: filter .15s; white-space: nowrap;
}
.cas-equip-btn:hover { filter: brightness(1.15); }

/* Ability Index */
.cas-index {
  margin-top: 1.1rem;
  border-top: 1px solid var(--border);
  padding-top: .85rem;
}
.cas-index-title {
  font-size: .82rem; font-weight: 800; color: var(--text2);
  margin-bottom: .6rem; display: flex; align-items: center; gap: .4rem;
}
.cas-index-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: .45rem;
}
@media (max-width: 480px) { .cas-index-grid { grid-template-columns: 1fr; } }
.cas-index-row {
  background: var(--bg3); border-radius: 8px;
  padding: .5rem .65rem; border-left: 3px solid var(--border2);
}
.cas-index-row.type-offense  { border-left-color: #f59e0b; }
.cas-index-row.type-defense  { border-left-color: #38bdf8; }
.cas-index-row.type-general  { border-left-color: #a78bfa; }
.cas-index-name {
  font-size: .75rem; font-weight: 700; color: var(--text); margin-bottom: .15rem;
}
.cas-index-effect {
  font-size: .68rem; color: var(--text3); line-height: 1.4;
}
.cas-index-type {
  font-size: .58rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; margin-top: .2rem;
}
.cas-index-type.type-offense { color: #f59e0b; }
.cas-index-type.type-defense { color: #38bdf8; }
.cas-index-type.type-general { color: #a78bfa; }

/* ============================================================
   TOURNAMENT SCREEN
   ============================================================ */
.tourn-list {
  display: flex; flex-direction: column; gap: .85rem;
}
.tourn-card {
  background: var(--bg2); border: 1.5px solid var(--border2);
  border-radius: 14px; padding: 1rem 1.1rem; transition: border-color .2s;
}
.tourn-card:hover { border-color: var(--accent); }
.tourn-card.tourn-locked { opacity: .55; pointer-events: none; }
.tourn-card-header {
  display: flex; align-items: flex-start; gap: .75rem; margin-bottom: .6rem;
}
.tourn-icon {
  font-size: 1.6rem; line-height: 1; flex-shrink: 0; margin-top: .1rem;
}
.tourn-meta { flex: 1; }
.tourn-name {
  font-size: .95rem; font-weight: 800; color: var(--text); margin-bottom: .3rem;
}
.tourn-tags { display: flex; gap: .35rem; flex-wrap: wrap; }
.tourn-status-pill, .tourn-format-pill {
  font-size: .6rem; font-weight: 700; padding: .08rem .38rem;
  border-radius: 4px; background: var(--bg3); color: var(--text3);
}
.tourn-time { text-align: right; flex-shrink: 0; }
.tourn-desc {
  font-size: .76rem; color: var(--text3); line-height: 1.5;
  margin-bottom: .75rem;
}
.tourn-prize { margin-bottom: .75rem; }
.tourn-prize-card {
  display: flex; align-items: center; gap: .6rem;
  background: var(--bg3); border: 1.5px solid var(--border2);
  border-radius: 9px; padding: .45rem .65rem;
}
.tourn-prize-info { flex: 1; }
.tourn-prize-rarity {
  font-size: .58rem; font-weight: 800; padding: .1rem .35rem;
  border-radius: 4px; flex-shrink: 0;
}
.tourn-footer { display: flex; align-items: center; gap: .75rem; }
.tourn-enter-btn {
  background: var(--accent); color: #000; border: none;
  border-radius: 8px; padding: .45rem 1rem;
  font-size: .8rem; font-weight: 800; cursor: pointer; transition: filter .15s;
}
.tourn-enter-btn:hover { filter: brightness(1.15); }
.tourn-enter-btn:disabled { background: #22c55e; cursor: default; }
.tourn-notify-btn {
  background: var(--bg3); color: var(--text2); border: 1px solid var(--border2);
  border-radius: 8px; padding: .4rem .9rem;
  font-size: .78rem; font-weight: 700; cursor: pointer; transition: filter .15s;
}
.tourn-notify-btn:hover { filter: brightness(1.1); }
.tourn-notify-btn:disabled { opacity: .6; cursor: default; }
.tourn-ineligible {
  font-size: .72rem; color: var(--text3); font-style: italic;
}

/* ============================================================
   DEV MODE TOGGLE
   ============================================================ */
.dev-mode-toggle {
  display: inline-flex; align-items: center; gap: .4rem;
  cursor: pointer; user-select: none;
  font-size: .75rem; font-weight: 700; color: var(--text3);
  padding: .35rem .65rem;
  border: 1px solid var(--border2);
  border-radius: 7px;
  background: var(--bg2);
  transition: color .15s, border-color .15s;
}
.dev-mode-toggle:has(input:checked) {
  color: #f59e0b;
  border-color: #f59e0b88;
  background: #f59e0b11;
}
.dev-mode-toggle input { display: none; }

/* ============================================================
   SEASON / PLAYOFFS DASHBOARD BUTTON
   ============================================================ */
.season-dash-btn {
  background: var(--bg3);
  border: 1px solid var(--border2);
  color: var(--text2);
  font-size: .72rem;
  font-weight: 700;
  padding: .28rem .65rem;
  border-radius: 7px;
  cursor: pointer;
  flex-shrink: 0;
  white-space: nowrap;
  transition: background .15s, color .15s;
}
.season-dash-btn:hover {
  background: var(--bg2);
  color: var(--text);
}
/* Dashboard button repositioned to sidebar */
.sb-dash-wrap {
  padding-bottom: .45rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: .4rem;
}
.sb-dash-btn {
  width: 100%;
  text-align: center;
  font-size: .68rem;
}

/* ============================================================
   DASHBOARD — RESUME LEAGUE BANNER
   ============================================================ */
.dash-resume-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: var(--accent);
  border-radius: 10px;
  padding: .7rem 1rem;
}
.drb-info { flex: 1; }
.drb-label {
  font-size: .8rem;
  font-weight: 800;
  color: #000;
}
.drb-detail {
  font-size: .7rem;
  color: rgba(0,0,0,.65);
  margin-top: .1rem;
}
.drb-btn {
  background: #000;
  color: #fff;
  border: none;
  border-radius: 7px;
  padding: .4rem .9rem;
  font-size: .8rem;
  font-weight: 800;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity .15s;
}
.drb-btn:hover { opacity: .85; }

/* ── Away card mirror flip ── */
/* The player image is mirrored so they face toward the home card */
.flip-card.fc-away {
  animation:
    cardReveal    .55s cubic-bezier(.22,.68,0,1.2) both,
    cardFloatAway 4.5s ease-in-out 0.6s infinite;
}
/* Outcome states must beat fc-away's specificity — explicit two-class overrides */
.flip-card.fc-away.loser {
  animation: cardDust 2.2s ease-in-out 1.3s both;
  pointer-events: none;
}
.flip-card.fc-away.winner {
  animation: cardWin .6s cubic-bezier(.22,.68,0,1.2) both;
}
.flip-card.fc-away.tie {
  animation: cardTie .5s ease-in-out 2;
}
.flip-card.fc-away.injured:not(.loser):not(.winner) {
  animation: cardInjury .9s ease-out both;
}
/* Away card image — no mirror, preserves any text in card art */
.flip-card.fc-away .fc-img {
  transform: none;
}
