:root {
  --bg-lacquer: #120b08;
  --surface-wood: #1d120e;
  --surface-panel: rgba(24, 14, 10, 0.92);
  --surface-card: #261712;
  --border-bronze: rgba(245, 184, 46, 0.34);
  --border-subtle: rgba(255, 240, 210, 0.14);
  --text-ivory: #faf3e6;
  --text-muted: #c9b79c;
  --accent-gold: #f5b82e;
  --accent-vermilion: #dc2626;
  --accent-jade: #14b8a6;
  --accent-amber: #fb923c;
  --font-display: 'Bricolage Grotesque', system-ui, sans-serif;
  --font-body: 'Plus Jakarta Sans', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-lacquer);
  color: var(--text-ivory);
  font-family: var(--font-body);
  user-select: none;
  -webkit-user-select: none;
}

.hidden {
  display: none !important;
}

.tabular-nums {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

#app-shell {
  width: 100vw;
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 45%, #2b1811 0%, #120b08 75%, #090504 100%);
  overflow: hidden;
}

#stage-frame {
  position: relative;
  width: min(100vw, calc(100dvh * 16 / 9));
  height: min(100dvh, calc(100vw * 9 / 16));
  aspect-ratio: 16 / 9;
  background: #140d0a;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.85);
  overflow: hidden;
  touch-action: none;
}

#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* ================= HUD ================= */
.hud-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}

.hud-top-bar {
  position: absolute;
  top: 10px;
  left: 14px;
  right: 60px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  align-items: start;
}

.fighter-panel {
  background: rgba(18, 10, 8, 0.82);
  border: 1px solid var(--border-bronze);
  border-radius: 10px;
  padding: 7px 10px;
  backdrop-filter: blur(4px);
}

.fighter-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
}

.fighter-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(11px, 1.25vw, 15px);
  color: var(--text-ivory);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fighter-sub {
  font-size: clamp(10px, 1vw, 12px);
  color: var(--accent-gold);
  white-space: nowrap;
}

