/* ============================================================
   EVOLUTION DRAGON  —  style.css
   Mobile-first portrait game UI
   ============================================================ */

/* ---------- RESET ---------- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    user-select: none;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #090400;
    font-family: 'Nunito', system-ui, sans-serif;
}

/* ---------- ROOT CONTAINER ---------- */
#game {
    position: relative;
    width: 100vw;
    height: 100dvh; /* dynamic viewport for mobile chrome bars */
    height: 100vh;  /* fallback */
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ============================================================
   GAME AREA (map background)
   ============================================================ */
#game-area {
    flex: 1;
    position: relative;
    overflow: hidden;
    background-image: url('Mapa/Mapa.webp');
    background-size: 100% 100%;
    background-position: center top;
    background-repeat: no-repeat;
    touch-action: none; /* prevent scroll interference during drag */
}

/* ============================================================
   TOP HUD
   ============================================================ */
#hud-top {
    position: absolute;
    top: 0; left: 0; right: 0;
    z-index: 60;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 0 8px;
    padding: 8px 10px 6px;
    pointer-events: none;
}

/* ------ Money ------ */
#money-section {
    pointer-events: none;
}

#money-display {
    font-family: 'Fredoka One', sans-serif;
    font-size: clamp(22px, 7vw, 30px);
    color: #FFD700;
    line-height: 1;
    text-shadow:
        0 0 14px rgba(255, 215, 0, 0.55),
        2px 2px 0 rgba(0,0,0,0.9),
        -1px -1px 0 rgba(0,0,0,0.9);
}

#income-display {
    font-size: 12px;
    font-weight: 800;
    color: #7AFF6A;
    text-shadow: 1px 1px 0 rgba(0,0,0,0.9);
    margin-top: 2px;
}

/* ------ Egg bar ------ */
#egg-bar-section {
    pointer-events: none;
}

#egg-bar-bg {
    height: 24px;
    background: rgba(0,0,0,0.55);
    border-radius: 12px;
    border: 2px solid rgba(255,255,255,0.25);
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(6px);
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.4);
}

#egg-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #FF6B00, #FFD700, #FFF176);
    border-radius: 10px;
    transition: width 0.15s linear;
    position: relative;
    overflow: hidden;
}

#egg-bar-fill::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg,
        transparent 0%,
        rgba(255,255,255,0.45) 50%,
        transparent 100%);
    background-size: 200% 100%;
    animation: eggShimmer 1.5s ease-in-out infinite;
}

@keyframes eggShimmer {
    0% { background-position: -100% 0; }
    100% { background-position: 200% 0; }
}

#egg-bar-icon {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    object-fit: contain;
    pointer-events: none;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.6));
}

/* ------ Controls (pause + auto-fusion) ------ */
#controls-section {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 5px;
    pointer-events: auto;
}

#pause-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(0,0,0,0.65);
    border: 2px solid rgba(255,255,255,0.3);
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    transition: transform 0.1s, background 0.15s;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

#pause-btn:active { transform: scale(0.88); }

#auto-fusion-box {
    display: flex;
    align-items: center;
    gap: 5px;
    background: rgba(0,0,0,0.6);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 14px;
    padding: 3px 8px 3px 6px;
    backdrop-filter: blur(4px);
}

#auto-egg-box {
    display: flex;
    align-items: center;
    gap: 5px;
    background: rgba(0,0,0,0.6);
    border: 1px solid rgba(255, 160, 0, 0.3);
    border-radius: 14px;
    padding: 3px 8px 3px 6px;
    backdrop-filter: blur(4px);
}

#auto-fusion-box > span {
    font-size: 10px;
    font-weight: 800;
    color: #fff;
    white-space: nowrap;
}

#auto-egg-box > span {
    font-size: 10px;
    font-weight: 800;
    color: #FFD180;
    white-space: nowrap;
}

/* Toggle switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 38px;
    height: 20px;
    flex-shrink: 0;
}

.toggle-switch input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
    position: absolute;
    inset: 0;
    background: #444;
    border-radius: 20px;
    transition: background 0.25s;
    cursor: pointer;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    left: 3px; top: 3px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.25s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}

.toggle-switch input:checked + .toggle-slider { background: #4CAF50; }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(18px); }

/* ============================================================
   BOTTOM PANEL  —  3 action buttons
   ============================================================ */
#bottom-panel {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 108px;
    background: linear-gradient(0deg, rgba(10,3,0,0.98) 0%, rgba(20,8,0,0.96) 100%);
    border-top: 2px solid rgba(200,130,30,0.35);
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: 8px 10px;
    gap: 8px;
    flex-shrink: 0;
    z-index: 50;
}

.btn-text-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
}
/* Hide Comprar/Mejorar labels in portrait to save vertical space */
.add-btn .btn-label, .egg-btn .btn-label {
    display: none;
}

.action-btn {
    flex: 1;
    height: 88px;
    border-radius: 18px;
    border: none;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 6px 4px;
    transition: transform 0.1s ease;
    position: relative;
    overflow: hidden;
}

.action-btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(255,255,255,0.12) 0%, transparent 55%);
    border-radius: inherit;
    pointer-events: none;
}

.action-btn:active { transform: scale(0.92); }

