:root {
  color-scheme: dark;
  --ink: #f8fbff;
  --muted: #b7c2d8;
  --panel: rgba(11, 14, 24, 0.78);
  --stroke: rgba(255, 255, 255, 0.18);
  --cyan: #40f4ff;
  --magenta: #ff3fb4;
  --gold: #ffd35a;
  --red: #ff584d;
  --green: #6cff95;
  --shadow: rgba(0, 0, 0, 0.42);
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  overflow-x: hidden;
  background:
    repeating-linear-gradient(
      118deg,
      rgba(255, 255, 255, 0.05) 0,
      rgba(255, 255, 255, 0.05) 1px,
      transparent 1px,
      transparent 28px
    ),
    linear-gradient(135deg, #070812 0%, #17101f 28%, #361522 58%, #06383e 100%);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 32px;
  position: relative;
  isolation: isolate;
}

.app-shell::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(90deg, rgba(64, 244, 255, 0.12), transparent 28%),
    linear-gradient(270deg, rgba(255, 211, 90, 0.14), transparent 34%),
    linear-gradient(180deg, transparent 0%, rgba(0, 0, 0, 0.38) 100%);
  pointer-events: none;
}

.arena {
  width: min(1160px, 100%);
  min-height: 680px;
  display: grid;
  grid-template-columns: minmax(0, 1.03fr) minmax(340px, 0.97fr);
  align-items: stretch;
  gap: 28px;
}

.copy-stack {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
  min-width: 0;
}

.kicker {
  width: fit-content;
  margin: 0;
  padding: 8px 12px;
  border: 1px solid rgba(64, 244, 255, 0.45);
  background: rgba(64, 244, 255, 0.1);
  color: var(--cyan);
  text-transform: uppercase;
  font-size: 0.8rem;
  font-weight: 800;
}

h1 {
  margin: 0;
  max-width: 720px;
  color: #ffffff;
  font-size: 4.4rem;
  line-height: 0.92;
  letter-spacing: 0;
  text-transform: uppercase;
  text-shadow:
    3px 3px 0 rgba(255, 63, 180, 0.68),
    7px 7px 0 rgba(64, 244, 255, 0.26),
    0 18px 42px var(--shadow);
}

.battle-panel,
.analysis-panel {
  border: 1px solid var(--stroke);
  background: var(--panel);
  box-shadow: 0 24px 70px var(--shadow);
  backdrop-filter: blur(16px);
}

.battle-panel {
  padding: 18px;
}

.fighters {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 64px minmax(0, 1fr);
  align-items: end;
  gap: 12px;
}

.fighter-field {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.fighter-field span {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
  text-transform: uppercase;
}

.fighter-field input {
  width: 100%;
  min-height: 56px;
  min-width: 0;
  border: 2px solid rgba(255, 255, 255, 0.24);
  border-radius: 0;
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
  padding: 0 14px;
  outline: none;
  font-size: 1.05rem;
  font-weight: 800;
  transition:
    border-color 160ms ease,
    background-color 160ms ease,
    box-shadow 160ms ease;
}

.fighter-field input:focus {
  border-color: var(--cyan);
  background: rgba(64, 244, 255, 0.12);
  box-shadow: 0 0 0 4px rgba(64, 244, 255, 0.16);
}

.locked-field input {
  color: var(--gold);
  border-color: rgba(255, 211, 90, 0.5);
  background:
    linear-gradient(135deg, rgba(255, 211, 90, 0.2), rgba(255, 88, 77, 0.12)),
    rgba(255, 255, 255, 0.06);
}

.versus-mark {
  min-height: 56px;
  display: grid;
  place-items: center;
  color: #080910;
  background: linear-gradient(135deg, var(--gold), var(--magenta));
  font-size: 1.25rem;
  font-weight: 1000;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.34);
}

#evaluate-button {
  width: 100%;
  min-height: 58px;
  margin-top: 14px;
  border: 0;
  border-radius: 0;
  background:
    linear-gradient(90deg, var(--cyan), var(--green) 48%, var(--gold)),
    var(--cyan);
  color: #080910;
  cursor: pointer;
  font-weight: 1000;
  text-transform: uppercase;
  box-shadow:
    0 16px 36px rgba(64, 244, 255, 0.22),
    inset 0 -4px 0 rgba(0, 0, 0, 0.18);
  transition:
    transform 160ms ease,
    filter 160ms ease,
    box-shadow 160ms ease;
}

#evaluate-button:hover {
  transform: translateY(-2px);
  filter: saturate(1.18);
  box-shadow:
    0 22px 44px rgba(255, 211, 90, 0.18),
    inset 0 -4px 0 rgba(0, 0, 0, 0.18);
}

#evaluate-button:disabled {
  cursor: wait;
  transform: none;
  filter: grayscale(0.2) brightness(0.74);
}

.analysis-panel {
  min-height: 258px;
  padding: 18px;
  display: grid;
  align-content: start;
  gap: 14px;
}

