:root {
  color-scheme: dark;
  --ink: #f7fbff;
  --muted: #9fb0c7;
  --line: rgba(255, 255, 255, 0.13);
  --panel: rgba(13, 18, 30, 0.86);
  --panel-strong: #111827;
  --gold: #f6c85f;
  --green: #4dd78a;
  --red: #ff6274;
  --blue: #68c8ff;
  --violet: #a98bff;
  --orange: #ff9f58;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 12%, rgba(255, 159, 88, 0.2), transparent 26rem),
    radial-gradient(circle at 88% 22%, rgba(104, 200, 255, 0.17), transparent 24rem),
    linear-gradient(135deg, #07111f 0%, #17202b 47%, #101820 100%);
  display: grid;
  place-items: center;
  padding: 18px;
}

button {
  color: inherit;
  font: inherit;
}

.phone-shell {
  width: min(100%, 440px);
  height: min(920px, calc(100vh - 36px));
  min-height: 700px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 28px;
  overflow: hidden;
  background: #090f18;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.45);
  position: relative;
}

.loading-screen,
.app-screen {
  height: 100%;
}

.loading-screen {
  display: grid;
  grid-template-rows: 1fr auto auto;
  gap: 28px;
  padding: 34px 24px;
  background:
    linear-gradient(rgba(5, 12, 22, 0.1), rgba(5, 12, 22, 0.84)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='720' height='1120' viewBox='0 0 720 1120'%3E%3Cdefs%3E%3ClinearGradient id='g' x1='0' x2='1' y1='0' y2='1'%3E%3Cstop stop-color='%23233d5a'/%3E%3Cstop offset='.52' stop-color='%231c2833'/%3E%3Cstop offset='1' stop-color='%23070d15'/%3E%3C/linearGradient%3E%3C/defs%3E%3Crect width='720' height='1120' fill='url(%23g)'/%3E%3Cpath d='M82 746 304 188l206 332 126-98v466H82z' fill='%23101a27'/%3E%3Cpath d='M172 804 358 336l158 270 78-62v260H172z' fill='%23274254'/%3E%3Cpath d='M360 254 462 610h-62l36 130-150-224h76l-76-262h74z' fill='%23f6c85f' opacity='.9'/%3E%3Cpath d='M154 922h410' stroke='%2368c8ff' stroke-width='10' opacity='.55'/%3E%3Cpath d='M96 982h532' stroke='%23ff9f58' stroke-width='8' opacity='.45'/%3E%3C/svg%3E") center / cover;
}

.brand-mark {
  align-self: end;
  width: 132px;
  aspect-ratio: 1;
  border-radius: 26px;
  background: linear-gradient(145deg, #f6c85f, #ff8c4f 52%, #68c8ff);
  display: grid;
  place-items: center;
  box-shadow: 0 20px 44px rgba(0, 0, 0, 0.38);
}

.brand-mark span {
  width: 74px;
  aspect-ratio: 1;
  clip-path: polygon(50% 0, 70% 35%, 100% 46%, 74% 66%, 79% 100%, 50% 82%, 21% 100%, 26% 66%, 0 46%, 30% 35%);
  background: #101820;
}

.loading-copy p,
.eyebrow {
  margin: 0 0 5px;
  color: var(--gold);
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0;
  font-weight: 800;
}

.loading-copy h1 {
  margin: 0;
  font-size: clamp(2.1rem, 12vw, 3.45rem);
  line-height: 0.96;
}

.loading-track {
  height: 12px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 999px;
  overflow: hidden;
}

.loading-bar {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--green), var(--gold), var(--orange));
  border-radius: inherit;
  transition: width 90ms linear;
}

.app-screen {
  display: grid;
  grid-template-rows: auto 1fr auto;
  background:
    linear-gradient(180deg, rgba(14, 25, 39, 0.92), rgba(9, 15, 24, 0.98)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='440' height='780' viewBox='0 0 440 780'%3E%3Crect width='440' height='780' fill='%23080e17'/%3E%3Cpath d='M0 96h440M0 215h440M0 334h440M0 453h440M0 572h440M0 691h440' stroke='%23ffffff' stroke-opacity='.035'/%3E%3Cpath d='M74 0v780M186 0v780M298 0v780M410 0v780' stroke='%23ffffff' stroke-opacity='.03'/%3E%3Cpath d='M-20 640 110 500l98 54 74-128 178 196v158H-20z' fill='%2314252e' opacity='.72'/%3E%3C/svg%3E") center / cover;
}

.is-hidden {
  display: none !important;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 22px 18px 12px;
}

.topbar h1 {
  margin: 0;
  font-size: 1.65rem;
}

.resource-strip {
  display: grid;
  gap: 6px;
  justify-items: end;
  font-size: 0.74rem;
  color: var(--muted);
}

.resource-strip span {
  white-space: nowrap;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
}

.resource-strip b {
  color: var(--ink);
}

.view {
  min-height: 0;
  overflow: auto;
  padding: 0 14px 12px;
}

.battle-hero {
  display: grid;
  gap: 12px;
}

.campaign-card,
.panel,
.closed-panel,
.stage-card,
.hero-card,
.result-banner {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
}

.campaign-card {
  padding: 16px;
  min-height: 146px;
  background:
    linear-gradient(135deg, rgba(246, 200, 95, 0.18), rgba(104, 200, 255, 0.1)),
    var(--panel);
}

.campaign-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 0.8rem;
}

.campaign-card h2 {
  margin: 12px 0 8px;
  font-size: 1.35rem;
}

.campaign-card p {
  margin: 0;
  color: #dbe6f5;
  line-height: 1.4;
}

.action-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.primary-button,
.secondary-button,
.small-button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
}

