#menu-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  padding-top: calc(24px + env(safe-area-inset-top));
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
  background: rgba(15, 47, 31, 0.48);
  backdrop-filter: blur(4px);
  transition: opacity 0.35s ease, visibility 0.35s ease;
}

#menu-overlay.menu-overlay-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

#menu-overlay.menu-overlay-paused {
  background: rgba(10, 24, 16, 0.58);
}

#menu-overlay.menu-overlay-fading {
  opacity: 0;
  pointer-events: none;
}

.menu-screen {
  width: min(100%, 420px);
  max-height: min(85vh, 720px);
}

.menu-screen-main {
  width: min(100%, 440px);
}

.menu-panel {
  background: rgba(15, 47, 31, 0.32);
  backdrop-filter: blur(24px) saturate(1.5);
  -webkit-backdrop-filter: blur(24px) saturate(1.5);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 20px;
  box-shadow:
    0 12px 40px rgba(0, 0, 0, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    inset 0 -1px 0 rgba(0, 0, 0, 0.1);
  color: #f5e6c8;
  overflow: hidden;
  transform: scale(0.96);
  opacity: 0;
  transition:
    transform 0.4s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.35s ease;
}

.menu-panel-enter {
  transform: scale(1);
  opacity: 1;
}

.menu-panel-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 22px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.03);
}

.menu-panel-title {
  margin: 0;
  font-family: "Cinzel", "Times New Roman", serif;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #ffd166;
}

.menu-panel-body {
  padding: 18px 22px 24px;
  overflow-y: auto;
  max-height: calc(min(85vh, 720px) - 72px);
  font-family: "Lora", Georgia, serif;
  line-height: 1.55;
}

.menu-main-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.menu-main-hero {
  gap: 22px;
}

.menu-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: center;
}

.menu-hero-title {
  margin: 0;
  font-family: "Cinzel", "Times New Roman", serif;
  font-size: clamp(2.4rem, 8vw, 3rem);
  font-weight: 700;
  letter-spacing: 0.1em;
  line-height: 1.1;
  background: linear-gradient(135deg, #ffe8a3 0%, #ffd166 35%, #c9a227 70%, #f5e6c8 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 2px 12px rgba(201, 162, 39, 0.35));
}

.menu-hero-subtitle {
  margin: 0;
  font-family: "Lora", Georgia, serif;
  font-size: 0.95rem;
  color: rgba(245, 230, 200, 0.82);
  letter-spacing: 0.02em;
}

.menu-hero-accent {
  width: 64px;
  height: 2px;
  margin-top: 6px;
  border-radius: 2px;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 209, 102, 0.85),
    transparent
  );
  box-shadow: 0 0 12px rgba(255, 209, 102, 0.4);
}

.menu-logo {
  width: min(220px, 70vw);
  height: auto;
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.35));
}

.menu-subtitle {
  margin: 0;
  text-align: center;
  color: #d4b483;
  font-size: 0.95rem;
}

.menu-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  margin-top: 8px;
}

.menu-btn {
  min-height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.07);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #f5e6c8;
  font-family: "Cinzel", serif;
  font-size: 0.95rem;
  letter-spacing: 0.03em;
  cursor: pointer;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 4px 16px rgba(0, 0, 0, 0.12);
  transition:
    background 0.2s ease,
    box-shadow 0.2s ease,
    border-color 0.2s ease,
    transform 0.15s ease;
}

.menu-btn:hover,
.menu-btn:focus-visible {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 209, 102, 0.35);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    0 0 20px rgba(255, 209, 102, 0.12),
    0 4px 16px rgba(0, 0, 0, 0.15);
  outline: none;
}

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

.menu-btn-primary {
  background: rgba(201, 162, 39, 0.38);
  border-color: rgba(255, 209, 102, 0.45);
  color: #fff8e7;
  font-weight: 700;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.2),
    0 4px 20px rgba(201, 162, 39, 0.25);
}

.menu-btn-primary:hover,
.menu-btn-primary:focus-visible {
  background: rgba(219, 180, 58, 0.52);
  border-color: rgba(255, 209, 102, 0.65);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.25),
    0 0 24px rgba(255, 209, 102, 0.2),
    0 6px 24px rgba(201, 162, 39, 0.3);
}

.menu-btn-icon {
  width: 40px;
  min-height: 40px;
  padding: 0;
  flex-shrink: 0;
}

.menu-rules h2 {
  margin: 1rem 0 0.35rem;
  font-family: "Cinzel", serif;
  font-size: 1rem;
  color: #ffd166;
}