.bar-track {
  position: relative;
  height: clamp(13px, 1.55vw, 18px);
  background: rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.bar-fill {
  height: 100%;
  transition: width 80ms linear;
}

.hp-fill {
  background: linear-gradient(90deg, #b91c1c, #ef4444 65%, #f59e0b);
}

.enemy-hp-fill {
  background: linear-gradient(90deg, #991b1b, #dc2626 70%, #fb7185);
}

.bar-value {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(9px, 0.95vw, 11px);
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9);
}

.sub-bars-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 4px;
}

.stamina-track,
.hype-track {
  height: clamp(11px, 1.25vw, 14px);
}

.stamina-fill {
  background: linear-gradient(90deg, #0f766e, #14b8a6);
}

.hype-fill {
  background: linear-gradient(90deg, #d97706, #f5b82e, #fde047);
}

.enemy-hype-fill {
  background: linear-gradient(90deg, #7c3aed, #c084fc);
}

.hype-track.linh-nguu-ready {
  box-shadow: 0 0 12px rgba(245, 184, 46, 0.95);
  border-color: #fde047;
}

.rage-weak-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}

.rage-track {
  flex: 1;
  height: clamp(10px, 1.15vw, 13px);
}

.rage-fill {
  background: linear-gradient(90deg, #b91c1c, #f97316, #fde047);
}

.enemy-rage-fill {
  background: linear-gradient(90deg, #991b1b, #ea580c);
}

.rage-track.rage-ready {
  box-shadow: 0 0 12px rgba(249, 115, 22, 0.95);
  border-color: #fb923c;
}

.weakpoint-badge {
  flex-shrink: 0;
  font-size: clamp(8px, 0.8vw, 10px);
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: var(--text-muted);
  white-space: nowrap;
}

.weakpoint-badge.active {
  background: rgba(244, 63, 94, 0.25);
  border-color: #fb7185;
  color: #fecdd3;
}

.bar-value-sm {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(8px, 0.8vw, 10px);
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9);
}

.status-line {
  margin-top: 4px;
  font-size: clamp(9px, 0.9vw, 11px);
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.enemy-status {
  text-align: right;
}

.round-clock-panel {
  min-width: clamp(120px, 14vw, 190px);
  background: rgba(18, 10, 8, 0.88);
  border: 1px solid var(--border-bronze);
  border-radius: 10px;
  padding: 6px 12px;
  text-align: center;
  backdrop-filter: blur(4px);
}

.round-label {
  font-size: clamp(9px, 0.95vw, 12px);
  color: var(--accent-gold);
  font-weight: 700;
  white-space: nowrap;
}

.round-timer {
  font-size: clamp(18px, 2.3vw, 28px);
  font-weight: 700;
  line-height: 1.1;
  color: var(--text-ivory);
}

.round-sub-row {
  display: flex;
  justify-content: center;
  gap: 6px;
  font-size: clamp(9px, 0.9vw, 11px);
  color: var(--text-muted);
}

.hud-pause-btn {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  border: 1px solid var(--border-bronze);
  background: rgba(24, 14, 10, 0.88);
  color: var(--accent-gold);
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hud-pause-btn:hover {
  background: rgba(245, 184, 46, 0.2);
}

.linh-nguu-banner {
  position: absolute;
  top: 86px;
  left: 50%;
  transform: translateX(-50%);
  padding: 5px 16px;
  background: rgba(180, 83, 9, 0.92);
  border: 1px solid #fde047;
  border-radius: 6px;
  color: #fef08a;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(10px, 1.15vw, 14px);
  letter-spacing: 0.04em;
  box-shadow: 0 0 20px rgba(245, 184, 46, 0.55);
  white-space: nowrap;
}

.clash-banner {
  position: absolute;
  top: 22%;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  padding: 8px 18px;
  background: rgba(20, 10, 8, 0.92);
  border: 2px solid var(--accent-gold);
  border-radius: 10px;
  box-shadow: 0 0 28px rgba(245, 184, 46, 0.5);
}

.clash-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(14px, 1.8vw, 22px);
  color: var(--accent-gold);
}

.clash-sub {
  font-size: clamp(10px, 1vw, 13px);
  color: var(--text-ivory);
}

/* ================= BRONZE-DRUM BUTTONS ================= */
.skill-pad {
  position: absolute;
  right: 16px;
  bottom: 14px;
  display: grid;
  grid-template-columns: repeat(2, auto);
  justify-items: center;
  gap: clamp(8px, 1vw, 12px);
  pointer-events: auto;
  touch-action: none;
}

.drum-btn-rage {
  grid-column: 1 / -1;
  border-color: #f97316;
  background: radial-gradient(
    circle at center,
    #fed7aa 0%,
    #ea580c 25%,
    #9a3412 55%,
    #450a0a 85%,
    #1c0907 100%
  );
}

.drum-btn-rage.rage-locked {
  opacity: 0.42;
  filter: grayscale(0.45);
}

@keyframes ragePulse {
  0%,
  100% {
    box-shadow: 0 0 0 2px rgba(249, 115, 22, 0.9), 0 0 20px rgba(249, 115, 22, 0.85);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(253, 224, 71, 0.45), 0 0 32px rgba(251, 146, 60, 1);
    transform: scale(1.06);
  }
}

.drum-btn-rage.rage-ready {
  opacity: 1;
  border-color: #fde047;
  animation: ragePulse 0.95s ease-in-out infinite;
}

.drum-btn {
  position: relative;
  width: clamp(58px, 6.8vw, 78px);
  height: clamp(58px, 6.8vw, 78px);
  border-radius: 50%;
  border: 2px solid #f5b82e;
  background: radial-gradient(
    circle at center,
    #fde047 0%,
    #b45309 22%,
    #78350f 48%,
    #3b1a0a 75%,
    #1c0d07 100%
  );
  color: #fff;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.65), inset 0 0 8px rgba(253, 224, 71, 0.35);
  transition: transform 90ms ease, filter 120ms ease;
  overflow: hidden;
  touch-action: none;
}

.drum-btn:active,
.drum-btn.active-press {
  transform: scale(0.92);
  filter: brightness(1.2);
}

.drum-btn.exhausted {
  opacity: 0.45;
  border-color: #ef4444;
}

.drum-ring {
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  border: 1px dashed rgba(253, 224, 71, 0.55);
  pointer-events: none;
}

.drum-label {
  position: relative;
  z-index: 2;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(12px, 1.3vw, 15px);
  color: #fffbeb;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.95);
}

.drum-key {
  position: relative;
  z-index: 2;
  font-size: clamp(7px, 0.72vw, 9px);
  color: #fde68a;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.95);
  white-space: nowrap;
}

.drum-cd {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.68);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 13px;
  color: #fde047;
  opacity: 0;
  pointer-events: none;
  z-index: 3;
}

.drum-cd.visible {
  opacity: 1;
}

.touch-hidden .skill-pad {
  display: none !important;
}

/* ================= OVERLAY SCREENS & MODALS ================= */
.overlay-screen {
  position: absolute;
  inset: 0;
  z-index: 30;
  background: rgba(12, 7, 5, 0.78);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

/* ================= NGƯU TRẠI HẮC PHONG LOBBY OVERLAY ================= */
.lobby-overlay {
  position: absolute;
  inset: 0;
  z-index: 24;
  pointer-events: none;
  padding: clamp(10px, 1.8vw, 20px);
}

/* TOP-CENTER: Carved Wooden Signboard */
.lobby-signboard {
  position: absolute;
  top: clamp(8px, 1.2vw, 16px);
  left: 50%;
  transform: translateX(-50%);
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.signboard-rope {
  position: absolute;
  top: -18px;
  width: 5px;
  height: 22px;
  background: linear-gradient(180deg, #78350f, #d97706);
  border-left: 1px solid #1c0d07;
  border-right: 1px solid #1c0d07;
}
.signboard-rope-left { left: 18%; }
.signboard-rope-right { right: 18%; }

.signboard-frame {
  position: relative;
  padding: clamp(7px, 1vw, 12px) clamp(20px, 3vw, 38px);
  background: linear-gradient(180deg, #5c2b16 0%, #3b190c 52%, #240f07 100%);
  border: 3px solid #f5b82e;
  border-radius: 12px;
  box-shadow:
    0 10px 28px rgba(0, 0, 0, 0.78),
    inset 0 0 0 2px #78350f,
    inset 0 2px 10px rgba(253, 224, 71, 0.25);
  text-align: center;
}

.signboard-corner {
  position: absolute;
  width: 10px;
  height: 10px;
  border: 2px solid #fde047;
  background: #991b1b;
  border-radius: 2px;
}
.signboard-corner.tl { top: 4px; left: 4px; }
.signboard-corner.tr { top: 4px; right: 4px; }
.signboard-corner.bl { bottom: 4px; left: 4px; }
.signboard-corner.br { bottom: 4px; right: 4px; }

.signboard-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(16px, 2.3vw, 29px);
  letter-spacing: 0.05em;
  line-height: 1.1;
  color: #fde047;
  text-shadow:
    0 2px 0 #451a03,
    0 0 14px rgba(253, 224, 71, 0.65),
    0 4px 10px rgba(0, 0, 0, 0.9);
  white-space: nowrap;
}

.signboard-sub {
  margin: 3px 0 0;
  font-size: clamp(9px, 0.95vw, 12px);
  font-weight: 700;
  color: #fed7aa;
  letter-spacing: 0.04em;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9);
}

/* TOP-LEFT: Player Profile Avatar Frame */
.lobby-profile-wrap {
  position: absolute;
  top: clamp(10px, 1.5vw, 18px);
  left: clamp(10px, 1.5vw, 18px);
  display: flex;
  flex-direction: column;
  gap: 7px;
  pointer-events: auto;
  max-width: clamp(210px, 26vw, 295px);
}

.lobby-profile-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px 8px 8px;
  background: linear-gradient(145deg, rgba(45, 22, 13, 0.94), rgba(22, 11, 7, 0.96));
  border: 2px solid #d97706;
  border-radius: 14px;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.7), inset 0 1px 6px rgba(253, 224, 71, 0.22);
}

.profile-avatar-frame {
  position: relative;
  flex-shrink: 0;
  width: clamp(48px, 5.2vw, 62px);
  height: clamp(48px, 5.2vw, 62px);
  border-radius: 50%;
  border: 2.5px solid #fde047;
  background: radial-gradient(circle, #78350f 0%, #2a130b 75%, #120704 100%);
  box-shadow: 0 0 12px rgba(245, 184, 46, 0.45);
  overflow: visible;
  display: flex;
  align-items: center;
  justify-content: center;
}

#menu-avatar-canvas {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  display: block;
}

.profile-level-badge {
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  padding: 1px 7px;
  border-radius: 999px;
  background: linear-gradient(180deg, #dc2626, #991b1b);
  border: 1.5px solid #fde047;
  font-size: clamp(8px, 0.85vw, 10px);
  font-weight: 800;
  color: #fffbeb;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.8);
}

.profile-details {
  min-width: 0;
  flex: 1;
}

.profile-name {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(11px, 1.18vw, 14px);
  color: #fffbeb;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profile-currency-row {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
}

.currency-icon {
  width: clamp(14px, 1.4vw, 18px);
  height: clamp(14px, 1.4vw, 18px);
  flex-shrink: 0;
}

.profile-points {
  font-size: clamp(12px, 1.25vw, 15px);
  font-weight: 800;
  color: #fde047;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.85);
}

.profile-mini-stats {
  margin-top: 2px;
  display: flex;
  gap: 5px;
  font-size: clamp(9px, 0.85vw, 11px);
  color: var(--text-muted);
  white-space: nowrap;
}

.lobby-left-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.lobby-pill-btn {
  padding: 5px 10px;
  font-size: clamp(9px, 0.9vw, 11px);
  border-radius: 8px;
  background: rgba(32, 16, 10, 0.9);
  border: 1.5px solid rgba(245, 184, 46, 0.55);
  color: #fde68a;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.55);
}

.lobby-pill-btn:hover {
  background: rgba(180, 83, 9, 0.45);
  border-color: #fde047;
  color: #fffbeb;
}

.lobby-gear-tag {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 4px 9px;
  border-radius: 8px;
  background: rgba(18, 10, 8, 0.82);
  border: 1px solid rgba(245, 184, 46, 0.3);
  font-size: clamp(8.5px, 0.82vw, 10.5px);
  color: var(--text-muted);
}

.lobby-gear-tag strong {
  color: #fde68a;
}

/* BOTTOM-RIGHT: 4 Bold Folk-Remix Buttons */
.lobby-bottom-right {
  position: absolute;
  right: clamp(12px, 1.8vw, 22px);
  bottom: clamp(12px, 1.8vw, 22px);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  pointer-events: auto;
}

.lobby-play-btn {
  position: relative;
  min-width: clamp(175px, 20vw, 250px);
  padding: clamp(10px, 1.3vw, 15px) clamp(22px, 2.6vw, 34px);
  border-radius: 14px;
  border: 3px solid #fde047;
  background: linear-gradient(180deg, #ef4444 0%, #b91c1c 58%, #7f1d1d 100%);
  color: #fffbeb;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow:
    0 10px 28px rgba(0, 0, 0, 0.78),
    0 0 22px rgba(239, 68, 68, 0.45),
    inset 0 2px 8px rgba(254, 240, 138, 0.45);
  transition: transform 130ms ease, filter 130ms ease, box-shadow 130ms ease;
}

.lobby-play-btn:hover {
  transform: translateY(-2px) scale(1.02);
  filter: brightness(1.08);
  box-shadow:
    0 14px 32px rgba(0, 0, 0, 0.85),
    0 0 28px rgba(253, 224, 71, 0.55),
    inset 0 2px 10px rgba(254, 240, 138, 0.6);
}

.lobby-play-btn:active {
  transform: scale(0.96);
}

.play-btn-rim {
  position: absolute;
  inset: 4px;
  border-radius: 10px;
  border: 1.5px dashed rgba(253, 224, 71, 0.55);
  pointer-events: none;
}

.play-btn-text {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(20px, 2.5vw, 30px);
  letter-spacing: 0.08em;
  line-height: 1.05;
  color: #fef08a;
  text-shadow: 0 2px 0 #450a0a, 0 0 12px rgba(253, 224, 71, 0.55);
}

.play-btn-sub {
  margin-top: 2px;
  font-size: clamp(9px, 0.9vw, 11px);
  font-weight: 700;
  color: #fee2e2;
  letter-spacing: 0.03em;
}

.lobby-sub-buttons {
  display: grid;
  grid-template-columns: repeat(3, auto);
  gap: 8px;
}

.lobby-wood-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: clamp(72px, 7.6vw, 94px);
  padding: clamp(7px, 0.85vw, 10px) clamp(8px, 1vw, 12px);
  border-radius: 12px;
  border: 2px solid #f5b82e;
  background: linear-gradient(180deg, #4b2313 0%, #2b130a 65%, #1a0b05 100%);
  color: #2dd4bf;
  box-shadow:
    0 8px 20px rgba(0, 0, 0, 0.78),
    0 0 12px rgba(45, 212, 191, 0.22),
    inset 0 0 0 1.5px rgba(245, 184, 46, 0.28);
  transition: transform 130ms ease, border-color 130ms ease, box-shadow 130ms ease;
}

.lobby-wood-btn:hover {
  transform: translateY(-2px);
  border-color: #fde047;
  box-shadow:
    0 10px 24px rgba(0, 0, 0, 0.85),
    0 0 16px rgba(45, 212, 191, 0.45);
}

.lobby-wood-btn:active {
  transform: scale(0.95);
}

.wood-btn-icon {
  width: clamp(16px, 1.8vw, 22px);
  height: clamp(16px, 1.8vw, 22px);
  filter: drop-shadow(0 0 6px rgba(45, 212, 191, 0.7));
}

.lobby-wood-btn span {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(8.5px, 0.9vw, 11px);
  color: #fef3c7;
  letter-spacing: 0.03em;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.95);
}

/* ================= BUTTONS ================= */
button,
.file-upload-btn {
  font-family: var(--font-body);
  font-weight: 700;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 140ms ease, background-color 140ms ease, border-color 140ms ease;
  white-space: nowrap;
}

button:focus-visible,
.file-upload-btn:focus-visible {
  outline: 2px solid var(--accent-gold);
  outline-offset: 2px;
}

.btn-primary {
  background: linear-gradient(135deg, #dc2626, #b91c1c);
  color: #fffbeb;
  border: 1px solid #f5b82e;
  padding: 11px 24px;
  font-size: 15px;
  box-shadow: 0 8px 20px rgba(185, 28, 28, 0.4);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  transform: translateY(-1px);
}

.btn-xl {
  padding: 13px 34px;
  font-size: 17px;
  min-width: 240px;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-ivory);
  border: 1px solid var(--border-subtle);
  padding: 10px 14px;
  font-size: 13px;
}

.btn-secondary:hover {
  background: rgba(245, 184, 46, 0.14);
  border-color: var(--border-bronze);
}

.btn-sm {
  padding: 7px 12px;
  font-size: 12px;
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
  padding: 7px 14px;
  font-size: 13px;
}

.btn-ghost:hover {
  color: var(--text-ivory);
  border-color: var(--border-bronze);
}

.btn-ghost-danger {
  background: transparent;
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.35);
  padding: 10px 16px;
  font-size: 14px;
}

/* ================= CARDS & MODALS ================= */
.modal-card,
.intro-card {
  background: var(--surface-panel);
  border: 1px solid var(--border-bronze);
  border-radius: 14px;
  padding: clamp(16px, 2.4vw, 26px);
  max-height: 92%;
  overflow-y: auto;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8);
}

.modal-sm {
  width: min(400px, 100%);
  text-align: center;
}

.modal-md {
  width: min(560px, 100%);
  text-align: center;
}

.modal-lg {
  width: min(860px, 100%);
}

.intro-card {
  width: min(700px, 100%);
}

.intro-header,
.modal-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.intro-visual-box,
.victory-visual-wrap {
  width: 100%;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  background: #140c08;
  margin-bottom: 14px;
}

#intro-canvas,
#victory-canvas {
  width: 100%;
  height: auto;
  display: block;
}

.intro-title,
.modal-title {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(18px, 2vw, 24px);
  color: var(--text-ivory);
}

.intro-text,
.modal-desc {
  margin: 0 0 16px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-muted);
}

.intro-footer {
  display: flex;
  justify-content: flex-end;
}

.modal-kicker {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-gold);
}

