/* -------------------------------------------------------------
 * Boss Battle Mode ("Đánh Boss Từ Khó")
 * Builds on the glassmorphism tokens from vocabulary_game.css
 * ------------------------------------------------------------- */

:root {
  --boss-gold: #fbbf24;
  --boss-gold-glow: rgba(251, 191, 36, 0.35);
  --boss-hp: #f43f5e;
  --boss-spell: #c084fc;
  --boss-normal: #60a5fa;
}

/* Mode card entry on the mode-selection screen */
.mode-card-boss {
  position: relative;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.12) 0%, rgba(244, 63, 94, 0.08) 100%);
  border-color: rgba(251, 191, 36, 0.3);
}

.mode-card-boss:hover {
  border-color: var(--boss-gold);
  box-shadow: 0 10px 30px var(--boss-gold-glow);
}

.boss-mode-badge {
  align-self: flex-start;
  margin-top: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(251, 191, 36, 0.12);
  border: 1px solid rgba(251, 191, 36, 0.35);
  color: var(--boss-gold);
  font-size: 0.78rem;
  font-weight: 700;
}

/* Boss counter on dashboard topic cards */
.topic-boss-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(244, 63, 94, 0.15);
  border: 1px solid rgba(244, 63, 94, 0.45);
  color: #fda4af;
  font-size: 0.75rem;
  font-weight: 700;
}

/* Shared header */
.boss-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.boss-header-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  text-align: center;
  flex: 1;
}

.btn-boss-icon {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #fff;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  font-size: 1.1rem;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s;
}

.btn-boss-icon:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* -------------------------------------------------------------
 * Lobby
 * ------------------------------------------------------------- */
.boss-lobby-banner {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  min-height: 220px;
  padding: 24px;
  border-radius: 20px;
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(9, 11, 17, 0.88) 0%, rgba(9, 11, 17, 0.55) 55%, rgba(9, 11, 17, 0.1) 100%),
    url('../assets/boss/bg_night_village.webp') center 65% / cover;
  border: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 20px;
}

.boss-lobby-text {
  max-width: 60%;
  align-self: center;
  position: relative;
  z-index: 1;
}

.boss-kicker {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: var(--boss-gold);
  margin-bottom: 6px;
}

.boss-lobby-name {
  font-size: 1.7rem;
  font-weight: 800;
  color: #fff;
  margin-bottom: 8px;
  line-height: 1.2;
}

.boss-lobby-tagline {
  font-size: 0.92rem;
  color: #e2e8f0;
  line-height: 1.5;
}

.boss-lobby-img {
  height: 190px;
  width: auto;
  max-width: 40%;
  object-fit: contain;
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.5));
  animation: bossBreathe 2.8s ease-in-out infinite;
  transform-origin: bottom center;
}

.boss-lobby-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.boss-stat {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 16px;
  padding: 14px 10px;
  text-align: center;
}

.boss-stat-val {
  display: block;
  font-size: 1.5rem;
  font-weight: 800;
  color: #fff;
}

.boss-stat-label {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 4px;
}

.boss-lobby-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 22px;
}

.btn-boss-fight {
  background: linear-gradient(135deg, #f43f5e 0%, #8b5cf6 100%);
  color: #fff;
  border: none;
  padding: 14px 26px;
  border-radius: 14px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(244, 63, 94, 0.3);
  transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s;
}

.btn-boss-fight:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 26px rgba(244, 63, 94, 0.45);
}

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

.btn-boss-patrol {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #fff;
  padding: 14px 22px;
  border-radius: 14px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
}

.btn-boss-patrol:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-2px);
}

.boss-rules {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 16px;
  padding: 14px 18px;
  margin-bottom: 22px;
}

.boss-rules summary {
  cursor: pointer;
  font-weight: 700;
  color: #fff;
  font-size: 0.95rem;
}

.boss-rules ul {
  list-style: none;
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.boss-rules li {
  font-size: 0.88rem;
  color: #cbd5e1;
  line-height: 1.5;
}

.boss-section-title {
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 12px;
}

.boss-word-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 10px;
}

