/* ===== GLOBAL STYLES ===== */
:root {
    --primary: #ff6b9d;
    --primary-dark: #e0457a;
    --secondary: #ffd700;
    --accent: #ff9f43;
    --bg-dark: #1a0a2e;
    --bg-mid: #2d1b4e;
    --bg-light: #3d2a5e;
    --card-bg: rgba(255,255,255,0.07);
    --card-border: rgba(255,255,255,0.15);
    --text-primary: #ffffff;
    --text-secondary: #c8a8e9;
    --text-muted: #8a6aaa;
    --success: #00d2a0;
    --danger: #ff4757;
    --shadow: 0 8px 32px rgba(0,0,0,0.4);
    --radius: 16px;
    --radius-sm: 8px;
    --transition: 0.2s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: linear-gradient(180deg, #87CEEB 0%, #B0E0FF 25%, #FFD1DC 50%, #FFB6C1 65%, #FF69B4 80%, #FF1493 100%);
    color: var(--text-primary);
    user-select: none;
}

/* ===== SCREENS ===== */
.screen {
    position: fixed;
    inset: 0;
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 1;
}

.screen.active {
    display: flex;
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: all var(--transition);
    text-transform: uppercase;
    min-height: 48px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    box-shadow: 0 4px 15px rgba(255,107,157,0.4);
}

.btn-primary:hover, .btn-primary:active {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255,107,157,0.6);
}

.btn-secondary {
    background: var(--card-bg);
    color: var(--text-primary);
    border: 1px solid var(--card-border);
    backdrop-filter: blur(10px);
}

.btn-secondary:hover, .btn-secondary:active {
    background: rgba(255,255,255,0.12);
    transform: translateY(-1px);
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger), #c0392b);
    color: white;
    box-shadow: 0 4px 15px rgba(255,71,87,0.3);
}

.btn-icon {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    color: var(--text-primary);
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    backdrop-filter: blur(10px);
}

.btn-icon:hover {
    background: rgba(255,255,255,0.12);
}

.btn-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all var(--transition);
}

.btn-close:hover {
    background: rgba(255,255,255,0.1);
    color: white;
}

/* ===== MODALS ===== */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
    padding: 16px;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: linear-gradient(135deg, rgba(45,27,78,0.92), rgba(26,10,46,0.95));
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    width: 100%;
    max-width: 500px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow), 0 0 60px rgba(255,105,180,0.15);
    overflow: hidden;
    backdrop-filter: blur(16px);
}

.modal-small {
    max-width: 380px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--card-border);
}

.modal-header h2 {
    font-size: 18px;
    font-weight: 800;
    letter-spacing: 1px;
    color: var(--secondary);
}

.modal-body {
    padding: 20px 24px;
    overflow-y: auto;
    flex: 1;
}

.modal-body::-webkit-scrollbar {
    width: 4px;
}

.modal-body::-webkit-scrollbar-track {
    background: transparent;
}

.modal-body::-webkit-scrollbar-thumb {
    background: var(--card-border);
    border-radius: 2px;
}

.modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

.modal-actions .btn {
    flex: 1;
}

/* ===== NOTIFICATION ===== */
.notification {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, rgba(255,107,157,0.95), rgba(224,69,122,0.95));
    color: white;
    padding: 12px 24px;
    border-radius: 30px;
    font-weight: 700;
    font-size: 14px;
    z-index: 2000;
    box-shadow: 0 4px 20px rgba(255,107,157,0.5), 0 0 40px rgba(255,105,180,0.3);
    transition: all 0.3s ease;
    white-space: nowrap;
    backdrop-filter: blur(8px);
}

.notification.hidden {
    display: none;
}

/* ===== TOGGLE BUTTON ===== */
.toggle-btn {
    background: var(--success);
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    transition: all var(--transition);
    min-width: 60px;
}

.toggle-btn.off {
    background: var(--text-muted);
}

/* ===== SETTING ROW ===== */
.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 0;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    font-size: 15px;
}

.setting-divider {
    height: 20px;
}

/* ===== HOW TO PLAY ===== */
.htp-step {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
    align-items: flex-start;
}

.htp-num {
    width: 32px;
    height: 32px;
    min-width: 32px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 14px;
}

.htp-step strong {
    display: block;
    margin-bottom: 4px;
    color: var(--secondary);
}

.htp-step p {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.5;
}

/* ===== LEVEL UP OVERLAY ===== */
.levelup-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    pointer-events: none;
    background: rgba(26,10,46,0.5);
    backdrop-filter: blur(6px);
}

.levelup-overlay.hidden {
    display: none;
}

.levelup-content {
    text-align: center;
    animation: levelupAnim 2s ease forwards;
    background: rgba(26,10,46,0.8);
    backdrop-filter: blur(16px);
    padding: 30px 50px;
    border-radius: 20px;
    border: 1px solid rgba(255,215,0,0.3);
    box-shadow: 0 0 40px rgba(255,215,0,0.3), 0 8px 32px rgba(0,0,0,0.4);
}