.modal-sub {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}

.modal-note {
  margin: 14px 0 18px;
  font-size: 13px;
  color: var(--accent-jade);
}

.stack-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.modal-actions-row {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 18px;
}

.stats-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 14px 0;
}

.stat-cell {
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 10px 8px;
  text-align: center;
}

.stat-label {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.stat-num {
  font-size: 18px;
  color: var(--text-ivory);
}

.highlight-gold {
  color: var(--accent-gold);
}

/* ================= SHOP & GUIDE & SETTINGS ================= */
.shop-columns,
.guide-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.shop-col-title {
  margin: 0 0 10px;
  font-size: 14px;
  color: var(--accent-gold);
}

.shop-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.shop-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 10px 12px;
}

.shop-item.equipped {
  border-color: var(--accent-gold);
}

.shop-item-info strong {
  display: block;
  font-size: 13px;
  color: var(--text-ivory);
}

.shop-item-info span {
  font-size: 11px;
  color: var(--text-muted);
}

.guide-block {
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 12px 14px;
}

.guide-block h3 {
  margin: 0 0 6px;
  font-size: 14px;
  color: var(--accent-gold);
}

.guide-block p,
.guide-block li {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-muted);
}

.guide-block ul {
  margin: 0;
  padding-left: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.settings-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: left;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  font-size: 13px;
}

