@font-face {
  font-family: 'Iranian Sans';
  src: url('/fonts/IranianSans.woff2') format('woff2'), url('/fonts/IranianSans.woff') format('woff');
  font-weight: 400;
  font-style: normal;
}

/* ── MAFIA BATTLE brand palette ── */
:root {
  --brand-bg: #0E0E0F;
  --brand-surface: #1C1C1E;
  --brand-surface-2: #2B2B2D;
  --brand-line: rgba(255, 255, 255, 0.10);
  --brand-text: #EDEDED;
  --brand-muted: #A6A6A6;
  --brand-red: #B80E13;
  --brand-red-deep: #7d0a0e;
  --brand-red-bright: #e0474b;
  --bottom-nav-h: 100px;
  --bottom-nav-clearance: calc(var(--bottom-nav-h) + 12px + env(safe-area-inset-bottom, 0px));
  /* Frame art sits outside the avatar circle (hollow ring around the face). */
  --avatar-frame-scale: 1.52;
  /* Portrait size inside a framed wrap — ~5% ornament overlap into the face. */
  --avatar-frame-face: 95%;
  /* Phones/tablets: full width. Desktop (≥1025px): centered 480px frame. */
  --app-frame-max-width: 100%;
  --app-frame-left: 0px;
}

@media (min-width: 1025px) {
  :root {
    --app-frame-max-width: 480px;
    --app-frame-left: max(0px, calc(50% - var(--app-frame-max-width) / 2));
  }
  .app-bg-video {
    max-width: 480px;
    margin: 0 auto;
  }
}



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

html, body {
  margin: 0;
  padding: 0;
  touch-action: manipulation;
  overscroll-behavior: none;
  overscroll-behavior-y: none;
}

.app-body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: 'Iranian Sans', Tahoma, sans-serif;
  background: #0E0E0F;
  color: #EDEDED;
  display: flex;
  flex-direction: column;
  /* Side safe-areas only (top inset lives on the HUD bar). */
  padding:
    0
    env(safe-area-inset-right, 0px)
    0
    env(safe-area-inset-left, 0px);
}

.app-body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(14, 14, 15, 0.45) 0%, rgba(14, 14, 15, 0.82) 60%, #0E0E0F 100%),
    radial-gradient(ellipse 90% 55% at 50% -5%, rgba(184, 14, 19, 0.22), transparent),
    radial-gradient(ellipse 50% 40% at 50% 100%, rgba(184, 14, 19, 0.08), transparent);
  pointer-events: none;
  z-index: 2;
}

.app-shell {
  position: relative;
  z-index: 3;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0;
  min-height: 100dvh;
  width: 100%;
  max-width: var(--app-frame-max-width);
  margin: 0 auto;
  overflow-x: clip;
  /* Collapse whitespace text nodes between header / main / footer. */
  font-size: 0;
  line-height: 0;
}

.app-shell > .app-top-bar,
.app-shell > .app-main,
.app-shell > .app-bottom-nav {
  font-size: 1rem;
  line-height: normal;
}

.app-shell > .app-top-bar {
  position: relative;
  z-index: 4;
}

.app-shell > .app-main {
  position: relative;
  z-index: 3;
}

/* ── Header / game HUD bar ── */
.app-top-bar.app-hud-bar {
  display: grid;
  padding: 0 20px;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
  gap: 4px;
  /* Flush to viewport top; pad for notch so chip content stays clear. */
  background:url("/icons/bg-items.webp") center / 100% 100% no-repeat !important;
  border: 1.5px solid rgba(255, 255, 255, 0.1);
  box-shadow:
    0 10px 28px rgba(0, 0, 0, 0.48),
    inset 0 1px 0 rgba(255, 255, 255, 0.07),
    inset 0 -2px 0 rgba(184, 14, 19, 0.22);
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}

.app-hud-bar::before {
  content: "";
  position: absolute;
  top: 0;
  left: 10%;
  right: 10%;
  height: 2px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(224, 71, 75, 0.15) 15%,
    var(--brand-red-bright) 50%,
    rgba(224, 71, 75, 0.15) 85%,
    transparent 100%
  );
  pointer-events: none;
}