/* ADD DRAGON btn */
.add-btn {
    background: linear-gradient(155deg, #2E7D32, #1B5E20);
    border: 2px solid #43A047;
    box-shadow: 0 4px 16px rgba(76,175,80,0.35), inset 0 1px 0 rgba(255,255,255,0.12);
}
.add-btn.can-afford {
    box-shadow: 0 4px 22px rgba(76,175,80,0.55);
    border-color: #66BB6A;
}
.add-btn.cant-afford { filter: brightness(0.55) saturate(0.45); }

/* EGG btn */
.egg-btn {
    background: linear-gradient(155deg, #BF360C, #7B2200);
    border: 2px solid #E64A19;
    box-shadow: 0 4px 16px rgba(255,100,30,0.35), inset 0 1px 0 rgba(255,255,255,0.12);
}
.egg-btn.can-afford {
    box-shadow: 0 4px 22px rgba(255,140,0,0.55);
    border-color: #FF6E40;
}
.egg-btn.cant-afford { filter: brightness(0.55) saturate(0.45); }

/* REBIRTH btn */
.rebirth-btn {
    background: linear-gradient(155deg, #2a2a2a, #141414);
    border: 2px solid #555;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}
.rebirth-btn.unlocked {
    background: linear-gradient(155deg, #6D1F00, #3E0E00);
    border: 2px solid #E64A19;
    box-shadow: 0 4px 20px rgba(255,80,0,0.45);
}
.rebirth-btn.maxed {
    background: linear-gradient(155deg, #4A148C, #1A0050);
    border: 2px solid #9C27B0;
    box-shadow: 0 4px 20px rgba(156,39,176,0.45);
}

/* INCUBATOR btn */
.incubator-btn {
    background: linear-gradient(155deg, #4A148C, #311B92);
    border: 2px solid #7E57C2;
    box-shadow: 0 4px 16px rgba(103,58,183,0.35), inset 0 1px 0 rgba(255,255,255,0.12);
}
.incubator-btn:active {
    filter: brightness(1.2);
}

/* INVENTORY btn */
.inventory-btn {
    background: linear-gradient(155deg, #5D4037, #3E2723);
    border: 2px solid #8D6E63;
    box-shadow: 0 4px 16px rgba(141,110,99,0.35), inset 0 1px 0 rgba(255,255,255,0.12);
}
.inventory-btn:active {
    filter: brightness(1.2);
}


/* Btn inner parts */
.btn-icon-wrap {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-img {
    width: 50px;
    height: 50px;
    object-fit: contain;
    filter: drop-shadow(0 2px 5px rgba(0,0,0,0.55));
    pointer-events: none;
    flex-shrink: 0;
}

.add-btn .btn-img { width: 44px; height: 44px; }
.egg-img { width: 46px !important; height: 46px !important; }
.rebirth-img { width: 52px !important; height: 52px !important; }

.btn-badge {
    position: absolute;
    top: -4px; right: -10px;
    background: #FFD700;
    color: #000;
    font-family: 'Fredoka One', sans-serif;
    font-size: 11px;
    padding: 0 5px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}

.lock-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.5);
    border-radius: 6px;
    font-size: 20px;
}

.btn-cost {
    font-family: 'Fredoka One', sans-serif;
    font-size: 13px;
    color: #FFD700;
    text-shadow: 1px 1px 0 rgba(0,0,0,0.9);
    line-height: 1;
}

.btn-time {
    font-size: 10px;
    color: #FFAB91;
    font-weight: 800;
    line-height: 1;
}

.btn-label {
    font-size: 10px;
    color: #888;
    font-weight: 800;
    text-align: center;
    line-height: 1;
}
.rebirth-btn.unlocked .btn-label { color: #FF8A65; }
.rebirth-btn.maxed .btn-label { color: #CE93D8; }

/* ============================================================
   DRAGONS
   ============================================================ */
.dragon {
    position: absolute;
    left: 0;
    top: 0;
    transform: translate(-50%, -50%);
    cursor: grab;
    z-index: 10;
    touch-action: none;
    will-change: transform;
}

.dragon-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    animation: breathe var(--breath-dur, 2.2s) ease-in-out infinite;
    animation-delay: var(--breath-delay, 0s);
    transform-origin: bottom center;
}

@keyframes breathe {
    0%, 100% { transform: scaleX(1) scaleY(1); }
    50%       { transform: scaleX(0.96) scaleY(1.07); }
}

.dragon-img {
    width: 100%;
    height: auto;
    object-fit: contain;
    pointer-events: none;
    filter: drop-shadow(0 3px 7px rgba(0,0,0,0.55));
    transition: filter 0.2s;
}

.dragon-label {
    background: rgba(0,0,0,0.72);
    color: #FFD700;
    font-family: 'Fredoka One', sans-serif;
    font-size: 11px;
    line-height: 1;
    padding: 2px 7px;
    border-radius: 10px;
    border: 1px solid rgba(255,215,0,0.38);
    pointer-events: none;
    white-space: nowrap;
    box-shadow: 0 1px 4px rgba(0,0,0,0.5);
}

/* Dragging */
.dragon.dragging {
    z-index: 200 !important;
    cursor: grabbing;
}
.dragon.dragging .dragon-inner {
    animation: none !important;
    transform: scaleX(1.08) scaleY(1.08);
}
.dragon.dragging .dragon-img {
    filter:
        drop-shadow(0 0 14px rgba(255,220,0,0.95))
        drop-shadow(0 4px 10px rgba(0,0,0,0.65));
}

/* ---- Attraction (auto-fusion pull) ---- */
.dragon.attracting .dragon-inner {
    animation: attractPulse 0.18s ease-in-out infinite alternate !important;
    transform-origin: center center;
}

.dragon.attracting .dragon-img {
    filter:
        drop-shadow(0 0 20px rgba(255, 220, 0, 1))
        drop-shadow(0 0 40px rgba(255, 150, 0, 0.85))
        drop-shadow(0 4px 10px rgba(0,0,0,0.55)) !important;
}

@keyframes attractPulse {
    0%   { transform: scaleX(0.78) scaleY(1.24); }
    100% { transform: scaleX(1.28) scaleY(0.76); }
}

/* ---- Fusion burst ---- */
.fusion-burst {
    position: absolute;
    transform: translate(-50%, -50%);
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: radial-gradient(circle,
        rgba(255,240,100,0.95) 0%,
        rgba(255,140,0,0.7) 40%,
        transparent 70%);
    pointer-events: none;
    z-index: 150;
    animation: fusionBurst 0.55s ease-out forwards;
}

@keyframes fusionBurst {
    0%   { transform: translate(-50%,-50%) scale(0.2); opacity: 1; }
    100% { transform: translate(-50%,-50%) scale(3.5); opacity: 0; }
}

/* ============================================================
   EGGS
   ============================================================ */
.egg-item {
    position: absolute;
    transform: translate(-50%, -50%);
    cursor: pointer;
    z-index: 15;
    touch-action: none;
    animation: eggWobble 2s ease-in-out infinite;
}

.egg-item img {
    width: 44px;
    height: 44px;
    object-fit: contain;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.5));
    pointer-events: none;
}

@keyframes eggWobble {
    0%, 100% { transform: translate(-50%,-50%) rotate(-7deg) scale(1); }
    50%       { transform: translate(-50%,-50%) rotate(7deg) scale(1.06); }
}

/* Egg dragging — long-press drag mode */
.egg-item.egg-dragging {
    animation: none !important;
    z-index: 30;
    cursor: grabbing;
}
.egg-item.egg-dragging img {
    filter: drop-shadow(0 0 14px rgba(255,215,0,0.9)) drop-shadow(0 4px 8px rgba(0,0,0,0.5));
    transform: scale(1.18);
    transition: transform 0.12s, filter 0.12s;
}

/* Fall-in animation */
.egg-item.falling {
    animation: eggFallIn 0.75s cubic-bezier(0.22,0.61,0.36,1) forwards;
}

@keyframes eggFallIn {
    0%   { transform: translate(-50%,-250%) scale(0.4); opacity: 0; }
    65%  { transform: translate(-50%, 8%) scale(1.08); opacity: 1; }
    82%  { transform: translate(-50%,-6%) scale(0.96); }
    100% { transform: translate(-50%,-50%) scale(1); opacity: 1; }
}

/* Hatch */
.egg-item.hatching {
    animation: eggHatch 0.4s ease-in forwards !important;
}

@keyframes eggHatch {
    0%   { transform: translate(-50%,-50%) scale(1) rotate(0deg); }
    30%  { transform: translate(-50%,-50%) scale(1.25) rotate(-18deg); }
    60%  { transform: translate(-50%,-50%) scale(1.3) rotate(18deg); }
    100% { transform: translate(-50%,-50%) scale(0) rotate(0deg); opacity: 0; }
}

/* ============================================================
   EVOLUTION SCREEN
   ============================================================ */
#evolution-screen {
    position: fixed;
    inset: 0;
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
}

#evolution-screen.hidden { display: none; }

#confetti-canvas {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 501;
}

#evo-rays {
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at center,
        rgba(70,50,0,0.88) 0%,
        rgba(0,0,0,0.94) 65%);
    overflow: hidden;
}

#evo-rays::before {
    content: '';
    position: absolute;
    inset: -50%;
    /* sunburst rays */
    background: repeating-conic-gradient(
        rgba(255,200,0,0.06) 0deg 5deg,
        transparent 5deg 10deg
    );
    animation: raysSpin 10s linear infinite;
}

@keyframes raysSpin { to { transform: rotate(360deg); } }

#evo-content {
    position: relative;
    z-index: 502;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
    padding: 0 20px;
}

