/* ═══════════════════════════════════════════════
   BLOCK BLAST – FOREST MENU SCREEN
   ═══════════════════════════════════════════════ */

/* ---------- Variables ---------- */
:root {
  --forest-bg: #1A3A1A;
  --forest-mid: #2D5A27;
  --forest-light: #4A8B3C;
  --wood-brown: #8B6914;
  --wood-light: #D4A843;
  --wood-panel: #C4A265;
  --leaf-green: #6BBF59;
  --leaf-gold: #F0C040;
  --leaf-orange: #E8A838;
  --cream: #F5F0E0;
  --dark-brown: #2C1810;
  --error-red: #E05050;
  --glow-green: #90EE90;
}

/* ---------- Menu Screen Container ---------- */
.menuScreen {
  height: 100svh;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: "Cairo", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  color: var(--cream);
  -webkit-user-select: none;
  user-select: none;
}

/* Background Image */
.menuScreen::before {
  content: "";
  position: absolute;
  inset: 0;
  background: url("../images/bg-title.webp") center / cover no-repeat;
  z-index: 0;
}

/* Dark Overlay */
.menuScreen::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(0,0,0,0.40), transparent 40%, rgba(0,0,0,0.60));
  z-index: 1;
}

/* ---------- Falling Leaves ---------- */
.snowLayer {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  overflow: hidden;
}

.snowFlake {
  position: absolute;
  top: -30px;
  border-radius: 0;
  background: none;
  box-shadow: none;
  animation: leafFall var(--dur, 10s) linear var(--delay, 0s) infinite;
  will-change: transform;
  pointer-events: none;
  line-height: 0;
}

/* Leaves always visible */

@keyframes leafFall {
  0% {
    transform: translate3d(0, -10vh, 0) rotate(0deg);
    opacity: 0;
  }
  10% { opacity: 0.8; }
  90% { opacity: 0.6; }
  100% {
    transform: translate3d(var(--drift, 0px), 110vh, 0) rotate(720deg);
    opacity: 0;
  }
}

/* ---------- Top Row ---------- */
.menuTopRow {
  position: absolute;
  top: 8px;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 16px 20px;
}

.menuTopLeft {
  display: flex;
  flex-direction: column;
}

.menuTopBanner {
  display: none;
}

.menuTopBannerLine {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(0,0,0,0.40);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 999px;
  padding: 8px 18px;
}

.menuTopBannerLineText {
  font-weight: 800;
  font-size: 16px;
  color: var(--cream);
}

.menuTopBannerLineIcon {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--leaf-gold);
  font-weight: 900;
  font-size: 18px;
}

.menuTopBannerLineIcon::before {
  content: attr(data-value);
}

.menuTopBannerLineIcon::after {
  display: none;
}

.menuBadgeIcon {
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
  color: var(--leaf-gold);
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.menuTop {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ---------- Profile Button ---------- */
.menuTopProfile {
  width: 56px;
  height: 56px;
  padding: 0;
  border: 2px solid var(--wood-brown);
  border-radius: 14px;
  background: linear-gradient(to bottom, var(--wood-panel), #A08040);
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  cursor: pointer;
  display: grid;
  place-items: center;
  position: relative;
  transition: transform 150ms ease, box-shadow 150ms ease;
}

.menuTopProfile:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3), 0 0 15px rgba(144,238,144,0.3);
}

.menuTopProfile:active {
  transform: scale(0.95);
}

.menuTopProfileCrown {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
}

.menuTopProfileCrownIcon {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: var(--leaf-gold);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 2px 0 rgba(0,0,0,0.25));
}

.menuTopProfileInner {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  overflow: hidden;
  display: grid;
  place-items: center;
  position: relative;
}

.menuTopProfileImg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 1;
}

.menuTopProfileIcon {
  width: 28px;
  height: 28px;
  fill: none;
  stroke: var(--dark-brown);
  stroke-width: 2.25;
  stroke-linecap: round;
  stroke-linejoin: round;
  position: relative;
  z-index: 0;
}