.levelup-title {
    font-size: 28px;
    font-weight: 900;
    color: var(--secondary);
    text-shadow: 0 0 20px rgba(255,215,0,0.8);
    letter-spacing: 3px;
}

.levelup-num {
    font-size: 72px;
    font-weight: 900;
    color: white;
    text-shadow: 0 0 30px rgba(255,215,0,0.6);
    line-height: 1;
}

.levelup-bonus {
    font-size: 18px;
    color: var(--success);
    margin-top: 8px;
}

/* ===== OFFLINE REWARD ===== */
.offline-reward {
    font-size: 32px;
    font-weight: 900;
    color: var(--secondary);
    text-align: center;
    padding: 16px;
    background: rgba(255,215,0,0.1);
    border-radius: var(--radius-sm);
    margin: 12px 0;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--card-border);
    border-radius: 3px;
}

/* ===== CANDY ISLAND WORLD ===== */
#candy-world {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

/* ===== SKY CLOUDS ===== */
.cloud {
    position: absolute;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.05));
}

.cloud-puff {
    position: absolute;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
}

.cloud-1 { top: 6%; left: -200px; animation: cloudDrift 45s linear infinite; }
.cloud-1 .cp1 { width: 80px; height: 50px; top: 10px; left: 0; border-radius: 50px; }
.cloud-1 .cp2 { width: 100px; height: 60px; top: 0; left: 40px; border-radius: 60px; }
.cloud-1 .cp3 { width: 70px; height: 45px; top: 12px; left: 100px; border-radius: 45px; }
.cloud-1 .cp4 { width: 60px; height: 35px; top: 18px; left: 140px; border-radius: 35px; }

.cloud-2 { top: 14%; left: -180px; animation: cloudDrift 55s linear infinite; animation-delay: -15s; }
.cloud-2 .cp1 { width: 60px; height: 38px; top: 8px; left: 0; border-radius: 38px; }
.cloud-2 .cp2 { width: 80px; height: 50px; top: 0; left: 30px; border-radius: 50px; }
.cloud-2 .cp3 { width: 55px; height: 35px; top: 10px; left: 80px; border-radius: 35px; }

.cloud-3 { top: 22%; left: -220px; animation: cloudDrift 65s linear infinite; animation-delay: -30s; }
.cloud-3 .cp1 { width: 90px; height: 55px; top: 10px; left: 0; border-radius: 55px; }
.cloud-3 .cp2 { width: 110px; height: 65px; top: 0; left: 50px; border-radius: 65px; }
.cloud-3 .cp3 { width: 80px; height: 48px; top: 12px; left: 120px; border-radius: 48px; }
.cloud-3 .cp4 { width: 65px; height: 40px; top: 16px; left: 170px; border-radius: 40px; }

.cloud-4 { top: 10%; left: -160px; animation: cloudDrift 50s linear infinite; animation-delay: -25s; }
.cloud-4 .cp1 { width: 50px; height: 32px; top: 6px; left: 0; border-radius: 32px; }
.cloud-4 .cp2 { width: 70px; height: 42px; top: 0; left: 25px; border-radius: 42px; }
.cloud-4 .cp3 { width: 48px; height: 30px; top: 8px; left: 65px; border-radius: 30px; }

.cloud-5 { top: 18%; left: -240px; animation: cloudDrift 70s linear infinite; animation-delay: -40s; }
.cloud-5 .cp1 { width: 75px; height: 46px; top: 10px; left: 0; border-radius: 46px; }
.cloud-5 .cp2 { width: 95px; height: 58px; top: 0; left: 45px; border-radius: 58px; }
.cloud-5 .cp3 { width: 68px; height: 42px; top: 14px; left: 110px; border-radius: 42px; }
.cloud-5 .cp4 { width: 55px; height: 34px; top: 18px; left: 155px; border-radius: 34px; }

/* ===== SCATTERED CANDIES ===== */
.bg-candy {
    position: absolute;
    font-size: 28px;
    opacity: 0.45;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.15));
    animation: candyFloat 6s ease-in-out infinite;
}

