/**
 * Mafia Battle — AAA mobile shell theme (mockup-aligned)
 * Black / gold / purple + Persepolis motifs. Lobby/in-game untouched.
 */

:root {
  --p-bg: #05040a;
  --p-bg-deep: #0a0712;
  --p-surface: #12101c;
  --p-surface-2: #1a1528;
  --p-surface-raised: #241c38;
  --p-purple: #5b2d9e;
  --p-purple-mid: #7b45c9;
  --p-purple-bright: #a56ef0;
  --p-purple-glow: rgba(123, 69, 201, 0.45);
  --p-gold: #e0b83a;
  --p-gold-light: #ffd56a;
  --p-gold-dark: #9a7418;
  --p-gold-deep: #5c4510;
  --p-gold-glow: rgba(224, 184, 58, 0.45);
  --p-cream: #fff4d8;
  --p-text: #f7f2ea;
  --p-text-muted: #b0a3c4;
  --p-line: rgba(224, 184, 58, 0.28);
  --p-line-purple: rgba(165, 110, 240, 0.28);
  --p-gem: #6ec8ff;

  --brand-bg: var(--p-bg);
  --brand-surface: var(--p-surface);
  --brand-surface-2: var(--p-surface-2);
  --brand-line: var(--p-line);
  --brand-text: var(--p-text);
  --brand-muted: var(--p-text-muted);
  --brand-red: var(--p-gold-dark);
  --brand-red-deep: var(--p-gold-deep);
  --brand-red-bright: var(--p-gold-light);

  --bottom-nav-h: 68px;
  --radius-card: 0;
  --radius-btn: 0;
  --shadow-card: 0 12px 36px rgba(0, 0, 0, 0.55);
}

.app-body::before {
  background: linear-gradient(
    180deg,
    rgba(5, 4, 10, 0.12) 0%,
    transparent 45%,
    transparent 100%
  );
}

/* Lobby / watch list: stronger fade for list readability */
body:has(main.app-main--lobby-list) .app-body::before {
  background:
    linear-gradient(180deg, rgba(5, 4, 10, 0.2) 0%, rgba(5, 4, 10, 0.75) 70%, var(--p-bg) 100%);
}

/* ── Redesign HUD header ── */
.app-top-bar.app-hud-bar--redesign {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: -1px 0 0 0;
  padding: env(safe-area-inset-top, 0px) 12px 8px;
  max-width: 100%;
  overflow: visible;
  box-sizing: border-box;
  border-bottom: none;
  box-shadow: inset 0 1px 0 rgba(255, 213, 106, 0.12);
  min-height:70px;
}

.app-hud-bar--redesign::before {
  height: 1.5px;
  background: linear-gradient(90deg, transparent, var(--p-gold-light), transparent);
}

.app-hud-bar--redesign::after {
  background: radial-gradient(ellipse 80% 90% at 50% -40%, var(--p-purple-glow), transparent 55%);
}

.hud-profile-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
  padding: 0;
  border: none;
  background: none;
  color: inherit;
  font-family: inherit;
  cursor: pointer;
  text-align: right;
}

.hud-profile-avatar {
  position: relative;
  flex-shrink: 0;
  width: 48px;
  height: 48px;
}

.hud-profile-avatar .chip-avatar-wrap {
  width: 42px;
  height: 42px;
}

.hud-profile-avatar .chip-avatar-img,
.hud-profile-avatar video.chip-avatar-img {
  width: 100%;
  height: 100%;
}

.hud-profile-avatar .chip-avatar-frame {
  width: calc(100% * var(--avatar-frame-scale, 1.52));
  height: calc(100% * var(--avatar-frame-scale, 1.52));
}

.hud-profile-meta {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  flex: 1;
}

.hud-profile-name {
  font-size: 12px;
  font-weight: 800;
  color: var(--p-cream);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.65);
}

.hud-profile-level-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.hud-profile-level {
  flex-shrink: 0;
  min-width: 22px;
  height: 18px;
  padding: 0 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 900;
  color: #1a1205;
  background: linear-gradient(180deg, var(--p-gold-light), var(--p-gold));
  border: 1px solid rgba(255, 213, 106, 0.6);
}

.hud-profile-xp-bar {
  position: relative;
  flex: 1;
  min-width: 48px;
  height: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(224, 184, 58, 0.25);
  overflow: hidden;
}