.setting-row select {
  background: #140d0a;
  color: var(--text-ivory);
  border: 1px solid var(--border-bronze);
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 12px;
}

/* ================= HISTORY MODAL ================= */
.history-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.history-summary-line {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 13px;
  color: var(--accent-gold);
}

.history-io-buttons {
  display: flex;
  gap: 8px;
}

.file-upload-btn {
  display: inline-flex;
  align-items: center;
}

.history-feedback {
  margin-bottom: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12.5px;
  background: rgba(20, 184, 166, 0.16);
  border: 1px solid rgba(20, 184, 166, 0.5);
  color: #99f6e4;
}

.history-feedback.error {
  background: rgba(220, 38, 38, 0.16);
  border-color: rgba(220, 38, 38, 0.5);
  color: #fecaca;
}

.history-table-wrap {
  max-height: 290px;
  overflow-y: auto;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  background: #140c08;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  text-align: left;
}

.history-table th,
.history-table td {
  padding: 8px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  white-space: nowrap;
}

.history-table th {
  position: sticky;
  top: 0;
  background: #23140f;
  color: var(--accent-gold);
  font-weight: 700;
}

.history-win {
  color: #4ade80;
  font-weight: 700;
}

.history-loss {
  color: #f87171;
  font-weight: 700;
}