#evo-dragon-img {
    width: min(55vw, 200px);
    height: min(55vw, 200px);
    object-fit: contain;
    filter: drop-shadow(0 0 28px rgba(255,210,0,0.85));
    animation: dragonPop 0.45s cubic-bezier(0.34,1.56,0.64,1) both;
}

@keyframes dragonPop {
    0%   { transform: scale(0.2) rotate(-12deg); opacity: 0; }
    100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

#evo-title {
    font-family: 'Fredoka One', sans-serif;
    font-size: clamp(26px, 9vw, 36px);
    color: #FFD700;
    text-align: center;
    letter-spacing: 2px;
    text-shadow:
        0 0 24px rgba(255,215,0,0.75),
        3px 3px 0 rgba(0,0,0,0.85),
        -1px -1px 0 rgba(0,0,0,0.7);
    animation: titleSlide 0.4s ease-out both;
    animation-delay: 0.1s;
}

@keyframes titleSlide {
    0%   { transform: translateY(20px); opacity: 0; }
    100% { transform: translateY(0); opacity: 1; }
}

/* Progress slots */
#evo-progress-bar {
    display: flex;
    gap: 5px;
    justify-content: center;
    flex-wrap: wrap;
    background: rgba(0,0,0,0.55);
    padding: 8px 12px;
    border-radius: 18px;
    border: 1px solid rgba(255,215,0,0.2);
    animation: titleSlide 0.4s ease-out both;
    animation-delay: 0.2s;
    max-width: 90vw;
}

.evo-slot {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.12);
    overflow: hidden;
    flex-shrink: 0;
}

.evo-slot img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.evo-slot.current {
    border: 2px solid #FFD700;
    background: rgba(255,215,0,0.2);
    box-shadow: 0 0 10px rgba(255,215,0,0.5);
    transform: scale(1.18);
}

.evo-slot.undiscovered {
    color: rgba(255,255,255,0.25);
    font-size: 15px;
    font-weight: bold;
    background: rgba(0,0,0,0.25);
}

/* ============================================================
   PAUSE OVERLAY
   ============================================================ */
#pause-overlay {
    position: fixed;
    inset: 0;
    z-index: 400;
    background: rgba(0,0,0,0.68);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
}
#pause-overlay.hidden { display: none; }

#pause-card {
    background: rgba(12,5,0,0.97);
    border: 2px solid rgba(220,160,30,0.4);
    border-radius: 26px;
    padding: 40px 48px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.6);
}

#pause-icon {
    font-size: 48px;
    line-height: 1;
}

#pause-card h2 {
    font-family: 'Fredoka One', sans-serif;
    font-size: 28px;
    color: #FFD700;
    letter-spacing: 3px;
}

#resume-btn {
    background: linear-gradient(135deg, #388E3C, #1B5E20);
    border: 2px solid #66BB6A;
    border-radius: 16px;
    color: #fff;
    font-family: 'Fredoka One', sans-serif;
    font-size: 20px;
    padding: 12px 32px;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(76,175,80,0.45);
    transition: transform 0.1s;
}
#resume-btn:active { transform: scale(0.93); }

/* ============================================================
   REBIRTH CONFIRM MODAL
   ============================================================ */
#rebirth-confirm {
    position: fixed;
    inset: 0;
    z-index: 450;
    background: rgba(0,0,0,0.72);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
#rebirth-confirm.hidden { display: none; }

#rebirth-card {
    background: rgba(12,3,0,0.98);
    border: 2px solid rgba(255,80,0,0.45);
    border-radius: 24px;
    padding: 26px 22px;
    width: 100%;
    max-width: 320px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    box-shadow: 0 8px 40px rgba(255,60,0,0.3);
}

#rebirth-card-icon {
    width: 72px;
    height: 72px;
    object-fit: contain;
    filter: drop-shadow(0 0 16px rgba(255,100,0,0.7));
    animation: rebirthSpin 3s linear infinite;
}

@keyframes rebirthSpin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

#rebirth-card h2 {
    font-family: 'Fredoka One', sans-serif;
    font-size: 26px;
    color: #FF6E40;
    text-shadow: 0 0 16px rgba(255,100,0,0.5);
}

.rebirth-warn {
    font-size: 13px;
    color: rgba(255,180,150,0.85);
    text-align: center;
    line-height: 1.45;
}

.rebirth-gain-title {
    font-size: 12px;
    color: rgba(255,255,255,0.55);
    text-transform: uppercase;
    letter-spacing: 1px;
}

#rebirth-reward-box {
    width: 100%;
    background: rgba(255,80,0,0.1);
    border: 1px solid rgba(255,100,30,0.25);
    border-radius: 14px;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Requirement box (cost + level needed) */
#rebirth-req-box {
    width: 100%;
    background: rgba(255,215,0,0.07);
    border: 1px solid rgba(255,215,0,0.25);
    border-radius: 14px;
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.req-row {
    display: flex;
    align-items: center;
    gap: 7px;
}

.req-icon { font-size: 16px; flex-shrink: 0; }

.req-label {
    font-size: 12px;
    color: rgba(255,255,255,0.55);
    flex-shrink: 0;
}

.req-row span:last-child {
    font-family: 'Fredoka One', sans-serif;
    font-size: 14px;
    color: #FFD700;
    margin-left: auto;
}

.reward-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.reward-icon { font-size: 18px; }

.reward-row span:last-child {
    font-family: 'Fredoka One', sans-serif;
    font-size: 15px;
    color: #FFD700;
}

#rebirth-btn-row {
    display: flex;
    gap: 10px;
    width: 100%;
}

.rebirth-modal-btn {
    flex: 1;
    padding: 13px 10px;
    border-radius: 14px;
    font-family: 'Fredoka One', sans-serif;
    font-size: 17px;
    cursor: pointer;
    border: none;
    transition: transform 0.1s;
}
.rebirth-modal-btn:active { transform: scale(0.93); }

.rebirth-modal-btn.cancel {
    background: rgba(80,80,80,0.5);
    color: #bbb;
    border: 2px solid rgba(200,200,200,0.2);
}

.rebirth-modal-btn.confirm {
    background: linear-gradient(135deg, #D84315, #BF360C);
    color: #fff;
    border: 2px solid #FF5722;
    box-shadow: 0 4px 16px rgba(255,87,34,0.45);
}

/* ============================================================
   LOGIN BANNER
   ============================================================ */
#login-banner {
    position: fixed;
    bottom: 122px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 300;
    background: rgba(0,10,50,0.92);
    border: 1px solid rgba(100,160,255,0.38);
    border-radius: 14px;
    padding: 8px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    backdrop-filter: blur(6px);
    white-space: nowrap;
    box-shadow: 0 4px 20px rgba(0,50,200,0.3);
}
#login-banner.hidden { display: none; }

