:root {
  --bg: #0b0e14;
  --panel: #141923;
  --panel-2: #1b2230;
  --border: #2b3548;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --p1: #c060c8;
  --p2: #4cc850;
  --hp: #ef4444;
  --stam: #f59e0b;
  --accent: #38bdf8;
  --gold: #fbbf24;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: radial-gradient(circle at top, #171d2b 0%, var(--bg) 70%);
  color: var(--text);
  min-height: 100vh;
}

.app-shell {
  max-width: 1400px;
  margin: 0 auto;
  padding: 14px 18px 24px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand h1 {
  margin: 0;
  font-size: 1.25rem;
  letter-spacing: 0.5px;
}

.brand h1 small {
  font-weight: 400;
  font-size: 0.85rem;
  color: var(--muted);
  margin-left: 6px;
}

.badge-round {
  background: linear-gradient(135deg, #c060c8, #7c3aed);
  padding: 5px 12px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.82rem;
  letter-spacing: 0.6px;
}

.topbar-actions {
  display: flex;
  gap: 8px;
}

.btn-pill {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 7px 13px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.85rem;
  transition: transform 0.1s, border-color 0.15s;
}

.btn-pill:hover { border-color: var(--accent); transform: translateY(-1px); }
.btn-pill.danger:hover { border-color: var(--hp); color: #fca5a5; }

.arena-grid {
  display: grid;
  grid-template-columns: 275px 1fr 275px;
  gap: 14px;
  align-items: start;
}

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

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.fighter-tag {
  font-weight: 800;
  font-size: 0.9rem;
  padding: 4px 10px;
  border-radius: 8px;
  letter-spacing: 0.5px;
}

.fighter-tag.p1 { background: rgba(192, 96, 200, 0.2); color: #e879f9; border: 1px solid rgba(192, 96, 200, 0.4); }
.fighter-tag.p2 { background: rgba(76, 200, 80, 0.18); color: #4ade80; border: 1px solid rgba(76, 200, 80, 0.4); }

.round-num, .enemy-style {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 600;
}

.bars { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.bar-label { display: flex; justify-content: space-between; font-size: 0.82rem; font-weight: 600; margin-bottom: 4px; }
.bar-track { height: 12px; background: #0b0e14; border-radius: 999px; overflow: hidden; border: 1px solid var(--border); }
.bar-fill { height: 100%; width: 100%; transition: width 0.3s ease; }
.bar-fill.hp { background: linear-gradient(90deg, #dc2626, #f87171); }
.bar-fill.hp.enemy { background: linear-gradient(90deg, #e11d48, #fb7185); }
.bar-fill.stam { background: linear-gradient(90deg, #d97706, #fbbf24); }

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}

.stat-box {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-icon { font-size: 0.95rem; }
.stat-name { font-size: 0.72rem; color: var(--muted); }
.stat-box strong { font-size: 1.05rem; color: var(--text); }

.items-section h3, .log-section h3 {
  margin: 0 0 8px;
  font-size: 0.85rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.items-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 220px;
  overflow-y: auto;
}

.item-chip {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--gold);
  border-radius: 8px;
  padding: 7px 9px;
  font-size: 0.78rem;
}

.item-chip strong { display: block; color: var(--gold); margin-bottom: 2px; }
.empty-hint { font-size: 0.8rem; color: var(--muted); font-style: italic; }

.center-stage {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.canvas-wrap {
  position: relative;
  background: #0d1017;
  border: 2px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 12px 30px rgba(0,0,0,0.45);
}

#ring-canvas {
  display: block;
  width: 100%;
  height: auto;
}

.clash-banner {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(11, 14, 20, 0.88);
  border: 1px solid var(--gold);
  color: var(--gold);
  padding: 5px 16px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 0.9rem;
  letter-spacing: 1px;
}

.clash-banner.hidden { display: none; }

.status-pills {
  position: absolute;
  bottom: 10px;
  left: 12px;
  right: 12px;
  display: flex;
  justify-content: space-between;
  pointer-events: none;
  font-size: 0.78rem;
  font-weight: 700;
}

.timeline-card, .actions-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
}

.timeline-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.row-label {
  width: 130px;
  font-size: 0.8rem;
  font-weight: 700;
  flex-shrink: 0;
}

.p1-label { color: #e879f9; }
.p2-label { color: #4ade80; }

.timeline-vs {
  text-align: center;
  font-size: 0.72rem;
  color: var(--muted);
  margin: 6px 0;
  letter-spacing: 0.6px;
}

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

.slot-box {
  min-width: 96px;
  height: 46px;
  border-radius: 10px;
  border: 1px dashed var(--border);
  background: #0e131d;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 0.76rem;
  padding: 4px 8px;
  transition: transform 0.15s, border-color 0.15s, background 0.15s;
}

.slot-box.filled {
  border-style: solid;
  border-color: var(--p1);
  background: rgba(192, 96, 200, 0.14);
  cursor: pointer;
}

.slot-box.enemy-filled {
  border-style: solid;
  border-color: rgba(76, 200, 80, 0.5);
  background: rgba(76, 200, 80, 0.1);
}

.slot-box.active-clash {
  transform: scale(1.07);
  border-color: var(--gold);
  box-shadow: 0 0 12px rgba(251, 191, 36, 0.45);
}

.slot-box small { font-size: 0.65rem; color: var(--muted); }

.actions-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-size: 0.85rem;
  flex-wrap: wrap;
  gap: 8px;
}

.queue-controls { display: flex; gap: 8px; }

.btn-small {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 12px;
  cursor: pointer;
  font-weight: 600;
}

.btn-fight {
  background: linear-gradient(135deg, #ef4444, #c060c8);
  color: white;
  border: none;
  border-radius: 10px;
  padding: 9px 18px;
  font-weight: 800;
  font-size: 0.9rem;
  cursor: pointer;
  letter-spacing: 0.5px;
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.35);
}

.btn-fight:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}

.moves-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
  gap: 8px;
}

.move-btn {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 10px;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: transform 0.1s, border-color 0.15s;
}

.move-btn:hover:not(:disabled) {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.move-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.move-top { display: flex; justify-content: space-between; font-weight: 800; font-size: 0.85rem; margin-bottom: 3px; }
.move-cost { color: var(--stam); font-size: 0.78rem; }
.move-desc { font-size: 0.72rem; color: var(--muted); line-height: 1.25; }

.combat-log {
  background: #0b0e14;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  height: 290px;
  overflow-y: auto;
  font-size: 0.78rem;
  line-height: 1.45;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.log-entry { padding-bottom: 5px; border-bottom: 1px solid rgba(255,255,255,0.05); }
.log-entry.good { color: #86efac; }
.log-entry.bad { color: #fca5a5; }
.log-entry.info { color: #93c5fd; }
.log-entry.gold { color: #fde047; font-weight: 600; }

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 7, 12, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 50;
}

.modal-backdrop.hidden { display: none; }

.modal-card {
  background: var(--panel);
  border: 2px solid var(--border);
  border-radius: 16px;
  max-width: 720px;
  width: 100%;
  padding: 22px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.65);
}

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

.draft-card {
  background: var(--panel-2);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s;
}

.draft-card:hover {
  border-color: var(--gold);
  transform: translateY(-3px);
}

.draft-card h4 { margin: 0 0 6px; color: var(--gold); font-size: 1rem; }
.draft-card p { margin: 0; font-size: 0.82rem; color: var(--text); line-height: 1.35; }

@media (max-width: 1060px) {
  .arena-grid { grid-template-columns: 1fr; }
  .draft-grid { grid-template-columns: 1fr; }
}
