/* =============================================
   99 Nights in the Forest — Enhanced Styles
   ============================================= */

/* --- Variables --- */
:root {
    --bg-dark: #06070d;
    --bg-mid: #0d0f1a;
    --bg-light: #13162b;
    --primary-cyan: #00f0ff;
    --primary-blue: #0066ff;
    --primary-glow: rgba(0, 240, 255, 0.18);
    --success-green: #00e676;
    --danger-red: #ff2244;
    --danger-dark: #cc0022;
    --warning-yellow: #ffcc00;
    --text-main: #ffffff;
    --text-muted: #8892a4;
    --border-subtle: rgba(0, 240, 255, 0.12);
    --radius-card: 16px;
    --radius-btn: 50px;
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; }

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-dark); }
::-webkit-scrollbar-thumb { background: var(--primary-cyan); border-radius: 10px; }

body {
    margin: 0;
    padding: 0 0 120px;
    font-family: 'Lato', sans-serif;
    background: var(--bg-dark);
    background-image:
        radial-gradient(ellipse at 20% 10%, rgba(0, 102, 255, 0.12) 0%, transparent 55%),
        radial-gradient(ellipse at 80% 80%, rgba(0, 240, 255, 0.08) 0%, transparent 55%);
    color: var(--text-main);
    text-align: center;
    overflow-x: hidden;
    min-height: 100vh;
}

/* --- Header --- */
.header-logo {
    max-width: 120px;
    margin-top: 20px;
    display: block;
    margin-left: auto;
    margin-right: auto;
    animation: float 4s ease-in-out infinite;
    filter: drop-shadow(0 6px 20px rgba(0, 240, 255, 0.35));
}

h1 {
    font-family: 'Fredoka One', cursive;
    font-size: clamp(1.4rem, 5vw, 2.2rem);
    color: #fff;
    text-shadow: 0 0 30px rgba(0, 240, 255, 0.4), 0 3px 8px rgba(0, 0, 0, 0.9);
    letter-spacing: 2px;
    margin: 8px 0 8px;
    text-transform: uppercase;
}

.subtitle-bar {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(0, 240, 255, 0.07);
    border: 1px solid var(--border-subtle);
    border-radius: 30px;
    padding: 6px 18px;
    font-size: 0.8rem;
    color: var(--primary-cyan);
    letter-spacing: 1px;
    margin-bottom: 20px;
    text-transform: uppercase;
}
.subtitle-bar .dot {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--success-green);
    box-shadow: 0 0 8px var(--success-green);
    animation: blink 1.2s infinite;
}
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0.3} }

/* --- +18 Button --- */
.adult-btn {
    position: fixed; bottom: 25px; left: 20px;
    width: 60px; height: 60px;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--danger-red), #880011);
    color: #fff; border-radius: 50%; text-decoration: none;
    font-weight: 900; font-family: 'Fredoka One', cursive; font-size: 1.25rem;
    box-shadow: 0 0 20px rgba(255, 34, 68, 0.55);
    border: 2px solid rgba(255,100,120,0.5);
    z-index: 9999; transition: transform 0.2s;
}
.adult-btn:hover { transform: scale(1.1); }

/* --- Live Feed --- */
.live-feed {
    position: fixed; bottom: 20px; right: 20px;
    background: rgba(8, 10, 20, 0.95);
    border-left: 3px solid var(--success-green);
    padding: 10px 16px; border-radius: 10px;
    font-size: 0.85rem; z-index: 9999;
    display: flex; align-items: center; gap: 10px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.7);
    transform: translateY(110%);
    transition: transform 0.45s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    backdrop-filter: blur(12px);
    max-width: 260px;
}
.live-feed.show { transform: translateY(0); }
.live-feed img { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--success-green); }
.live-feed .live-dot { width: 6px; height: 6px; background: var(--success-green); border-radius: 50%; flex-shrink: 0; box-shadow: 0 0 6px var(--success-green); animation: blink 1s infinite; }
.text-neon-green { color: var(--success-green); font-weight: 700; }

/* --- Ad Wrapper --- */
.ad-wrapper {
    width: 300px; height: 250px;
    margin: 10px auto 25px;
    background: rgba(0,0,0,0.3);
    border-radius: var(--radius-card);
    overflow: hidden;
    border: 1px solid var(--border-subtle);
    display: flex; align-items: center; justify-content: center;
}

