* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; }
html, body { width: 100%; height: 100%; min-height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Tahoma, sans-serif;
  color: #fff;
  overflow: hidden;
  background: #120a07;
  touch-action: manipulation;
}
.app {
  position: relative; display: flex; flex-direction: column; width: 100%; max-width: none;
  height: 100vh; height: 100svh; height: 100dvh; margin: 0; overflow: hidden;
  background: #120a07;
  touch-action: manipulation;
}

/* ===== BACKGROUND IMAGE ===== */
.forest-bg {
  position: absolute; inset: 0; z-index: 0; overflow: hidden;
  background: radial-gradient(circle at 50% 68%, #6b3a19 0%, #25150d 36%, #0d0907 78%);
}
.bg-img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover; object-position: center 48%;
  filter: brightness(0.92) saturate(1.14) contrast(1.03) sepia(0.04);
  pointer-events: none;
}
.fog {
  position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse 72% 42% at 50% 68%, rgba(255,174,63,0.24) 0%, rgba(123,55,16,0.08) 45%, transparent 72%),
              radial-gradient(ellipse 75% 48% at 24% 30%, rgba(255,230,150,0.14) 0%, transparent 67%),
              linear-gradient(180deg, rgba(20,8,4,0.27) 0%, transparent 28%, transparent 64%, rgba(18,8,4,0.56) 100%);
}