#login-banner > span {
    font-size: 12px;
    color: rgba(180,210,255,0.9);
}

#login-btn {
    background: linear-gradient(135deg, #1565C0, #0D47A1);
    border: 1px solid rgba(100,160,255,0.45);
    border-radius: 10px;
    color: #fff;
    font-family: 'Fredoka One', sans-serif;
    font-size: 13px;
    padding: 5px 12px;
    cursor: pointer;
    transition: transform 0.1s;
}
#login-btn:active { transform: scale(0.92); }

/* ============================================================
   SHAKE ANIMATION (for can't-afford feedback)
   ============================================================ */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%       { transform: translateX(-8px); }
    40%       { transform: translateX(8px); }
    60%       { transform: translateX(-5px); }
    80%       { transform: translateX(5px); }
}

.shaking { animation: shake 0.38s ease-in-out; }

/* ============================================================
   HIDDEN UTILITY
   ============================================================ */
.hidden { display: none !important; }

/* ============================================================
   MAP SELECTOR BUTTON  (floating, bottom-right above panel)
   ============================================================ */
#map-btn {
    position: absolute;
    right: 12px;
    bottom: 120px;
    z-index: 80;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: 2px solid rgba(255,200,0,0.5);
    background: rgba(10,5,0,0.85);
    padding: 5px;
    cursor: pointer;
    box-shadow: 0 4px 18px rgba(0,0,0,0.55), 0 0 12px rgba(255,180,0,0.3);
    backdrop-filter: blur(6px);
    transition: transform 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
}
#map-btn img { width: 100%; height: 100%; object-fit: contain; }
#map-btn:active { transform: scale(0.88); }

/* ============================================================
   MAP SELECT SCREEN
   ============================================================ */
#map-select {
    position: fixed;
    inset: 0;
    z-index: 480;
    background: rgba(0,0,0,0.78);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
#map-select.hidden { display: none !important; }

#map-select-card {
    background: rgba(8,4,0,0.98);
    border: 2px solid rgba(200,130,30,0.4);
    border-radius: 26px;
    width: 100%;
    max-width: 340px;
    padding: 20px 16px 28px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.7);
}

#map-select-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
#map-select-header h2 {
    font-family: 'Fredoka One', sans-serif;
    font-size: 20px;
    color: #FFD700;
    text-shadow: 0 0 12px rgba(255,215,0,0.5);
}
#map-select-close {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 50%;
    width: 30px;
    height: 30px;
    color: #fff;
    font-size: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
#map-select-close:active { background: rgba(255,255,255,0.25); }

#map-tree {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
}

.map-node {
    width: 100%;
    cursor: pointer;
    transition: transform 0.12s;
}
.map-node:active:not(.locked-node) { transform: scale(0.97); }
.map-node.locked-node { cursor: not-allowed; }

.map-node-inner {
    position: relative;
    border-radius: 16px;
    border: 2px solid rgba(255,200,0,0.25);
    background: rgba(255,255,255,0.04);
    transition: border-color 0.2s, box-shadow 0.2s;
    padding: 6px 6px 0;
}
.map-node:not(.locked-node):hover .map-node-inner {
    border-color: rgba(255,200,0,0.6);
    box-shadow: 0 0 20px rgba(255,200,0,0.2);
}
.map-node.locked-node .map-node-inner { border-color: rgba(80,80,80,0.3); }

.minimap-img {
    width: 100%;
    height: auto;
    max-height: 100px;
    object-fit: contain;
    display: block;
    border-radius: 10px;
}
.map-node.locked-node .minimap-img { filter: grayscale(0.8) brightness(0.45); opacity: 0.6; }

.map-node-label {
    font-family: 'Fredoka One', sans-serif;
    font-size: 14px;
    color: #FFD700;
    padding: 6px 10px 2px;
}
.map-node.locked-node .map-node-label { color: #666; }

.map-node-badge {
    font-size: 10px;
    font-weight: 800;
    padding: 2px 10px 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.map-node-badge.unlocked { color: #7AFF6A; }
.map-node-badge.locked   { color: #666; }
.map-node-badge.active   { color: #FFD700; }

.map-lock-overlay {
    position: absolute;
    inset: 6px 6px 0;
    background: rgba(0,0,0,0.55);
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    z-index: 2;
}
.lock-icon  { font-size: 26px; }
.lock-text  { font-size: 10px; font-weight: 800; color: #999; text-align: center; padding: 0 10px; }

.map-tree-line {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 4px 0;
}
.map-tree-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: rgba(255,200,0,0.5);
}
.map-tree-track {
    width: 3px;
    height: 24px;
    background: linear-gradient(180deg, rgba(255,200,0,0.5), rgba(255,200,0,0.15));
}

.map-node.current-map .map-node-inner {
    border-color: #FFD700;
    box-shadow: 0 0 20px rgba(255,215,0,0.3);
}

/* ============================================================
   PAUSE — VOLUME CONTROLS
   ============================================================ */
#volume-controls {
    width: 100%;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 14px;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.vol-row {
    display: flex;
    align-items: center;
    gap: 10px;
}
.vol-icon  { font-size: 18px; flex-shrink: 0; }
.vol-label { font-size: 11px; font-weight: 800; color: rgba(255,255,255,0.55); flex-shrink: 0; width: 48px; }
.vol-row input[type="range"] {
    flex: 1;
    -webkit-appearance: none;
    height: 5px;
    border-radius: 4px;
    background: rgba(255,255,255,0.15);
    outline: none;
    cursor: pointer;
}
.vol-row input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #FFD700;
    box-shadow: 0 1px 4px rgba(0,0,0,0.5);
    cursor: pointer;
}

/* ============================================================
   PAUSE — LANGUAGE CONTROLS
   ============================================================ */
#language-controls {
    width: 100%;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 14px;
    padding: 10px 14px;
    margin-top: 4px;
    display: flex;
    flex-direction: column;
}
.lang-row {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: space-between;
}
.lang-icon {
    font-size: 18px;
    flex-shrink: 0;
}
.lang-label {
    font-size: 11px;
    font-weight: 800;
    color: rgba(255,255,255,0.55);
    flex-shrink: 0;
    text-transform: uppercase;
}
#lang-select {
    flex: 1;
    max-width: 130px;
    background: rgba(20, 10, 0, 0.9);
    border: 1px solid rgba(255, 190, 60, 0.4);
    border-radius: 8px;
    color: #ffcf60;
    padding: 6px 10px;
    font-family: 'Fredoka One', sans-serif;
    font-size: 12px;
    outline: none;
    cursor: pointer;
}
#lang-select option {
    background: #140a00;
    color: #ffcf60;
}


/* ============================================================
   MAP 2 UNLOCK TOAST
   ============================================================ */
#map2-unlock-toast {
    position: fixed;
    top: 70px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    z-index: 600;
    background: linear-gradient(135deg, rgba(90,30,180,0.97), rgba(40,8,90,0.97));
    border: 2px solid rgba(170,90,255,0.6);
    border-radius: 18px;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 6px 28px rgba(100,30,220,0.5);
    font-family: 'Fredoka One', sans-serif;
    font-size: 14px;
    color: #fff;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s, transform 0.4s;
}
#map2-unlock-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ============================================================
   NEW MODALS (LIBRARY, INCUBATOR, INVENTORY, CUSTOM TOAST)
   ============================================================ */