.hud-profile-xp-fill {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 0;
  background: linear-gradient(90deg, var(--p-gold-dark), var(--p-gold-light));
  box-shadow: 0 0 8px var(--p-gold-glow);
  z-index: 1;
  pointer-events: none;
}

.hud-profile-xp-text {
  position: relative;
  z-index: 2;
  font-size: 7px;
  font-weight: 800;
  color: var(--p-cream);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  line-height: 1;
  padding: 0 4px;
  text-shadow:
    0 1px 2px rgba(0, 0, 0, 0.95),
    0 0 4px rgba(0, 0, 0, 0.65);
  pointer-events: none;
}

.hud-actions-cluster {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.hud-gem-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 34px;
  padding: 0 8px 0 6px;
  text-decoration: none;
  color: inherit;
  border: 1px solid rgba(110, 200, 255, 0.35);
  background: linear-gradient(180deg, #1a2740 0%, #0d1420 100%);
  box-shadow: 0 0 14px rgba(110, 200, 255, 0.15);
}

.hud-gem-chip .gem-icon {
  width: 20px;
  height: 20px;
}

.hud-gem-chip .gem-count {
  color: var(--p-gem);
  font-size: 12px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.hud-icon-btn {
  position: relative;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid rgba(224, 184, 58, 0.3);
  background: #141414;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  touch-action: manipulation;
}

.hud-icon-btn img {
  width: 22px;
  height: 22px;
  object-fit: contain;
}

/* ── Bottom nav — 5 tabs ── */
.app-bottom-nav--redesign {
  position: relative;
  gap: 2px;
  grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
  min-height: calc(76px + env(safe-area-inset-bottom, 0px));
  padding:
    clamp(6px, 1.6vw, 10px)
    clamp(4px, 1.2vw, 8px)
    env(safe-area-inset-bottom, 0px);
  max-width: 100%;
  flex-shrink: 0;
  box-sizing: border-box;
  border-top: none;
  background: url("/icons/nav-items-bg.webp") center / 100% 100% no-repeat;
}

.app-bottom-nav--redesign .nav-item {
  font-size: 9px;
  gap: 3px;
  min-height: 60px;
}

.app-bottom-nav--redesign .nav-icon-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  flex-shrink: 0;
}

.app-bottom-nav--redesign .nav-icon {
  width: 46px !important;
  height: 46px;
  filter: none !important;
  opacity: 0.85;
}

.app-bottom-nav--redesign .nav-icon-wrap--profile {
  width: clamp(46px, 12vw, 52px);
  height: clamp(46px, 12vw, 52px);
}

.app-bottom-nav--redesign .nav-profile-icon {
  width: clamp(42px, 11vw, 48px) !important;
  height: clamp(42px, 11vw, 48px);
  object-fit: contain;
  filter: drop-shadow(0 0 4px rgba(224, 184, 58, 0.25));
}

.app-bottom-nav--redesign .nav-quest-dot {
  position: absolute;
  top: 0;
  left: 0;
  margin: 0;
  width: 9px;
  height: 9px;
  min-width: 9px;
  min-height: 9px;
  padding: 0;
  border-radius: 50% !important;
  aspect-ratio: 1;
  box-sizing: border-box;
}

.app-bottom-nav--redesign .nav-clan-dot {
  position: absolute;
  top: 0;
  left: 0;
  margin: 0;
  width: 9px;
  height: 9px;
  min-width: 9px;
  min-height: 9px;
  padding: 0;
  border-radius: 50% !important;
  aspect-ratio: 1;
  box-sizing: border-box;
  display: none;
}

.app-bottom-nav--redesign .nav-item--clan.has-unread-messages .nav-clan-dot {
  display: block;
}

.app-bottom-nav--redesign .nav-item.is-active {
  color: var(--p-gold-light);
  background: linear-gradient(
    180deg,
    rgba(8, 6, 12, 0.50) 0%,
    rgba(20, 15, 8, 0.50) 65%,
    rgba(92, 69, 16, 0.30) 100%
  )
}

.app-bottom-nav--redesign .nav-item.is-active .nav-icon {
  opacity: 1;
  filter: drop-shadow(0 0 6px var(--p-gold-glow)) !important;
}

.nav-quest-dot,
.nav-clan-dot,
.gem-transfer-dot {
  background: #e53935;
  width: 9px;
  height: 9px;
  min-width: 9px;
  min-height: 9px;
  padding: 0;
  border-radius: 50% !important;
  aspect-ratio: 1;
  box-sizing: border-box;
}

.app-bottom-nav--redesign .nav-icon-wrap--clan {
  width: clamp(46px, 12vw, 52px);
  height: clamp(46px, 12vw, 52px);
}

.app-bottom-nav--redesign .nav-clan-icon {
  width: clamp(42px, 11vw, 48px) !important;
  height: clamp(42px, 11vw, 48px);
  object-fit: contain;
  filter: drop-shadow(0 0 4px rgba(224, 184, 58, 0.25));
}

.app-bottom-nav--redesign .nav-item--clan {
  justify-content: center;
}

/* ── Mobile / narrow viewport — header + footer ── */
@media (max-width: 420px) {
  .app-top-bar.app-hud-bar--redesign {
    gap: 6px;
    padding-top: env(safe-area-inset-top, 0px);
    padding-left: max(8px, env(safe-area-inset-left, 0px));
    padding-right: max(8px, env(safe-area-inset-right, 0px));
  }

  .hud-profile-chip {
    gap: 6px;
    min-width: 0;
    max-width: calc(100% - 118px);
  }

  .hud-profile-avatar {
    width: 42px;
    height: 42px;
  }

  .hud-profile-avatar .chip-avatar-wrap {
    width: 36px;
    height: 36px;
  }

  .hud-profile-name {
    font-size: 11px;
  }

  .hud-profile-level-row {
    gap: 4px;
  }

  .hud-profile-xp-bar {
    min-width: 40px;
    height: 13px;
  }

  .hud-profile-xp-text {
    font-size: 6.5px;
  }

  .hud-actions-cluster {
    gap: 4px;
    flex-shrink: 0;
  }

  .hud-gem-chip {
    min-height: 32px;
    padding: 0 6px 0 4px;
    gap: 3px;
  }

  .hud-gem-chip .gem-icon {
    width: 18px;
    height: 18px;
  }

  .hud-gem-chip .gem-count {
    font-size: 11px;
    max-width: 52px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .hud-icon-btn {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
  }

  .hud-icon-btn img {
    width: 18px;
    height: 18px;
  }
}

@media (max-width: 360px) {
  .hud-profile-chip {
    max-width: calc(100% - 108px);
  }

  .hud-gem-chip .gem-count {
    max-width: 40px;
  }
}

@media (max-width: 320px) {
  .hud-profile-avatar {
    width: 38px;
    height: 38px;
  }

  .hud-profile-avatar .chip-avatar-wrap {
    width: 32px;
    height: 32px;
  }

  .hud-profile-name {
    font-size: 10px;
  }

  .hud-profile-level {
    min-width: 18px;
    height: 16px;
    font-size: 9px;
  }

  .hud-profile-xp-bar {
    height: 12px;
  }

  .hud-profile-xp-text {
    font-size: 6px;
    padding: 0 2px;
  }
}

/* Bottom nav — fit 5 tabs on small screens */
.app-bottom-nav--redesign .nav-label {
  display: block;
  max-width: 100%;
  padding: 0 1px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: clamp(7px, 2.1vw, 9px);
  line-height: 1.2;
}

.app-bottom-nav--redesign .nav-item {
  min-height: 56px;
  padding: 6px 0 16px;
  min-width: 0;
}

.app-bottom-nav--redesign .nav-icon-wrap {
  width: clamp(42px, 12vw, 52px);
  height: clamp(42px, 12vw, 52px);
  flex-shrink: 0;
}

.app-bottom-nav--redesign .nav-icon {
  width: clamp(38px, 11vw, 46px) !important;
  height: clamp(38px, 11vw, 46px);
}

.app-bottom-nav--redesign .nav-icon-wrap--profile {
  width: clamp(42px, 11vw, 48px);
  height: clamp(42px, 11vw, 48px);
}

@media (max-width: 360px) {
  .app-bottom-nav--redesign {
    min-height: calc(68px + env(safe-area-inset-bottom, 0px));
  }

  .app-bottom-nav--redesign .nav-item {
    min-height: 52px;
  }
}

@media (max-height: 640px) {
  .app-bottom-nav--redesign .nav-item {
    min-height: 56px;
  }
}

/* ── Shared AAA buttons ── */
.mb-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 48px;
  padding: 12px 16px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 800;
  text-decoration: none;
  text-align: center;
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform 0.12s ease, filter 0.12s ease, box-shadow 0.12s ease;
}

.mb-btn:active {
  transform: scale(0.98);
}

.mb-btn--gold {
  color: #1a1205;
  background: linear-gradient(180deg, #ffe08a 0%, #e0b83a 40%, #9a7418 100%);
  border-color: rgba(255, 213, 106, 0.7);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4), 0 0 24px var(--p-gold-glow);
}

.mb-btn--purple {
  color: #fff;
  background: linear-gradient(180deg, #8b52d6 0%, #5b2d9e 55%, #3a1a6a 100%);
  border-color: rgba(165, 110, 240, 0.55);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4), 0 0 20px var(--p-purple-glow);
}

.mb-btn--ghost {
  color: var(--p-cream);
  background: linear-gradient(180deg, rgba(36, 28, 56, 0.9), rgba(14, 10, 22, 0.95));
  border-color: var(--p-line);
}

/* ── Page titles ── */
.app-page-title {
  color: var(--p-cream);
  text-align: center;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.55);
}