/* ---------- Under Top Row (Ranked) ---------- */
.menuUnderTopRow {
  display: none;
}

/* ---------- Logo ---------- */
.menuLogo {
  position: relative;
  z-index: 10;
  text-align: center;
  margin-bottom: 32px;
  animation: float 3s ease-in-out infinite;
}

.menuLogoBlocks {
  display: none;
}

.menuLogoTitle {
  font-size: clamp(56px, 15vw, 88px);
  font-weight: 900;
  color: var(--cream);
  line-height: 0.9;
  text-shadow:
    0 0 40px rgba(107,191,89,0.6),
    0 4px 12px rgba(0,0,0,0.8),
    0 0 80px rgba(144,238,144,0.3);
  letter-spacing: -1px;
}

.menuLogoSubtitle {
  font-size: clamp(44px, 12vw, 68px);
  font-weight: 900;
  color: var(--leaf-green);
  line-height: 0.9;
  margin-top: -4px;
  text-shadow:
    0 0 30px rgba(107,191,89,0.5),
    0 2px 8px rgba(0,0,0,0.6);
}

.menuLogoTag {
  font-size: 18px;
  font-weight: 700;
  color: var(--wood-light);
  letter-spacing: 6px;
  margin-top: 4px;
  text-shadow: 0 2px 8px rgba(0,0,0,0.7);
}

/* ---------- Buttons ---------- */
.menuButtons {
  position: relative;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  width: 100%;
  padding: 0 24px;
}

/* Play button */
.menuBtn.classic {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: min(280px, 100%);
  height: 58px;
  border-radius: 16px;
  font-weight: 900;
  font-size: 20px;
  letter-spacing: 2px;
  text-decoration: none;
  color: var(--cream);
  background: linear-gradient(to bottom, var(--leaf-green), var(--forest-light));
  border: 2px solid var(--forest-mid);
  box-shadow:
    0 4px 12px rgba(0,0,0,0.3),
    0 2px 4px rgba(0,0,0,0.2),
    0 0 20px rgba(107,191,89,0.3);
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
  cursor: pointer;
  transition: transform 150ms ease, box-shadow 150ms ease;
  animation: pulseGlow 2s ease-in-out infinite;
}

.menuBtn.classic:hover {
  transform: scale(1.05);
  box-shadow:
    0 6px 20px rgba(0,0,0,0.4),
    0 0 20px rgba(107,191,89,0.4);
}

.menuBtn.classic:active {
  transform: scale(0.95);
  box-shadow: inset 0 2px 8px rgba(0,0,0,0.3);
}

@keyframes pulseGlow {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.03); }
}

.menuBtn.withIcon {
  position: relative;
  overflow: hidden;
}

.menuBtnLabel {
  font-size: 20px;
  letter-spacing: 2px;
}

.menuClassicIconWrap {
  display: none;
}

/* Secondary buttons row */
.menuSecondaryBtns {
  display: flex;
  align-items: center;
  gap: 12px;
}

.menuIconBtn {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(to bottom, var(--wood-panel), #A08040);
  border: 2px solid var(--wood-brown);
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  cursor: pointer;
  transition: transform 150ms ease, box-shadow 150ms ease;
  padding: 0;
  color: var(--dark-brown);
}

.menuIconBtn:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3), 0 0 15px rgba(144,238,144,0.3);
}

.menuIconBtn:active {
  transform: scale(0.95);
}

.menuIconBtn svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: var(--dark-brown);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- Forest Spirit ---------- */
.menuSpirit {
  position: absolute;
  bottom: 80px;
  left: 16px;
  width: 100px;
  height: 140px;
  z-index: 5;
  animation: float 3s ease-in-out infinite;
  opacity: 0.9;
  pointer-events: none;
}

.menuSpirit img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 8px 16px rgba(0,0,0,0.4));
}