/* ===== TOP BAR ===== */
.top-bar { display: flex; flex: 0 0 auto; justify-content: space-between; align-items: center; width: min(100%, 900px); margin: 0 auto; padding: calc(8px + env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) 8px max(8px, env(safe-area-inset-left)); z-index: 5; position: relative; gap: 5px; }
.icon-btn { width: 38px; height: 38px; border-radius: 50%; border: 0; background: rgba(0,0,0,0.6); color: #fff; font-size: 18px; cursor: pointer; flex-shrink: 0; display: flex; align-items: center; justify-content: center; backdrop-filter: blur(6px); border: 1px solid rgba(255,255,255,0.15); box-shadow: 0 2px 8px rgba(0,0,0,0.4); transition: transform 0.15s; text-decoration: none; }
.icon-btn:active { transform: scale(0.92); }
.wallet-btn {
  padding: 5px;
  overflow: hidden;
  background: linear-gradient(145deg, rgba(20,39,61,.96), rgba(4,13,23,.94));
  border-color: rgba(77,224,255,.56);
  box-shadow: 0 0 0 1px rgba(112,242,255,.08), 0 5px 18px rgba(0,170,220,.26);
}
.wallet-btn img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 2px 5px rgba(44,220,255,.32)); }
.energy, .currency-box { display: flex; min-width: 0; align-items: center; gap: 4px; background: linear-gradient(180deg, rgba(45,25,15,0.83), rgba(14,8,6,0.79)); padding: 6px 9px; border-radius: 18px; font-weight: 700; font-size: 12px; backdrop-filter: blur(10px); border: 1px solid rgba(255,195,92,0.34); box-shadow: 0 5px 16px rgba(20,8,2,0.32), inset 0 1px rgba(255,255,255,0.08); white-space: nowrap; }
.energy { border-color: rgba(74,215,255,0.4); }
.e-icon { color: #4ad7ff; font-size: 14px; }
.e-max { opacity: 0.6; font-size: 10px; }
.currency-box .c-icon { font-size: 14px; }
.currency-box.scruff-coin { border-color: rgba(255,216,77,0.5); }
.currency-box.scruff-coin #scruffCoins { display: block; max-width: 76px; overflow: hidden; text-overflow: ellipsis; }
.currency-box.diamond { border-color: rgba(140,200,255,0.5); background: linear-gradient(135deg, rgba(0,30,60,0.7), rgba(0,0,0,0.6)); }
.currency-box.diamond #diamonds { display: block; max-width: 62px; overflow: hidden; text-overflow: ellipsis; }
.c-label { font-size: 9px; opacity: 0.7; font-weight: 600; }

/* ===== STAGE ===== */
.stage {
  flex: 1 1 auto; min-height: 0; position: relative; z-index: 3; isolation: isolate;
  display: flex; align-items: center; justify-content: center; flex-direction: column;
  overflow: hidden;
  margin: 0;
  padding: clamp(2px, 0.8vh, 8px) 58px clamp(4px, 1vh, 10px) 12px;
  cursor: pointer;
  touch-action: manipulation;
  /* کلیک فعال باشه */
  pointer-events: auto;
}
.stage::before { content: ""; position: absolute; z-index: 0; width: min(76vw, 620px); aspect-ratio: 1; left: 50%; bottom: -22%; transform: translateX(-50%); border-radius: 50%; pointer-events: none; background: radial-gradient(circle, rgba(255,182,72,0.27) 0%, rgba(255,103,25,0.11) 38%, transparent 71%); filter: blur(2px); transition: filter .2s, opacity .2s; }
.stage.stage-hit::before { animation: arena-hit .22s ease-out; }
@keyframes arena-hit { 0% { opacity: .58; filter: blur(8px); } 45% { opacity: 1; filter: blur(0); } 100% { opacity: .76; filter: blur(2px); } }
.float-layer { position: absolute; inset: 0; z-index: 20; pointer-events: none; overflow: hidden; }
button, input, a { touch-action: manipulation; }
input { user-select: text; -webkit-user-select: text; }

.chest-progress { position: relative; width: min(calc(100vw - 76px), 430px); margin: clamp(2px, .7vh, 6px) 0; display: flex; align-items: center; gap: 8px; z-index: 4; pointer-events: none; }
.chest-progress-bar { flex: 1; height: 8px; background: rgba(0,0,0,0.6); border: 1px solid rgba(255,210,74,0.4); border-radius: 6px; overflow: hidden; }
.chest-progress-fill { height: 100%; background: linear-gradient(90deg, #ffd24a 0%, #ff8800 100%); width: 0%; transition: width 0.3s linear; box-shadow: 0 0 6px rgba(255,210,74,0.6); }
.chest-progress-text { font-size: 11px; font-weight: 700; color: #ffd24a; min-width: 50px; text-align: center; text-shadow: 0 1px 2px rgba(0,0,0,0.8); font-variant-numeric: tabular-nums; }

/* CHEST */
.chest-container { position: absolute; z-index: 6; pointer-events: none; top: 25%; left: -120px; transition: left 0.5s cubic-bezier(0.2, 0.8, 0.2, 1); width: 90px; height: 90px; }
.chest-container.show { left: 8px; pointer-events: auto; animation: chest-wiggle 1.5s ease-in-out infinite; }
@keyframes chest-wiggle { 0%, 100% { transform: rotate(-3deg) translateY(0); } 50% { transform: rotate(3deg) translateY(-5px); } }
.chest-container.leaving { left: -120px !important; transition: left 0.8s ease-in; }
.chest { position: relative; width: 100%; height: 100%; filter: drop-shadow(0 6px 8px rgba(0,0,0,0.5)); animation: chest-float 2s ease-in-out infinite; cursor: pointer; pointer-events: auto; }
@keyframes chest-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
.chest-body { position: relative; width: 70px; height: 70px; margin: 0 auto; font-size: 50px; display: flex; align-items: center; justify-content: center; }
.chest-front { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 50px; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5)); }
.chest-lid { position: absolute; top: -8px; left: 50%; transform: translateX(-50%); width: 80%; height: 16px; background: linear-gradient(180deg, #b8731a 0%, #8b5a0f 100%); border-radius: 8px 8px 4px 4px; border: 2px solid #5a3a0a; }
.chest-shadow { position: absolute; bottom: 0; left: 50%; transform: translateX(-50%); width: 60px; height: 8px; background: radial-gradient(ellipse, rgba(0,0,0,0.5) 0%, transparent 70%); }
.chest.opened .chest-lid { animation: lid-open 0.6s ease-out forwards; }
@keyframes lid-open { 0% { transform: translateX(-50%) rotate(0); } 100% { transform: translateX(-50%) rotate(-30deg) translateY(-20px); } }
.chest.opened .chest-front { animation: chest-burst 0.6s ease-out forwards; }
@keyframes chest-burst { 0% { transform: scale(1); } 30% { transform: scale(1.3) rotate(10deg); filter: brightness(2); } 100% { transform: scale(0.5); opacity: 0.5; } }

/* HP */
.hp-wrap { position: relative; width: min(calc(100vw - 76px), 430px); margin: clamp(2px, .7vh, 6px) 0 clamp(2px, .5vh, 4px); z-index: 4; pointer-events: none; }
.hp-info { display: flex; justify-content: space-between; align-items: center; font-size: 12px; font-weight: 800; margin-bottom: 3px; text-shadow: 0 1px 2px rgba(0,0,0,0.8); }
.hp-name { color: #ffd24a; font-size: 14px; letter-spacing: 1px; }
.hp-num { color: #fff; font-variant-numeric: tabular-nums; font-size: 11px; }
.hp-bar { height: 14px; background: rgba(0,0,0,0.6); border: 2px solid #ffd24a; border-radius: 10px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.5), inset 0 1px 2px rgba(0,0,0,0.5); }
.hp-fill { position: relative; height: 100%; background: linear-gradient(180deg, #ff6a55 0%, #c92a2a 50%, #7a0b08 100%); width: 100%; transition: width 0.3s ease; box-shadow: 0 0 8px rgba(255,80,80,0.6); }
.hp-fill::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(255,255,255,0.3) 0%, transparent 50%); }
.hp-fill.warn { background: linear-gradient(180deg, #ffaa00 0%, #ff6600 50%, #aa3300 100%); }
.hp-fill.danger { background: linear-gradient(180deg, #ff0000 0%, #cc0000 50%, #660000 100%); animation: danger-pulse 0.5s ease-in-out infinite; }
@keyframes danger-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.6; } }

.char-3d.dying { animation: dying-shake 0.3s ease-in-out infinite; filter: grayscale(0.5) brightness(0.7); }
@keyframes dying-shake { 0%, 100% { transform: translate(0, 0) rotate(0); } 25% { transform: translate(-3px, 2px) rotate(-2deg); } 75% { transform: translate(3px, -2px) rotate(2deg); } }
.char-3d.dying-fast { animation: dying-fast 0.6s ease-in forwards; pointer-events: none; }
@keyframes dying-fast { 0% { transform: scale(1) rotate(0); opacity: 1; filter: brightness(1); } 30% { transform: scale(1.1) rotate(5deg); filter: brightness(1.5) saturate(0.5); } 60% { transform: scale(0.9) rotate(-3deg); opacity: 0.6; filter: brightness(0.3) blur(2px); } 100% { transform: scale(0.3) rotate(20deg); opacity: 0; filter: brightness(0) blur(8px); } }
.char-3d.entering { animation: enter-burst 0.6s ease-out; }
@keyframes enter-burst { 0% { transform: scale(0.3) rotate(-30deg); opacity: 0; filter: brightness(2) blur(4px); } 50% { transform: scale(1.2) rotate(5deg); opacity: 1; filter: brightness(1.4); } 100% { transform: scale(1) rotate(0); opacity: 1; filter: brightness(1); } }

.char-3d { position: relative; width: min(66vw, 375px); height: min(46dvh, 500px); min-height: 0; aspect-ratio: 3/4; perspective: 1200px; perspective-origin: 50% 30%; display: flex; align-items: flex-end; justify-content: center; animation: idle-bob 3.8s ease-in-out infinite; pointer-events: none; z-index: 2; }
.char-3d::before { content: ""; position: absolute; width: 108%; aspect-ratio: 1; left: 50%; bottom: 5%; transform: translateX(-50%); border-radius: 50%; background: radial-gradient(circle, rgba(255,220,121,.34) 0%, rgba(255,125,36,.12) 40%, transparent 70%); filter: blur(8px); z-index: 0; animation: aura-breathe 3.8s ease-in-out infinite; }
@keyframes aura-breathe { 0%,100% { opacity:.66; transform:translateX(-50%) scale(.92); } 50% { opacity:1; transform:translateX(-50%) scale(1.05); } }
@keyframes idle-bob { 0%, 100% { transform: translateY(0) rotateY(-2deg); } 50% { transform: translateY(-8px) rotateY(2deg); } }
.char-img { display: block; width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 22px 26px rgba(21,8,2,0.72)) drop-shadow(0 0 8px rgba(255,196,82,.2)); position: relative; z-index: 2; pointer-events: none; -webkit-user-drag: none; transform-origin: 50% 95%; transition: transform 0.2s cubic-bezier(0.2, 1.4, 0.4, 1); }
.char-img.bounce { animation: char-bounce 0.5s ease-out; }
@keyframes char-bounce { 0% { transform: scale(1) rotate(0); } 20% { transform: scale(0.93) rotate(-2deg); } 40% { transform: scale(1.05) rotate(1deg); } 60% { transform: scale(0.97) rotate(-1deg); } 100% { transform: scale(1) rotate(0); } }
.char-img.hit-flash { filter: drop-shadow(0 0 12px #ff0000) drop-shadow(0 18px 24px rgba(0,0,0,0.6)) brightness(1.5) !important; }
.char-shadow { position: absolute; bottom: 0; left: 50%; transform: translateX(-50%); width: 70%; height: 4%; background: radial-gradient(ellipse, rgba(0,0,0,0.6) 0%, transparent 70%); pointer-events: none; z-index: 1; animation: shadow-pulse 3.8s ease-in-out infinite; }
@keyframes shadow-pulse { 0%, 100% { transform: translateX(-50%) scale(1); opacity: 0.7; } 50% { transform: translateX(-50%) scale(0.88); opacity: 0.9; } }

.float-num { position: absolute; font-weight: 900; font-size: 28px; color: #fff7c2; text-shadow: 0 2px 0 #000, 0 0 12px rgba(0,0,0,0.5); pointer-events: none; animation: floatUp 0.9s ease-out forwards; z-index: 20; }
.float-dmg { color: #ff5555 !important; font-size: 24px; }
.float-diamond { color: #6cc4ff !important; font-size: 22px; text-shadow: 0 2px 0 #003366, 0 0 12px rgba(0,150,255,0.5); }
@keyframes floatUp { 0% { transform: translate(-50%, 0) scale(1); opacity: 1; } 100% { transform: translate(-50%, -90px) scale(1.4); opacity: 0; } }

.per-tap { position: relative; z-index: 4; margin-top: clamp(2px, .7vh, 6px); background: linear-gradient(180deg, rgba(46,24,13,.82), rgba(14,8,5,.79)); padding: 6px 13px; border-radius: 14px; font-size: 12px; border: 1px solid rgba(255,176,78,0.45); box-shadow: 0 4px 14px rgba(24,8,2,.28); font-weight: 650; color: #ffe7c4; pointer-events: none; }
.per-tap b:last-of-type { color: #86ddff; }

.mission-strip { position: relative; z-index: 4; width: min(calc(100vw - 76px), 430px); display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: clamp(2px, .6vh, 5px) 0; padding: 7px 10px; border: 1px solid rgba(117,218,255,.45); border-radius: 12px; background: linear-gradient(135deg, rgba(8,37,52,.82), rgba(18,12,8,.79)); box-shadow: 0 5px 16px rgba(12,6,3,.27), inset 0 1px rgba(255,255,255,.07); backdrop-filter: blur(9px); pointer-events: none; }
.mission-phase { color: #8ae2ff; font-size: 10px; font-weight: 900; letter-spacing: .07em; white-space: nowrap; }
.mission-goal { color: rgba(255,255,255,.86); font-size: 10px; font-weight: 650; text-align: right; line-height: 1.25; }
.mission-strip.scruff-phase { border-color: rgba(255,206,92,.55); background: linear-gradient(135deg, rgba(65,38,10,.86), rgba(20,12,7,.82)); }
.mission-strip.scruff-phase .mission-phase { color: #ffd66d; }

/* TABS */
.tabs { display: grid; flex: 0 0 auto; width: min(100%, 760px); margin: 0 auto; grid-template-columns: repeat(3, 1fr); background: linear-gradient(180deg, rgba(34,17,10,.93), rgba(12,7,5,.97)); padding: 8px max(8px, env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)); gap: 6px; border-top: 2px solid rgba(255,195,82,0.48); z-index: 10; position: relative; box-shadow: 0 -6px 22px rgba(20,8,2,.32); }
.tab { background: transparent; border: 0; color: #fff; padding: 12px 6px; border-radius: 10px; font-weight: 800; font-size: 14px; cursor: pointer; white-space: nowrap; min-height: 44px; }
.tab.active { background: linear-gradient(180deg, #ffd24a, #ff9a00); color: #2a1500; }

/* DRAWER */
.drawer-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 50; opacity: 0; pointer-events: none; transition: opacity 0.25s; }
.drawer-overlay.open { opacity: 1; pointer-events: auto; }
.drawer { position: fixed; left: 0; right: 0; bottom: 0; width: min(720px, calc(100vw - 24px)); height: min(68dvh, 560px); margin: 0 auto; background: linear-gradient(180deg, #2a170d 0%, #120a07 100%); border: 2px solid rgba(255,198,86,.72); border-bottom: 0; border-radius: 24px 24px 0 0; transform: translateY(100%); transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1); z-index: 60; overflow: hidden; display: flex; flex-direction: column; box-shadow: 0 -12px 40px rgba(16,6,2,0.72); }
.drawer.open { transform: translateY(0); }
.drawer-close { position: absolute; top: 8px; right: 8px; width: 36px; height: 36px; border-radius: 50%; background: rgba(255,255,255,0.1); color: #fff; border: 0; font-size: 18px; font-weight: 800; cursor: pointer; z-index: 5; }
.drawer-close:active { background: rgba(255,255,255,0.2); }
.drawer .panel { position: relative; inset: auto; max-height: none; overflow-y: auto; background: transparent; border: 0; padding: 20px 16px calc(24px + env(safe-area-inset-bottom)); flex: 1; }
.drawer .panel.hidden { display: none; }
.drawer h3 { font-size: 18px; margin-bottom: 14px; color: #ffd24a; text-align: center; }
.upgrades, .boosts { display: flex; flex-direction: column; gap: 10px; }
.upgrade-row, .boost-row { display: flex; align-items: center; gap: 12px; background: linear-gradient(135deg, rgba(255,255,255,.085), rgba(255,167,70,.035)); border: 1px solid rgba(255,214,142,.16); padding: 12px; border-radius: 14px; box-shadow: inset 0 1px rgba(255,255,255,.04); }
.upgrade-row .ico, .boost-row .ico { width: 48px; height: 48px; border-radius: 10px; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; font-size: 24px; flex-shrink: 0; }
.upgrade-row .info, .boost-row .info { flex: 1; min-width: 0; }
.upgrade-row .info b, .boost-row .info b { display: block; font-size: 14px; }
.upgrade-row .info small, .boost-row .info small { opacity: 0.75; font-size: 12px; }
.buy-btn { background: linear-gradient(180deg, #ffd24a, #ff9a00); color: #2a1500; border: 0; padding: 10px 14px; border-radius: 10px; font-weight: 800; font-size: 13px; cursor: pointer; flex-shrink: 0; white-space: nowrap; }
.buy-btn:active { transform: scale(0.96); }
.buy-btn:disabled { background: #555; color: #bbb; cursor: not-allowed; }
.upgrade-level { color: #ffd66d; }
.phase-hint { display: block; margin-top: 4px; font-weight: 750; }
.diamond-hint { color: #7bdcff; }
.scruff-hint { color: #ffd66d; }
.upgrade-row.scruff-locked { border-color: rgba(255,205,101,.28); }
.buy-btn.scruff-gate { color: #fff5d5; background: linear-gradient(180deg, #7b521b, #4c2e0e); border: 1px solid rgba(255,220,130,.38); }
.stat-row { background: rgba(255,255,255,0.06); padding: 12px 14px; border-radius: 10px; margin-bottom: 8px; display: flex; justify-content: space-between; font-size: 14px; }
.reset-btn { margin-top: 14px; width: 100%; padding: 12px; border-radius: 10px; border: 0; background: #c0392b; color: #fff; font-weight: 800; cursor: pointer; }

/* SETTINGS */
.setting-row { display: flex; align-items: center; gap: 12px; background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.1); padding: 12px; border-radius: 12px; margin-bottom: 8px; }
.setting-info { flex: 1; }
.setting-info b { display: block; font-size: 14px; }
.setting-info small { opacity: 0.7; font-size: 11px; }
.setting-btn { background: linear-gradient(180deg, #ffd24a, #ff9a00); color: #2a1500; border: 0; padding: 8px 16px; border-radius: 10px; font-weight: 800; cursor: pointer; }
.setting-btn.danger { background: linear-gradient(180deg, #ff5050, #c92a2a); color: #fff; }
.switch { position: relative; display: inline-block; width: 50px; height: 28px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; inset: 0; background: #555; border-radius: 28px; transition: 0.3s; }
.slider:before { content: ""; position: absolute; height: 22px; width: 22px; right: 3px; top: 3px; background: #fff; border-radius: 50%; transition: 0.3s; }
input:checked + .slider { background: linear-gradient(180deg, #ffd24a, #ff9a00); }
input:checked + .slider:before { transform: translateX(-22px); }
.about-row { text-align: center; margin-top: 20px; opacity: 0.7; }
.about-row p { margin: 4px 0; }
.about-small { font-size: 11px; opacity: 0.5; }

/* WALLET */
.wallet-header { text-align: center; margin-bottom: 16px; }
.wallet-logo {
  width: 76px;
  height: 76px;
  margin: 0 auto 10px;
  display: block;
  filter: drop-shadow(0 10px 22px rgba(0,190,235,.34));
}
.wallet-disconnected { text-align: center; }
.wallet-icon-big { font-size: 50px; margin-bottom: 12px; opacity: 0.8; }
.wallet-disconnected p { font-size: 13px; opacity: 0.85; margin-bottom: 16px; line-height: 1.6; }
.wallet-connect-btn { width: 100%; padding: 14px; border-radius: 12px; border: 0; background: linear-gradient(180deg, #00d4ff 0%, #0099cc 100%); color: #fff; font-weight: 800; font-size: 15px; cursor: pointer; box-shadow: 0 4px 12px rgba(0,212,255,0.4); margin-bottom: 16px; }
.wallet-connect-btn:disabled, .wallet-option:disabled { cursor: not-allowed; opacity: 0.58; }
.wallet-action-btn:disabled { cursor: not-allowed; opacity: .58; }
.wallet-install-link { display: inline-block; color: #62e6ff; font-size: 12px; font-weight: 700; margin: 0 0 14px; text-underline-offset: 3px; }
.wallet-status { min-height: 20px; margin: 0; color: rgba(255,255,255,.76); font-size: 12px; line-height: 1.45; }
.wallet-status.error { color: #ff8f8f; }
.wallet-status.success { color: #7dffbc; }
.wallet-coming-soon { margin: 10px 0 0 !important; padding-top: 10px; border-top: 1px solid rgba(255,255,255,.1); font-size: 11px !important; opacity: .64 !important; }
.wallet-providers { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.provider-btn { background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.15); color: #fff; padding: 10px; border-radius: 10px; font-size: 12px; font-weight: 600; cursor: pointer; }
.wallet-connected { text-align: center; }
.wallet-success { padding: 16px 0; }
.check-icon { width: 60px; height: 60px; border-radius: 50%; background: linear-gradient(180deg, #4ade80, #16a34a); margin: 0 auto 12px; display: flex; align-items: center; justify-content: center; font-size: 32px; font-weight: 900; color: #fff; box-shadow: 0 0 20px rgba(74,222,128,0.5); animation: check-pop 0.5s cubic-bezier(0.2,1.5,0.4,1); }
@keyframes check-pop { 0% { transform: scale(0); } 100% { transform: scale(1); } }
.wallet-info-card { background: rgba(0,30,60,0.5); border: 1px solid rgba(0,212,255,0.3); border-radius: 12px; padding: 12px; margin: 12px 0; text-align: left; }
.wallet-info-row { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; font-size: 13px; }
.wallet-info-row code { max-width: 68%; overflow: hidden; text-overflow: ellipsis; background: rgba(0,0,0,0.4); padding: 2px 8px; border-radius: 6px; font-size: 11px; color: #00d4ff; }
.wallet-info-row b { color: #fff; max-width: 58%; text-align: right; overflow-wrap: anywhere; }
.wallet-actions { display: flex; flex-direction: column; gap: 8px; }
.wallet-action-btn { width: 100%; padding: 12px; border-radius: 10px; border: 0; background: linear-gradient(180deg, #ffd24a, #ff9a00); color: #2a1500; font-weight: 800; font-size: 14px; cursor: pointer; }
.wallet-action-btn.secondary { background: rgba(255,255,255,0.1); color: #fff; border: 1px solid rgba(255,255,255,0.2); }
.hidden { display: none !important; }

/* BOOST POPUP */
.boost-popup { position: fixed; inset: 0; background: rgba(0,0,0,0.75); display: none; align-items: center; justify-content: center; z-index: 100; backdrop-filter: blur(4px); }
.boost-popup.show { display: flex; animation: pop-fade 0.3s; }
@keyframes pop-fade { 0% { opacity: 0; } 100% { opacity: 1; } }
.boost-popup-content { background: linear-gradient(180deg, #2a1a0a 0%, #1a0a05 100%); border: 3px solid #ffd24a; border-radius: 20px; padding: 24px 32px; text-align: center; max-width: 320px; box-shadow: 0 0 40px rgba(255,210,74,0.5); animation: pop-bounce 0.4s cubic-bezier(0.2, 1.5, 0.4, 1); }
@keyframes pop-bounce { 0% { transform: scale(0.5); } 100% { transform: scale(1); } }
.boost-emoji { font-size: 60px; animation: emoji-spin 1s ease-out; }
@keyframes emoji-spin { 0% { transform: rotate(-180deg) scale(0); } 100% { transform: rotate(0) scale(1); } }
.boost-popup h2 { color: #ffd24a; font-size: 18px; margin: 12px 0 8px; }
.boost-mult { font-size: 48px; font-weight: 900; color: #fff; text-shadow: 0 0 20px #ff6600, 0 4px 0 #8b0000; margin: 8px 0; }
.boost-popup p { font-size: 13px; margin: 4px 0; opacity: 0.9; }
.boost-dur { color: #6cc4ff; font-weight: 700; }
.boost-ok { margin-top: 16px; padding: 10px 24px; background: linear-gradient(180deg, #ffd24a, #ff9a00); color: #2a1500; border: 0; border-radius: 12px; font-weight: 800; font-size: 14px; cursor: pointer; }

/* WALLET POPUP */
.wallet-popup { position: fixed; inset: 0; background: rgba(0,0,0,0.75); display: none; align-items: center; justify-content: center; z-index: 110; backdrop-filter: blur(4px); }
.wallet-popup.show { display: flex; animation: pop-fade 0.3s; }
.wallet-popup-content { background: linear-gradient(180deg, #0a1a2a 0%, #051018 100%); border: 2px solid #00d4ff; border-radius: 20px; padding: 20px; max-width: 360px; width: 90%; }
.wallet-popup h3 { color: #00d4ff; font-size: 18px; margin-bottom: 8px; text-align: center; }
.wallet-popup p { color: #fff; font-size: 13px; opacity: 0.85; margin-bottom: 16px; text-align: center; }
.wallet-options { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.wallet-option { display: flex; align-items: center; gap: 12px; background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.1); padding: 14px; border-radius: 12px; color: #fff; font-size: 14px; font-weight: 600; cursor: pointer; }
.opt-icon { font-size: 24px; }
.wallet-cancel { width: 100%; padding: 10px; border-radius: 10px; border: 0; background: rgba(255,255,255,0.1); color: #fff; font-weight: 600; cursor: pointer; }

/* START OVERLAY */
.start-overlay { position: fixed; inset: 0; padding: calc(16px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom)); background: rgba(16,7,3,0.83); display: flex; align-items: center; justify-content: center; z-index: 200; backdrop-filter: blur(10px); overflow-y: auto; }
.start-overlay.hidden { display: none; }
.start-content { background: linear-gradient(180deg, rgba(58,31,14,.97) 0%, rgba(20,10,6,.98) 100%); border: 2px solid #ffd268; border-radius: 24px; padding: clamp(22px, 5vh, 32px) 24px; text-align: center; max-width: 360px; width: min(100%, 360px); max-height: 100%; box-shadow: 0 0 55px rgba(255,167,52,0.38), inset 0 1px rgba(255,255,255,.08); animation: pop-bounce 0.5s cubic-bezier(0.2, 1.5, 0.4, 1); }
.start-logo { font-size: 80px; margin-bottom: 8px; filter: drop-shadow(0 4px 8px rgba(0,0,0,0.5)); }
.start-content h1 { color: #ffd24a; font-size: 24px; margin-bottom: 8px; letter-spacing: 2px; }
.start-content p { color: #fff; font-size: 13px; margin-bottom: 20px; opacity: 0.85; }
.start-content .demo-badge { margin: -6px 0 16px; padding: 7px 9px; color: #ffd24a; background: rgba(255,210,74,.08); border: 1px solid rgba(255,210,74,.45); font-size: 9px; font-weight: 800; letter-spacing: .08em; opacity: 1; }
.start-btn { width: 100%; padding: 14px; border-radius: 12px; border: 0; background: linear-gradient(180deg, #ffd24a 0%, #ff9a00 100%); color: #2a1500; font-weight: 900; font-size: 16px; cursor: pointer; box-shadow: 0 4px 12px rgba(255,210,74,0.4); margin-bottom: 12px; }
.start-btn:active { transform: scale(0.96); }
.start-small { font-size: 11px !important; opacity: 0.6 !important; margin-bottom: 0 !important; }

@media (max-width: 600px) {
  .drawer { width: 100%; border-left: 0; border-right: 0; }
}

@media (max-width: 520px) {
  .top-bar { gap: 4px; }
  .energy, .currency-box { padding-left: 7px; padding-right: 7px; }
  .c-label { display: none; }
  .currency-box.scruff-coin #scruffCoins { max-width: 58px; }
}

@media (max-width: 430px) {
  .e-max { display: none; }
  .currency-box.scruff-coin #scruffCoins,
  .currency-box.diamond #diamonds { max-width: 50px; }
}

@media (max-width: 360px) {
  .top-bar { gap: 3px; padding-left: 5px; padding-right: 5px; }
  .icon-btn { width: 34px; height: 34px; }
  .energy, .currency-box { gap: 2px; padding: 5px 7px; font-size: 10px; }
  .e-max, .c-label { display: none; }
  .side-btn { width: 44px; height: 44px; }
  .stage { padding-right: 50px; padding-left: 8px; }
}

@media (max-height: 650px) and (orientation: portrait) {
  .top-bar { padding-bottom: 4px; }
  .stage { padding-top: 0; padding-bottom: 2px; }
  .player-level-box, .hp-wrap, .chest-progress, .mission-strip { margin-top: 1px; margin-bottom: 1px; }
  .char-3d { height: min(34dvh, 250px); width: min(54vw, 230px); }
  .per-tap { margin-top: 1px; padding-top: 4px; padding-bottom: 4px; }
  .tab { min-height: 40px; padding-top: 8px; padding-bottom: 8px; }
}

@media (orientation: landscape) and (max-height: 600px) {
  .top-bar { padding-top: calc(4px + env(safe-area-inset-top)); padding-bottom: 4px; }
  .stage { display: grid; grid-template-columns: minmax(230px, .9fr) minmax(180px, 1.1fr); grid-template-rows: repeat(5, auto); align-content: center; justify-items: center; column-gap: clamp(8px, 3vw, 34px); padding: 4px max(58px, env(safe-area-inset-right)) 4px max(12px, env(safe-area-inset-left)); }
  .player-level-box { grid-column: 1; grid-row: 1; }
  .mission-strip { grid-column: 1; grid-row: 2; }
  .hp-wrap { grid-column: 1; grid-row: 3; }
  .chest-progress { grid-column: 1; grid-row: 4; }
  .per-tap { grid-column: 1; grid-row: 5; }
  .player-level-box, .mission-strip, .hp-wrap, .chest-progress { width: min(42vw, 430px); margin: 2px 0; }
  .char-3d { grid-column: 2; grid-row: 1 / 6; width: min(32vw, 270px); height: min(64dvh, 340px); }
  .side-panel { gap: 5px; }
  .side-btn { width: 42px; height: 42px; }
  .side-icon { font-size: 17px; }
  .side-label { font-size: 8px; }
  .tabs { width: min(100%, 680px); padding-top: 5px; }
  .tab { min-height: 38px; padding: 7px 5px; font-size: 12px; }
  .drawer { height: min(82dvh, 460px); }
}

@media (prefers-reduced-motion: reduce) {
  .char-3d,
  .char-shadow,
  .chest,
  .chest-container,
  .medal-card.unlocked,
  .char-3d::before,
  .stage.stage-hit::before,
  .float-num,
  .boost-popup-content,
  .start-content,
  .levelup-content,
  .levelup-stars {
    animation: none !important;
  }
}

/* ===== MEDALS & ITEMS ===== */
.panel-desc { color: rgba(255,255,255,0.7); font-size: 12px; margin-bottom: 12px; text-align: center; line-height: 1.5; }
.medals-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.medal-card { background: linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.03)); border: 2px solid rgba(255,255,255,0.15); padding: 14px 10px; border-radius: 14px; text-align: center; transition: all 0.2s; }
.medal-card.locked { opacity: 0.4; filter: grayscale(1); }
.medal-card.unlocked { border-color: #ffd24a; box-shadow: 0 0 16px rgba(255,210,74,0.3); animation: medal-shine 3s ease-in-out infinite; }
@keyframes medal-shine { 0%, 100% { box-shadow: 0 0 16px rgba(255,210,74,0.3); } 50% { box-shadow: 0 0 24px rgba(255,210,74,0.6); } }
.medal-icon { font-size: 42px; margin-bottom: 6px; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5)); }
.medal-name { font-size: 13px; font-weight: 800; color: #ffd24a; margin-bottom: 4px; }
.medal-count { font-size: 11px; color: #fff; opacity: 0.85; }
.medal-bonus { font-size: 10px; color: #6cc4ff; margin-top: 4px; font-weight: 700; }

/* ===== DAILY TASKS ===== */
.tasks-list { display: flex; flex-direction: column; gap: 10px; }
.task-card { background: linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.03)); border: 2px solid rgba(255,255,255,0.15); padding: 12px; border-radius: 12px; }
.task-card.done { border-color: #4ade80; background: linear-gradient(180deg, rgba(74,222,128,0.15), rgba(74,222,128,0.05)); }
.task-header { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.task-icon { font-size: 28px; flex-shrink: 0; }
.task-info { flex: 1; min-width: 0; }
.task-name { font-size: 13px; font-weight: 700; color: #fff; }
.task-desc { font-size: 11px; color: rgba(255,255,255,0.7); margin-top: 2px; }
.task-reward { background: linear-gradient(180deg, rgba(108,196,255,0.2), rgba(108,196,255,0.05)); border: 1px solid #6cc4ff; padding: 4px 8px; border-radius: 8px; font-size: 11px; font-weight: 700; color: #6cc4ff; white-space: nowrap; }
.task-progress { background: rgba(0,0,0,0.4); height: 8px; border-radius: 4px; overflow: hidden; margin-bottom: 8px; }
.task-progress-fill { height: 100%; background: linear-gradient(90deg, #6cc4ff 0%, #00d4ff 100%); transition: width 0.3s; border-radius: 4px; }
.task-progress-text { font-size: 10px; color: rgba(255,255,255,0.7); margin-bottom: 6px; display: flex; justify-content: space-between; }
.task-claim-btn { width: 100%; padding: 8px; border-radius: 8px; border: 0; background: linear-gradient(180deg, #4ade80, #16a34a); color: #fff; font-weight: 800; font-size: 12px; cursor: pointer; }
.task-claim-btn:disabled { background: #555; color: #aaa; cursor: not-allowed; }
.tasks-timer { text-align: center; margin-top: 12px; font-size: 12px; color: #6cc4ff; font-weight: 600; }

/* ===== PLAYER LEVEL ===== */
.player-level-box { position: relative; width: min(calc(100vw - 76px), 430px); margin: clamp(2px, .7vh, 6px) 0 clamp(2px, .5vh, 4px); background: linear-gradient(180deg, rgba(47,25,14,.82), rgba(14,8,5,.78)); border: 1px solid rgba(255,200,93,.46); border-radius: 12px; padding: 6px 10px; z-index: 4; pointer-events: none; backdrop-filter: blur(9px); box-shadow: 0 5px 16px rgba(22,8,2,.26), inset 0 1px rgba(255,255,255,.07); }
.level-badge { font-size: 12px; font-weight: 800; color: #ffd24a; text-align: center; margin-bottom: 4px; }
.level-badge b { color: #fff; }
.xp-bar { height: 6px; background: rgba(0,0,0,0.5); border-radius: 3px; overflow: hidden; margin-bottom: 3px; }
.xp-fill { height: 100%; background: linear-gradient(90deg, #ffd24a 0%, #ff8800 100%); width: 0%; transition: width 0.3s; box-shadow: 0 0 4px rgba(255,210,74,0.6); }
.xp-text { font-size: 9px; color: rgba(255,255,255,0.7); text-align: center; font-variant-numeric: tabular-nums; }

/* ===== LEADERBOARD ===== */
.player-name-row { display: flex; gap: 6px; margin-bottom: 12px; }
.player-input { flex: 1; background: rgba(0,0,0,0.4); border: 1px solid rgba(255,255,255,0.15); border-radius: 8px; padding: 8px 10px; color: #fff; font-size: 13px; font-family: inherit; }
.player-input,
.wallet-info-row code { user-select: text; -webkit-user-select: text; }
.save-name-btn { background: linear-gradient(180deg, #ffd24a, #ff9a00); color: #2a1500; border: 0; padding: 8px 14px; border-radius: 8px; font-weight: 800; font-size: 12px; cursor: pointer; }
.leaderboard-list { display: flex; flex-direction: column; gap: 6px; }
.lb-row { display: flex; align-items: center; gap: 10px; background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.1); padding: 8px 10px; border-radius: 10px; }
.lb-row.gold { background: linear-gradient(180deg, rgba(255,210,74,0.2), rgba(255,150,0,0.05)); border-color: #ffd24a; }
.lb-row.silver { background: linear-gradient(180deg, rgba(192,192,192,0.2), rgba(192,192,192,0.05)); border-color: #c0c0c0; }
.lb-row.bronze { background: linear-gradient(180deg, rgba(205,127,50,0.2), rgba(205,127,50,0.05)); border-color: #cd7f32; }
.lb-row.me { background: linear-gradient(180deg, rgba(108,196,255,0.2), rgba(108,196,255,0.05)); border-color: #6cc4ff; }
.lb-rank { width: 28px; font-weight: 900; font-size: 14px; color: #ffd24a; text-align: center; }
.lb-rank-medal { font-size: 18px; }
.lb-info { flex: 1; min-width: 0; }
.lb-name { font-size: 13px; font-weight: 700; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-name-input { background: rgba(0,0,0,0.4); border: 1px solid rgba(255,255,255,0.2); border-radius: 6px; padding: 4px 6px; color: #fff; font-size: 12px; font-family: inherit; width: 100%; }
.lb-stats { font-size: 10px; color: rgba(255,255,255,0.7); margin-top: 2px; }
.lb-diamonds { font-size: 12px; font-weight: 700; color: #6cc4ff; }

/* ===== SIDE PANEL (ستون سمت راست) ===== */
.side-panel { position: fixed; right: max(0px, calc((100vw - 1100px) / 2)); top: 50%; transform: translateY(-50%); z-index: 8; display: flex; flex-direction: column; gap: 8px; padding: 6px 6px 6px 0; }
.side-btn { position: relative; width: 50px; height: 50px; border-radius: 14px 0 0 14px; border: 0; background: linear-gradient(180deg, rgba(0,0,0,0.7), rgba(0,0,0,0.5)); color: #fff; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; border: 1px solid rgba(255,210,74,0.3); border-right: 0; backdrop-filter: blur(6px); box-shadow: -2px 2px 8px rgba(0,0,0,0.4); transition: transform 0.15s; }
.side-btn:active { transform: translateX(-3px); }
.side-icon { font-size: 20px; line-height: 1; }
.side-label { font-size: 9px; font-weight: 700; color: #ffd24a; }
.side-badge { position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; background: #ff5050; color: #fff; font-size: 10px; font-weight: 800; border-radius: 9px; padding: 0 5px; display: flex; align-items: center; justify-content: center; border: 2px solid #000; }

/* Side drawer (از سمت راست) */
.side-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 50; opacity: 0; pointer-events: none; transition: opacity 0.25s; }
.side-overlay.show { opacity: 1; pointer-events: auto; }
.side-drawer { position: fixed; right: 0; top: 0; bottom: 0; width: 86vw; max-width: 420px; background: linear-gradient(180deg, #2a170d 0%, #120a07 100%); border-left: 2px solid #ffd268; transform: translateX(100%); transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1); z-index: 60; overflow-y: auto; padding: calc(20px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) calc(24px + env(safe-area-inset-bottom)) 16px; }
.side-drawer.show { transform: translateX(0); }
.side-drawer h3 { font-size: 18px; margin-bottom: 14px; color: #ffd24a; text-align: center; }
.side-drawer .drawer-close { position: absolute; top: 8px; right: 8px; width: 36px; height: 36px; border-radius: 50%; background: rgba(255,255,255,0.1); color: #fff; border: 0; font-size: 18px; font-weight: 800; cursor: pointer; z-index: 5; }

/* ===== LEVEL UP POPUP ===== */
.levelup-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.85); z-index: 300; display: flex; align-items: center; justify-content: center; opacity: 0; transition: opacity 0.3s; backdrop-filter: blur(8px); pointer-events: auto; }
.levelup-overlay.show { opacity: 1; }
.levelup-content { background: linear-gradient(180deg, #2a1a0a 0%, #1a0a05 100%); border: 3px solid #ffd24a; border-radius: 24px; padding: 28px 24px; text-align: center; max-width: 320px; width: 90%; box-shadow: 0 0 60px rgba(255,210,74,0.6); transform: scale(0.5); transition: transform 0.4s cubic-bezier(0.2, 1.5, 0.4, 1); }
.levelup-overlay.show .levelup-content { transform: scale(1); }
.levelup-stars { font-size: 36px; margin-bottom: 8px; animation: star-spin 2s ease-in-out infinite; }
@keyframes star-spin { 0%, 100% { transform: scale(1) rotate(0); } 50% { transform: scale(1.15) rotate(10deg); } }
.levelup-big { font-size: 42px; font-weight: 900; color: #ffd24a; text-shadow: 0 0 20px #ffd24a, 0 4px 0 #8b5a0f; margin: 8px 0; letter-spacing: 2px; }
.levelup-msg { font-size: 16px; color: #fff; margin: 6px 0; font-weight: 700; }
.levelup-line { width: 80%; height: 1px; background: linear-gradient(90deg, transparent, #ffd24a, transparent); margin: 14px auto; }
.levelup-detail { font-size: 13px; color: rgba(255,255,255,0.9); margin: 4px 0; }
.levelup-percent { font-size: 28px; font-weight: 900; color: #6cc4ff; text-shadow: 0 0 12px #6cc4ff; margin: 6px 0; }
.levelup-max { font-size: 12px; color: rgba(255,255,255,0.75); margin: 8px 0; }
.levelup-reward { font-size: 16px; color: #ffd24a; font-weight: 800; margin: 8px 0 16px; }
.levelup-btn { width: 100%; padding: 12px; border-radius: 12px; border: 0; background: linear-gradient(180deg, #ffd24a, #ff9a00); color: #2a1500; font-weight: 800; font-size: 15px; cursor: pointer; }

/* These rules stay last because the player/side-panel components are defined
   below the core responsive block in this legacy stylesheet. */
@media (max-width: 360px) {
  .side-btn { width: 44px; height: 44px; }
}

@media (max-height: 650px) and (orientation: portrait) {
  .player-level-box { margin-top: 1px; margin-bottom: 1px; }
}

@media (orientation: landscape) and (max-height: 600px) {
  .player-level-box { grid-column: 1; grid-row: 1; width: min(42vw, 430px); margin: 2px 0; }
  .side-panel { gap: 5px; }
  .side-btn { width: 42px; height: 42px; }
  .side-icon { font-size: 17px; }
  .side-label { font-size: 8px; }
}