#library-modal, #incubator-modal, #inventory-modal {
    position: fixed;
    inset: 0;
    z-index: 480;
    background: rgba(0,0,0,0.8);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

#library-card, #incubator-card, #inventory-card {
    background: rgba(10,5,0,0.98);
    border: 2px solid rgba(200,130,30,0.4);
    border-radius: 26px;
    width: 100%;
    max-width: 360px;
    max-height: 80dvh;
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.8);
    overflow: hidden;
}

#library-header, #incubator-header, #inventory-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

#library-header h2, #incubator-header h2, #inventory-header h2 {
    font-family: 'Fredoka One', sans-serif;
    font-size: 18px;
    color: #FFD700;
    text-shadow: 0 0 10px rgba(255,215,0,0.4);
}

.modal-close-btn {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 50%;
    width: 30px;
    height: 30px;
    color: #fff;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.modal-close-btn:active { background: rgba(255,255,255,0.25); }

/* --- Library modal specific --- */
#library-content-scroll {
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding-right: 4px;
}
#library-content-scroll::-webkit-scrollbar {
    width: 6px;
}
#library-content-scroll::-webkit-scrollbar-thumb {
    background: rgba(255,200,0,0.2);
    border-radius: 3px;
}

.library-section h3 {
    font-family: 'Fredoka One', sans-serif;
    font-size: 13px;
    color: #FFA726;
    margin-bottom: 8px;
    border-left: 3px solid #FFA726;
    padding-left: 6px;
}

.library-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.library-card {
    background: rgba(255,255,255,0.03);
    border: 2px solid rgba(255,255,255,0.1);
    border-radius: 14px;
    padding: 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    position: relative;
    transition: transform 0.1s;
}

.library-card.unlocked-card:active {
    transform: scale(0.95);
}

.library-card-img-wrap {
    width: 50px;
    height: 50px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 4px;
    transform-origin: bottom center;
}

.library-card.unlocked-card .library-card-img-wrap {
    animation: breathe var(--breath-dur, 2.2s) ease-in-out infinite;
    animation-delay: var(--breath-delay, 0s);
}

.library-card-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}

.library-card.locked-card .library-card-img {
    filter: brightness(0) contrast(1) opacity(0.35);
}

.library-card-lvl {
    font-size: 9px;
    font-weight: 800;
    color: #aaa;
    background: rgba(0,0,0,0.4);
    padding: 1px 4px;
    border-radius: 6px;
    margin-bottom: 2px;
}

.library-card-name {
    font-family: 'Fredoka One', sans-serif;
    font-size: 9px;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}
.library-card.locked-card .library-card-name {
    color: #555;
}

.library-card-count {
    position: absolute;
    top: -4px; right: -4px;
    background: #4CAF50;
    color: #fff;
    font-family: 'Fredoka One', sans-serif;
    font-size: 9px;
    padding: 0 4px;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}

