/* ==========================================================================
   battle.css — ⚔️ Moral Battle (js/battle.js)
   Ko'k-binafsha gradient, katta tugmalar (bir qo'l bilan bosish uchun),
   Duolingo uslubidagi "3D" soyalar. Ranglar styles.css tokenlaridan.
   ========================================================================== */

.bt {
  --bt-grad: linear-gradient(135deg, #7C5CFC 0%, #5B7FFF 100%);
  --bt-grad-deep: linear-gradient(160deg, #5B3FE0 0%, #3F63F0 100%);
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 560px;
  margin: 0 auto;
  padding-bottom: 24px;
  position: relative;
}

.bt-card {
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-md);
  padding: 18px;
}

/* ------------------------------- Statistika ------------------------------- */

.bt-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  background: var(--bt-grad);
  color: #fff;
  box-shadow: var(--shadow-brand);
}

.bt-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 4px;
  border-radius: var(--r-sm);
  background: rgba(255, 255, 255, .14);
  min-width: 0;
}

.bt-stat__icon { font-size: 18px; line-height: 1; }
.bt-stat__value { font-size: 20px; font-weight: 900; line-height: 1.2; }
.bt-stat__label { font-size: 11.5px; font-weight: 700; opacity: .88; white-space: nowrap; }

/* --------------------------------- Sozlash --------------------------------- */

.bt-setup { display: flex; flex-direction: column; gap: 18px; }

.bt-step { transition: opacity .2s; }
.bt-step.is-off { opacity: .45; }

.bt-step__title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 15px;
  color: var(--text);
  margin-bottom: 10px;
}

.bt-step__n {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  background: var(--bt-grad);
  color: #fff;
  font-size: 13px;
}