.app-hud-bar::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 70% 80% at 50% -30%, rgba(184, 14, 19, 0.14), transparent 55%);
  pointer-events: none;
}

.app-header-slot {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 0;
  max-width: 100%;
  padding: 0;
  background: none;
  border: none;
  text-decoration: none;
  color: inherit;
  font-family: inherit;
  touch-action: manipulation;
  transition: transform 0.14s ease, filter 0.14s ease;
}

.app-header-slot--profile {
  justify-self: start;
  cursor: pointer;
}

.app-header-slot--clan {
  justify-self: end;
}

.app-header-slot--gems {
  justify-self: center;
  align-self: center;
  padding-bottom: 14px;
  position: relative;
}

.gem-transfer-dot {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #e53935;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.4), 0 0 6px rgba(229, 57, 53, 0.6);
  pointer-events: none;
}

.gem-transfer-dot[hidden] {
  display: none;
}

.hud-slot:hover,
.hud-slot:focus-visible {
  filter: brightness(1.06);
  outline: none;
}

.hud-slot:active {
  transform: scale(0.97);
}

.hud-slot-plate {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  border: 1.5px solid rgba(255, 255, 255, 0.12);
}

.hud-slot-plate--profile {
  width: 92px;
  height: 92px;
  padding: 5px;
  border-color: rgba(184, 14, 19, 0.45);
}

.hud-slot-plate--gems {
  flex-direction: row;
  gap: 8px;
  min-width: 96px;
  height: 48px;
  padding: 0 16px;
  border-color: rgba(72, 168, 255, 0.35);
  background:
    linear-gradient(165deg, #1a2838 0%, #121820 55%, #0e1218 100%);
  box-shadow:
    0 5px 16px rgba(0, 0, 0, 0.42),
    0 0 18px rgba(56, 160, 255, 0.12),
    inset 0 1px 0 rgba(140, 210, 255, 0.14);
}

.hud-slot-plate--clan {
  width: 58px;
  height: 58px;
  border: none !important;
}

.clan-chip--list .hud-slot-plate--clan {
  border-style: dashed;
}

.hud-slot-caption {
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: min(30vw, 108px);
  min-height: 20px;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.hud-slot-caption--muted {
  background: rgba(0, 0, 0, 0.35);
  border-color: rgba(72, 168, 255, 0.15);
}

.hud-slot-caption-text {
  font-size: 10px;
  font-weight: 700;
  color: #7ec8ff;
  letter-spacing: 0.04em;
}

.header-slot-label {
  font-size: 11px;
  font-weight: 700;
  color: #f2f2f2;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
  line-height: 1.25;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.65);
}

.header-clan-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 61px;
  height: 61px;
  font-size: 34px;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.45));
}

.header-clan-logo {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  display: block;
  object-fit: cover;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.clan-logo-wrap--header {
  position: relative;
  display: inline-block;
  width: 68px;
  height: 68px;
  flex-shrink: 0;
}

.clan-logo-wrap--header .clan-logo-img {
  position: absolute;
  top: 48%;
  left: 50%;
  width: 80%;
  height: 80%;
  transform: translate(-50%, -50%);
  object-fit: contain;
  filter: drop-shadow(0 0 6px rgba(184, 14, 19, 0.55));
}

.clan-logo-wrap--header .clan-logo-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  object-fit: contain;
}

.clan-chip {
  max-width: min(34vw, 120px);
}

.user-chip-btn {
  cursor: pointer;
  font-family: inherit;
  color: inherit;
}

.chip-avatar-wrap {
  position: relative;
  display: inline-block;
  width: 75px;
  height: 75px;
  flex-shrink: 0;
  overflow: visible;
}

.chip-avatar-frame {
  position: absolute;
  top: 50%;
  left: 50%;
  width: calc(100% * var(--avatar-frame-scale, 1.52));
  height: calc(100% * var(--avatar-frame-scale, 1.52));
  max-width: none;
  max-height: none;
  transform: translate(-50%, -50%);
  border-radius: 0;
  object-fit: contain;
  pointer-events: none;
  z-index: 2;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.5));
}