/* Rarity specific card styling */
.rarity-comun { border-color: rgba(150,150,150,0.2); }
.rarity-raro { 
    border-color: rgba(30,136,229,0.5); 
    box-shadow: inset 0 0 8px rgba(30,136,229,0.15);
}
.rarity-raro .library-card-lvl { color: #90CAF9; }
.rarity-epico { 
    border-color: rgba(142,36,170,0.55); 
    box-shadow: inset 0 0 10px rgba(142,36,170,0.2);
}
.rarity-epico .library-card-lvl { color: #E1BEE7; }
.rarity-legendario { 
    border-color: rgba(255,160,0,0.65); 
    box-shadow: inset 0 0 12px rgba(255,160,0,0.25), 0 0 4px rgba(255,160,0,0.15);
}
.rarity-legendario .library-card-lvl { color: #FFE082; }
.rarity-mitico { 
    border-color: rgba(244,67,54,0.8); 
    box-shadow: inset 0 0 14px rgba(244,67,54,0.3), 0 0 8px rgba(244,67,54,0.25);
    animation: mythicalGlowPulse 2s infinite alternate;
}
.rarity-mitico .library-card-lvl { color: #FFCDD2; }

@keyframes mythicalGlowPulse {
    0% { box-shadow: inset 0 0 10px rgba(244,67,54,0.25), 0 0 6px rgba(244,67,54,0.2); }
    100% { box-shadow: inset 0 0 18px rgba(244,67,54,0.4), 0 0 14px rgba(244,67,54,0.4); border-color: rgba(255,110,64,0.95); }
}

/* --- Floating Library button --- */
#library-btn {
    position: absolute;
    right: 74px;
    bottom: 120px;
    z-index: 80;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: 2px solid rgba(255,200,0,0.5);
    background: rgba(10,5,0,0.85);
    padding: 5px;
    cursor: pointer;
    box-shadow: 0 4px 18px rgba(0,0,0,0.55), 0 0 12px rgba(255,180,0,0.3);
    backdrop-filter: blur(6px);
    transition: transform 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
}
#library-btn img { width: 100%; height: 100%; object-fit: contain; }
#library-btn:active { transform: scale(0.88); }

/* --- Incubator modal content --- */
#incubator-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    text-align: center;
    width: 100%;
}

.incubator-empty-text {
    font-size: 13px;
    color: #aaa;
    line-height: 1.5;
    padding: 20px 10px;
}

.incubator-egg-glowing {
    width: 90px;
    height: 90px;
    object-fit: contain;
    filter: drop-shadow(0 0 14px rgba(255,100,0,0.7));
    animation: eggWobble 2s ease-in-out infinite;
}

.incubator-slots {
    display: flex;
    justify-content: space-around;
    width: 100%;
    gap: 8px;
    margin-top: 10px;
}

.incubator-slot-card {
    flex: 1;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 12px;
    padding: 8px 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.incubator-slot-card.slotted {
    border-color: rgba(76,175,80,0.5);
    background: rgba(76,175,80,0.05);
}

.incubator-slot-img {
    width: 36px;
    height: 36px;
    object-fit: contain;
}

.incubator-slot-card.empty-slot .incubator-slot-img {
    filter: grayscale(1) opacity(0.2);
}

.incubator-slot-label {
    font-size: 10px;
    font-weight: 800;
    color: #fff;
    white-space: nowrap;
}

.slot-btn {
    background: linear-gradient(135deg, #FF9800, #F57C00);
    border: none;
    border-radius: 8px;
    color: #000;
    font-family: 'Fredoka One', sans-serif;
    font-size: 10px;
    padding: 3px 8px;
    cursor: pointer;
    transition: transform 0.1s;
}
.slot-btn:active { transform: scale(0.92); }

.slot-ok-badge {
    color: #4CAF50;
    font-weight: bold;
    font-size: 11px;
}

.awaken-btn {
    width: 100%;
    background: linear-gradient(135deg, #F44336, #D32F2F);
    border: 2px solid #FF5252;
    border-radius: 16px;
    color: #fff;
    font-family: 'Fredoka One', sans-serif;
    font-size: 16px;
    padding: 12px;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(244,67,54,0.5);
    transition: transform 0.1s, box-shadow 0.2s;
    animation: awakenPulse 1.5s infinite alternate;
}
.awaken-btn:active { transform: scale(0.95); }

@keyframes awakenPulse {
    0% { box-shadow: 0 4px 14px rgba(244,67,54,0.4); }
    100% { box-shadow: 0 4px 24px rgba(244,67,54,0.8), 0 0 10px rgba(255,215,0,0.3); }
}

/* --- Inventory modal content --- */
#inventory-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

.inventory-row {
    display: flex;
    align-items: center;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 16px;
    padding: 10px 14px;
    gap: 12px;
}

.inventory-row-img {
    width: 44px;
    height: 44px;
    object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}

.inventory-row-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.inventory-row-name {
    font-family: 'Fredoka One', sans-serif;
    font-size: 13px;
    color: #FFD700;
}

.inventory-row-desc {
    font-size: 10px;
    color: #aaa;
    line-height: 1.3;
    text-align: left;
}

.inventory-row-count {
    font-family: 'Fredoka One', sans-serif;
    font-size: 20px;
    color: #fff;
    background: rgba(0,0,0,0.3);
    padding: 4px 10px;
    border-radius: 10px;
    min-width: 36px;
    text-align: center;
}

/* --- Special egg on map --- */
.egg-item.special-egg img {
    filter: drop-shadow(0 0 8px rgba(255,100,0,0.8)) drop-shadow(0 4px 8px rgba(0,0,0,0.5));
    animation: specialEggPulse 1.5s infinite alternate;
}

@keyframes specialEggPulse {
    0% { filter: drop-shadow(0 0 6px rgba(255,100,0,0.7)) drop-shadow(0 4px 8px rgba(0,0,0,0.5)); }
    100% { filter: drop-shadow(0 0 16px rgba(255,150,0,0.95)) drop-shadow(0 4px 8px rgba(0,0,0,0.5)); }
}

/* --- Map items --- */
.map-item {
    position: absolute;
    transform: translate(-50%, -50%);
    cursor: pointer;
    z-index: 12;
    animation: mapItemPulse 1.5s infinite alternate;
}

.map-item img {
    width: 32px;
    height: 32px;
    object-fit: contain;
    filter: drop-shadow(0 0 6px rgba(255,215,0,0.6));
}

@keyframes mapItemPulse {
    0% { transform: translate(-50%, -50%) scale(1); filter: drop-shadow(0 0 4px rgba(255,215,0,0.5)); }
    100% { transform: translate(-50%, -50%) scale(1.15); filter: drop-shadow(0 0 12px rgba(255,215,0,0.85)); }
}

/* --- Mythical dragon on map --- */
.dragon.mythical-dragon .dragon-img {
    filter: drop-shadow(0 0 12px rgba(244,67,54,0.7)) drop-shadow(0 0 25px rgba(255,215,0,0.5)) !important;
    animation: mythicalPulse 2s infinite alternate;
}

@keyframes mythicalPulse {
    0% { filter: drop-shadow(0 0 10px rgba(244,67,54,0.6)) drop-shadow(0 0 20px rgba(255,215,0,0.4)) !important; }
    100% { filter: drop-shadow(0 0 22px rgba(244,67,54,0.9)) drop-shadow(0 0 40px rgba(255,215,0,0.75)) !important; }
}

/* --- Custom Toast Notification --- */
#custom-toast {
    position: fixed;
    top: 70px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    z-index: 600;
    background: linear-gradient(135deg, rgba(230,81,0,0.95), rgba(94,22,0,0.95));
    border: 2px solid rgba(255,171,64,0.6);
    border-radius: 18px;
    padding: 10px 20px;
    box-shadow: 0 6px 28px rgba(230,81,0,0.5);
    font-family: 'Fredoka One', sans-serif;
    font-size: 13px;
    color: #fff;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s, transform 0.4s;
}
#custom-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.modal-header-icon {
    width: 24px;
    height: 24px;
    vertical-align: middle;
    margin-right: 8px;
    object-fit: contain;
}

/* ============================================================
   RESPONSIVITY FOR 5 BOTTOM PANEL BUTTONS
   ============================================================ */
@media (max-width: 480px) {
    #bottom-panel {
        gap: 3px !important;
        padding: 8px 4px !important;
        height: 98px !important;
    }
    .action-btn {
        height: 80px !important;
        border-radius: 12px !important;
        padding: 4px 2px !important;
    }
    .btn-img {
        width: 32px !important;
        height: 32px !important;
    }
    .add-btn .btn-img { width: 28px !important; height: 28px !important; }
    .egg-img { width: 28px !important; height: 28px !important; }
    .rebirth-img { width: 34px !important; height: 34px !important; }
    .incubator-img { width: 28px !important; height: 28px !important; }
    .inventory-img { width: 28px !important; height: 28px !important; }
    
    .btn-cost, .btn-label {
        font-size: 9px !important;
    }
    .btn-time {
        font-size: 7px !important;
    }
    .btn-badge {
        font-size: 8px !important;
        padding: 0 3px !important;
        top: -3px !important;
        right: -8px !important;
    }
}

/* ============================================================
   LANDSCAPE (TABLET / PC) DYNAMIC LAYOUT
   ============================================================ */
@media (orientation: landscape) {
    #game {
        display: flex;
        flex-direction: row;
        justify-content: stretch;
        align-items: stretch;
        background: #090400;
    }
    #game-area {
        position: relative;
        flex: 1;
        width: 100%;
        height: 100%;
        background-size: 100% 100%;
        box-shadow: none;
        border: none;
    }

    #hud-top {
        top: 12px;
        left: 20px;
        right: 20px;
        grid-template-columns: auto 1fr auto;
    }
    #money-display {
        font-size: clamp(24px, 3.2vw, 34px);
    }

    #egg-bar-bg {
        max-width: 320px;
        margin: 0 auto;
    }

    /* Keep bottom panel at bottom in landscape */
    #bottom-panel {
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        height: 108px;
        background: linear-gradient(0deg, rgba(10,3,0,0.98) 0%, rgba(20,8,0,0.96) 100%);
        border-top: 2px solid rgba(200,130,30,0.35);
        display: flex;
        flex-direction: row !important;
        justify-content: space-around;
        align-items: center;
        padding: 8px 12%; /* Keep buttons centered and beautifully spaced */
        gap: 16px;
        width: 100% !important;
        top: auto !important;
        border-radius: 0;
    }

    .action-btn {
        flex: 1;
        max-width: 160px;
        height: 88px !important;
        flex-direction: column !important;
        justify-content: center !important;
        align-items: center !important;
        padding: 6px 4px !important;
        gap: 2px !important;
        border-radius: 18px;
        text-align: center;
    }

    .btn-icon-wrap {
        width: 50px !important;
        height: 50px !important;
        flex-shrink: 0;
    }
    .btn-img {
        width: 50px !important;
        height: 50px !important;
    }
    .add-btn .btn-img { width: 44px !important; height: 44px !important; }
    .egg-img { width: 46px !important; height: 46px !important; }
    .rebirth-img { width: 52px !important; height: 52px !important; }
    .incubator-img { width: 46px !important; height: 46px !important; }
    .inventory-img { width: 46px !important; height: 46px !important; }

    .btn-badge {
        top: -4px;
        right: -8px;
        font-size: 9px;
        padding: 0 4px;
    }

    .btn-text-wrap {
        display: flex;
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 2px;
    }

    .btn-label {
        display: none !important;
    }
    .incubator-btn .btn-label, .inventory-btn .btn-label, .rebirth-btn .btn-label {
        display: block !important;
        font-size: 10px !important;
        color: #888 !important;
        font-weight: 800 !important;
        text-align: center !important;
    }
    .rebirth-btn.unlocked .btn-label { color: #FF8A65 !important; }
    .rebirth-btn.maxed .btn-label { color: #CE93D8 !important; }

    .btn-cost {
        font-size: 13px !important;
        color: #FFD700;
    }
    .btn-time {
        font-size: 10px !important;
        color: #FFAB91;
    }

    /* Floating buttons side-by-side above bottom panel on the right */
    #library-btn {
        position: absolute;
        right: 20px;
        bottom: 120px;
        top: auto !important;
        left: auto !important;
        width: 54px;
        height: 54px;
        box-shadow: 0 4px 20px rgba(0,0,0,0.6), 0 0 12px rgba(255,180,0,0.2);
    }
    #map-btn {
        position: absolute;
        right: 84px;
        bottom: 120px;
        top: auto !important;
        left: auto !important;
        width: 54px;
        height: 54px;
        box-shadow: 0 4px 20px rgba(0,0,0,0.6), 0 0 12px rgba(255,180,0,0.2);
    }
}