/* ---------- Version ---------- */
.menuVersion {
  position: absolute;
  bottom: 12px;
  right: 16px;
  font-size: 11px;
  color: rgba(245, 240, 224, 0.4);
  z-index: 10;
}

/* ---------- Float Animation ---------- */
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

/* ═══════════════════════════════════════════════
   RANKED / LEADERBOARD POPUP
   ═══════════════════════════════════════════════ */

.rankedBackdrop {
  position: fixed;
  inset: 0;
  z-index: 9998;
  background: rgba(0,0,0,0.70);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  padding: 18px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.rankedBackdrop.hidden {
  display: none;
}

.rankedCard {
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  background: linear-gradient(180deg, var(--forest-bg), var(--forest-mid) 50%, var(--forest-bg));
  border: 2px solid rgba(139,105,20,0.3);
  border-radius: 20px;
  overflow: hidden;
}

/* Ranked Header */
.rankedTitle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 16px;
  font-weight: 900;
  font-size: 18px;
  color: var(--cream);
  background: rgba(0,0,0,0.40);
  backdrop-filter: blur(4px);
  border-bottom: 1px solid rgba(139,105,20,0.3);
  text-shadow: 0 2px 8px rgba(0,0,0,0.5);
}

/* Trophy image in leaderboard */
.rankedTrophy {
  display: flex;
  justify-content: center;
  padding: 16px 0;
}

.rankedTrophy img {
  width: 72px;
  height: 72px;
  object-fit: contain;
  filter: drop-shadow(0 6px 12px rgba(0,0,0,0.4));
  animation: float 3s ease-in-out infinite;
}

.rankedBody {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0 16px 16px;
  scrollbar-width: thin;
  scrollbar-color: var(--wood-brown) transparent;
}

.rankedBody::-webkit-scrollbar { width: 6px; }
.rankedBody::-webkit-scrollbar-track { background: transparent; }
.rankedBody::-webkit-scrollbar-thumb { background: var(--wood-brown); border-radius: 3px; }

.rankedList {
  display: grid;
  gap: 8px;
}

.rankedRow {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(0,0,0,0.20);
  border: 1px solid rgba(255,255,255,0.05);
  animation: slideIn 0.3s ease-out both;
}

.rankedRow:nth-child(1) {
  background: rgba(255,215,0,0.10);
  border-color: rgba(255,215,0,0.30);
}
.rankedRow:nth-child(2) {
  background: rgba(192,192,192,0.10);
  border-color: rgba(192,192,192,0.30);
}
.rankedRow:nth-child(3) {
  background: rgba(205,127,50,0.10);
  border-color: rgba(205,127,50,0.30);
}

.rankedPos {
  width: 32px;
  font-weight: 900;
  color: rgba(245,240,224,0.4);
  text-align: center;
  font-size: 14px;
}