/* --- Selection Area --- */
.selection-area {
    background: rgba(10, 13, 28, 0.7);
    padding: 30px 20px 25px;
    border-radius: 24px;
    max-width: 680px;
    margin: 0 auto 35px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.7), 0 0 0 1px var(--border-subtle);
    width: 92%;
    backdrop-filter: blur(12px);
}

.slots-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.slots {
    display: flex; justify-content: center; gap: 16px;
    margin-bottom: 22px;
}

.slot {
    width: 140px; height: 185px;
    background: rgba(255, 255, 255, 0.04);
    border: 2px dashed rgba(255,255,255,0.12);
    border-radius: var(--radius-card);
    position: relative; display: flex;
    align-items: center; justify-content: center;
    cursor: pointer;
    transition: all var(--transition);
}
.slot:hover { border-color: rgba(0, 240, 255, 0.3); background: rgba(0, 240, 255, 0.04); }
.slot.filled { border: 2px solid rgba(0, 230, 118, 0.4); background: transparent; box-shadow: 0 0 20px rgba(0,230,118,0.1); }

.slot-placeholder { color: rgba(255,255,255,0.2); font-size: 2rem; pointer-events: none; }

.slot-card { position: relative; width: 100%; height: 100%; pointer-events: none; }
.slot-card .frame { width: 100%; height: 100%; position: absolute; top:0; left:0; object-fit: cover; border-radius: 14px; }
.slot-card .pet { position: absolute; width: 70%; height: 55%; top: 42%; left: 50%; transform: translate(-50%, -50%); object-fit: contain; filter: drop-shadow(0 6px 14px rgba(0,0,0,0.9)); z-index: 2; }
.slot-card .img-caption { position: absolute; bottom: 10px; width: 100%; text-align: center; font-size: 0.82rem; font-family: 'Fredoka One', cursive; z-index: 3; text-shadow: 0 2px 6px #000; color: #fff; }
.slot-card .remove-hint { position: absolute; top: 6px; right: 8px; z-index: 5; background: rgba(255,34,68,0.8); color: #fff; width: 20px; height: 20px; border-radius: 50%; font-size: 0.7rem; display: flex; align-items: center; justify-content: center; pointer-events: none; }

@keyframes shakeX {
    0%,100%{transform:translateX(0)} 20%{transform:translateX(-7px)} 40%{transform:translateX(7px)} 60%{transform:translateX(-5px)} 80%{transform:translateX(5px)}
}
.slots.shake { animation: shakeX .35s ease; }

#continue-btn {
    background: linear-gradient(90deg, var(--primary-blue), var(--primary-cyan));
    color: #fff; border: none;
    padding: 15px 40px; border-radius: var(--radius-btn);
    font-size: 1.1rem; font-family: 'Fredoka One', cursive;
    cursor: pointer; text-transform: uppercase;
    box-shadow: 0 6px 25px rgba(0, 240, 255, 0.25);
    transition: var(--transition); opacity: 0; pointer-events: none;
    width: 80%; max-width: 320px; visibility: hidden; letter-spacing: 1px;
}
#continue-btn.active {
    opacity: 1; visibility: visible; pointer-events: auto;
    animation: pulse-glow 2.5s infinite;
}
#continue-btn:hover { transform: translateY(-2px); box-shadow: 0 10px 35px rgba(0, 240, 255, 0.4); }

/* --- Gallery --- */
#gallery {
    max-width: 860px; margin: 0 auto;
    padding: 0 14px;
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px;
}

.img-container {
    position: relative; border-radius: var(--radius-card);
    height: 220px;
    cursor: pointer; overflow: hidden;
    border: 2px solid transparent;
    background: rgba(255,255,255,0.02);
    transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
    box-shadow: 0 8px 20px rgba(0,0,0,0.5);
}
.img-container::before {
    content: ''; position: absolute; inset: 0;
    background: linear-gradient(to bottom, transparent 40%, rgba(0,0,0,0.7) 100%);
    z-index: 3; pointer-events: none; border-radius: 14px;
}
.img-container:hover {
    transform: translateY(-6px);
    border-color: rgba(0, 240, 255, 0.4);
    box-shadow: 0 18px 40px rgba(0, 240, 255, 0.2);
}
.img-container.selected-item {
    border-color: var(--success-green);
    box-shadow: 0 0 25px rgba(0, 230, 118, 0.35);
    transform: scale(0.97);
}
.img-container.selected-item::after {
    content: '✓';
    position: absolute; top: 8px; right: 10px;
    background: var(--success-green); color: #000;
    width: 22px; height: 22px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 900; font-size: 0.75rem; z-index: 10;
}