/* ================================================================
   ACHIEVEMENTS, MULTIPLIERS & POTION EFFECTS
   ================================================================ */
#top-buttons-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

#achievements-btn {
    position: relative;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(0,0,0,0.65);
    border: 2px solid rgba(255,200,0,0.4);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    transition: transform 0.1s;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
    padding: 6px;
}
#achievements-btn img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}
#achievements-btn:active {
    transform: scale(0.88);
}
#achievements-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: #FF1744;
    color: #fff;
    font-family: 'Fredoka One', sans-serif;
    font-size: 10px;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}

#achievement-toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-100px);
    z-index: 9999;
    background: rgba(15, 8, 3, 0.95);
    border: 2px solid #FFD700;
    border-radius: 20px;
    padding: 12px 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.8), 0 0 15px rgba(255, 215, 0, 0.25);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s;
    opacity: 0;
    pointer-events: auto;
    min-width: 280px;
    max-width: 90vw;
}
#achievement-toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}
#achievement-toast-icon {
    width: 44px;
    height: 44px;
    object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}
#achievement-toast-text-wrap {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}
.achievement-toast-title {
    font-size: 10px;
    font-weight: 800;
    color: #FFD700;
    letter-spacing: 1px;
}
#achievement-toast-name {
    font-family: 'Fredoka One', sans-serif;
    font-size: 15px;
    color: #fff;
}
#achievement-toast-close {
    background: transparent;
    border: none;
    color: #888;
    font-size: 22px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    transition: color 0.15s;
}
#achievement-toast-close:hover {
    color: #fff;
}

#achievements-modal {
    position: fixed;
    inset: 0;
    z-index: 480;
    background: rgba(0,0,0,0.8);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
#achievements-card {
    background: rgba(10,5,0,0.98);
    border: 2px solid rgba(200,130,30,0.4);
    border-radius: 26px;
    width: 100%;
    max-width: 360px;
    max-height: 80dvh;
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.8);
    overflow: hidden;
}
#achievements-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
#achievements-header h2 {
    font-family: 'Fredoka One', sans-serif;
    font-size: 18px;
    color: #FFD700;
    text-shadow: 0 0 10px rgba(255,215,0,0.4);
    display: flex;
    align-items: center;
    gap: 8px;
}
#achievements-content-scroll {
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-right: 4px;
}
#achievements-content-scroll::-webkit-scrollbar {
    width: 6px;
}
#achievements-content-scroll::-webkit-scrollbar-thumb {
    background: rgba(255,200,0,0.2);
    border-radius: 3px;
}
.achievement-row {
    background: rgba(255,255,255,0.03);
    border: 2px solid rgba(255,255,255,0.08);
    border-radius: 16px;
    padding: 10px 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: background 0.2s, border-color 0.2s;
}
.achievement-row.unlocked {
    background: rgba(255, 215, 0, 0.04);
    border-color: rgba(255, 215, 0, 0.25);
    box-shadow: inset 0 0 10px rgba(255, 215, 0, 0.05);
}
.achievement-row.locked {
    opacity: 0.55;
    filter: grayscale(0.85);
}
.achievement-row-img {
    width: 44px;
    height: 44px;
    object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}
.achievement-row-info {
    display: flex;
    flex-direction: column;
    gap: 1px;
    flex: 1;
}
.achievement-row-name {
    font-family: 'Fredoka One', sans-serif;
    font-size: 13px;
    color: #fff;
}
.achievement-row.unlocked .achievement-row-name {
    color: #FFD700;
}
.achievement-row-desc {
    font-size: 10px;
    color: #aaa;
    line-height: 1.2;
}
.achievement-row-status {
    font-family: 'Fredoka One', sans-serif;
    font-size: 10px;
}
.achievement-row.unlocked .achievement-row-status {
    color: #4CAF50;
}
.achievement-row.locked .achievement-row-status {
    color: #888;
}

/* Aura for dragons when dragging upgrade potion */
.dragon-inner.upgrade-aura {
    filter: drop-shadow(0 0 12px rgba(76, 175, 80, 0.9));
    animation: auraBlink 0.6s infinite alternate;
}
@keyframes auraBlink {
    0% { opacity: 0.7; }
    100% { opacity: 1.0; filter: drop-shadow(0 0 18px rgba(76, 175, 80, 1.0)); }
}

/* Upgrade burst visual effect */
.upgrade-burst {
    position: absolute;
    width: 120px;
    height: 120px;
    background: radial-gradient(circle, rgba(76,175,80,0.8) 0%, transparent 70%);
    transform: translate(-50%, -50%) scale(0.1);
    border-radius: 50%;
    pointer-events: none;
    z-index: 250;
    animation: upgradeBurstAnim 0.5s cubic-bezier(0.1, 0.8, 0.3, 1) forwards;
}
@keyframes upgradeBurstAnim {
    to { transform: translate(-50%, -50%) scale(1.3); opacity: 0; }
}

