/* =========================================================================
   SHADOWFALL: Ninja Ascension — Stylesheet
   A dark, anime-inspired ninja RPG interface.
   Signature device: the gold ◆ mark ties the brand (logo) to the rarest
   ninjas (SSR) — the diamond marks what's most valuable.
   ========================================================================= */

/* ---------- Design tokens ---------- */
:root {
  /* Backgrounds */
  --void-black: #07080f;
  --night-navy: #10122a;
  --panel-indigo: #1b1a3a;
  --panel-indigo-deep: #15142e;
  --panel-edge: #423a78;
  --panel-edge-soft: rgba(120, 105, 200, 0.28);

  /* Text */
  --text-primary: #f2eff9;
  --text-muted: #9d99bd;
  --text-faint: #6f6b90;

  /* Signature gold */
  --gold: #f0b93a;
  --gold-bright: #ffd77a;
  --gold-dim: #a9863a;

  /* Elemental palette (bright, distinct per element) */
  --el-flame: #ff5f3e;
  --el-tide: #31c4f3;
  --el-gale: #4be3a0;
  --el-stone: #c9945a;
  --el-void: #9c6bff;
  --el-light: #ffe97a;

  /* Rarity */
  --rarity-r: #9c98b8;
  --rarity-sr: #5aa8ff;
  --rarity-ssr: #f0b93a;

  /* Status */
  --success: #4be3a0;
  --danger: #ff6b6b;
  --hp-full: #4be3a0;
  --hp-mid: #f0b93a;
  --hp-low: #ff6b6b;
  --ore: #7dd8ff;

  /* Shape + motion */
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --radius-pill: 999px;
  --transition-fast: 150ms ease;
  --transition-mid: 300ms ease;

  --bottom-nav-height: 68px;
}

/* ---------- Reset ---------- */
*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(ellipse 900px 500px at 50% -10%, rgba(66, 58, 120, 0.35), transparent 60%),
    linear-gradient(180deg, var(--night-navy) 0%, var(--void-black) 100%);
  background-attachment: fixed;
  color: var(--text-primary);
  font-family: 'Segoe UI', 'Helvetica Neue', Roboto, 'Noto Sans', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
  padding-bottom: calc(var(--bottom-nav-height) + 1.5rem);
}

h1, h2, h3, p {
  margin: 0;
}

button {
  font-family: inherit;
}

/* Visible keyboard focus */
a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--gold-bright);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

/* ---------- Header ---------- */
.top-header {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1.1rem;
  background: linear-gradient(180deg, #12142c, #10112a);
  border-bottom: 1px solid var(--panel-edge-soft);
  box-shadow: 0 1px 0 rgba(240, 185, 58, 0.12), 0 8px 24px rgba(0, 0, 0, 0.35);
}

.logo {
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-primary);
  white-space: nowrap;
}

.logo-accent {
  color: var(--gold-bright);
  text-shadow: 0 0 8px rgba(255, 215, 122, 0.85), 0 0 18px rgba(240, 185, 58, 0.55);
  margin-left: 0.15em;
}

.resources {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

.resource-pill {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.7rem;
  background: var(--panel-indigo);
  border: 1px solid var(--panel-edge-soft);
  border-radius: var(--radius-pill);
  font-weight: 700;
  font-size: 0.92rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.resource-icon {
  font-size: 1rem;
}

/* ---------- Bottom tab bar ---------- */
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  height: var(--bottom-nav-height);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: #0c0d21;
  border-top: 1px solid var(--panel-edge-soft);
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.4);
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.tab-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  cursor: pointer;
  transition: color var(--transition-fast);
  position: relative;
}

.tab-icon {
  font-size: 1.35rem;
  line-height: 1;
  filter: grayscale(60%) opacity(0.8);
  transition: filter var(--transition-fast), transform var(--transition-fast);
}

.tab-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.tab-btn.active {
  color: var(--gold-bright);
}

.tab-btn.active .tab-icon {
  filter: none;
  transform: translateY(-1px);
  text-shadow: 0 0 10px rgba(240, 185, 58, 0.6);
}

.tab-btn.active::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 28px;
  height: 3px;
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg, var(--gold), var(--gold-bright));
  box-shadow: 0 0 10px rgba(240, 185, 58, 0.6);
}

