:root {
  --bg: #060914;
  --panel: rgba(13, 20, 39, .92);
  --panel2: rgba(18, 29, 56, .9);
  --text: #eef6ff;
  --muted: #a9b8d4;
  --line: rgba(255,255,255,.12);
  --accent: #66e3ff;
  --accent2: #ff4f88;
  --good: #8dffb5;
  --warn: #ffd36e;
  --shadow: 0 20px 70px rgba(0,0,0,.45);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 20% 0%, rgba(102,227,255,.15), transparent 34%),
    radial-gradient(circle at 85% 10%, rgba(255,79,136,.16), transparent 32%),
    linear-gradient(180deg, #080d1d, var(--bg));
  min-height: 100vh;
}

.topbar {
  max-width: 1480px;
  margin: 0 auto;
  padding: 28px 18px 16px;
  display: flex;
  gap: 18px;
  align-items: flex-start;
}

.backlink {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 150px;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  text-decoration: none;
  background: rgba(255,255,255,.06);
}

.backlink:hover {
  border-color: var(--accent);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: .12em;
  font-size: 12px;
  font-weight: 700;
}

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

h1 {
  margin-bottom: 8px;
  font-size: clamp(36px, 6vw, 76px);
  line-height: .92;
}

.subtitle {
  max-width: 850px;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.5;
}

.layout {
  max-width: 1480px;
  margin: 0 auto;
  padding: 16px 18px 22px;
  display: grid;
  grid-template-columns: 310px minmax(420px, 1fr) 330px;
  gap: 18px;
}

.panel, .arena-panel, .info {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 18px;
}

.panel h2 {
  margin-bottom: 18px;
}

label {
  display: block;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

select, input[type="range"] {
  width: 100%;
  margin-top: 7px;
}

select {
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 13px;
  background: #0a1022;
  color: var(--text);
  outline: none;
}

select:focus {
  border-color: var(--accent);
}

input[type="range"] {
  accent-color: var(--accent);
}

.blade-card {
  margin-top: 18px;
  padding: 14px;
  border-radius: 18px;
  background: var(--panel2);
  border: 1px solid var(--line);
}

.blade-card h3 {
  font-size: 15px;
  line-height: 1.4;
  color: var(--text);
}

.stats {
  display: grid;
  gap: 9px;
}

.stat {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(255,255,255,.055);
  font-size: 12px;
}

.stat span, .stat b {
  position: relative;
  z-index: 2;
}

.stat i {
  position: absolute;
  inset: 0 auto 0 0;
  background: linear-gradient(90deg, rgba(102,227,255,.28), rgba(255,79,136,.18));
  z-index: 1;
}

.progress-box {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.progress-box div {
  border: 1px solid var(--line);
  background: rgba(255,255,255,.045);
  border-radius: 16px;
  padding: 12px;
}

.progress-box span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.progress-box b {
  font-size: 24px;
}

.arena-panel {
  padding: 16px;
}

.battle-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  margin-bottom: 12px;
}

.battle-head h2 {
  margin: 0;
}

.score {
  min-width: 110px;
  text-align: center;
  padding: 10px 14px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.06);
  font-size: 30px;
  font-weight: 900;
}

canvas {
  display: block;
  width: 100%;
  max-height: 68vh;
  border-radius: 22px;
  border: 1px solid rgba(102,227,255,.22);
  background: #050814;
}

.hud {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 9px;
  margin-top: 12px;
}

.hud div {
  border: 1px solid var(--line);
  background: rgba(255,255,255,.045);
  border-radius: 14px;
  padding: 10px;
}

.hud span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 5px;
}

.hud b {
  font-size: 18px;
}

.result {
  margin-top: 12px;
  padding: 13px 14px;
  border-radius: 16px;
  background: rgba(102,227,255,.09);
  border: 1px solid rgba(102,227,255,.22);
  color: var(--text);
  font-weight: 700;
}

.tactics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
  margin-top: 12px;
}

button {
  border: 0;
  border-radius: 14px;
  padding: 12px 13px;
  color: var(--text);
  background: rgba(255,255,255,.09);
  border: 1px solid var(--line);
  cursor: pointer;
  font-weight: 800;
}

button:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

button:disabled {
  opacity: .55;
  cursor: not-allowed;
  transform: none;
}

.primary {
  width: 100%;
  margin-top: 4px;
  background: linear-gradient(135deg, rgba(102,227,255,.95), rgba(255,79,136,.9));
  color: #04101d;
  border: 0;
  font-size: 16px;
}

.ghost {
  width: 100%;
  margin-top: 10px;
}

.rules, .log {
  margin-top: 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255,255,255,.045);
}

.rules p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  margin-bottom: 8px;
}

.log h3, .rules h3 {
  margin-bottom: 10px;
}

#battleLog {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

#battleLog div {
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}

.info {
  max-width: 1480px;
  margin: 0 auto 36px;
  padding: 22px;
}

.info p {
  color: var(--muted);
  line-height: 1.65;
  margin-bottom: 0;
}

@media (max-width: 1180px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .hud {
    grid-template-columns: repeat(2, 1fr);
  }

  canvas {
    max-height: none;
  }
}

@media (max-width: 680px) {
  .topbar {
    flex-direction: column;
  }

  .backlink {
    min-width: 0;
  }

  .hud, .tactics, .progress-box {
    grid-template-columns: 1fr;
  }

  .battle-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .score {
    width: 100%;
  }
}