.primary-button {
  background: linear-gradient(135deg, var(--gold), var(--orange));
  color: #17110a;
}

.secondary-button,
.small-button {
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
  border: 1px solid var(--line);
}

.small-button {
  min-height: 34px;
  padding: 0 10px;
  font-size: 0.8rem;
}

.small-button:disabled {
  color: #6d7d91;
  cursor: default;
}

.battlefield {
  display: grid;
  grid-template-columns: 1fr 36px 1fr;
  align-items: stretch;
  gap: 8px;
  min-height: 250px;
}

.team-column {
  display: grid;
  gap: 8px;
}

.fighter {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 8px;
  align-items: center;
  min-height: 58px;
  padding: 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.fighter.is-fainted {
  opacity: 0.42;
  filter: grayscale(1);
}

.portrait {
  width: 42px;
  aspect-ratio: 1;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: #07111f;
  font-size: 1.25rem;
  font-weight: 900;
}

.fighter-name {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 800;
}

.level-pill {
  color: var(--gold);
  font-size: 0.7rem;
  white-space: nowrap;
}

.hp-track {
  height: 7px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.35);
  overflow: hidden;
  margin-top: 7px;
}

.hp-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--green), #c8f26b);
  border-radius: inherit;
}

.versus {
  display: grid;
  place-items: center;
  color: var(--gold);
  font-weight: 900;
}

.combat-log {
  max-height: 132px;
  overflow: auto;
  padding: 10px;
  color: #d7e2f2;
  font-size: 0.78rem;
  line-height: 1.45;
}

.combat-log p {
  margin: 0 0 6px;
}

.result-banner {
  padding: 12px;
  display: grid;
  gap: 5px;
}

.result-banner strong {
  color: var(--gold);
}

.hero-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.hero-card {
  padding: 10px;
  display: grid;
  gap: 10px;
  min-height: 214px;
}

.hero-art {
  position: relative;
  min-height: 96px;
  border-radius: 8px;
  overflow: hidden;
  background: linear-gradient(135deg, var(--hero-a), var(--hero-b));
}

.hero-art::before {
  content: "";
  position: absolute;
  inset: 22px auto auto 50%;
  width: 58px;
  aspect-ratio: 1;
  transform: translateX(-50%) rotate(45deg);
  background: rgba(255, 255, 255, 0.76);
  clip-path: polygon(50% 0, 100% 42%, 78% 100%, 22% 100%, 0 42%);
}

.hero-art::after {
  content: attr(data-initial);
  position: absolute;
  inset: auto 0 15px;
  text-align: center;
  color: rgba(7, 17, 31, 0.95);
  font-size: 2.1rem;
  font-weight: 950;
}

.hero-card h3 {
  margin: 0;
  font-size: 1rem;
}

.hero-card p,
.stat-line,
.stage-card p,
.closed-panel p {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.stat-line {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.rarity {
  color: var(--gold);
  font-size: 0.75rem;
  font-weight: 800;
}

.formation-list {
  display: grid;
  gap: 8px;
}

.formation-row {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06);
}

.stage-list {
  display: grid;
  gap: 10px;
}

.stage-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 12px;
}

.stage-card h3 {
  margin: 0 0 4px;
  font-size: 0.98rem;
}

.stage-card.is-locked {
  opacity: 0.52;
}

.closed-panel {
  min-height: 420px;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 22px;
}

.closed-panel h2 {
  margin: 10px 0 8px;
}

.lock-icon {
  width: 74px;
  aspect-ratio: 1;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #334155, #111827);
  border: 1px solid var(--line);
}

.lock-icon svg {
  width: 40px;
  fill: var(--gold);
}

.bottom-nav {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 3px;
  padding: 8px 9px 12px;
  background: rgba(7, 10, 16, 0.92);
  border-top: 1px solid var(--line);
}

.nav-button {
  min-width: 0;
  height: 58px;
  display: grid;
  place-items: center;
  gap: 3px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #8fa3bc;
  cursor: pointer;
  font-size: 0.67rem;
  font-weight: 800;
}

.nav-button svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.nav-button.is-active {
  color: #15120b;
  background: linear-gradient(135deg, var(--gold), #ffb162);
}

@media (max-width: 390px) {
  body {
    padding: 0;
  }

  .phone-shell {
    width: 100%;
    height: 100vh;
    min-height: 620px;
    border-radius: 0;
    border: 0;
  }

  .topbar {
    padding-inline: 12px;
  }

  .hero-grid {
    gap: 8px;
  }

  .hero-card {
    min-height: 204px;
  }
}