/* ---------- Sub-tabs (Roster / Formation) ---------- */
.subtab-bar {
  display: flex;
  gap: 0.5rem;
  padding: 0.25rem;
  background: var(--panel-indigo-deep);
  border: 1px solid var(--panel-edge-soft);
  border-radius: var(--radius-pill);
}

.subtab-btn {
  flex: 1;
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.88rem;
  padding: 0.55rem 0.5rem;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.subtab-btn.active {
  background: linear-gradient(135deg, var(--gold-bright), var(--gold));
  color: #241c05;
}

.subtab-panel {
  display: none;
  flex-direction: column;
  gap: 1.1rem;
}

.subtab-panel.subtab-active {
  display: flex;
}

/* ---------- Layout ---------- */
.app-main {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.25rem 1rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.screen {
  display: none;
  flex-direction: column;
  gap: 1.1rem;
  animation: screen-fade-in var(--transition-mid);
}

.screen.screen-active {
  display: flex;
}

@keyframes screen-fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.screen-hero {
  padding: 0.25rem 0.1rem 0.1rem;
}

.page-title {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  color: var(--text-primary);
  position: relative;
  display: inline-block;
  padding-bottom: 0.5rem;
}

.page-title::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 46px;
  height: 3px;
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg, var(--gold), var(--gold-bright));
  box-shadow: 0 0 10px rgba(240, 185, 58, 0.6);
}

.page-subtitle {
  margin-top: 0.5rem;
  color: var(--text-muted);
  font-size: 0.98rem;
}

/* ---------- Panels ---------- */
.panel {
  background: linear-gradient(165deg, var(--panel-indigo) 0%, var(--panel-indigo-deep) 100%);
  border: 1px solid var(--panel-edge-soft);
  border-radius: var(--radius-lg);
  padding: 1.1rem;
  box-shadow: 0 10px 30px rgba(4, 4, 12, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.panel-title {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  margin-bottom: 0.85rem;
}

.panel-hint {
  font-size: 0.78rem;
  color: var(--text-faint);
  margin: -0.5rem 0 0.75rem;
}

.panel-actions {
  display: flex;
  gap: 0.6rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

/* ---------- Buttons ---------- */
.btn {
  appearance: none;
  cursor: pointer;
  border: none;
  border-radius: var(--radius-pill);
  font-weight: 700;
  font-size: 0.92rem;
  letter-spacing: 0.01em;
  padding: 0.7rem 1.3rem;
  min-height: 44px;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), opacity var(--transition-fast);
}

.btn:active {
  transform: scale(0.97);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--gold-bright), var(--gold));
  color: #241c05;
  box-shadow: 0 6px 18px rgba(240, 185, 58, 0.35);
}

.btn-primary:hover:not(:disabled) {
  box-shadow: 0 6px 22px rgba(240, 185, 58, 0.55);
}

.btn-outline {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--panel-edge);
}

.btn-outline:hover:not(:disabled) {
  border-color: var(--gold-dim);
  color: var(--gold-bright);
}

.btn-large {
  width: 100%;
  padding: 0.85rem 1.5rem;
  font-size: 1rem;
}

.btn-small {
  padding: 0.4rem 0.8rem;
  min-height: 34px;
  font-size: 0.78rem;
}

.btn-add {
  background: rgba(75, 227, 160, 0.14);
  color: var(--success);
  border: 1px solid rgba(75, 227, 160, 0.4);
}

.btn-add:hover {
  background: rgba(75, 227, 160, 0.22);
}

.btn-remove {
  background: rgba(255, 107, 107, 0.1);
  color: var(--danger);
  border: 1px solid rgba(255, 107, 107, 0.35);
}

.btn-remove:hover {
  background: rgba(255, 107, 107, 0.18);
}

.btn-enhance {
  background: rgba(125, 216, 255, 0.14);
  color: var(--ore);
  border: 1px solid rgba(125, 216, 255, 0.4);
  white-space: nowrap;
}

.btn-enhance:hover:not(:disabled) {
  background: rgba(125, 216, 255, 0.24);
}

/* ---------- Squad slots (used on Home + Formation) ---------- */
.formation-zone + .formation-zone {
  margin-top: 0.9rem;
}

.formation-label {
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 0.5rem;
}

.squad-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 0.6rem;
}

.squad-grid-front { grid-template-columns: repeat(3, 1fr); }
.squad-grid-back { grid-template-columns: repeat(2, 1fr); max-width: 66%; }

