:root {
  color-scheme: dark;
  --bg: #1e1e1e;
  --panel: #292929;
  --panel-alt: #242424;
  --panel-border: rgba(255, 255, 255, 0.08);
  --text: #f3f0f5;
  --muted: #b7afbc;
  --accent: #6e1d7a;
  --accent-strong: #9626a7;
  --accent-soft: rgba(110, 29, 122, 0.22);
  --success: #3bb273;
  --danger: #f25f5c;
  --shadow: 0 28px 64px rgba(0, 0, 0, 0.35);
  --header-height: 88px;
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --max-width: 1400px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(110, 29, 122, 0.3), transparent 28%),
    radial-gradient(circle at top right, rgba(150, 38, 167, 0.14), transparent 22%),
    linear-gradient(180deg, #212121, var(--bg));
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  border-radius: 999px;
  padding: 14px 20px;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  transition: transform 160ms ease, opacity 160ms ease, box-shadow 160ms ease;
  box-shadow: 0 16px 32px rgba(110, 29, 122, 0.28);
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  box-shadow: none;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid rgba(150, 38, 167, 0.9);
  outline-offset: 2px;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  min-height: var(--header-height);
  backdrop-filter: blur(16px);
  background: rgba(24, 24, 24, 0.92);
  border-bottom: 1px solid var(--panel-border);
}

.header-inner {
  width: min(calc(100% - 32px), var(--max-width));
  min-height: var(--header-height);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.eyebrow,
.step {
  margin: 0 0 10px;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #d4addb;
}

.header-inner h1,
.panel-heading h2 {
  margin: 0;
}

.header-copy {
  max-width: 56ch;
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.header-actions {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.language-toggle {
  flex: 0 0 auto;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: none;
}

.page-shell {
  width: min(calc(100% - 32px), var(--max-width));
  margin: 24px auto 40px;
  display: grid;
  gap: 20px;
}

.stepper {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.stepper__item {
  border-radius: var(--radius-md);
  padding: 16px 18px;
  text-align: left;
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  border: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: none;
}

.stepper__item.is-active {
  background: linear-gradient(135deg, rgba(110, 29, 122, 0.5), rgba(150, 38, 167, 0.85));
  color: #fff;
}

.stepper__item.is-complete {
  background: rgba(59, 178, 115, 0.16);
  color: #d5f8e5;
}

.stepper__item.is-locked {
  opacity: 0.55;
}

.is-hidden {
  display: none;
}

.panel {
  background: linear-gradient(180deg, var(--panel), var(--panel-alt));
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow);
}

.panel-copy {
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

.upload-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 16px;
  margin-top: 24px;
}

.upload-field,
.textarea-field {
  display: block;
}

.upload-field {
  padding: 18px;
  border-radius: var(--radius-md);
  border: 1px dashed rgba(212, 173, 219, 0.34);
  background: rgba(255, 255, 255, 0.02);
}

.upload-field input {
  width: 100%;
  margin-top: 12px;
  color: var(--muted);
}

.upload-field__title,
.textarea-field__title {
  display: block;
  font-weight: 700;
}

.upload-field__hint {
  display: block;
  margin-top: 10px;
  color: var(--muted);
  line-height: 1.6;
}

.file-summary {
  padding: 18px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.file-summary__title {
  margin: 0 0 10px;
  font-weight: 700;
}

.file-summary__body {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

textarea {
  width: 100%;
  min-height: 280px;
  margin-top: 12px;
  padding: 18px;
  resize: vertical;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(9, 9, 9, 0.34);
  color: var(--text);
  line-height: 1.7;
}

.action-row {
  margin-top: 22px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.status-inline {
  min-height: 24px;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.status-inline[data-state="loading"]::before {
  content: "";
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.24);
  border-top-color: #fff;
  animation: spin 0.8s linear infinite;
}

.empty-state {
  min-height: 160px;
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
  border-radius: var(--radius-md);
  border: 1px dashed rgba(255, 255, 255, 0.09);
  background: rgba(255, 255, 255, 0.025);
  color: var(--muted);
}

.character-list,
.stats-grid,
.battle-selection {
  margin-top: 24px;
}

.character-cards,
.battle-cards {
  display: grid;
  gap: 14px;
}

.character-card,
.fighter-card {
  display: grid;
  gap: 10px;
  padding: 18px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(255, 255, 255, 0.03);
}

.character-card label,
.fighter-card label {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  cursor: pointer;
}

.character-card input,
.fighter-card input {
  margin-top: 5px;
}

.character-card__name,
.fighter-card__name,
.stat-card__name {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
}

.character-card__summary,
.fighter-card__meta,
.stat-card__summary,
.battle-summary p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag {
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: #efd7f3;
  font-size: 0.84rem;
}

.stat-cards {
  display: grid;
  gap: 16px;
}

.stat-card {
  display: grid;
  gap: 18px;
  padding: 20px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(255, 255, 255, 0.03);
}

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

.metric {
  display: grid;
  gap: 8px;
}

.metric__header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.95rem;
}

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

.metric__value {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #c46cda);
}

.special-move {
  padding: 14px;
  border-radius: var(--radius-sm);
  background: rgba(110, 29, 122, 0.14);
  border: 1px solid rgba(196, 108, 218, 0.14);
}

.special-move strong {
  display: block;
  margin-bottom: 8px;
}

.battle-summary {
  min-height: 82px;
  margin-top: 18px;
  padding: 18px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(255, 255, 255, 0.03);
}

.battle-log {
  margin: 18px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 14px;
}

.battle-log__item {
  padding: 18px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(255, 255, 255, 0.025);
}

.battle-log__item strong {
  display: inline-block;
  margin-bottom: 8px;
}

.battle-log__emotion {
  color: #d4addb;
  font-weight: 600;
}

.site-footer {
  width: min(calc(100% - 32px), var(--max-width));
  margin: 0 auto;
  padding: 8px 0 32px;
  color: var(--muted);
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 24px;
  max-width: min(420px, calc(100% - 32px));
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: rgba(242, 95, 92, 0.95);
  color: #fff;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 160ms ease, transform 160ms ease;
}

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

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 1080px) {
  .header-inner {
    padding: 16px 0;
    flex-direction: column;
    align-items: flex-start;
  }

  .header-actions {
    width: 100%;
    flex-direction: column;
  }

  .site-header {
    position: relative;
  }
}

@media (max-width: 768px) {
  :root {
    --header-height: auto;
  }

  .page-shell,
  .site-footer {
    width: min(calc(100% - 24px), var(--max-width));
  }

  .panel {
    padding: 22px 18px;
  }

  .upload-grid,
  .metrics-grid {
    grid-template-columns: 1fr;
  }

  .stepper {
    grid-template-columns: 1fr;
  }

  .toast {
    right: 12px;
    left: 12px;
    max-width: none;
  }
}