body.cap-reached .img-container:not(.selected-item) {
    filter: grayscale(80%) brightness(0.4);
    pointer-events: none;
}

.img-container .frame { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 14px; z-index: 1; object-fit: cover; pointer-events: none; }
.img-container .pet { position: absolute; width: 70%; height: 48%; top: 38%; left: 50%; transform: translate(-50%, -50%); object-fit: contain; z-index: 2; filter: drop-shadow(0 8px 14px rgba(0,0,0,0.9)); pointer-events: none; }
.img-container .img-caption { position: absolute; bottom: 42px; width: 100%; z-index: 4; font-family: 'Fredoka One', cursive; font-size: 0.9rem; color: #fff; text-shadow: 0 2px 6px #000; pointer-events: none; padding: 0 8px; line-height: 1.2; }

.claim-btn {
    position: absolute; bottom: 10px; left: 8%; width: 84%; z-index: 5;
    background: linear-gradient(90deg, var(--primary-cyan), var(--primary-blue));
    border: none; color: #fff;
    padding: 8px 0; border-radius: 10px;
    font-family: 'Fredoka One', cursive; font-size: 0.9rem;
    text-transform: uppercase; cursor: pointer;
    box-shadow: 0 4px 14px rgba(0,0,0,0.5);
    transition: opacity 0.2s; pointer-events: none;
}
.img-container.selected-item .claim-btn { display: none; }

/* --- Modal --- */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(4, 5, 10, 0.92);
    z-index: 10000; display: none;
    backdrop-filter: blur(14px);
    flex-direction: column; align-items: center; justify-content: center;
    padding: 16px;
    transition: opacity 0.3s ease;
}