.squad-slot {
  border-radius: var(--radius-md);
  padding: 0.7rem 0.5rem;
  text-align: center;
  min-height: 96px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  position: relative;
}

.squad-slot.filled {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--panel-edge-soft);
}

.squad-slot.filled.tappable {
  cursor: pointer;
  transition: transform var(--transition-fast), border-color var(--transition-fast);
}

.squad-slot.filled.tappable:hover {
  border-color: var(--gold-dim);
  transform: translateY(-1px);
}

.squad-slot.rarity-ssr {
  border-color: rgba(240, 185, 58, 0.55);
  box-shadow: 0 0 16px rgba(240, 185, 58, 0.18);
}

.squad-slot.rarity-sr {
  border-color: rgba(90, 168, 255, 0.45);
}

.slot-level-badge {
  position: absolute;
  top: 0.3rem;
  right: 0.35rem;
  font-size: 0.62rem;
  font-weight: 800;
  color: var(--gold-bright);
  background: rgba(0, 0, 0, 0.4);
  padding: 0.05rem 0.3rem;
  border-radius: var(--radius-sm);
}

.slot-icon {
  font-size: 1.6rem;
  line-height: 1;
}

.slot-name {
  font-weight: 700;
  font-size: 0.85rem;
  margin-top: 0.15rem;
}

.slot-element {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.squad-slot.empty {
  border: 1px dashed var(--panel-edge);
  color: var(--text-faint);
}

.slot-empty-icon {
  font-size: 1.4rem;
  color: var(--text-faint);
}

.slot-empty-text {
  font-size: 0.72rem;
  letter-spacing: 0.02em;
}

/* ---------- Home: elements ---------- */
.elements-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(84px, 1fr));
  gap: 0.6rem;
}

.element-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  padding: 0.75rem 0.4rem;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--panel-edge-soft);
}

.element-icon {
  font-size: 1.5rem;
}

.element-name {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.element-flame .element-name { color: var(--el-flame); }
.element-tide .element-name { color: var(--el-tide); }
.element-gale .element-name { color: var(--el-gale); }
.element-stone .element-name { color: var(--el-stone); }
.element-void .element-name { color: var(--el-void); }
.element-light .element-name { color: var(--el-light); }

.element-flame { box-shadow: inset 0 0 0 1px rgba(255, 95, 62, 0.25); }
.element-tide { box-shadow: inset 0 0 0 1px rgba(49, 196, 243, 0.25); }
.element-gale { box-shadow: inset 0 0 0 1px rgba(75, 227, 160, 0.25); }
.element-stone { box-shadow: inset 0 0 0 1px rgba(201, 148, 90, 0.25); }
.element-void { box-shadow: inset 0 0 0 1px rgba(156, 107, 255, 0.25); }
.element-light { box-shadow: inset 0 0 0 1px rgba(255, 233, 122, 0.25); }

/* ---------- Ninja roster ---------- */
.roster-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
  gap: 0.75rem;
}

.roster-card {
  position: relative;
  background: linear-gradient(165deg, var(--panel-indigo) 0%, var(--panel-indigo-deep) 100%);
  border: 1px solid var(--panel-edge-soft);
  border-radius: var(--radius-lg);
  padding: 1rem 0.85rem 0.85rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.25rem;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.roster-card.rarity-sr {
  border-color: rgba(90, 168, 255, 0.4);
  box-shadow: 0 0 16px rgba(90, 168, 255, 0.12);
}

.roster-card.rarity-ssr {
  border-color: rgba(240, 185, 58, 0.6);
  box-shadow: 0 0 22px rgba(240, 185, 58, 0.22);
  animation: ssr-glow 3.4s ease-in-out infinite;
}

@keyframes ssr-glow {
  0%, 100% { box-shadow: 0 0 18px rgba(240, 185, 58, 0.18); }
  50% { box-shadow: 0 0 28px rgba(240, 185, 58, 0.38); }
}

.roster-card.in-squad {
  outline: 1px solid rgba(75, 227, 160, 0.5);
  outline-offset: 2px;
}

.rarity-tag {
  position: absolute;
  top: 0.6rem;
  left: 0.6rem;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-sm);
}

.level-tag {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-sm);
  background: rgba(240, 185, 58, 0.14);
  color: var(--gold-bright);
}

.roster-card.rarity-r .rarity-tag {
  background: rgba(156, 152, 184, 0.16);
  color: var(--rarity-r);
}