.history-empty {
  padding: 28px;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}

@media (max-width: 720px) {
  .menu-secondary-grid,
  .shop-columns,
  .guide-grid {
    grid-template-columns: 1fr 1fr;
  }

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

@media (max-width: 520px) {
  .menu-secondary-grid,
  .shop-columns,
  .guide-grid {
    grid-template-columns: 1fr;
  }
}

/* ================= TUTORIAL: SỚI TẬP KHAI HỘI ================= */
.menu-primary-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.btn-xl-side {
  padding: 13px 20px;
  font-size: 15px;
  border-color: var(--border-bronze);
  color: var(--accent-gold);
}

.tutorial-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 18;
}

.tutorial-top-row {
  position: absolute;
  top: 12px;
  left: 16px;
  right: 16px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.elder-dialogue-card {
  flex: 1;
  max-width: 780px;
  background: rgba(20, 11, 8, 0.94);
  border: 2px solid var(--accent-gold);
  border-radius: 12px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.72);
}

.elder-badge {
  flex-shrink: 0;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fde047, #b45309 65%, #451a03);
  border: 2px solid #fffbeb;
  color: #1c0d07;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.elder-content {
  flex: 1;
  min-width: 0;
}

.elder-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 4px;
}

.elder-header strong {
  font-family: var(--font-display);
  font-size: clamp(13px, 1.35vw, 16px);
  color: var(--accent-gold);
}