h1.app-page-title::after {
  width: 72px;
  height: 2px;
  margin: 10px auto 0;
  background: linear-gradient(90deg, transparent, var(--p-gold-light), transparent);
}

img.app-page-title {
  text-shadow: none;
}

/* Home layout lives in home-page.css */

/* Start modal */
.start-game-modal.mb-modal {
  max-width: 100%;
  width: 100%;
  background: transparent !important;
  border: none !important;
  box-shadow: none;
  padding: 0 16px;
}

.start-game-modal.mb-modal .modal-header {
  display: none;
}

.start-game-actions {
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
}

.mb-btn--lobby,
.mb-btn--watch {
  width: 100%;
  max-width: 340px;
  aspect-ratio: auto;
  min-height: 0;
  padding: 0;
  border: none;
  background: none;
  box-shadow: none;
}

.mb-btn--lobby {
  background: url("/views/images/buttons/lobbyList_button.png") center / contain no-repeat;
  height: 72px;
  animation: startBtnSlideIn 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.mb-btn--watch {
  background: url("/views/images/buttons/watchList_button.png") center / contain no-repeat;
  height: 72px;
  animation: startBtnSlideIn 0.45s cubic-bezier(0.22, 1, 0.36, 1) 0.12s both;
}

@keyframes startBtnSlideIn {
  from {
    opacity: 0;
    transform: translateY(-24px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Legacy menu-btn hooks still used elsewhere */
.menu-btn.start {
  display: none;
}

/* ══════════════════════════════════════
   Shared ornate cards
══════════════════════════════════════ */
.shop-page,
.settings-section,
.support-section,
.ranking-row,
.lobby-card:not(.lobby-card--custom-bg),
.clan-card {
  border-color: var(--p-line) !important;
  background: url("/icons/bg-items.webp") center / 100% 100% no-repeat !important;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4) !important;
}

.legal-tab.is-active {
  border-color: rgba(224, 184, 58, 0.55) !important;
  background: url("/icons/bg-items.webp") center / 100% 100% no-repeat !important;
  color: var(--p-gold-light) !important;
  box-shadow: 0 0 16px rgba(91, 45, 158, 0.35) !important;
}

.shop-purchase-btn,
.support-submit-btn,
.clans-action-btn:not(:disabled) {
  background: linear-gradient(180deg, #ffe08a 0%, #e0b83a 40%, #9a7418 100%) !important;
  border: 1px solid rgba(255, 213, 106, 0.7) !important;
  color: #1a1205 !important;
  box-shadow: 0 0 20px var(--p-gold-glow) !important;
  font-weight: 800 !important;
  min-height: 36px;
}

.lobby-create-btn {
  background: url("/icons/createnewgame.webp") center / 100% 100% no-repeat !important;
  border: none !important;
  box-shadow: none !important;
}

.settings-section-title,
.support-section-title,
.settings-section-title,
.support-section-title {
  color: var(--p-gold-light) !important;
}

.modal {
  background: url("/icons/bg-items.webp") center / 100% 100% no-repeat !important;
  border: 1.5px solid var(--p-line) !important;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6), 0 0 30px rgba(91, 45, 158, 0.2) !important;
}

.modal-title {
  color: var(--p-gold-light) !important;
  font-weight: 800 !important;
}

.app-page-loader-spinner {
  border-top-color: var(--p-gold-light);
  box-shadow: 0 0 12px var(--p-gold-glow);
  border-radius: 50% !important;
  aspect-ratio: 1;
  box-sizing: border-box;
}

/* ══════════════════════════════════════
   Ranking podium
══════════════════════════════════════ */
.ranking-podium {
  display: grid;
  grid-template-columns: 1fr 1.15fr 1fr;
  align-items: end;
  gap: 8px;
  margin: 8px 0 18px;
  padding: 18px 10px 12px;
  background:
    radial-gradient(ellipse 80% 60% at 50% 0%, rgba(91, 45, 158, 0.35), transparent 60%),
    linear-gradient(180deg, rgba(28, 21, 48, 0.75), rgba(10, 7, 18, 0.95));
  border: 1px solid var(--p-line);
}

.ranking-podium-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
  cursor: pointer;
  min-width: 0;
}

.ranking-podium-avatar {
  position: relative;
  width: 56px;
  height: 56px;
}

.ranking-podium-slot--1 .ranking-podium-avatar {
  width: 72px;
  height: 72px;
}

.ranking-podium-avatar img.ranking-avatar {
  width: calc(100% / var(--avatar-frame-scale, 1.52));
  height: calc(100% / var(--avatar-frame-scale, 1.52));
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  position: absolute;
  border-radius: 50%;
  object-fit: cover;
}

.ranking-podium-avatar img.ranking-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

.ranking-podium-slot--1 .ranking-podium-avatar {
  filter: drop-shadow(0 0 16px var(--p-gold-glow));
}

.ranking-podium-place {
  font-size: 12px;
  font-weight: 900;
  color: var(--p-gold-light);
}

.ranking-podium-name {
  font-size: 12px;
  font-weight: 800;
  color: var(--p-cream);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ranking-podium-points {
  font-size: 11px;
  color: var(--p-text-muted);
}

.ranking-podium-base {
  width: 100%;
  background: linear-gradient(180deg, #5b2d9e, #2a1848);
  border: 1px solid rgba(224, 184, 58, 0.35);
}

.ranking-podium-slot--2 .ranking-podium-base { height: 36px; }
.ranking-podium-slot--1 .ranking-podium-base {
  height: 52px;
  background: linear-gradient(180deg, #e0b83a, #9a7418);
}
.ranking-podium-slot--3 .ranking-podium-base { height: 28px; }

.ranking-podium-slot--3 .ranking-podium-score{
  color: #cb7f43;
}

.ranking-podium-slot--2 .ranking-podium-score{
  color: #cccccc;
}

.ranking-rank--top {
  color: var(--p-gold-light) !important;
  text-shadow: 0 0 10px var(--p-gold-glow);
}

.ranking-row:hover {
  border-color: rgba(224, 184, 58, 0.4) !important;
  background: rgba(36, 28, 56, 0.85) !important;
}

/* Shop gold frames */
.shop-card,
.shop-grid > * {
  border-color: rgba(224, 184, 58, 0.3) !important;
}

.lobby-card:hover {
  border-color: rgba(224, 184, 58, 0.45) !important;
  box-shadow: 0 0 20px rgba(91, 45, 158, 0.25) !important;
}

.history-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 14px;
  padding: 28px 16px 40px;
}

.history-placeholder-icon {
  width: 80px;
  height: 80px;
  filter: drop-shadow(0 0 16px var(--p-gold-glow));
}

.history-placeholder-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--p-cream);
}

.history-placeholder-text {
  margin: 0;
  font-size: 0.9rem;
  color: var(--p-text-muted);
  line-height: 1.65;
  max-width: 280px;
}

.history-back-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 22px;
  border: 1px solid var(--p-line);
  background: linear-gradient(180deg, rgba(91, 45, 158, 0.45), rgba(36, 28, 56, 0.9));
  color: var(--p-cream);
  text-decoration: none;
  font-weight: 800;
}

.ban-notice {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 4;
  width: min(calc(100% - 28px), 300px);
  background: linear-gradient(180deg, rgba(91, 45, 158, 0.35), rgba(60, 20, 20, 0.4)) !important;
  border-color: rgba(224, 184, 58, 0.4) !important;
}