.status-line {
  min-height: 36px;
  display: flex;
  align-items: center;
  border-left: 4px solid var(--magenta);
  padding-left: 12px;
  color: var(--gold);
  font-weight: 900;
  line-height: 1.25;
  text-transform: uppercase;
}

.comparison-log {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 24px;
  color: var(--muted);
}

.comparison-log li {
  min-height: 24px;
  padding-left: 4px;
  line-height: 1.42;
  word-break: break-word;
}

.comparison-log li::marker {
  color: var(--cyan);
  font-weight: 900;
}

.result-card {
  display: grid;
  gap: 12px;
  margin-top: 4px;
  border-top: 1px solid rgba(255, 255, 255, 0.16);
  padding-top: 16px;
  animation: result-pop 360ms ease both;
}

.result-label,
.opponent-line {
  margin: 0;
  color: var(--muted);
  font-weight: 800;
}

.result-card h2 {
  margin: 0;
  color: var(--green);
  font-size: 2.35rem;
  line-height: 1;
  letter-spacing: 0;
  text-transform: uppercase;
  text-shadow: 3px 3px 0 rgba(0, 0, 0, 0.34);
  word-break: break-word;
}

.probability {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 10px;
  margin: 0;
}

.probability span:first-child {
  color: var(--gold);
  font-size: 3.2rem;
  line-height: 1;
  font-weight: 1000;
}

.probability span:last-child {
  color: var(--ink);
  font-weight: 900;
  line-height: 1.2;
  text-transform: uppercase;
}

.opponent-line strong {
  color: var(--ink);
  word-break: break-word;
}

.stat-grid {
  display: grid;
  gap: 10px;
}

.stat-row {
  display: grid;
  grid-template-columns: 138px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}

.stat-row span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 850;
}

.stat-track {
  min-height: 12px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.11);
}

.stat-fill {
  display: block;
  width: var(--score);
  height: 12px;
  background: linear-gradient(90deg, var(--cyan), var(--gold));
  box-shadow: 0 0 18px rgba(64, 244, 255, 0.35);
}

.character-stage {
  position: relative;
  min-height: 680px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background:
    repeating-linear-gradient(
      160deg,
      rgba(255, 255, 255, 0.08) 0,
      rgba(255, 255, 255, 0.08) 2px,
      transparent 2px,
      transparent 26px
    ),
    linear-gradient(180deg, rgba(64, 244, 255, 0.1), rgba(255, 63, 180, 0.09)),
    rgba(7, 8, 18, 0.76);
  box-shadow: 0 24px 70px var(--shadow);
}

.character-stage::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 28%;
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.58));
  pointer-events: none;
}

.character-stage img {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  max-height: none;
  object-fit: cover;
  object-position: center center;
  filter:
    drop-shadow(0 32px 34px rgba(0, 0, 0, 0.54))
    saturate(1.08)
    contrast(1.04);
}

.duel-badge {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 18px;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(4, 6, 12, 0.74);
  backdrop-filter: blur(12px);
}

.duel-badge span,
.duel-badge strong {
  text-transform: uppercase;
}

.duel-badge span {
  color: var(--gold);
  font-weight: 1000;
  font-size: 1.18rem;
}

.duel-badge strong {
  color: var(--cyan);
  font-size: 0.86rem;
}

.is-loading .status-line::after {
  content: "";
  width: 10px;
  height: 10px;
  margin-left: 12px;
  background: var(--gold);
  animation: blink 700ms steps(2, end) infinite;
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

@keyframes result-pop {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 1ms !important;
  }
}

@media (max-width: 920px) {
  .app-shell {
    padding: 18px;
    place-items: start center;
  }

  .arena {
    min-height: auto;
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 3.2rem;
  }

  .character-stage {
    order: -1;
    min-height: 0;
    aspect-ratio: 4 / 3;
  }
}

@media (max-width: 640px) {
  .app-shell {
    padding: 12px;
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }

  .copy-stack {
    gap: 14px;
  }

  .kicker {
    max-width: 100%;
    line-height: 1.2;
  }

  h1 {
    font-size: 2.42rem;
    line-height: 0.98;
  }

  .battle-panel,
  .analysis-panel {
    padding: 14px;
  }

  .fighters {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .fighter-field input {
    min-height: 52px;
    font-size: 1rem;
  }

  .versus-mark {
    min-height: 42px;
  }

  #evaluate-button {
    min-height: 54px;
  }

  .analysis-panel {
    min-height: 0;
  }

  .comparison-log {
    padding-left: 20px;
  }

  .result-card h2 {
    font-size: 1.85rem;
  }

  .probability span:first-child {
    font-size: 2.35rem;
  }

  .stat-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .duel-badge {
    align-items: flex-start;
    flex-direction: column;
    left: 12px;
    right: 12px;
    bottom: 12px;
    gap: 4px;
    padding: 10px 12px;
  }

  .duel-badge span {
    font-size: 1rem;
  }
}

@media (max-width: 380px) {
  h1 {
    font-size: 2.05rem;
  }

  .probability span:first-child {
    font-size: 2rem;
  }
}