.roster-card.rarity-sr .rarity-tag {
  background: rgba(90, 168, 255, 0.16);
  color: var(--rarity-sr);
}

.roster-card.rarity-ssr .rarity-tag {
  background: rgba(240, 185, 58, 0.18);
  color: var(--rarity-ssr);
}

.roster-card.rarity-ssr .rarity-tag::before {
  content: "◆ ";
}

.roster-icon {
  font-size: 2.1rem;
  margin-top: 0.6rem;
}

.roster-name {
  font-weight: 800;
  font-size: 1rem;
}

.roster-element {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.roster-power {
  font-size: 0.78rem;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

.roster-desc {
  font-size: 0.74rem;
  color: var(--text-faint);
  line-height: 1.4;
  margin: 0.15rem 0 0.1rem;
  min-height: 2.2em;
}

.roster-status {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--success);
  min-height: 1em;
}

.roster-card-buttons {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-top: 0.4rem;
}

.roster-card-buttons .btn {
  width: 100%;
}

.levelup-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font-size: 0.72rem;
  color: var(--text-faint);
}

/* ---------- Gear / Veil Forge ---------- */
.gear-select-panel {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.gear-ore-pill {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.7rem;
  background: rgba(125, 216, 255, 0.1);
  border: 1px solid rgba(125, 216, 255, 0.35);
  border-radius: var(--radius-pill);
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--ore);
}

.gear-character-strip {
  display: flex;
  gap: 0.6rem;
  overflow-x: auto;
  padding-bottom: 0.15rem;
}

.gear-avatar-btn {
  flex-shrink: 0;
  appearance: none;
  cursor: pointer;
  width: 64px;
  height: 64px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.03);
  border: 2px solid var(--panel-edge-soft);
  font-size: 1.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color var(--transition-fast), transform var(--transition-fast);
}

.gear-avatar-btn.active {
  border-color: var(--gold);
  box-shadow: 0 0 14px rgba(240, 185, 58, 0.35);
  transform: translateY(-2px);
}

.gear-empty-message {
  color: var(--text-faint);
  font-size: 0.85rem;
}

.gear-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.gear-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.75rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--panel-edge-soft);
  border-radius: var(--radius-md);
}

.gear-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
  width: 36px;
  text-align: center;
}

.gear-info {
  flex: 1;
  min-width: 0;
}

.gear-name-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.gear-name {
  font-weight: 700;
  font-size: 0.9rem;
}

.gear-level {
  font-size: 0.7rem;
  color: var(--ore);
  font-weight: 700;
}

.gear-stat {
  font-size: 0.76rem;
  color: var(--text-muted);
  margin-top: 0.1rem;
}

.gear-row .btn-enhance {
  flex-shrink: 0;
}

/* ---------- Battle arena ---------- */
.arena-shell {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.arena-scene {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  min-height: 280px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.75rem;
  border: 1px solid var(--panel-edge-soft);
  user-select: none;
}

.arena-sky {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, #211c45 0%, #171335 55%, #100e26 100%);
}

.arena-mountains {
  position: absolute;
  left: -5%;
  right: -5%;
  bottom: 34%;
  height: 90px;
  background: linear-gradient(180deg, transparent 0%, rgba(66, 58, 120, 0.5) 100%);
  clip-path: polygon(0% 100%, 8% 40%, 18% 75%, 30% 20%, 42% 60%, 55% 10%, 68% 55%, 80% 25%, 92% 65%, 100% 100%);
  opacity: 0.7;
}

.arena-torii {
  position: absolute;
  top: 14%;
  right: 6%;
  font-size: 2rem;
  opacity: 0.35;
  filter: drop-shadow(0 0 8px rgba(240, 185, 58, 0.25));
}

.arena-ground {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 38%;
  background: linear-gradient(180deg, #1a1735 0%, #0c0b1e 100%);
  border-top: 1px solid rgba(120, 105, 200, 0.25);
}

.arena-scene .team,
.arena-scene .vs-divider {
  position: relative;
  z-index: 2;
}

.team {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  align-items: flex-end;
}

.vs-divider {
  flex-shrink: 0;
  font-weight: 900;
  font-size: 1.1rem;
  color: var(--gold-bright);
  text-shadow: 0 0 10px rgba(240, 185, 58, 0.5);
  padding: 0 0.4rem;
  align-self: center;
}

.empty-team-message {
  color: var(--text-faint);
  font-size: 0.85rem;
  text-align: center;
  padding: 1rem 0.5rem;
}

.fighter-card {
  background: rgba(15, 14, 32, 0.72);
  backdrop-filter: blur(2px);
  border: 1px solid var(--panel-edge-soft);
  border-radius: var(--radius-md);
  padding: 0.5rem 0.45rem 0.55rem;
  width: 88px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  text-align: center;
  transition: opacity var(--transition-mid), transform var(--transition-mid);
}

.fighter-card.defeated {
  opacity: 0.25;
  transform: scale(0.9);
}

.enemy-team .fighter-card {
  border-color: rgba(156, 107, 255, 0.35);
}

.hp-bar-track {
  width: 100%;
  height: 6px;
  border-radius: var(--radius-pill);
  background: rgba(0, 0, 0, 0.45);
  overflow: hidden;
  order: -1;
  margin-bottom: 0.3rem;
}

.hp-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--hp-full), var(--hp-mid));
  border-radius: var(--radius-pill);
  transition: width 400ms ease;
}

