@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: 92px;
  --bottom-nav-clearance: calc(var(--bottom-nav-h) + 12px + env(safe-area-inset-bottom, 0px));
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  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;
  padding:
    max(12px, env(safe-area-inset-top))
    max(14px, env(safe-area-inset-right))
    max(12px, env(safe-area-inset-bottom))
    max(14px, env(safe-area-inset-left));
}

.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: 0;
}

.app-bg-video {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  opacity: 0.3;
  z-index: 0;
}

.app-bg-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.15);
  pointer-events: none;
  z-index: 0;
}

.app-shell {
  position: relative;
  z-index: 1;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: calc(100dvh - max(12px, env(safe-area-inset-top)) - max(12px, env(safe-area-inset-bottom)));
  max-width: 480px;
  width: 100%;
  margin: 0 auto;
}

/* ── Header / game HUD bar ── */
.app-top-bar.app-hud-bar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
  gap: 4px;
  margin-bottom: 18px;
  padding: 10px 8px 12px;
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(35, 35, 38, 0.94) 0%, rgba(14, 14, 15, 0.98) 100%);
  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-legal-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  margin: -8px 0 14px;
  padding: 0 8px;
  flex-shrink: 0;
}

.app-legal-bar-link {
  border: none;
  background: none;
  padding: 4px 6px;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--brand-muted);
  cursor: pointer;
  text-decoration: none;
  transition: color 0.14s ease;
}

.app-legal-bar-link:hover,
.app-legal-bar-link:focus-visible {
  color: var(--brand-red-bright);
  outline: none;
  text-decoration: underline;
}

.app-legal-bar-sep {
  color: rgba(255, 255, 255, 0.22);
  font-size: 0.78rem;
  user-select: 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;
}

.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;
  background: linear-gradient(165deg, #2e2e32 0%, #18181a 55%, #101012 100%);
  border: 1.5px solid rgba(255, 255, 255, 0.12);
  box-shadow:
    0 5px 14px rgba(0, 0, 0, 0.42),
    inset 0 1px 0 rgba(255, 255, 255, 0.11);
}

.hud-slot-plate--profile {
  width: 92px;
  height: 92px;
  border-radius: 50%;
  padding: 5px;
  border-color: rgba(184, 14, 19, 0.45);
  background:
    radial-gradient(circle at 50% 28%, rgba(184, 14, 19, 0.28) 0%, transparent 58%),
    linear-gradient(165deg, #2a2224 0%, #141415 100%);
  box-shadow:
    0 5px 16px rgba(0, 0, 0, 0.45),
    0 0 0 1px rgba(184, 14, 19, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.hud-slot-plate--gems {
  flex-direction: row;
  gap: 8px;
  min-width: 96px;
  height: 48px;
  padding: 0 16px;
  border-radius: 14px;
  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: 88px;
  height: 88px;
  border-radius: 20px;
  border-color: rgba(184, 14, 19, 0.32);
  background:
    radial-gradient(circle at 50% 20%, rgba(184, 14, 19, 0.2) 0%, transparent 60%),
    linear-gradient(165deg, #2a2628 0%, #161618 100%);
}

.clan-chip--list .hud-slot-plate--clan {
  border-style: dashed;
  border-color: rgba(255, 255, 255, 0.16);
  background: linear-gradient(165deg, #242426 0%, #141415 100%);
}

.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;
  border-radius: 10px;
  object-fit: cover;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.clan-logo-wrap--header {
  position: relative;
  display: inline-block;
  width: 78px;
  height: 78px;
  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;
  width: 75px;
  height: 75px;
  flex-shrink: 0;
  overflow: visible;
}

.chip-avatar-frame {
  position: absolute;
  inset: -12px;
  width: calc(100% + 24px);
  height: calc(100% + 24px);
  max-width: none;
  max-height: none;
  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: 75px;
  height: 75px;
  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);
}

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: 17px;
  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 {
    padding: 8px 6px 10px;
    gap: 2px;
  }

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

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

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

  .hud-slot-plate--clan {
    width: 78px;
    height: 78px;
  }

  .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;
  padding-bottom: var(--bottom-nav-clearance);
}

.app-main--menu {
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 20px 0 calc(var(--bottom-nav-h) + 16px + env(safe-area-inset-bottom, 0px));
}

.app-main--page {
  padding-bottom: var(--bottom-nav-clearance);
  overflow-y: auto;
  overscroll-behavior: none;
  overscroll-behavior-y: none;
}

.app-main--lobby-list {
  padding-bottom: var(--bottom-nav-clearance);
  min-height: 0;
  overflow-y: auto;
  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: 0 0 16px;
  font-size: 1.35rem;
  font-weight: 700;
  color: #EDEDED;
  letter-spacing: 0.01em;
}

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

.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;
  border-radius: 16px;
  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 {
  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 {
  filter: brightness(1.08);
}

.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);
  border-radius: 14px;
  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: fixed;
  bottom: 0;
  left: max(14px, env(safe-area-inset-left));
  right: max(14px, env(safe-area-inset-right));
  max-width: 480px;
  margin: 0 auto;
  z-index: 50;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  padding-top: 10px;
  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: 16px 16px 0 0;
  padding-left: 4px;
  padding-right: 4px;
  padding-bottom: max(4px, env(safe-area-inset-bottom));
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 4px;
  color: #bbb;
  text-decoration: none;
  font-size: 11px;
  font-weight: 600;
  border-radius: 12px;
  transition: background 0.12s, color 0.12s;
}

.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: 28px;
  height: 28px;
  flex-shrink: 0;
  object-fit: contain;
}

/* ── 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;
  border-radius: 12px;
  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);
}