.menu-rules h2:first-child {
  margin-top: 0;
}

.menu-rules p,
.menu-rules ul {
  margin: 0 0 0.75rem;
}

.menu-rules ul {
  padding-left: 1.2rem;
}

.menu-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.menu-field-label {
  font-family: "Cinzel", serif;
  font-size: 0.9rem;
  color: #ffd166;
}

.menu-field-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.menu-field-row input[type="range"] {
  flex: 1;
  accent-color: #c9a227;
}

.menu-field-value {
  min-width: 3rem;
  text-align: right;
  color: #d4b483;
}

.menu-field-toggle {
  flex-direction: row;
  align-items: center;
  gap: 10px;
}

.menu-stat-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.menu-stat-row strong {
  color: #ffd166;
}

.menu-credits p {
  margin: 0 0 0.75rem;
}

.menu-credits-muted {
  color: #a88958;
  font-size: 0.9rem;
}

.menu-credits-muted {
  color: #a88958;
  font-size: 0.9rem;
}

.menu-form {
  width: 100%;
}

.menu-field-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #f5e6c8;
  font-family: "Lora", Georgia, serif;
  font-size: 1rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.menu-field-input:focus {
  outline: none;
  border-color: rgba(255, 209, 102, 0.5);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 0 0 2px rgba(255, 209, 102, 0.15);
}

.menu-error {
  color: #ff8a80;
  font-size: 0.9rem;
  margin: 0 0 12px;
}

.menu-form-footer {
  text-align: center;
  margin-top: 12px;
  font-size: 0.9rem;
  color: #d4b483;
}

.menu-link-btn {
  background: none;
  border: none;
  color: #ffd166;
  cursor: pointer;
  font-family: inherit;
  text-decoration: underline;
  padding: 0;
}

.menu-auth-actions {
  margin-top: 8px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  width: 100%;
}

.menu-auth-actions--guest {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  align-items: stretch;
}

.menu-auth-actions--guest .menu-btn {
  width: 100%;
  min-width: 0;
  padding-inline: 8px;
}

.menu-lobby-intro {
  text-align: center;
  color: #d4b483;
  margin: 0 0 8px;
}

.menu-lobby-target {
  text-align: center;
  margin: 0 0 16px;
  font-size: 0.88rem;
  font-weight: 600;
  color: #ffd166;
}

.menu-lobby-code {
  text-align: center;
  font-family: "Cinzel", serif;
  font-size: 2rem;
  letter-spacing: 0.2em;
  color: #ffd166;
  margin: 0 0 8px;
}

.menu-lobby-ttl {
  text-align: center;
  color: #a88958;
  font-size: 0.85rem;
  margin: 0 0 16px;
}

.menu-lobby-link {
  word-break: break-all;
  font-size: 0.8rem;
  color: #a88958;
  margin: 12px 0;
}

.menu-lobby-players {
  margin-bottom: 12px;
}

.menu-share-label {
  text-align: center;
  font-size: 0.85rem;
  font-weight: 600;
  color: #d4b483;
  margin: 16px 0 8px;
}

.menu-share-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.menu-share-actions .menu-btn {
  width: 100%;
  min-width: 0;
  padding-inline: 8px;
  font-size: 0.85rem;
}

.menu-friends-section {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 209, 102, 0.15);
}

.menu-friends-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
  margin-top: 8px;
}

.menu-friends-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.menu-friends-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid rgba(255, 209, 102, 0.3);
  flex-shrink: 0;
}

.menu-friends-name {
  flex: 1;
  font-weight: 600;
  color: #ffd166;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.menu-btn-compact {
  padding: 8px 12px !important;
  font-size: 0.8rem !important;
  min-width: 0 !important;
  flex-shrink: 0;
}

.menu-friends-page {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.menu-friends-block {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.menu-friends-block-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: #ffd166;
}

.menu-friends-search-results {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.menu-profile {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.menu-profile-avatar-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.menu-profile-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255, 209, 102, 0.4);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.menu-leaderboard-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.menu-leaderboard-rank {
  min-width: 1.5rem;
  color: #ffd166;
  font-weight: 700;
}

.menu-leaderboard-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
}

.menu-leaderboard-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.menu-leaderboard-info span {
  font-size: 0.85rem;
  color: #a88958;
}

.menu-loading {
  text-align: center;
  color: #d4b483;
}

.menu-confirm p {
  margin: 0 0 16px;
  text-align: center;
}

@media (max-width: 767px) {
  #menu-overlay {
    padding: 16px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
  }

  .menu-screen {
    width: 100%;
  }

  .menu-panel-title {
    font-size: 1.15rem;
  }

  .menu-hero-title {
    font-size: 2.2rem;
    letter-spacing: 0.08em;
  }

  .menu-panel-body {
    padding: 16px 18px 20px;
  }
}