.hp-bar-fill.hp-low {
  background: linear-gradient(90deg, var(--hp-mid), var(--hp-low));
}

.fighter-icon {
  font-size: 1.4rem;
}

.fighter-name {
  font-size: 0.72rem;
  font-weight: 700;
  max-width: 100%;
  line-height: 1.15;
}

.fighter-element {
  font-size: 0.64rem;
  color: var(--text-muted);
}

.fighter-power {
  font-size: 0.62rem;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

.damage-float-layer {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}

.damage-float {
  position: absolute;
  font-weight: 900;
  font-size: 1rem;
  color: var(--gold-bright);
  text-shadow: 0 0 8px rgba(0, 0, 0, 0.6);
  animation: damage-rise 700ms ease-out forwards;
}

.damage-float.damage-bonus {
  color: var(--el-flame);
}

@keyframes damage-rise {
  0% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-34px); }
}

.arena-tap-btn {
  appearance: none;
  cursor: pointer;
  border: 1px solid var(--panel-edge);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
  font-weight: 700;
  font-size: 0.88rem;
  padding: 0.65rem 1rem;
  border-radius: var(--radius-md);
  transition: background var(--transition-fast), border-color var(--transition-fast), transform 80ms ease;
}

.arena-tap-btn:not(:disabled):hover {
  border-color: var(--gold-dim);
}

.arena-tap-btn:not(:disabled):active {
  transform: scale(0.98);
  background: rgba(240, 185, 58, 0.12);
}

.arena-tap-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.battle-controls {
  display: flex;
  justify-content: center;
}

.combat-log-panel {
  display: flex;
  flex-direction: column;
}

.combat-log {
  height: 190px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding-right: 0.25rem;
}

.combat-log-line {
  font-size: 0.85rem;
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.03);
  border-left: 2px solid var(--panel-edge);
  padding: 0.4rem 0.6rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  animation: log-in 220ms ease;
}

.combat-log-line.log-wave {
  border-left-color: var(--gold);
  color: var(--gold-bright);
  font-weight: 700;
}

@keyframes log-in {
  from { opacity: 0; transform: translateX(-4px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ---------- Summon / Gacha screen ---------- */
.summon-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 1.6rem 1.25rem 2rem;
  gap: 0.35rem;
}

.pity-track {
  width: 100%;
  max-width: 360px;
  margin-bottom: 0.5rem;
}

.pity-bar-track {
  width: 100%;
  height: 8px;
  border-radius: var(--radius-pill);
  background: rgba(0, 0, 0, 0.4);
  overflow: hidden;
  border: 1px solid var(--panel-edge-soft);
}

.pity-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--el-void), var(--gold-bright));
  border-radius: var(--radius-pill);
  transition: width 400ms ease;
}

.pity-text {
  margin-top: 0.4rem;
  font-size: 0.76rem;
  color: var(--text-faint);
}

.summon-decoration {
  font-size: 3rem;
  color: var(--gold-bright);
  text-shadow: 0 0 20px rgba(240, 185, 58, 0.6), 0 0 40px rgba(156, 107, 255, 0.3);
  margin: 0.6rem 0 0.2rem;
  animation: summon-idle 4s ease-in-out infinite;
}

