/* =========================================================
   Beat Battle — reskinned to match KOTT's purple/gold theme
   (style.css). Scoped to .battle-root so it doesn't leak
   into the rest of the app. Class names are unchanged from
   the original port, only the look changed.
   ========================================================= */

.battle-root {
  /* Reuse the site palette from style.css :root */
  --bb-gold:       var(--gold);
  --bb-gold-dim:   var(--gold-dim);
  --bb-purple:     var(--purple);
  --bb-red:        var(--red);
  --bb-green:      var(--green);
  --bb-text:       var(--text);
  --bb-muted:      var(--muted);
  --bb-border:     var(--border);
  --bb-card:       var(--bg-2);
  --bb-card-hi:    var(--bg-3);

  color: var(--bb-text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  min-height: 100vh;
}

/* ── Layout utilities (replace the Tailwind helpers the
      original React pages used) ─────────────────────────── */
.battle-root .bb-wrap   { max-width: 56rem; margin: 0 auto; padding: 24px 16px 48px; }
.battle-root .bb-wrap-lg{ max-width: 64rem; margin: 0 auto; padding: 24px 16px 48px; }
.battle-root .bb-row    { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.battle-root .bb-between{ display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.battle-root .bb-col    { display: flex; flex-direction: column; gap: 12px; }
.battle-root .bb-space  > * + * { margin-top: 12px; }
.battle-root .bb-space-lg > * + * { margin-top: 24px; }
.battle-root .bb-grid2  { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.battle-root .bb-grid3  { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.battle-root .bb-grid4  { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.battle-root .bb-gridauto { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
@media (max-width: 700px) {
  .battle-root .bb-grid2, .battle-root .bb-grid3, .battle-root .bb-grid4 { grid-template-columns: 1fr; }
}
@media (max-width: 900px) and (min-width: 701px) {
  .battle-root .bb-grid4 { grid-template-columns: repeat(2, 1fr); }
}
.battle-root .bb-muted  { color: var(--bb-muted); }
.battle-root .bb-mono   { font-family: monospace; }
.battle-root .bb-sm     { font-size: 0.85rem; }
.battle-root .bb-xs     { font-size: 0.7rem; }
.battle-root .bb-center { text-align: center; }
.battle-root .bb-bold   { font-weight: 700; }
.battle-root .bb-mt     { margin-top: 12px; }
.battle-root .bb-mb     { margin-bottom: 12px; }
.battle-root .bb-mt-lg  { margin-top: 24px; }
.battle-root .bb-mb-lg  { margin-bottom: 24px; }
.battle-root .bb-full   { width: 100%; }
.battle-root .bb-auto   { margin-left: auto; }
.battle-root .bb-green  { color: var(--bb-green); }
.battle-root .bb-red    { color: var(--bb-red); }
.battle-root .bb-scroll-x { overflow-x: auto; }
.battle-root .bb-locked-card { opacity: 0.5; }
.battle-root .bb-elosec { font-family: monospace; color: var(--bb-gold); }
.battle-root a.bb-link  { color: var(--bb-purple); }
.battle-root a.bb-link:hover { color: var(--bb-gold); }

/* ── Main title — matches .title in style.css ────────────── */
.battle-root .arcade-title {
  font-family: Georgia, 'Times New Roman', serif;
  font-weight: 700;
  font-size: clamp(28px, 5vw, 52px);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-align: center;
  color: var(--bb-gold);
  text-shadow: 0 0 30px rgba(232, 185, 73, 0.35);
  position: relative;
}
/* Gold underline accent */
.battle-root .arcade-title::after {
  content: '';
  display: block;
  margin: 8px auto 0;
  width: 60%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--bb-gold), transparent);
  opacity: 0.7;
}

/* ── Section headings ────────────────────────────────────── */
.battle-root .arcade-heading {
  font-family: Georgia, 'Times New Roman', serif;
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--bb-gold);
  position: relative;
  padding-left: 12px;
}
.battle-root .arcade-heading::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 100%;
  border-radius: 2px;
  background: var(--bb-gold);
  box-shadow: 0 0 8px rgba(232, 185, 73, 0.4);
}

/* ── Labels — like .section-label / .subtitle ────────────── */
.battle-root .arcade-label {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  color: var(--bb-muted);
  text-transform: uppercase;
}

/* ── Panels — match .card / .song-card ───────────────────── */
.battle-root .panel {
  background: rgba(31, 25, 48, 0.75);
  border: 1px solid var(--bb-border);
  border-radius: 14px;
  padding: 24px;
  position: relative;
}

.battle-root .panel-tight {
  background: var(--bb-card);
  border: 1px solid var(--bb-border);
  border-radius: 10px;
  padding: 14px;
}
button.panel-tight, a.panel-tight {
  display: block;
  width: 100%;
  text-align: left;
  color: var(--bb-text);
  text-decoration: none;
}
button.panel-tight:hover:not(:disabled), a.panel-tight:hover {
  border-color: var(--bb-gold);
  box-shadow: 0 0 16px rgba(232, 185, 73, 0.12);
}

/* ── Buttons — match style.css button / button.primary ───── */
.battle-root .btn {
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  padding: 10px 18px;
  border: 1px solid var(--bb-border);
  border-radius: 8px;
  background: var(--bb-card-hi);
  cursor: pointer;
  transition: all 0.15s ease;
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  color: var(--bb-text);
}
.battle-root .btn:hover:not(:disabled) {
  border-color: var(--bb-gold);
  color: var(--bb-gold);
}
.battle-root .btn:disabled { opacity: 0.4; cursor: not-allowed; }

.battle-root .btn-primary {
  background: var(--bb-gold);
  border-color: var(--bb-gold);
  color: #1a1408;
  font-weight: 700;
}
.battle-root .btn-primary:hover:not(:disabled) {
  filter: brightness(1.1);
  color: #1a1408;
}
.battle-root .btn-primary:active:not(:disabled) {
  transform: scale(0.98);
}

.battle-root .btn-secondary:hover:not(:disabled) {
  box-shadow: 0 0 12px rgba(232, 185, 73, 0.15);
}
.battle-root .btn-secondary:active:not(:disabled) {
  transform: scale(0.98);
}

.battle-root .btn-locked {
  opacity: 0.35;
  cursor: not-allowed;
  filter: grayscale(0.6);
}

/* ── Input fields — match style.css input/select ─────────── */
.battle-root .input-field {
  background: var(--bb-card);
  border: 1px solid var(--bb-border);
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--bb-text);
  font-family: inherit;
  font-size: 0.9rem;
  width: 100%;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.battle-root .input-field:focus {
  border-color: var(--bb-gold);
  box-shadow: 0 0 0 2px rgba(232, 185, 73, 0.15);
}
.battle-root input[type="range"] { accent-color: var(--bb-gold); }
.battle-root input[type="checkbox"] { accent-color: var(--bb-gold); width: auto; }
.battle-root input[type="file"] { color: var(--bb-muted); }

/* ── Status / misc ───────────────────────────────────────── */
.battle-root .status-msg {
  color: var(--bb-red);
  font-size: 0.8rem;
  letter-spacing: 0.05em;
  min-height: 1.2em;
}

.battle-root .corner-btn {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.15em;
  padding: 6px 14px;
  border: 1px solid var(--bb-border);
  border-radius: 999px;
  background: transparent;
  color: var(--bb-muted);
  cursor: pointer;
  text-transform: uppercase;
  text-decoration: none;
  transition: all 0.15s;
}
.battle-root .corner-btn:hover {
  border-color: var(--bb-gold-dim);
  color: var(--bb-gold);
}

/* ── Pill badges — match .phase-badge ────────────────────── */
.battle-root .pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 14px;
  border-radius: 999px;
  background: var(--bb-purple);
  border: 1px solid var(--bb-purple);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* ── Slot cards — match .defender-chip ───────────────────── */
.battle-root .slot-card {
  background: var(--bb-card);
  border: 1px solid var(--bb-border);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
}
.battle-root .slot-card:hover {
  border-color: var(--bb-gold-dim);
  box-shadow: 0 0 12px rgba(232, 185, 73, 0.12);
  transform: translateY(-1px);
}
.battle-root .slot-locked {
  border-color: var(--bb-gold);
  background: linear-gradient(180deg, rgba(232, 185, 73, 0.12), transparent);
  box-shadow: 0 0 16px rgba(232, 185, 73, 0.2);
}

/* ── Toast ───────────────────────────────────────────────── */
.battle-root .toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--bb-card-hi);
  border: 1px solid var(--bb-gold);
  border-radius: 10px;
  padding: 12px 20px;
  color: var(--bb-text);
  font-size: 0.8rem;
  letter-spacing: 0.05em;
  box-shadow: 0 0 24px rgba(232, 185, 73, 0.3);
  z-index: 1000;
  animation: toastIn 0.25s ease-out;
}
@keyframes toastIn {
  from { transform: translateX(40px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ── Animations ──────────────────────────────────────────── */
.battle-root .fade-in {
  animation: bbFadeIn 0.4s ease-out both;
}
@keyframes bbFadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.battle-root .speed-in {
  animation: speedIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) both;
}
@keyframes speedIn {
  from { opacity: 0; transform: translateX(-20px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* Stagger children */
.battle-root .stagger > * { animation: bbFadeIn 0.35s ease-out both; }
.battle-root .stagger > *:nth-child(1) { animation-delay: 0ms; }
.battle-root .stagger > *:nth-child(2) { animation-delay: 60ms; }
.battle-root .stagger > *:nth-child(3) { animation-delay: 120ms; }
.battle-root .stagger > *:nth-child(4) { animation-delay: 180ms; }
.battle-root .stagger > *:nth-child(5) { animation-delay: 240ms; }
.battle-root .stagger > *:nth-child(6) { animation-delay: 300ms; }
.battle-root .stagger > *:nth-child(7) { animation-delay: 360ms; }
.battle-root .stagger > *:nth-child(8) { animation-delay: 420ms; }

/* Rotating border glow for player card / active battle */
.battle-root .ring-glow {
  position: relative;
}
.battle-root .ring-glow::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  background: conic-gradient(from var(--angle, 0deg),
    transparent 30%, var(--bb-gold) 50%, transparent 70%);
  animation: spinGlow 3s linear infinite;
  opacity: 0.6;
  z-index: -1;
}
@keyframes spinGlow { to { transform: rotate(360deg); } }

/* Reactive pad — flashes gold on hit */
.battle-root .pad-hit {
  animation: padFlash 0.15s ease-out;
}
@keyframes padFlash {
  0%   { box-shadow: 0 0 0   rgba(232,185,73,0); background-color: var(--bb-gold); }
  50%  { box-shadow: 0 0 20px rgba(232,185,73,0.8); }
  100% { box-shadow: 0 0 4px  rgba(232,185,73,0); }
}

/* Timer — urgent pulse when low */
.battle-root .timer-urgent {
  animation: urgentPulse 0.6s ease-in-out infinite;
  color: var(--bb-red) !important;
}
@keyframes urgentPulse {
  0%, 100% { opacity: 1; text-shadow: 0 0 8px var(--bb-red); }
  50%       { opacity: 0.7; text-shadow: 0 0 20px var(--bb-red); }
}

/* ELO delta number pop */
.battle-root .elo-up {
  animation: eloPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  color: var(--bb-green) !important;
}
.battle-root .elo-down {
  animation: eloPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  color: var(--bb-red) !important;
}
@keyframes eloPop {
  from { transform: scale(0.6) translateY(4px); opacity: 0; }
  to   { transform: scale(1)   translateY(0);   opacity: 1; }
}

/* Leaderboard rank #1 gold shimmer */
.battle-root .rank-one {
  background: linear-gradient(90deg, var(--bb-gold-dim) 0%, var(--bb-gold) 50%, var(--bb-gold-dim) 100%);
  background-size: 200%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: shimmer 2.5s linear infinite;
}
@keyframes shimmer {
  0%   { background-position: 200% center; }
  100% { background-position: -200% center; }
}

/* Spice selector active */
.battle-root .spice-active {
  background: var(--bb-gold);
  border-color: var(--bb-gold);
  color: #1a1408;
  box-shadow: 0 0 12px rgba(232, 185, 73, 0.4);
  transform: scale(1.05);
}