.boss-word-chip {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.boss-word-chip.is-due {
  border-color: rgba(244, 63, 94, 0.45);
  background: rgba(244, 63, 94, 0.07);
}

.boss-word-chip.is-sealed {
  opacity: 0.6;
}

.boss-chip-word {
  font-weight: 700;
  color: #fff;
  font-size: 0.95rem;
  word-break: break-word;
}

.boss-chip-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--muted);
}

.boss-chip-stars {
  letter-spacing: 1px;
  color: var(--boss-gold);
}

.boss-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 26px 16px;
  border: 1px dashed rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.6;
}

/* -------------------------------------------------------------
 * Arena
 * ------------------------------------------------------------- */
.boss-stage {
  position: relative;
  aspect-ratio: 16 / 7.5;
  min-height: 240px;
  border-radius: 20px;
  overflow: hidden;
  background: #2a1f5c url('../assets/boss/bg_night_village.webp') center 70% / cover;
  border: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 20px;
}

.boss-stage::after {
  content: '';
  position: absolute;
  inset: auto 0 0 0;
  height: 30%;
  background: linear-gradient(0deg, rgba(9, 11, 17, 0.55) 0%, transparent 100%);
  pointer-events: none;
}

.boss-hud {
  position: absolute;
  top: 12px;
  z-index: 3;
  background: rgba(9, 11, 17, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  padding: 8px 12px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.boss-hud-hero {
  left: 12px;
}

.boss-hud-enemy {
  right: 12px;
  min-width: 46%;
  max-width: 60%;
}

.boss-hud-name {
  font-size: 0.78rem;
  font-weight: 800;
  color: #fff;
  margin-bottom: 5px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.boss-hud-name span:last-child {
  color: var(--muted);
  font-weight: 600;
}

.boss-hearts {
  font-size: 1.05rem;
  letter-spacing: 2px;
  line-height: 1;
}

.boss-combo {
  margin-top: 5px;
  font-size: 0.75rem;
  font-weight: 800;
  color: #fb923c;
  min-height: 1em;
}

.boss-hp-bar {
  display: flex;
  gap: 3px;
  height: 12px;
}

.boss-hp-seg {
  flex: 1;
  border-radius: 3px;
  background: linear-gradient(180deg, #fb7185 0%, var(--boss-hp) 100%);
  box-shadow: 0 0 6px rgba(244, 63, 94, 0.5);
  transition: background 0.3s, box-shadow 0.3s, transform 0.3s;
}

.boss-hp-seg.empty {
  background: rgba(255, 255, 255, 0.1);
  box-shadow: none;
  transform: scaleY(0.6);
}

.boss-hero,
.boss-enemy {
  position: absolute;
  bottom: 5%;
  z-index: 2;
}

.boss-hero {
  left: 7%;
  height: 58%;
}

.boss-enemy {
  right: 8%;
  height: 66%;
}

.boss-idle {
  height: 100%;
  animation: bossFloat 2.6s ease-in-out infinite;
}

.boss-enemy .boss-idle {
  animation: bossBreathe 2.8s ease-in-out infinite;
  transform-origin: bottom center;
}

.boss-hero img,
.boss-enemy img {
  height: 100%;
  width: auto;
  display: block;
  filter: drop-shadow(0 8px 12px rgba(0, 0, 0, 0.45));
  transition: filter 0.15s;
}

.boss-hero img {
  transform: scaleX(-1); /* face the boss */
}

.boss-hero.is-hurt img,
.boss-enemy.is-hit img {
  filter: brightness(1.7) drop-shadow(0 0 14px #f43f5e);
}

.boss-projectile {
  position: absolute;
  left: 0;
  top: 0;
  width: 46px;
  height: auto;
  z-index: 4;
  display: none;
  pointer-events: none;
  filter: drop-shadow(0 0 10px rgba(251, 191, 36, 0.9));
}

.boss-potion {
  position: absolute;
  width: 54px;
  z-index: 4;
  display: none;
  pointer-events: none;
  filter: drop-shadow(0 0 10px rgba(244, 114, 182, 0.8));
}

.boss-pop {
  position: absolute;
  z-index: 5;
  transform: translate(-50%, -50%);
  font-weight: 800;
  font-size: 1.4rem;
  white-space: nowrap;
  pointer-events: none;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.8);
}

.boss-pop.dmg { color: #fff; }
.boss-pop.crit { color: #fb923c; font-size: 1.8rem; }
.boss-pop.seal { color: var(--boss-gold); font-size: 1.25rem; }
.boss-pop.hurt { color: #f87171; }
.boss-pop.heal { color: #f9a8d4; font-size: 1.1rem; }

/* Question panel */
.boss-question-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.boss-attack-label {
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 800;
  border: 1px solid;
}

.boss-attack-label.tier-0 {
  color: var(--boss-normal);
  background: rgba(59, 130, 246, 0.12);
  border-color: rgba(59, 130, 246, 0.4);
}

.boss-attack-label.tier-1 {
  color: var(--boss-spell);
  background: rgba(139, 92, 246, 0.12);
  border-color: rgba(139, 92, 246, 0.45);
}

.boss-attack-label.tier-2 {
  color: var(--boss-gold);
  background: rgba(251, 191, 36, 0.12);
  border-color: rgba(251, 191, 36, 0.45);
}

.boss-seal {
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 600;
}

.boss-q-main {
  font-size: 1.9rem;
  font-weight: 800;
  color: #fff;
  margin-bottom: 6px;
  line-height: 1.3;
  word-break: break-word;
}

.boss-q-main.is-meaning {
  font-size: 1.4rem;
  color: #c084fc;
}

.boss-q-main.is-sentence {
  font-size: 1.1rem;
  font-weight: 500;
  line-height: 1.6;
  color: #e2e8f0;
  text-align: left;
}

.boss-q-sub {
  font-size: 1rem;
  color: var(--muted);
  margin-bottom: 10px;
}

.boss-q-tools {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 6px;
}

.boss-spell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 25px;
}

.boss-spell .spelling-input {
  max-width: 420px;
}

.boss-hint-pattern {
  font-family: 'Segoe UI', monospace;
  letter-spacing: 3px;
  color: var(--boss-gold);
  font-weight: 700;
  min-height: 1.2em;
  white-space: pre-wrap;
  text-align: center;
}

.btn-boss-submit {
  background: linear-gradient(135deg, #f59e0b 0%, #f43f5e 100%);
  color: #fff;
  border: none;
  padding: 10px 22px;
  border-radius: 10px;
  font-family: inherit;
  font-weight: 800;
  cursor: pointer;
}

.btn-boss-submit:disabled {
  opacity: 0.5;
  cursor: default;
}

/* -------------------------------------------------------------
 * Result
 * ------------------------------------------------------------- */
.boss-result-img {
  height: 150px;
  width: auto;
  margin-bottom: 10px;
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.45));
  animation: float 2s infinite ease-in-out;
}

.boss-result-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 560px;
  margin: 0 auto 30px;
  text-align: left;
}

.boss-result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.boss-result-word {
  font-weight: 700;
  color: #fff;
  word-break: break-word;
}

.boss-result-status {
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
}

.boss-result-status.good { color: var(--correct); }
.boss-result-status.gold { color: var(--boss-gold); }
.boss-result-status.bad { color: #f87171; }

.boss-result-title {
  font-size: 1.8rem;
  font-weight: 800;
  color: #fff;
  margin-bottom: 8px;
}

#boss-result .results-stats-row {
  flex-wrap: wrap;
  gap: 12px;
}

#boss-result .res-stat-card {
  display: flex;
  flex-direction: column;
  min-width: 110px;
}

@keyframes bossFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

@keyframes bossBreathe {
  0%, 100% { transform: scale(1, 1); }
  50% { transform: scale(1.03, 0.97); }
}

@media (max-width: 640px) {
  .boss-lobby-banner {
    min-height: 180px;
    padding: 18px;
  }

  .boss-lobby-text {
    max-width: 62%;
  }

  .boss-lobby-name {
    font-size: 1.3rem;
  }

  .boss-lobby-img {
    height: 130px;
  }

  .boss-lobby-stats {
    gap: 8px;
  }

  .boss-stat-val {
    font-size: 1.2rem;
  }

  .boss-stage {
    aspect-ratio: 4 / 3;
  }

  .boss-hud-enemy {
    min-width: 50%;
  }

  .boss-q-main {
    font-size: 1.5rem;
  }

  .boss-lobby-actions > button {
    flex: 1 1 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .boss-idle,
  .boss-enemy .boss-idle,
  .boss-lobby-img,
  .boss-result-img {
    animation: none;
  }
}