.chip-avatar-img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  position: relative;
  z-index: 1;
  background: #000;
  box-shadow:
    0 2px 8px rgba(0, 0, 0, 0.45),
    inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.chip-avatar-wrap.has-frame .chip-avatar-img,
.chip-avatar-wrap.has-frame video.chip-avatar-img {
  width: var(--avatar-frame-face, 95%);
  height: var(--avatar-frame-face, 95%);
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

video.chip-avatar-img {
  pointer-events: none;
}

.gem-icon {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  object-fit: contain;
  filter: drop-shadow(0 0 6px rgba(100, 200, 255, 0.75));
}

.gem-count {
  font-size: 14px;
  font-weight: 800;
  color: #c8ecff;
  min-width: 1ch;
  letter-spacing: 0.02em;
  text-shadow:
    0 0 10px rgba(80, 190, 255, 0.45),
    0 1px 2px rgba(0, 0, 0, 0.6);
  font-variant-numeric: tabular-nums;
}

@media (max-width: 360px) {
  .app-hud-bar:not(.app-hud-bar--redesign) {
    padding: max(8px, env(safe-area-inset-top, 0px)) 6px 10px;
    gap: 2px;
  }

  .hud-slot-plate--profile {
    width: 82px;
    height: 82px;
  }

  .chip-avatar-wrap {
    width: 68px;
    height: 68px;
  }

  .hud-slot-plate--gems {
    min-width: 84px;
    height: 44px;
    padding: 0 12px;
  }

  .header-clan-logo {
    width: 58px;
    height: 58px;
  }

  .hud-slot-caption {
    max-width: min(28vw, 88px);
    padding: 2px 8px;
  }

  .header-slot-label {
    font-size: 10px;
  }
}

/* ── Main content area ── */
.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  margin: 0;
  padding: 0;
  gap: 0;
}

.app-main--menu {
  align-items: stretch;
  justify-content: flex-start;
  gap: 0;
  padding: 0;
  margin: 0;
}

.app-main--page {
  overflow-x: clip;
  overflow-y: auto;
  overscroll-behavior: none;
  overscroll-behavior-y: none;
  max-width: 100%;
  min-width: 0;
  margin: 0;
  padding: 0;
  gap: 0;
}

.app-main--lobby-list {
  min-height: 0;
  overflow: hidden;
  overscroll-behavior: none;
  overscroll-behavior-y: none;
}

/* ── Page content loader (header/footer stay visible) ── */
.app-page-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  width: 100%;
}

/* Menu page lays out its buttons through the content wrapper */
.app-main--menu .app-page-content {
  align-items: center;
  justify-content: center;
  gap: 14px;
}

.app-page-loader {
  display: none;
  flex: 1;
  align-items: center;
  justify-content: center;
  min-height: 220px;
  padding: 32px 16px;
}

.app-page-loader-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.app-page-loader-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.12);
  border-top-color: var(--brand-red-bright);
  border-radius: 50%;
  animation: app-page-spin 0.75s linear infinite;
}

.app-page-loader-text {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--brand-muted);
}

.app-main.is-page-loading .app-page-loader {
  display: flex;
}

.app-main.is-page-loading .app-page-content {
  display: none;
}

@keyframes app-page-spin {
  to {
    transform: rotate(360deg);
  }
}

.app-page-title {
  margin: 14px 0 5px;
  font-size: 1.35rem;
  font-weight: 700;
  color: #EDEDED;
  letter-spacing: 0.01em;
}

h1.app-page-title::after {
  content: "";
  display: block;
  width: 44px;
  height: 3px;
  margin-top: 8px;
  background: #B80E13;
}

img.app-page-title {
  display: block;
  width: min(100%, 360px);
  height: auto;
  margin-left: auto;
  margin-right: auto;
  object-fit: contain;
  opacity: 0.9;
}

.app-page-placeholder {
  margin: 0;
  color: var(--brand-muted);
  font-size: 15px;
  line-height: 1.7;
  text-align: center;
  padding: 8px 12px 24px;
}