/* Item countdown timer labels */
.item-time-label, .egg-time-label {
    position: absolute;
    top: -16px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #FFF;
    font-size: 9px;
    font-family: monospace;
    font-weight: bold;
    padding: 1px 4px;
    border-radius: 4px;
    pointer-events: none;
    box-shadow: 0 1px 3px rgba(0,0,0,0.5);
    white-space: nowrap;
    z-index: 10;
}
.egg-time-label {
    top: -12px;
    border-color: rgba(255, 100, 100, 0.4);
}

/* Speed multiplier active label */
#egg-speed-multiplier-label {
    font-family: 'Fredoka One', sans-serif;
    font-size: 10px;
    color: #FFD700;
    text-align: center;
    text-shadow: 1px 1px 0 rgba(0,0,0,0.8);
    margin-top: 4px;
    animation: pulseGlow 1s infinite alternate;
}
@keyframes pulseGlow {
    0% { text-shadow: 0 0 4px rgba(255,215,0,0.5), 1px 1px 0 #000; }
    100% { text-shadow: 0 0 10px rgba(255,215,0,0.9), 1px 1px 0 #000; }
}

/* Make sure potion items have nice visuals when being dragged */
.map-item.dragging {
    pointer-events: none;
    opacity: 0.8;
}

/* Custom badge positioning for floating library and map select buttons */
#library-btn .btn-badge, #map-btn .btn-badge {
    position: absolute;
    top: -2px !important;
    right: -2px !important;
    background: #FF1744 !important;
    color: #fff !important;
    font-family: 'Fredoka One', sans-serif !important;
    font-size: 10px !important;
    width: 17px !important;
    height: 17px !important;
    border-radius: 50% !important;
    display: flex;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;
    box-shadow: 0 2px 4px rgba(0,0,0,0.4) !important;
}

#library-btn .btn-badge.hidden, #map-btn .btn-badge.hidden {
    display: none !important;
}

/* Wider achievements card and larger icons on PC/Tablet displays */
@media (min-width: 768px) {
    #achievements-card {
        max-width: 480px !important;
        max-height: 85dvh !important;
        padding: 24px 20px !important;
    }
    .achievement-row {
        padding: 14px 16px !important;
        gap: 16px !important;
    }
    .achievement-row-img {
        width: 54px !important;
        height: 54px !important;
    }
    .achievement-row-name {
        font-size: 15px !important;
    }
    .achievement-row-desc {
        font-size: 11px !important;
    }
}


/* ============================================================
   TUTORIAL SYSTEM
   ============================================================ */

/* Overlay that sits above everything */
#tutorial-overlay {
    position: absolute;
    inset: 0;
    z-index: 9000;
    pointer-events: none;
}
#tutorial-overlay.hidden { display: none; }

/* Spotlight — full dark overlay, JS sets radial cutout — pointer-events: none so drags pass through */
#tutorial-spotlight {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.62);
    pointer-events: none;
}

/* Animated bouncing finger */
#tutorial-finger {
    position: absolute;
    width: clamp(48px, 10vmin, 72px);
    height: auto;
    filter: drop-shadow(0 4px 12px rgba(0,0,0,0.7));
    pointer-events: none;
    animation: tut-bounce 0.9s ease-in-out infinite alternate;
    transform-origin: top left;
}
@keyframes tut-bounce {
    from { transform: translate(0, 0) rotate(-10deg); }
    to   { transform: translate(4px, 10px) rotate(5deg); }
}

/* Text chip — minimal translucent pill */
#tutorial-chip {
    position: absolute;
    background: rgba(20, 12, 0, 0.88);
    border: 1.5px solid rgba(255,190,60,0.55);
    border-radius: 14px;
    color: #ffe8a0;
    font-family: 'Nunito', system-ui, sans-serif;
    font-size: clamp(11px, 3vmin, 15px);
    font-weight: 700;
    padding: 7px 16px;
    pointer-events: none;
    box-shadow: 0 4px 18px rgba(0,0,0,0.5);
    text-align: center;
    max-width: 88vw;
    white-space: normal;
    line-height: 1.4;
    animation: tut-fade-in 0.3s ease;
}
@keyframes tut-fade-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Skip button */
#tutorial-skip {
    position: absolute;
    top: max(12px, env(safe-area-inset-top, 12px));
    right: 14px;
    background: rgba(30,18,0,0.82);
    border: 1.5px solid rgba(255,190,60,0.45);
    border-radius: 20px;
    color: #ffcf60;
    font-family: 'Nunito', system-ui, sans-serif;
    font-size: clamp(11px, 3vmin, 14px);
    font-weight: 700;
    padding: 6px 16px;
    cursor: pointer;
    pointer-events: all;
    z-index: 9010;
    transition: background 0.18s, transform 0.12s;
}
#tutorial-skip:hover  { background: rgba(60,36,0,0.95); transform: scale(1.04); }
#tutorial-skip:active { transform: scale(0.97); }

/* Pulsing golden ring on action buttons during tutorial steps 2 & 3 */
.tut-btn-pulse {
    animation: tut-pulse-ring 1.1s ease-out infinite;
    outline: 3px solid rgba(255,210,60,0.0);
    outline-offset: 0px;
}
@keyframes tut-pulse-ring {
    0%   { outline-color: rgba(255,210,60,0.0);  outline-offset: 0px;  }
    40%  { outline-color: rgba(255,210,60,0.85); outline-offset: 4px;  }
    100% { outline-color: rgba(255,210,60,0.0);  outline-offset: 10px; }
}

/* PC adjustments */
@media (min-width: 768px) {
    #tutorial-finger { width: clamp(60px, 7vmin, 84px); }
    #tutorial-chip   { font-size: clamp(13px, 2vmin, 16px); padding: 9px 20px; }
}

/* ========== NARRATIVE OVERLAY ========== */
#narrative-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 10000;
    display: flex;
    justify-content: center;
    align-items: center;
}
#narrative-card {
    background: linear-gradient(135deg, #1f140e 0%, #120904 100%);
    border: 3px solid #ff9f43;
    box-shadow: 0 10px 30px rgba(0,0,0,0.8), 0 0 20px rgba(255, 159, 67, 0.2);
    border-radius: 20px;
    width: 85%;
    max-width: 320px;
    padding: 24px 20px;
    text-align: center;
    color: #fff;
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
#narrative-icon {
    font-size: 40px;
    margin-bottom: 12px;
    animation: float 2.5s ease-in-out infinite;
}
#narrative-text {
    font-family: 'Fredoka One', sans-serif;
    font-size: 15px;
    line-height: 1.5;
    margin-bottom: 20px;
    color: #FFE082;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}
#narrative-btn {
    background: linear-gradient(135deg, #ff9f43 0%, #ff6b6b 100%);
    border: none;
    border-radius: 12px;
    color: #fff;
    font-family: 'Fredoka One', sans-serif;
    font-size: 14px;
    padding: 10px 24px;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(255, 107, 107, 0.4);
    transition: transform 0.1s, box-shadow 0.1s;
}
#narrative-btn:active {
    transform: scale(0.95);
    box-shadow: 0 2px 5px rgba(255, 107, 107, 0.4);
}