.tut-progress {
  font-size: 13px;
  font-weight: 700;
  color: #2dd4bf;
}

.elder-dialogue {
  margin: 0;
  font-size: clamp(12px, 1.2vw, 14px);
  line-height: 1.45;
  color: var(--text-ivory);
}

.btn-skip-tutorial {
  pointer-events: auto;
  background: rgba(20, 11, 8, 0.9);
  color: var(--text-ivory);
  border: 1px solid var(--border-bronze);
  padding: 9px 15px;
  font-size: 13px;
  flex-shrink: 0;
}

.btn-skip-tutorial:hover {
  background: rgba(245, 184, 46, 0.2);
  color: #fde047;
}

@keyframes tutPulse {
  0%,
  100% {
    box-shadow: 0 0 0 3px rgba(253, 224, 71, 0.95), 0 0 24px rgba(253, 224, 71, 0.85);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(253, 224, 71, 0.35), 0 0 34px rgba(253, 224, 71, 1);
    transform: scale(1.07);
  }
}

.tutorial-spotlight {
  animation: tutPulse 0.95s ease-in-out infinite !important;
  border-color: #fef08a !important;
  z-index: 5;
}

.tut-complete-card {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(500px, 90%);
  background: rgba(20, 11, 8, 0.95);
  border: 2px solid var(--accent-gold);
  border-radius: 16px;
  padding: 24px;
  text-align: center;
  pointer-events: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.85);
}