/* ── Main menu (home) ── */
.menu-btn {
  width: min(100%, 300px);
  padding: 18px 24px;
  font-family: inherit;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  color: #fff;
  text-decoration: none;
  text-align: center;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

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

.menu-btn.start {
  background: linear-gradient(180deg, #22884a 0%, #1a6840 100%);
  border: 1px solid rgba(120, 230, 160, 0.45);
}

.menu-btn.start:hover {
  filter: brightness(1.08);
}

.menu-btn.watch,
.menu-btn.history,
.menu-btn.start-game-option {
  background: linear-gradient(180deg, #26262a 0%, #18181a 100%);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: rgba(237, 237, 237, 0.95);
}

.menu-btn.watch:hover,
.menu-btn.history:hover,
.menu-btn.start-game-option:hover {
  filter: brightness(1.08);
}

.menu-btn.start-game-option--enter {
  background: linear-gradient(180deg, #22884a 0%, #1a6840 100%);
  border: 1px solid rgba(120, 230, 160, 0.45);
  color: #fff;
}

.start-game-modal {
  max-width: 100%;
  width: 100%;
}

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

.start-game-actions .menu-btn {
  width: 100%;
  text-decoration: none;
  box-sizing: border-box;
}

.nav-quest-dot {
  position: absolute;
  top: 6px;
  left: 50%;
  margin-left: -18px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #e53935;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.35);
  display: none;
}

.nav-item--quests.has-claimable .nav-quest-dot {
  display: block;
}

.nav-clan-dot {
  position: absolute;
  top: 6px;
  left: 50%;
  margin-left: -18px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #e53935;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.35);
  display: none;
}

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

.menu-btn.start.is-banned {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.ban-notice {
  width: min(100%, 300px);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 16px;
  background: linear-gradient(180deg, rgba(184, 14, 19, 0.28) 0%, rgba(125, 10, 14, 0.32) 100%);
  border: 1px solid rgba(224, 71, 75, 0.55);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}

.ban-notice[hidden] {
  display: none !important;
}

.ban-notice-icon {
  flex-shrink: 0;
  font-size: 20px;
  line-height: 1.5;
}

.ban-notice-text {
  margin: 0;
  font-size: 14px;
  line-height: 1.65;
  color: #ffd0d0;
  text-align: right;
}

/* ── Footer nav ── */
.app-bottom-nav {
  position: sticky;
  bottom: 0;
  width: 100%;
  max-width: none;
  margin-top: auto;
  z-index: 50;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  flex-shrink: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.10);
  background: linear-gradient(180deg, rgba(28, 28, 30, 0.95) 0%, rgba(14, 14, 15, 0.98) 100%);
  border-radius: 0;
  min-height: calc(68px + env(safe-area-inset-bottom, 0px));
  box-sizing: border-box;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 4px 0 10px 0;
  color: #bbb;
  text-decoration: none;
  font-size: 12px;
  font-weight: 700;
  transition: background 0.12s, color 0.12s;
  position: relative;
  border: 0;
  background: transparent;
  font-family: inherit;
  cursor: pointer;
  width: 100%;
  min-height: 72px;
}

.nav-item:hover,
.nav-item:focus-visible {
  background: rgba(255, 255, 255, 0.06);
  color: #EDEDED;
  outline: none;
}

.nav-item.is-active {
  color: #e0474b;
  background: rgba(184, 14, 19, 0.16);
}

.nav-item .nav-icon {
  width: 42px;
  flex-shrink: 0;
  object-fit: contain;
}

.nav-item-wrap {
  position: relative;
  display: flex;
  align-items: stretch;
}

/* ── Background music consent ── */
.app-music-consent-modal {
  max-width: 340px;
  width: min(100%, 340px);
  text-align: center;
}

.app-music-consent-text {
  margin: 0 0 18px;
  color: var(--brand-muted);
  font-size: 14px;
  line-height: 1.7;
}

.app-music-consent-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.app-music-consent-btn {
  width: 100%;
  padding: 12px 16px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid transparent;
}

.app-music-consent-btn--yes {
  background: linear-gradient(180deg, #22884a 0%, #1a6840 100%);
  color: #fff;
  border-color: rgba(120, 230, 160, 0.45);
}

.app-music-consent-btn--no {
  background: #1c1c1e;
  color: #bbb;
  border-color: rgba(255, 255, 255, 0.12);
}