.bg-candy-1  { top: 8%;  left: 5%;  animation-delay: 0s;    font-size: 32px; opacity: 0.5; }
.bg-candy-2  { top: 12%; left: 18%; animation-delay: -1.2s; font-size: 24px; }
.bg-candy-3  { top: 5%;  left: 35%; animation-delay: -2.4s; font-size: 30px; opacity: 0.4; }
.bg-candy-4  { top: 15%; left: 52%; animation-delay: -0.8s; font-size: 26px; }
.bg-candy-5  { top: 7%;  left: 68%; animation-delay: -3.6s; font-size: 28px; opacity: 0.35; }
.bg-candy-6  { top: 18%; left: 82%; animation-delay: -1.6s; font-size: 34px; opacity: 0.45; }
.bg-candy-7  { top: 25%; left: 10%; animation-delay: -4.2s; font-size: 22px; }
.bg-candy-8  { top: 20%; left: 42%; animation-delay: -2.0s; font-size: 26px; opacity: 0.3; }
.bg-candy-9  { top: 30%; left: 75%; animation-delay: -0.4s; font-size: 30px; }
.bg-candy-10 { top: 28%; left: 90%; animation-delay: -3.0s; font-size: 24px; opacity: 0.4; }
.bg-candy-11 { top: 35%; left: 3%;  animation-delay: -5.0s; font-size: 28px; }
.bg-candy-12 { top: 40%; left: 22%; animation-delay: -1.8s; font-size: 22px; opacity: 0.35; }
.bg-candy-13 { top: 10%; left: 58%; animation-delay: -2.8s; font-size: 34px; }
.bg-candy-14 { top: 22%; left: 95%; animation-delay: -0.6s; font-size: 26px; opacity: 0.3; }
.bg-candy-15 { top: 38%; left: 45%; animation-delay: -4.6s; font-size: 30px; }
.bg-candy-16 { top: 32%; left: 62%; animation-delay: -1.4s; font-size: 24px; opacity: 0.4; }
.bg-candy-17 { top: 42%; left: 8%;  animation-delay: -3.4s; font-size: 28px; }
.bg-candy-18 { top: 15%; left: 28%; animation-delay: -2.2s; font-size: 22px; opacity: 0.35; }
.bg-candy-19 { top: 45%; left: 38%; animation-delay: -0.2s; font-size: 30px; }
.bg-candy-20 { top: 48%; left: 55%; animation-delay: -4.0s; font-size: 26px; opacity: 0.3; }
.bg-candy-21 { top: 44%; left: 72%; animation-delay: -1.0s; font-size: 34px; }
.bg-candy-22 { top: 50%; left: 15%; animation-delay: -2.6s; font-size: 24px; opacity: 0.4; }
.bg-candy-23 { top: 52%; left: 88%; animation-delay: -3.8s; font-size: 28px; }
.bg-candy-24 { top: 55%; left: 48%; animation-delay: -1.6s; font-size: 32px; opacity: 0.35; }

/* ===== CANDY LANDSCAPE ===== */
.candy-landscape {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 220px;
}