@keyframes summon-idle {
  0%, 100% { transform: scale(1); opacity: 0.92; }
  50% { transform: scale(1.08); opacity: 1; }
}

.summon-decoration.summon-pulse {
  animation: summon-burst 700ms ease;
}

@keyframes summon-burst {
  0% { transform: scale(1); text-shadow: 0 0 20px rgba(240, 185, 58, 0.6); }
  40% { transform: scale(1.35); text-shadow: 0 0 46px rgba(240, 185, 58, 0.95), 0 0 70px rgba(156, 107, 255, 0.6); }
  100% { transform: scale(1); text-shadow: 0 0 20px rgba(240, 185, 58, 0.6); }
}

.summon-rates {
  color: var(--text-muted);
  font-size: 0.82rem;
  margin-bottom: 0.75rem;
}

.summon-btn-row {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  justify-content: center;
  width: 100%;
  max-width: 420px;
}

.summon-btn-row .btn {
  flex: 1;
  min-width: 160px;
}

.summon-result {
  margin-top: 1.2rem;
  min-height: 1px;
  width: 100%;
}

.summon-reveal {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 1rem 1.5rem;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--panel-edge-soft);
  animation: screen-fade-in var(--transition-mid);
}

.summon-reveal.rarity-ssr {
  border-color: rgba(240, 185, 58, 0.6);
  box-shadow: 0 0 24px rgba(240, 185, 58, 0.28);
}

.summon-reveal.rarity-sr {
  border-color: rgba(90, 168, 255, 0.5);
  box-shadow: 0 0 16px rgba(90, 168, 255, 0.16);
}

.summon-reveal-icon {
  font-size: 2.4rem;
}

.summon-reveal-name {
  font-weight: 800;
  font-size: 1.05rem;
}

.summon-reveal-rarity {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.summon-x10-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(84px, 1fr));
  gap: 0.5rem;
  width: 100%;
  animation: screen-fade-in var(--transition-mid);
}

.summon-x10-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  padding: 0.6rem 0.3rem;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--panel-edge-soft);
}

.summon-x10-card.rarity-ssr {
  border-color: rgba(240, 185, 58, 0.55);
  box-shadow: 0 0 14px rgba(240, 185, 58, 0.2);
}

.summon-x10-card.rarity-sr {
  border-color: rgba(90, 168, 255, 0.45);
}

.summon-x10-icon {
  font-size: 1.5rem;
}

.summon-x10-name {
  font-size: 0.68rem;
  font-weight: 700;
}

.summon-x10-rarity {
  font-size: 0.6rem;
  color: var(--text-faint);
}

/* ---------- Toasts ---------- */
.toast-container {
  position: fixed;
  left: 50%;
  bottom: calc(var(--bottom-nav-height) + 0.85rem);
  transform: translateX(-50%);
  display: flex;
  flex-direction: column-reverse;
  gap: 0.5rem;
  z-index: 100;
  width: min(92vw, 380px);
  align-items: center;
}

.toast {
  width: 100%;
  text-align: center;
  padding: 0.75rem 1.1rem;
  border-radius: var(--radius-md);
  background: rgba(20, 20, 42, 0.96);
  border: 1px solid var(--panel-edge);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity var(--transition-mid), transform var(--transition-mid);
}

.toast.toast-visible {
  opacity: 1;
  transform: translateY(0);
}

.toast-success {
  border-color: rgba(75, 227, 160, 0.5);
}

.toast-error {
  border-color: rgba(255, 107, 107, 0.55);
  color: #ffd9d9;
}

.toast-info {
  border-color: var(--panel-edge);
}

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  .top-header {
    padding: 0.7rem 0.75rem;
  }

  .logo {
    font-size: 1.05rem;
  }

  .resource-pill {
    font-size: 0.82rem;
    padding: 0.35rem 0.55rem;
  }

  .page-title {
    font-size: 1.35rem;
  }

  .fighter-card {
    width: 78px;
  }

  .summon-decoration {
    font-size: 2.4rem;
  }

  .squad-grid-back {
    max-width: 100%;
  }
}

@media (max-width: 380px) {
  .fighter-card {
    width: 70px;
    padding: 0.4rem 0.3rem 0.45rem;
  }

  .fighter-name {
    font-size: 0.66rem;
  }

  .tab-label {
    font-size: 0.62rem;
  }

  .tab-icon {
    font-size: 1.2rem;
  }
}

/* Respect reduced-motion preference */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