.menu-credits-badge {
  text-align: center;
  margin: 8px 0 0;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 209, 102, 0.12);
  color: #ffd166;
  font-size: 0.95rem;
}

.menu-main-balance {
  width: 100%;
}

.menu-donation-link {
  color: #ffd166;
  font-weight: 600;
}

.menu-profile-credits {
  margin-top: 12px;
}

.ad-consent-banner {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 16px;
  z-index: 10000;
  padding: 16px 18px;
  border-radius: 14px;
  background: rgba(20, 14, 8, 0.94);
  border: 1px solid rgba(255, 209, 102, 0.25);
  color: #f5e6c8;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

.ad-consent-banner p {
  margin: 0 0 12px;
  font-size: 0.95rem;
  line-height: 1.45;
}

.ad-consent-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.ad-gate-overlay,
.ad-mock-overlay,
.play-mode-overlay {
  position: fixed;
  inset: 0;
  z-index: 10001;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.72);
}

.ad-gate-panel,
.ad-mock-panel,
.play-mode-panel {
  width: min(100%, 420px);
  padding: 20px 22px;
  border-radius: 16px;
}

.ad-gate-title,
.ad-mock-panel h2,
.play-mode-title {
  margin: 0 0 12px;
  font-family: "Cinzel", serif;
  color: #ffd166;
}

.ad-gate-body {
  margin: 0 0 10px;
  color: #f5e6c8;
  line-height: 1.5;
}

.play-mode-body {
  margin: 0 0 16px;
  color: #f5e6c8;
  line-height: 1.5;
}

.ad-gate-hint {
  margin: 0 0 16px;
}

.ad-gate-actions {
  margin-top: 8px;
}

.play-mode-actions {
  margin-top: 0;
}

.play-mode-section-label {
  margin: 0 0 8px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #b7e4c7;
}

.play-mode-target-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.play-mode-target-btn {
  min-height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.07);
  color: #f5e6c8;
  font-family: "Cinzel", serif;
  font-size: 0.92rem;
  cursor: pointer;
  transition:
    background 0.2s ease,
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

.play-mode-target-btn:hover,
.play-mode-target-btn:focus-visible {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 209, 102, 0.35);
  outline: none;
}

.play-mode-target-btn--active {
  background: rgba(201, 162, 39, 0.38);
  border-color: rgba(255, 209, 102, 0.45);
  color: #fff8e7;
  box-shadow: 0 0 16px rgba(255, 209, 102, 0.12);
}

.ad-mock-timer {
  text-align: center;
  font-size: 1.25rem;
  color: #ffd166;
}

.ad-mock-progress {
  height: 8px;
  margin-top: 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

.ad-mock-progress-bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #ffd166, #ff9f1c);
  transition: width 0.2s linear;
}

.menu-settings-hub .menu-actions {
  margin-top: 0;
}

.menu-settings-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.menu-settings-section-title {
  margin: 0;
  font-family: "Cinzel", serif;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: #ffd166;
}

.menu-settings-notice {
  margin: 0;
  color: #d4b483;
  font-size: 0.92rem;
  line-height: 1.45;
}

.menu-settings-status {
  margin: 0;
  font-size: 0.85rem;
  color: #52b788;
}

.menu-settings-status--error {
  color: #ff8a8a;
}

.menu-theme-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.menu-theme-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  color: #f5e6c8;
  cursor: pointer;
  text-align: left;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    transform 0.15s ease;
}

.menu-theme-card:hover,
.menu-theme-card:focus-visible {
  border-color: rgba(255, 209, 102, 0.35);
  outline: none;
}

.menu-theme-card--selected {
  border-color: rgba(255, 209, 102, 0.75);
  box-shadow:
    0 0 0 1px rgba(255, 209, 102, 0.35),
    0 0 20px rgba(255, 209, 102, 0.12);
}

.menu-theme-preview {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.2);
}

.menu-theme-label {
  font-family: "Cinzel", serif;
  font-size: 0.78rem;
  letter-spacing: 0.03em;
  line-height: 1.2;
}