.rankedRow:nth-child(1) .rankedPos { color: #FFD700; }
.rankedRow:nth-child(2) .rankedPos { color: #C0C0C0; }
.rankedRow:nth-child(3) .rankedPos { color: #CD7F32; }

.rankedName {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
  font-size: 14px;
  color: var(--cream);
}

.rankedScore {
  font-weight: 900;
  font-size: 14px;
  color: var(--leaf-gold);
}

.rankedActions {
  padding: 12px 16px;
  display: flex;
  justify-content: center;
  border-top: 1px solid rgba(139,105,20,0.2);
}

@keyframes slideIn {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ═══════════════════════════════════════════════
   COMMON BUTTON STYLES
   ═══════════════════════════════════════════════ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 12px;
  font-weight: 800;
  font-size: 14px;
  cursor: pointer;
  transition: all 150ms ease;
  background: linear-gradient(to bottom, var(--wood-panel), #A08040);
  border: 2px solid var(--wood-brown);
  color: var(--dark-brown);
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.btn:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.btn:active {
  transform: scale(0.95);
}

.btn.primary {
  background: linear-gradient(to bottom, var(--leaf-green), var(--forest-light));
  border-color: var(--forest-mid);
  color: var(--cream);
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

/* ═══════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════ */

@media (max-height: 600px) {
  .menuLogo { margin-bottom: 16px; }
  .menuLogoTitle { font-size: 40px; }
  .menuLogoSubtitle { font-size: 30px; }
  .menuSpirit { width: 70px; height: 100px; bottom: 60px; }
}

@media (min-width: 768px) {
  .menuLogoTitle { font-size: 88px; }
  .menuLogoSubtitle { font-size: 68px; }
  .menuLogoTag { font-size: 22px; letter-spacing: 8px; }
  .menuBtn.classic { width: 320px; height: 64px; font-size: 24px; }
  .menuSpirit { width: 120px; height: 170px; }
}

/* ═══════════════════════════════════════════════
   SETTINGS & HELP POPUPS
   ═══════════════════════════════════════════════ */

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

.helpStep {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  background: linear-gradient(135deg, rgba(196,162,101,0.9), rgba(160,128,64,0.9));
  border: 2px solid #8B6914;
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.helpStepIcon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 2px solid;
}

.helpStepText h3 {
  font-size: 16px;
  font-weight: 800;
  color: var(--cream);
  margin: 0 0 4px;
}

.helpStepText p {
  font-size: 14px;
  color: rgba(245, 240, 224, 0.7);
  margin: 0;
  line-height: 1.4;
}

.helpStepNum {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 14px;
  flex-shrink: 0;
}

.helpTips {
  background: linear-gradient(135deg, rgba(196,162,101,0.95), rgba(139,105,20,0.95));
  border: 3px solid #8B6914;
  border-radius: 20px;
  padding: 16px;
  margin-top: 8px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.1);
}

.helpTipsTitle {
  font-size: 18px;
  font-weight: 800;
  color: #F0C040;
  margin: 0 0 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.helpTipsList {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.helpTipsList li {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 14px;
  color: rgba(245, 240, 224, 0.7);
}

.helpTipsList li span {
  color: #6BBF59;
}

.settingsPanel {
  background: linear-gradient(135deg, rgba(196,162,101,0.95), rgba(139,105,20,0.95));
  border: 3px solid #8B6914;
  border-radius: 20px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.1);
}

.settingsRow {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.settingsRowLeft {
  display: flex;
  align-items: center;
  gap: 12px;
}

.settingsIcon {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.settingsTitle {
  font-size: 14px;
  font-weight: 800;
  color: var(--cream);
}

.settingsSub {
  font-size: 12px;
  color: rgba(245, 240, 224, 0.5);
}

.settingsDivider {
  height: 1px;
  background: rgba(139, 105, 20, 0.3);
}

.settingsToggle {
  position: relative;
  display: inline-block;
  width: 56px;
  height: 28px;
}

.settingsToggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.settingsToggleSlider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #4b5563;
  transition: .2s;
  border-radius: 34px;
}

.settingsToggleSlider:before {
  position: absolute;
  content: "";
  height: 24px;
  width: 24px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  transition: .2s;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.settingsToggle input:checked + .settingsToggleSlider {
  background-color: #6BBF59;
}

.settingsToggle input:checked + .settingsToggleSlider:before {
  transform: translateX(28px);
}

.settingsSelect {
  background: #2D5A27;
  color: var(--cream);
  font-size: 14px;
  border-radius: 8px;
  padding: 8px 12px;
  border: 1px solid rgba(139, 105, 20, 0.5);
  outline: none;
  font-family: inherit;
}

.settingsResetBtn {
  width: 100%;
  padding: 12px;
  border-radius: 12px;
  background: rgba(153, 27, 27, 0.3);
  border: 1px solid rgba(153, 27, 27, 0.5);
  color: #f87171;
  font-weight: 800;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: background 0.2s;
}

.settingsResetBtn:hover {
  background: rgba(153, 27, 27, 0.5);
}