.popup-content {
    background: linear-gradient(150deg, #13162b 0%, #0a0c1a 100%);
    border-radius: 22px; width: 100%; max-width: 440px;
    padding: 32px 24px;
    border: 1px solid rgba(0, 240, 255, 0.2);
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(0,240,255,0.05);
    text-align: center;
    animation: popIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes popIn { from { transform: scale(0.88) translateY(20px); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.popup-header h3 {
    font-family: 'Fredoka One', cursive; font-size: 1.55rem;
    color: var(--primary-cyan); margin: 0 0 22px;
    text-shadow: 0 0 20px rgba(0, 240, 255, 0.4);
    text-transform: uppercase; letter-spacing: 1px;
}

.verified-badge {
    font-size: 0.7rem; background: rgba(0,230,118,0.15); color: var(--success-green);
    border: 1px solid rgba(0,230,118,0.3); border-radius: 20px;
    padding: 2px 8px; vertical-align: middle; letter-spacing: 0.5px;
}
.unverified-badge {
    font-size: 0.7rem; background: rgba(255,204,0,0.12); color: var(--warning-yellow);
    border: 1px solid rgba(255,204,0,0.3); border-radius: 20px;
    padding: 2px 8px; vertical-align: middle;
}

.selected-images-container {
    display: flex; justify-content: center; gap: 12px;
    margin-bottom: 24px; flex-wrap: wrap;
}
.thumb-card {
    width: 90px; height: 120px; position: relative;
    border-radius: 12px; overflow: hidden;
}
.thumb-card .frame { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 12px; object-fit: cover; }
.thumb-card .pet { position: absolute; top: 38%; left: 50%; transform: translate(-50%, -50%); width: 72%; height: 58%; object-fit: contain; z-index: 2; filter: drop-shadow(0 4px 8px rgba(0,0,0,0.7)); }
.thumb-card .thumb-name { position: absolute; bottom: 6px; width: 100%; text-align: center; font-size: 0.65rem; font-family: 'Fredoka One', cursive; color: #fff; text-shadow: 0 1px 4px #000; z-index: 3; }

.input-group { margin-bottom: 4px; }
.input-group input {
    width: 100%; padding: 13px 16px;
    border-radius: 10px; border: 2px solid rgba(255,255,255,0.1);
    background: rgba(255,255,255,0.06);
    font-size: 1.3rem; text-align: center;
    font-family: 'Fredoka One', cursive; font-weight: 900;
    letter-spacing: 2px; color: #fff;
    outline: none; transition: border-color 0.2s, box-shadow 0.2s;
    -webkit-text-fill-color: #fff;
}
.input-group input::placeholder { color: rgba(255,255,255,0.3); font-size: 1rem; letter-spacing: 1px; }
.input-group input:focus { border-color: var(--primary-cyan); box-shadow: 0 0 18px rgba(0, 240, 255, 0.2); }
.input-group input.is-valid { border-color: var(--success-green); box-shadow: 0 0 18px rgba(0, 230, 118, 0.2); }
@keyframes shakeAnim { 0%,100%{transform:translateX(0)} 20%{transform:translateX(-8px)} 40%{transform:translateX(8px)} 60%{transform:translateX(-5px)} 80%{transform:translateX(5px)} }
.shake-input { animation: shakeAnim 0.35s ease; }

.user-error {
    color: var(--danger-red); font-size: 0.9rem;
    margin: 8px 0; font-family: 'Lato', sans-serif; font-weight: 700;
}

.popup-buttons, .modal-actions {
    display: flex; gap: 10px; justify-content: stretch; margin-top: 18px;
}
.popup-buttons button, .modal-actions button {
    flex: 1; padding: 14px 10px; border-radius: 12px;
    font-weight: 700; cursor: pointer; border: none;
    font-size: 1rem; text-transform: uppercase;
    font-family: 'Fredoka One', cursive;
    transition: transform 0.15s, box-shadow 0.15s;
    letter-spacing: 0.5px;
}
.popup-buttons button:hover, .modal-actions button:hover { transform: translateY(-2px); }
.cancel-btn { background: linear-gradient(135deg, #ff4055, #bb001a); color: #fff; }
.free-btn { background: linear-gradient(90deg, var(--primary-cyan), var(--primary-blue)); color: #fff; }

.result-avatar {
    width: 110px; height: 110px; border-radius: 50%;
    border: 3px solid var(--success-green); margin: 8px auto 4px;
    box-shadow: 0 0 30px rgba(0, 230, 118, 0.35);
    background: var(--bg-mid); object-fit: cover; display: block;
}
.result-username {
    font-size: 1.6rem; font-family: 'Fredoka One', cursive;
    color: #fff; margin: 6px 0 20px;
    text-shadow: 0 2px 8px rgba(0,0,0,0.7);
}

.confirm-btn { background: linear-gradient(90deg, var(--success-green), #00994d); box-shadow: 0 5px 18px rgba(0, 230, 118, 0.3); }
.edit-btn { background: linear-gradient(135deg, #ff4055, #bb001a); }

.popup-subtitle.text-warning { color: var(--warning-yellow); margin: 0 0 12px; font-family: 'Fredoka One', cursive; font-size: 1.3rem; }
.verify-desc { font-size: 0.9rem; color: var(--text-muted); margin-bottom: 12px; }
.btn-accept {
    width: 100%; padding: 16px;
    background: linear-gradient(90deg, var(--danger-red), #aa0022);
    color: #fff; border: none; border-radius: 12px;
    font-size: 1.2rem; font-family: 'Fredoka One', cursive;
    cursor: pointer; text-transform: uppercase;
    animation: danger-pulse 1.5s infinite; margin-top: 10px;
    box-shadow: 0 6px 22px rgba(255, 34, 68, 0.4);
    letter-spacing: 1px;
}

/* --- Loading Spinner --- */
.folding {
    margin: 18px auto; width: 56px; height: 56px;
    position: relative; transform: rotateZ(45deg);
}
.folding .sk-cube { float: left; width: 50%; height: 50%; position: relative; transform: scale(1.1); }
.folding .sk-cube::before {
    content: ''; position: absolute; inset: 0;
    background: var(--primary-cyan);
    animation: sk-foldCubeAngle 2.4s infinite linear both;
    transform-origin: 100% 100%;
    box-shadow: 0 0 12px rgba(0, 240, 255, 0.5);
}
.folding .sk-cube2 { transform: scale(1.1) rotateZ(90deg); }
.folding .sk-cube3 { transform: scale(1.1) rotateZ(180deg); }
.folding .sk-cube4 { transform: scale(1.1) rotateZ(270deg); }
.folding .sk-cube2::before { animation-delay: 0.3s; }
.folding .sk-cube3::before { animation-delay: 0.6s; }
.folding .sk-cube4::before { animation-delay: 0.9s; }
@keyframes sk-foldCubeAngle {
    0%,10%{transform:perspective(140px) rotateX(-180deg);opacity:0}
    25%,75%{transform:perspective(140px) rotateX(0deg);opacity:1}
    90%,100%{transform:perspective(140px) rotateY(180deg);opacity:0}
}
.searching-text {
    color: var(--primary-cyan); font-family: 'Fredoka One', cursive;
    font-size: 1.15rem; margin-top: 22px; letter-spacing: 1px;
}

/* --- Toast Notification --- */
#toast-notification {
    position: fixed; top: -80px; left: 50%; transform: translateX(-50%);
    background: rgba(10, 12, 25, 0.95);
    border-radius: 30px; padding: 10px 24px;
    font-size: 0.9rem; font-weight: 700;
    box-shadow: 0 8px 30px rgba(0,0,0,0.6);
    border: 1px solid rgba(255,255,255,0.08);
    backdrop-filter: blur(12px);
    transition: top 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 99999; pointer-events: none;
    white-space: nowrap;
}
#toast-notification.show { top: 20px; }
#toast-notification.toast-error { border-color: rgba(255,34,68,0.4); color: #ff6677; }
#toast-notification.toast-info { border-color: rgba(0,240,255,0.3); color: var(--primary-cyan); }
#toast-notification.toast-success { border-color: rgba(0,230,118,0.3); color: var(--success-green); }

/* --- Keyframes --- */
@keyframes float { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-8px)} }
@keyframes pulse-glow {
    0%,100%{box-shadow:0 6px 25px rgba(0,240,255,0.25)}
    50%{box-shadow:0 6px 40px rgba(0,240,255,0.5), 0 0 0 10px rgba(0,240,255,0.05)}
}
@keyframes danger-pulse {
    0%,100%{box-shadow:0 6px 22px rgba(255,34,68,0.4)}
    50%{box-shadow:0 6px 35px rgba(255,34,68,0.7), 0 0 0 8px rgba(255,34,68,0.05)}
}

/* --- Section Titles --- */
.section-title {
    font-family: 'Fredoka One', cursive;
    font-size: clamp(1rem, 3vw, 1.3rem);
    color: var(--text-muted); text-transform: uppercase;
    letter-spacing: 3px; margin: 0 0 20px;
    position: relative;
}
.section-title::after {
    content: ''; display: block; width: 50px; height: 2px;
    background: linear-gradient(90deg, var(--primary-cyan), transparent);
    margin: 8px auto 0;
}

/* =============================================
   Mobile Responsive
   ============================================= */
@media (max-width: 600px) {
    h1 { font-size: 1.3rem; margin-bottom: 10px; }
    .header-logo { max-width: 90px; margin-top: 14px; }
    .selection-area { padding: 18px 10px; border-radius: 16px; width: 96%; }
    .slots { gap: 8px; }
    .slot { width: 30vw; max-width: 110px; height: 125px; border-radius: 10px; }
    .slot-card .pet { height: 48%; top: 38%; }
    .slot-card .img-caption { font-size: 0.7rem; bottom: 6px; }
    #continue-btn { width: 100%; font-size: 1rem; padding: 13px 16px; }
    #gallery { grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 0 8px; }
    .img-container { height: 148px; }
    .img-container .img-caption { bottom: 34px; font-size: 0.65rem; }
    .claim-btn { bottom: 6px; padding: 6px 0; font-size: 0.75rem; left: 5%; width: 90%; border-radius: 8px; }
    .live-feed { bottom: 12px; right: 10px; left: 10px; max-width: none; font-size: 0.8rem; padding: 8px 12px; }
    .popup-content { padding: 22px 16px; border-radius: 16px; }
    .input-group input { font-size: 1.1rem; }
    .thumb-card { width: 75px; height: 100px; }
    .adult-btn { width: 50px; height: 50px; font-size: 1rem; bottom: 16px; left: 14px; }
}