:root {
  --bg: #0b0d12;
  --panel: #151922;
  --panel-2: #1c2230;
  --line: #2b3345;
  --text: #e8ecf4;
  --muted: #93a0b8;
  --gold: #f2b544;
  --red: #ef5f5f;
  --green: #4cc38a;
  --blue: #5aa9f7;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: radial-gradient(1200px 600px at 50% -10%, #1b2130 0%, var(--bg) 60%);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(11, 13, 18, 0.7);
}

.topbar h1 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.ladder {
  font-size: 13px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 12px;
}

main {
  flex: 1;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 20px 18px 30px;
}

.screen {
  width: 100%;
  max-width: 940px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.hidden {
  display: none !important;
}

.panel {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 26px 28px;
}

.panel h2 {
  margin: 0 0 8px;
  font-size: 22px;
}

.panel p {
  margin: 0 0 16px;
  color: var(--muted);
  line-height: 1.55;
}

.panel a {
  color: var(--blue);
}

input[type="text"],
input[type="password"] {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 13px 14px;
  font-size: 16px;
  outline: none;
}

input:focus {
  border-color: var(--gold);
}

button {
  font: inherit;
  cursor: pointer;
  border-radius: 10px;
  border: 1px solid transparent;
  padding: 11px 20px;
  font-size: 15px;
}

.primary {
  background: var(--gold);
  color: #1a1400;
  font-weight: 700;
  margin-top: 16px;
}

.primary:disabled {
  opacity: 0.55;
  cursor: default;
}

.ghost {
  background: transparent;
  color: var(--muted);
  border-color: var(--line);
}

.ghost:hover {
  color: var(--text);
  border-color: var(--muted);
}

.error {
  color: var(--red);
  font-size: 14px;
  margin: 10px 0 0;
}

.advanced-toggle {
  margin-top: 20px;
  font-size: 13px;
  width: 100%;
}

#keyManual {
  margin-top: 16px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

#keyManual .primary {
  margin-top: 12px;
}

.examples {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.example {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  padding: 7px 11px;
  border-radius: 999px;
}

.example:hover {
  color: var(--text);
  border-color: var(--gold);
}

/* Fighter cards */
.card {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 18px;
}

.card h3 {
  margin: 0 0 4px;
  font-size: 20px;
  color: var(--gold);
}

.card .epithet {
  color: var(--muted);
  font-style: italic;
  font-size: 14px;
  margin-bottom: 12px;
}

.card .look {
  font-size: 14px;
  line-height: 1.5;
  margin-bottom: 14px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.stat {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 6px;
  text-align: center;
}

.stat b {
  display: block;
  font-size: 18px;
}

.stat span {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  font-size: 12px;
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 999px;
  padding: 4px 9px;
}

/* Arena */
.arena {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 14px;
  align-items: stretch;
}

.fighter {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
}

.fighter h3 {
  margin: 0;
  font-size: 18px;
  color: var(--gold);
}

.fighter.enemy h3 {
  color: var(--red);
}

.fighter .epithet {
  color: var(--muted);
  font-size: 13px;
  font-style: italic;
  margin: 3px 0 12px;
}

.hpbar {
  height: 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
}

.hpfill {
  height: 100%;
  background: linear-gradient(90deg, var(--green), #8ee6b8);
  transition: width 0.4s ease;
}

.hpfill.low {
  background: linear-gradient(90deg, var(--red), #ff9a9a);
}

.hptext {
  font-size: 13px;
  color: var(--muted);
  margin-top: 6px;
}

.vs {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  min-width: 90px;
}

.vs strong {
  font-size: 26px;
  color: var(--gold);
}

.logwrap {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px 18px;
}

.log {
  min-height: 190px;
  max-height: 330px;
  overflow-y: auto;
  line-height: 1.6;
  font-size: 15px;
}

.log p {
  margin: 0 0 8px;
}

.log .round {
  color: var(--gold);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.1em;
}

.log .crit {
  color: var(--red);
}

.log .win {
  color: var(--green);
}

.controls {
  display: flex;
  gap: 10px;
  margin-top: 14px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.controls .primary {
  margin-top: 0;
}

footer {
  padding: 16px;
  display: flex;
  justify-content: center;
  opacity: 0.85;
}

footer img {
  height: 30px;
}

@media (max-width: 720px) {
  .arena {
    grid-template-columns: 1fr;
  }
  .vs {
    flex-direction: row;
  }
  .stats {
    grid-template-columns: repeat(2, 1fr);
  }
}