.bt-chips { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.bt-chips--levels { grid-template-columns: repeat(5, 1fr); }

.bt-chip {
  font: inherit;
  font-weight: 800;
  font-size: 15px;
  min-height: 52px;
  padding: 8px 6px;
  border-radius: var(--r-md);
  border: 2px solid var(--border);
  border-bottom-width: 4px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  transition: transform .08s, border-color .15s, background .15s;
}

.bt-chip:active:not(:disabled) { transform: translateY(2px); border-bottom-width: 2px; }

.bt-chip.is-on {
  border-color: var(--brand-1);
  background: var(--gradient-soft);
  color: var(--brand-1);
}

.bt-chip:disabled { cursor: default; opacity: .5; }
.bt-chip__icon { font-size: 20px; line-height: 1.1; }
.bt-chip__note { font-size: 10px; font-weight: 700; color: var(--text-3); white-space: nowrap; }

@media (max-width: 380px) {
  .bt-chips--levels { grid-template-columns: repeat(3, 1fr); }
}

/* ------------------------------ Katta tugmalar ------------------------------ */

.bt-actions { display: flex; flex-direction: column; gap: 10px; align-items: stretch; }
.bt-actions--row { flex-direction: row; }
.bt-actions--row > * { flex: 1; }

.bt-big {
  font: inherit;
  font-weight: 900;
  font-size: 16px;
  min-height: 56px;
  padding: 12px 16px;
  border: 0;
  border-radius: var(--r-md);
  color: #fff;
  cursor: pointer;
  transition: transform .08s, box-shadow .08s, filter .15s;
}

.bt-big--online { background: var(--bt-grad); box-shadow: 0 5px 0 #4A36B8; }
.bt-big--friend { background: linear-gradient(135deg, #58CC02 0%, #3FB5A0 100%); box-shadow: 0 5px 0 #3E8F02; }
.bt-big--danger { background: var(--red); box-shadow: 0 5px 0 #C83434; }
.bt-big--ghost { background: var(--surface-2); color: var(--text); box-shadow: 0 5px 0 var(--border); }

.bt-big:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 1px 0 rgba(0, 0, 0, .2); }
.bt-big:disabled { filter: grayscale(.8); opacity: .55; cursor: default; }

.bt-rules { text-align: center; font-size: 12.5px; color: var(--text-3); margin: 0; }

/* ------------------------------ Xabar kartalari ------------------------------ */

.bt-notice { text-align: center; display: flex; flex-direction: column; gap: 12px; align-items: stretch; }
.bt-notice__icon { font-size: 54px; line-height: 1; }
.bt-notice__title { margin: 0; font-size: 20px; font-weight: 900; color: var(--text); line-height: 1.3; }
.bt-notice__text { margin: 0; color: var(--text-2); font-size: 15px; line-height: 1.45; }

.bt-invite__label {
  align-self: center;
  margin: 0;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--gradient-soft);
  color: var(--brand-1);
  font-weight: 800;
}

/* ------------------------------ Kutish ekrani ------------------------------ */

.bt-wait { text-align: center; display: flex; flex-direction: column; gap: 10px; align-items: stretch; padding: 26px 18px; }
.bt-wait__emoji { font-size: 48px; }
.bt-wait__title { margin: 0; font-size: 20px; font-weight: 900; color: var(--text); }
.bt-wait__sub { margin: 0; color: var(--brand-1); font-weight: 800; }
.bt-wait__hint { margin: 0; color: var(--text-2); font-size: 13px; }
.bt-wait__count { font-size: 34px; font-weight: 900; color: var(--text); font-variant-numeric: tabular-nums; }

.bt-radar { position: relative; width: 120px; height: 120px; margin: 4px auto 8px; }
.bt-radar span {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
}
.bt-radar span:nth-child(1),
.bt-radar span:nth-child(2) {
  border: 3px solid var(--brand-1);
  opacity: 0;
  animation: bt-ping 2s ease-out infinite;
}
.bt-radar span:nth-child(2) { animation-delay: 1s; }
.bt-radar span:nth-child(3) {
  inset: 30px;
  background: var(--bt-grad);
  font-size: 28px;
  box-shadow: var(--shadow-brand);
}

@keyframes bt-ping {
  0% { transform: scale(.4); opacity: .9; }
  100% { transform: scale(1); opacity: 0; }
}

.bt-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 34px;
  font-weight: 900;
  letter-spacing: 6px;
  padding: 10px;
  border-radius: var(--r-md);
  background: var(--gradient-soft);
  color: var(--brand-1);
  user-select: all;
}

/* ---------------------------------- O'yin ---------------------------------- */

.bt--game { gap: 12px; }

.bt-board {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-radius: var(--r-lg);
  background: var(--bt-grad-deep);
  color: #fff;
  box-shadow: var(--shadow-brand);
}

.bt-board__side { display: flex; align-items: center; gap: 8px; min-width: 0; }
.bt-board__side--me { justify-content: flex-end; }
.bt-board__name { font-weight: 800; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bt-board__score { font-size: 28px; font-weight: 900; font-variant-numeric: tabular-nums; }
.bt-board__q {
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .18);
  font-weight: 800;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.bt-tag { text-align: center; font-size: 12.5px; font-weight: 800; color: var(--text-2); }
.bt-tag__cur { color: var(--brand-1); }

.bt-timer {
  position: relative;
  height: 14px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, .06);
}

.bt-timer__bar {
  position: absolute;
  inset: 0;
  transform-origin: left center;
  background: var(--bt-grad);
  border-radius: inherit;
}

.bt-timer.is-danger .bt-timer__bar { background: var(--red); }

.bt-timer__num {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  font-weight: 900;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.bt-timer__num.is-danger { color: #fff; }

.bt-question {
  min-height: 96px;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 18px 14px;
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  font-size: 20px;
  font-weight: 800;
  line-height: 1.35;
  color: var(--text);
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.bt-options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.bt-opt {
  font: inherit;
  font-weight: 800;
  font-size: 16px;
  min-height: 64px;
  padding: 10px 8px;
  border-radius: var(--r-md);
  border: 2px solid var(--border);
  border-bottom-width: 5px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  overflow-wrap: anywhere;
  transition: transform .06s, background .15s, border-color .15s;
}

/* 3 variant: uchinchisi ikkala ustunni egallaydi (bo'sh katak qolmaydi) */
.bt-options--3 .bt-opt:last-child { grid-column: 1 / -1; }

.bt-opt:active:not(:disabled) { transform: translateY(3px); border-bottom-width: 2px; }
.bt-opt:disabled { cursor: default; }
.bt-opt:disabled:not(.is-correct):not(.is-wrong):not(.is-picked) { opacity: .6; }

.bt-opt.is-picked { border-color: var(--brand-1); background: var(--gradient-soft); }
.bt-opt.is-correct { border-color: var(--green-dark); background: var(--green); color: #fff; }
.bt-opt.is-wrong { border-color: #C83434; background: var(--red); color: #fff; animation: bt-shake .35s; }

@keyframes bt-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

@media (max-width: 360px) {
  .bt-options { grid-template-columns: 1fr; }
  .bt-opt { min-height: 54px; }
}

.bt-status {
  text-align: center;
  font-weight: 800;
  padding: 10px 12px;
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--text-2);
}
.bt-status.is-wrong { background: rgba(255, 75, 75, .12); color: var(--red); }
.bt-status.is-turn { background: var(--gold); color: #5A4300; animation: bt-pop .3s; }

.bt-banner {
  text-align: center;
  font-size: 20px;
  font-weight: 900;
  padding: 12px;
  border-radius: var(--r-md);
  animation: bt-pop .25s;
}
.bt-banner.is-me { background: var(--green); color: #fff; }
.bt-banner.is-opp { background: var(--bt-grad); color: #fff; }
.bt-banner.is-none { background: var(--surface-2); color: var(--text-2); }

@keyframes bt-pop {
  0% { transform: scale(.85); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.bt-countdown { display: grid; place-items: center; height: 220px; }
.bt-countdown span {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--bt-grad);
  color: #fff;
  font-size: 84px;
  font-weight: 900;
  box-shadow: var(--shadow-brand);
  animation: bt-pop .35s;
}
.bt-countdown__sub { text-align: center; margin: 0; font-weight: 800; color: var(--text-2); }

.bt-exit {
  align-self: center;
  margin-top: 6px;
  font: inherit;
  font-weight: 800;
  font-size: 13px;
  padding: 8px 16px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
}

/* O'yin paytida pastki menyu yashiriladi — tasodifan boshqa bo'limga o'tib
   ketmaslik uchun (chiqish faqat "Chiqish" tugmasi orqali, tasdiq bilan). */
body.bt-lock .tabbar { display: none; }
body.bt-lock .sidebar__nav { pointer-events: none; opacity: .4; }

/* ---------------------------------- Yakun ---------------------------------- */

.bt-final { text-align: center; display: flex; flex-direction: column; gap: 10px; align-items: stretch; position: relative; z-index: 1; }

.bt-final__mascot { position: relative; width: 120px; height: 120px; margin: 0 auto; }
.bt-final__mascot img { width: 100%; height: 100%; object-fit: contain; }
.bt-final__fallback { display: none; font-size: 80px; line-height: 120px; }
.bt-final__mascot.is-missing img { display: none; }
.bt-final__mascot.is-missing .bt-final__fallback { display: block; }

.is-win .bt-final__mascot { animation: bt-jump .8s ease-in-out infinite alternate; }
.is-loss .bt-final__mascot { filter: grayscale(1) brightness(.9); transform: rotate(-8deg); }

@keyframes bt-jump {
  from { transform: translateY(0) rotate(-4deg); }
  to { transform: translateY(-10px) rotate(4deg); }
}

.bt-final__score {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  font-size: 40px;
}
.bt-final__score b { font-size: 44px; font-weight: 900; color: var(--text); font-variant-numeric: tabular-nums; }

.bt-final__names {
  display: flex;
  justify-content: center;
  gap: 64px;
  margin-top: -6px;
  font-weight: 800;
  font-size: 13px;
  color: var(--text-2);
}

.bt-final__note { margin: 0; font-size: 13px; font-weight: 800; color: var(--text-2); }
.bt-final__text { margin: 4px 0; font-size: 16px; line-height: 1.45; font-weight: 700; color: var(--text); }

.bt-rematch__hint { margin: 0; font-size: 13.5px; font-weight: 800; color: var(--text-2); }
.bt-rematch__hint.is-hot { color: var(--orange); animation: bt-pop .3s; }

.bt-confetti { position: absolute; inset: -40px 0 0; pointer-events: none; overflow: hidden; z-index: 2; }
.bt-confetti i {
  position: absolute;
  top: -12px;
  width: 8px;
  height: 14px;
  border-radius: 2px;
  opacity: 0;
  animation-name: bt-fall;
  animation-timing-function: ease-in;
  animation-fill-mode: forwards;
}

@keyframes bt-fall {
  0% { transform: translateY(0) rotate(0); opacity: 1; }
  100% { transform: translateY(560px) rotate(540deg); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .bt-confetti, .bt-radar span:nth-child(1), .bt-radar span:nth-child(2) { display: none; }
  .is-win .bt-final__mascot, .bt-opt.is-wrong { animation: none; }
}

/* ------------------------------ Tasdiq oynasi ------------------------------ */

.bt-confirm { text-align: center; display: flex; flex-direction: column; gap: 14px; padding: 6px 0 4px; }
.bt-confirm__icon { font-size: 48px; }
.bt-confirm h3 { margin: 0; font-size: 18px; font-weight: 900; color: var(--text); }

/* --------------------------- Kod bilan kirish --------------------------- */

.bt-join { display: flex; flex-direction: column; gap: 8px; padding: 16px 18px; }
.bt-join .bt-step__title { margin-bottom: 0; }
.bt-join__hint { margin: 0; font-size: 13px; color: var(--text-2); }
.bt-join__row { display: flex; gap: 8px; }
.bt-join__input {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 4px;
  text-transform: uppercase;
  text-align: center;
  padding: 10px 12px;
  border-radius: var(--r-md);
  border: 2px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  outline: none;
}
.bt-join__input:focus { border-color: var(--brand-1); }
.bt-join__input::placeholder { color: var(--text-3); opacity: .6; }
.bt-join__btn { flex: 0 0 auto; min-height: 52px; padding: 10px 20px; }