.tutorial-mode .hud-top-bar,
.tutorial-mode .hud-pause-btn,
.tutorial-mode .drum-btn-rage {
  display: none !important;
}

/* ================= PROFILE SUBTITLE & REWARD BANNER ================= */
.profile-farm-sub {
  font-size: clamp(9.5px, 0.92vw, 11.5px);
  font-weight: 700;
  color: #fde68a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reward-banner {
  margin: 4px 0 12px;
  padding: 9px 14px;
  border-radius: 10px;
  background: linear-gradient(90deg, rgba(180, 83, 9, 0.38), rgba(245, 184, 46, 0.28));
  border: 1px solid var(--accent-gold);
  color: #fef08a;
  font-weight: 700;
  font-size: 14px;
}

/* ================= 3-TAB SHOP MODAL ================= */
.shop-tabs-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.shop-tab-btn {
  flex: 1;
  min-width: 140px;
  padding: 9px 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 12.5px;
  border-radius: 9px;
}

.shop-tab-btn.active {
  background: linear-gradient(135deg, rgba(185, 28, 28, 0.85), rgba(127, 29, 29, 0.9));
  border-color: var(--accent-gold);
  color: #fef08a;
  box-shadow: 0 4px 14px rgba(245, 184, 46, 0.25);
}

.shop-buffaloes-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.buffalo-shop-card {
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.buffalo-shop-card.owned {
  border-color: rgba(45, 212, 191, 0.45);
}

.buffalo-shop-card.selected {
  border-color: var(--accent-gold);
  box-shadow: 0 0 18px rgba(245, 184, 46, 0.22);
}

.buffalo-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.buffalo-thumb-canvas {
  width: 56px;
  height: 56px;
  border-radius: 10px;
  background: rgba(15, 9, 7, 0.85);
  border: 1px solid var(--border-bronze);
  flex-shrink: 0;
}

.buffalo-card-title {
  flex: 1;
  min-width: 0;
}

.buffalo-name-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 14px;
  color: var(--text-ivory);
}

.buffalo-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.badge-lvl {
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(245, 184, 46, 0.2);
  border: 1px solid var(--accent-gold);
  color: #fde047;
  font-size: 10.5px;
  font-weight: 700;
}