/* Back hills - softer colors */
.hill-back-1 {
    position: absolute;
    bottom: 80px;
    left: -5%;
    width: 45%;
    height: 160px;
    background: radial-gradient(ellipse at bottom, #FFB6C1 0%, #FF91A4 60%, transparent 70%);
    border-radius: 50% 50% 0 0;
    opacity: 0.6;
}

.hill-back-2 {
    position: absolute;
    bottom: 70px;
    left: 30%;
    width: 50%;
    height: 180px;
    background: radial-gradient(ellipse at bottom, #DDA0DD 0%, #BA55D3 60%, transparent 70%);
    border-radius: 50% 50% 0 0;
    opacity: 0.5;
}

.hill-back-3 {
    position: absolute;
    bottom: 75px;
    right: -10%;
    width: 40%;
    height: 150px;
    background: radial-gradient(ellipse at bottom, #FFDAB9 0%, #FF8C69 60%, transparent 70%);
    border-radius: 50% 50% 0 0;
    opacity: 0.55;
}

/* Front hills - candy colored */
.hill-front-1 {
    position: absolute;
    bottom: 30px;
    left: -8%;
    width: 50%;
    height: 130px;
    background: linear-gradient(180deg, #FF69B4 0%, #FF1493 60%, #C71585 100%);
    border-radius: 60% 70% 0 0;
    opacity: 0.75;
}

.hill-front-2 {
    position: absolute;
    bottom: 25px;
    left: 25%;
    width: 55%;
    height: 145px;
    background: linear-gradient(180deg, #FF85C8 0%, #FF5CAD 60%, #E91E8C 100%);
    border-radius: 65% 55% 0 0;
    opacity: 0.7;
}

.hill-front-3 {
    position: absolute;
    bottom: 28px;
    right: -12%;
    width: 48%;
    height: 125px;
    background: linear-gradient(180deg, #FF7EB3 0%, #FF5098 60%, #D63384 100%);
    border-radius: 55% 65% 0 0;
    opacity: 0.75;
}

/* Ground base - chocolate brown */
.candy-ground {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 45px;
    background: linear-gradient(180deg, #8B4513 0%, #6B3410 40%, #4A2508 100%);
    border-top: 3px solid #A0522D;
}

.candy-ground::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 10px;
    background: repeating-linear-gradient(
        90deg,
        #228B22 0px, #228B22 12px,
        #2E8B2E 12px, #2E8B2E 24px,
        #32CD32 24px, #32CD32 36px
    );
    border-radius: 0 0 4px 4px;
}

/* Chocolate mountain peak */
.choco-mountain {
    position: absolute;
    bottom: 80px;
    right: 15%;
    width: 0;
    height: 0;
    border-left: 60px solid transparent;
    border-right: 60px solid transparent;
    border-bottom: 110px solid #8B4513;
    opacity: 0.6;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}

.choco-mountain::after {
    content: '';
    position: absolute;
    top: 30px;
    left: -40px;
    width: 0;
    height: 0;
    border-left: 40px solid transparent;
    border-right: 40px solid transparent;
    border-bottom: 80px solid #A0522D;
}

/* ===== LOLLIPOP TREES ===== */
.lollipop {
    position: absolute;
    bottom: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.lollipop-head {
    font-size: 42px;
    filter: drop-shadow(0 2px 6px rgba(0,0,0,0.2));
    animation: lollipopSway 4s ease-in-out infinite;
}

.lollipop-stick {
    width: 6px;
    height: 35px;
    background: linear-gradient(180deg, #F5DEB3 0%, #DEB887 50%, #D2B48C 100%);
    border-radius: 3px;
    margin-top: -4px;
}

.lp-1 { left: 12%; }
.lp-1 .lollipop-head { animation-delay: 0s; }

.lp-2 { left: 55%; bottom: 42px; }
.lp-2 .lollipop-head { font-size: 36px; animation-delay: -1.5s; }
.lp-2 .lollipop-stick { height: 28px; }

.lp-3 { right: 20%; bottom: 38px; }
.lp-3 .lollipop-head { font-size: 38px; animation-delay: -3s; }
.lp-3 .lollipop-stick { height: 30px; }

/* ===== CANDY CANE POLES ===== */
.candy-cane {
    position: absolute;
    bottom: 45px;
    width: 14px;
    height: 60px;
    opacity: 0.55;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.15));
}

.cane-hook {
    position: absolute;
    top: 0;
    left: 0;
    width: 40px;
    height: 14px;
    border-radius: 14px 0 0 14px;
    background: repeating-linear-gradient(
        45deg,
        #ff2d55 0px, #ff2d55 6px,
        #ffffff 6px, #ffffff 12px
    );
}

.cane-hook::after {
    content: '';
    position: absolute;
    top: 0;
    right: -12px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: repeating-linear-gradient(
        45deg,
        #ff2d55 0px, #ff2d55 6px,
        #ffffff 6px, #ffffff 12px
    );
}

.cane-body {
    position: absolute;
    top: 10px;
    left: 0;
    width: 14px;
    height: 50px;
    background: repeating-linear-gradient(
        45deg,
        #ff2d55 0px, #ff2d55 6px,
        #ffffff 6px, #ffffff 12px
    );
    border-radius: 0 0 7px 7px;
}

.cane-1 { left: 32%; animation: lollipopSway 5s ease-in-out infinite; }
.cane-2 { right: 30%; animation: lollipopSway 5.5s ease-in-out infinite; animation-delay: -2s; }

/* ===== CANDY WORLD RESPONSIVE ===== */
@media (max-width: 899px) {
    .candy-landscape { height: 160px; }
    .hill-back-1 { height: 110px; bottom: 60px; }
    .hill-back-2 { height: 120px; bottom: 50px; }
    .hill-back-3 { height: 100px; bottom: 55px; }
    .hill-front-1 { height: 95px; bottom: 25px; }
    .hill-front-2 { height: 105px; bottom: 20px; }
    .hill-front-3 { height: 90px; bottom: 22px; }
    .candy-ground { height: 35px; }
    .lollipop-head { font-size: 30px; }
    .lollipop-stick { height: 24px; }
    .candy-cane { height: 45px; width: 11px; bottom: 35px; }
    .cane-hook { width: 30px; height: 11px; }
    .cane-hook::after { right: -9px; width: 11px; height: 11px; }
    .cane-body { top: 7px; width: 11px; height: 38px; }
    .choco-mountain { border-bottom-width: 70px; border-left-width: 40px; border-right-width: 40px; bottom: 55px; }
    .choco-mountain::after { border-bottom-width: 50px; border-left-width: 25px; border-right-width: 25px; top: 20px; left: -25px; }
}

@media (max-width: 599px) {
    .bg-candy { font-size: 22px; }
    .bg-candy-1  { font-size: 26px; }
    .bg-candy-6  { font-size: 28px; }
    .bg-candy-13 { font-size: 28px; }
    .bg-candy-21 { font-size: 28px; }
    .cloud-1 { zoom: 0.8; }
    .cloud-3 { zoom: 0.7; }
    .cloud-5 { zoom: 0.75; }
}