.badge-lock {
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
  font-size: 10px;
}

.buffalo-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 6px 8px;
  border-radius: 8px;
  background: rgba(12, 7, 5, 0.55);
  font-size: 11.5px;
  color: var(--text-muted);
}

.buffalo-stats-grid strong {
  color: var(--text-ivory);
}

.buffalo-rage-box {
  background: rgba(180, 83, 9, 0.14);
  border: 1px solid rgba(245, 184, 46, 0.25);
  border-radius: 8px;
  padding: 7px 9px;
}

.rage-skill-title {
  font-size: 11.5px;
  font-weight: 700;
  color: #fde047;
  margin-bottom: 2px;
}

.rage-skill-desc {
  margin: 0;
  font-size: 11px;
  line-height: 1.4;
  color: var(--text-muted);
}

.buffalo-action-btn {
  width: 100%;
  margin-top: auto;
}

.shop-upgrade-target {
  background: linear-gradient(135deg, rgba(69, 26, 3, 0.65), rgba(38, 23, 18, 0.92));
  border: 1px solid var(--accent-gold);
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 12px;
}

.upgrade-target-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 14px;
}

.upgrade-target-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 12px;
  color: var(--text-ivory);
}

.upgrade-target-stats em {
  font-style: normal;
  color: #4ade80;
  font-weight: 700;
}

.item-count-tag {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

.skill-upgrade-panel {
  background: var(--surface-card);
  border: 1px solid var(--border-bronze);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.skill-upgrade-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.skill-upgrade-header h3 {
  margin: 0;
  font-size: 17px;
  color: var(--text-ivory);
}

.skill-upgrade-desc {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-muted);
}

.skill-scaling-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.scaling-cell {
  background: rgba(12, 7, 5, 0.6);
  border: 1px solid var(--border-subtle);
  border-radius: 9px;
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12.5px;
  color: var(--text-muted);
}

.scaling-cell strong {
  color: #4ade80;
}

/* ================= TRAINING STAGES MODAL ================= */
.stages-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.stages-deploy-bar {
  background: var(--surface-card);
  border: 1px solid var(--border-bronze);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.deploy-label {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--accent-gold);
}

.stages-buffalo-switcher {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.stage-buffalo-pill {
  padding: 5px 11px;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  font-size: 12px;
}

.stage-buffalo-pill.active {
  background: rgba(185, 28, 28, 0.8);
  border-color: var(--accent-gold);
  color: #fef08a;
}

.stages-active-stats {
  font-size: 11.5px;
  color: var(--text-muted);
}

.stages-active-stats b {
  color: var(--text-ivory);
}

.stages-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.stage-card {
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: 11px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stage-card.unlocked {
  border-color: rgba(245, 184, 46, 0.45);
}

.stage-card.cleared {
  border-color: rgba(74, 222, 128, 0.45);
}

.stage-card.locked {
  opacity: 0.62;
}

.stage-card-body {
  display: flex;
  align-items: center;
  gap: 10px;
}

.stage-bot-thumb {
  width: 52px;
  height: 52px;
  border-radius: 9px;
  background: rgba(12, 7, 5, 0.85);
  border: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.stage-card-info {
  flex: 1;
  min-width: 0;
}

.stage-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.stage-title {
  font-size: 13px;
  color: var(--text-ivory);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stage-status-badge {
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  flex-shrink: 0;
}

.stage-status-badge.open {
  background: rgba(245, 184, 46, 0.22);
  color: #fde047;
}

.stage-status-badge.cleared {
  background: rgba(74, 222, 128, 0.2);
  color: #4ade80;
}

.stage-status-badge.locked {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
}

.stage-bot-line,
.stage-power-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 3px;
}

.stage-reward {
  color: var(--accent-gold);
  font-weight: 700;
}

.stage-play-btn {
  width: 100%;
}

button:disabled {
  opacity: 0.48;
  cursor: not-allowed;
  transform: none !important;
}

@media (max-width: 720px) {
  .shop-buffaloes-grid,
  .stages-grid,
  .skill-scaling-row {
    grid-template-columns: 1fr;
  }
}


