:root {
    --pixel-font: 'Press Start 2P', cursive;
    --main-font: 'Outfit', sans-serif;
    --border-thick: 4px solid #000;
    --comic-shadow: 6px 6px 0px #000;
    --bg-panel: rgba(255, 255, 255, 0.95);
    --primary: #FF5722;
    --secondary: #4CAF50;
    --yellow: #FFEB3B;
    --blue: #2196F3;
    --pastel-blue: #B3E5FC;
}

#app * {
    box-sizing: border-box;
}

body {
    font-family: var(--main-font);
    margin: 0;
    padding: 10px;
    display: flex;
    justify-content: center;
    min-height: 100vh;
    color: #000;
    transition: background-color 0.3s, color 0.3s;
    position: relative;
}

/* Subtle Opacity background layer */
body::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url('https://lh3.googleusercontent.com/d/1owYPkhSw_PxQgx_l_aH68X2tKMBZERjc');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    opacity: 0.15;
    /* Subtly integrated background image */
    z-index: -1;
}

#app {
    width: 100%;
    max-width: 500px;
    background: var(--bg-panel);
    border: var(--border-thick);
    box-shadow: var(--comic-shadow);
    overflow: hidden;
    position: relative;
    padding-bottom: 20px;
    transition: all 0.3s;
}

/* ADMIN MODE OPTIMIZATION */
body.admin-mode #app {
    max-width: 1200px;
    /* PC Wide Screen layout */
    width: 95%;
}

body.admin-mode .user-only {
    display: none !important;
}

.admin-grid {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

@media (min-width: 768px) {
    .admin-grid {
        flex-direction: row;
        align-items: stretch;
    }

    .admin-col {
        flex: 1;
        min-width: 0;
    }
}

.admin-box {
    background: #ECEFF1;
    border: 3px solid #000;
    padding: 12px;
    box-shadow: 4px 4px 0px #000;
    margin-top: 5px;
    margin-bottom: 15px;
    height: 100%;
    box-sizing: border-box;
}

.admin-box-title {
    font-family: var(--pixel-font);
    font-size: 10px;
    margin-top: 5px;
    margin-bottom: 10px;
}

/* SLEEP MODE (DARK MODE) STYLES */
body.sleep-mode {
    background-color: #0A0A1A;
    color: #EEE;
}

body.sleep-mode::before {
    background-image: none;
    /* Disable bright background in Sleep Mode */
    background-color: #0A0A1A;
}

body.sleep-mode #app {
    background: rgba(30, 30, 40, 0.95);
    border-color: #555;
    box-shadow: 6px 6px 0px #111;
    color: #fff;
}

body.sleep-mode .app-header {
    background: #2a2a3e;
    border-bottom-color: #555;
}

body.sleep-mode .badge,
body.sleep-mode .logout-btn {
    background: #3a3a4e;
    border-color: #555;
    color: #fff;
    box-shadow: 3px 3px 0px #111;
}

body.sleep-mode .logout-btn {
    background: #b71c1c;
}

body.sleep-mode .btn {
    background: #3a3a4e;
    color: #eee;
    border-color: #555;
    box-shadow: 4px 4px 0px #111;
}

body.sleep-mode .btn-read {
    background: #555;
}

body.sleep-mode .btn-feed {
    background: #2E7D32;
}

body.sleep-mode .btn-train {
    background: #1565C0;
}

body.sleep-mode .retro-select {
    background: #3a3a4e;
    color: #fff;
    border-color: #555;
}

body.sleep-mode .evo-side-panel {
    background: #2a2a3e;
    border-color: #555;
}

body.sleep-mode .evo-slot {
    background: #3a3a4e;
    border-color: #555;
    color: #fff;
}

body.sleep-mode .evo-slot.unlocked {
    background: #2E7D32;
}

body.sleep-mode .evo-slot.locked {
    background: #444;
}

body.sleep-mode .section-title {
    background: #222;
    color: #fff;
    box-shadow: 4px 4px 0px #111;
}

body.sleep-mode .collection-wrapper {
    background: #1a1a2e;
    border-color: #555;
    box-shadow: inset 4px 4px 0px rgba(0, 0, 0, 0.5);
}

body.sleep-mode .poke-box {
    background: #3a3a4e;
    border-color: #555;
    color: #fff;
}

body.sleep-mode .poke-box.owned {
    background: #4a4a5e;
}

body.sleep-mode .poke-box.active-pet {
    background: #2E7D32;
    border-color: #4CAF50;
}

body.sleep-mode .dialog-box {
    background: #2a2a3e !important;
    border-color: #555 !important;
    color: #fff;
    box-shadow: 8px 8px 0px #111 !important;
}

body.sleep-mode .dialog-title {
    color: #fff;
}

body.sleep-mode .admin-input {
    background: #3a3a4e;
    color: #fff;
    border-color: #555;
}

body.sleep-mode .story-card {
    background: #2a2a3e;
    border-color: #555;
    color: #fff;
}

body.sleep-mode .story-title {
    color: #fff;
}

body.sleep-mode #read-mode {
    background: #1a1a2e;
    border-color: #555;
}

body.sleep-mode .admin-box {
    background: #2a2a3e;
    border-color: #555;
    color: #fff;
    box-shadow: 4px 4px 0px #111;
}

body.sleep-mode .admin-box-title {
    color: #ffb74d !important;
}

body.sleep-mode .story-list-item {
    background: #3a3a4e;
    border-color: #555;
    color: #fff;
    box-shadow: 2px 2px 0px #111;
}

body.sleep-mode .story-list-item button {
    background: #222;
    border-color: #555;
    color: #fff;
}

body.sleep-mode .gimbot-prop {
    background: #555;
    color: #fff;
    border-color: #222;
}

body.sleep-mode .overlay {
    background: rgba(0, 0, 0, 0.9);
}

body.sleep-mode .pet-bubble {
    background: #3a3a4e;
    border-color: #555;
    color: #fff;
}

body.sleep-mode .bedtime-box {
    background: #1a1a2e;
    border-color: #444;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.8);
}

/* === LOGIN SCREEN === */
#login-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
    min-height: 450px;
}

.login-logo {
    width: 120px;
    height: 120px;
    object-fit: contain;
    margin-bottom: 30px;
    background: transparent;
    border: none;
    box-shadow: none;
}

.login-title {
    font-family: var(--pixel-font);
    font-size: 14px;
    color: inherit;
    line-height: 1.8;
    margin-bottom: 30px;
    text-shadow: 2px 2px 0 var(--yellow);
}

body.sleep-mode .login-title {
    text-shadow: 2px 2px 0 #555;
}

/* === LOADING SCREEN === */
#loading-screen {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    min-height: 400px;
}

.retro-spin-logo {
    width: 110px;
    height: 110px;
    object-fit: contain;
    background: transparent;
    border: none;
    box-shadow: none;
    margin-bottom: 25px;
    animation: retroStepsSpin 2.5s steps(8) infinite;
}

@keyframes retroStepsSpin {
    0% {
        transform: rotate(0deg) scale(1);
    }

    50% {
        transform: rotate(180deg) scale(1.1);
    }

    100% {
        transform: rotate(360deg) scale(1);
    }
}

/* === HEADER === */
.app-header {
    text-align: center;
    padding: 12px 10px 12px;
    background: #fff;
    border-bottom: var(--border-thick);
}

.status-bar {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    position: relative;
}

.badge {
    background: #fff;
    border: 3px solid #000;
    padding: 8px 12px;
    font-family: var(--pixel-font);
    font-size: 8px;
    box-shadow: 3px 3px 0px #000;
    white-space: nowrap;
}

.logout-btn {
    background: #FFCDD2;
    border: 3px solid #000;
    padding: 6px;
    box-shadow: 2px 2px 0px #000;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.logout-btn:active {
    transform: translate(1px, 1px);
    box-shadow: 1px 1px 0px #000;
}

.container {
    padding: 15px;
}

.btn {
    font-family: var(--pixel-font);
    text-transform: uppercase;
    border: 3px solid #000;
    padding: 15px;
    cursor: pointer;
    width: 100%;
    margin-bottom: 12px;
    font-size: 10px;
    box-shadow: 4px 4px 0px #000;
    transition: all 0.1s;
    text-align: center;
    font-weight: bold;
    background: #fff;
}

.btn:active {
    transform: translate(3px, 3px);
    box-shadow: 1px 1px 0px #000;
}

.btn-read {
    background: var(--yellow);
    font-size: 13px;
    padding: 18px;
    border: 4px solid #000;
}

.btn-feed {
    background: var(--secondary);
    color: white;
}

.btn-train {
    background: var(--blue);
    color: white;
}

.btn:disabled {
    background: #ccc !important;
    cursor: not-allowed;
    color: #666 !important;
    box-shadow: none !important;
    transform: translate(3px, 3px);
}

/* === PLAYGROUND === */
.playground-wrapper {
    border: var(--border-thick);
    margin-bottom: 10px;
    height: 220px;
    position: relative;
    overflow: hidden;
    box-shadow: inset 0px 5px 10px rgba(0, 0, 0, 0.3);
    background: linear-gradient(to bottom, #87CEEB 0%, #87CEEB 60%, #90EE90 60%, #4CAF50 100%);
    transition: background 1s ease;
}

.playground-wrapper.sleeping::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(10, 10, 40, 0.75);
    z-index: 8;
    pointer-events: none;
}

#weather-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.pixel-sun {
    position: absolute;
    top: 10px;
    right: 20px;
    width: 40px;
    height: 40px;
    background: var(--yellow);
    border: 3px solid #000;
    box-shadow: 0 0 10px rgba(255, 235, 59, 0.8);
    animation: pulseSun 2s infinite alternate;
}

@keyframes pulseSun {
    0% {
        transform: scale(1)
    }

    100% {
        transform: scale(1.1)
    }
}

.pixel-moon {
    position: absolute;
    top: 10px;
    right: 20px;
    width: 36px;
    height: 36px;
    background: #FFEB3B;
    /* Tetap kuning bersinar terang */
    border: 3px solid #000;
    border-radius: 50%;
    box-shadow: 0 0 20px #FFEB3B, 0 0 10px rgba(255, 235, 59, 0.8);
    /* Efek glow kuning benderang */
    z-index: 9;
    /* Tembus overlay gelap saat mode tidur malam */
}

.pixel-star {
    position: absolute;
    width: 5px;
    height: 5px;
    background: #fff;
    border-radius: 50%;
    animation: twinkle 1.5s infinite alternate;
}

@keyframes twinkle {
    0% {
        opacity: 0.3
    }

    100% {
        opacity: 1
    }
}

.rain-drop {
    position: absolute;
    width: 3px;
    height: 15px;
    background: rgba(255, 255, 255, 0.7);
    animation: fall linear infinite;
}

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

    100% {
        transform: translateY(220px);
        opacity: 0
    }
}

.gimbot-prop {
    position: absolute;
    left: 75%;
    top: 78%;
    transform: translate(-50%, -50%);
    font-size: 8px;
    font-family: var(--pixel-font);
    background: #FFEB3B;
    border: 2px solid #000;
    padding: 2px 4px;
    z-index: 4;
    display: none;
    filter: drop-shadow(0px 5px 2px rgba(0, 0, 0, 0.5));
}

.pet-entity {
    position: absolute;
    left: 50%;
    top: 75%;
    transform: translate(-50%, -50%);
    font-size: 50px;
    transition: left 1.5s ease-in-out, top 1.5s ease-in-out, transform 0.4s;
    z-index: 5;
    filter: drop-shadow(0px 10px 5px rgba(0, 0, 0, 0.6));
    white-space: nowrap;
    cursor: pointer;
}

.pet-entity.sleeping-pet {
    filter: drop-shadow(0px 4px 3px rgba(0, 0, 80, 0.4)) brightness(0.7);
}

.sleeping-zzz {
    position: absolute;
    top: -48px;
    left: 50%;
    transform: translateX(-50%);
    font-family: var(--pixel-font);
    font-size: 10px;
    color: #fff;
    text-shadow: 1px 1px 0 #000;
    animation: floatZzz 2s infinite;
    z-index: 10;
    pointer-events: none;
}

@keyframes floatZzz {
    0% {
        opacity: 0;
        transform: translateX(-50%) translateY(0)
    }

    50% {
        opacity: 1
    }

    100% {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px)
    }
}

.pixel-emoji {
    display: inline-block;
    filter: contrast(1.5) saturate(1.5);
    image-rendering: pixelated;
}

.pet-bubble {
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    background: #fff;
    border: 3px solid #000;
    border-radius: 15px;
    padding: 4px 8px;
    font-size: 8px;
    font-family: var(--pixel-font);
    display: none;
    box-shadow: 2px 2px 0px #000;
    animation: floatBubble 1s infinite alternate;
    z-index: 10;
}

.love-bubble {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-size: 18px;
    color: #E53935;
    font-family: var(--main-font);
    font-weight: bold;
    pointer-events: none;
    z-index: 15;
    animation: loveFloat 1.2s ease-out forwards;
}

@keyframes loveFloat {
    0% {
        opacity: 1;
        top: -30px;
    }

    60% {
        opacity: 1;
        top: -65px;
    }

    100% {
        opacity: 0;
        top: -80px;
    }
}

@keyframes floatBubble {
    0% {
        transform: translate(-50%, 0)
    }

    100% {
        transform: translate(-50%, -8px)
    }
}

.pet-stats {
    background: transparent;
    border: none;
    padding: 0;
    margin-bottom: 0px;
    text-align: center;
}

.progress-bar {
    width: 100%;
    height: 12px;
    background: #eee;
    border: 3px solid #000;
    overflow: hidden;
    margin-top: 5px;
}

.progress-fill {
    height: 100%;
    background: var(--yellow);
    border-right: 3px solid #000;
    width: 0%;
    transition: width 0.3s;
}

/* === PET SELECTOR ROW + EVO PANEL === */
.pet-selector-row {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    margin-bottom: 16px;
}

.pet-info-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.retro-select {
    flex: 1;
    padding: 12px;
    font-family: var(--pixel-font);
    font-size: 9px;
    border: 3px solid #000;
    box-shadow: 4px 4px 0px #000;
    background: #fff;
    cursor: pointer;
    appearance: none;
}

.evo-side-panel {
    width: 90px;
    min-width: 90px;
    background: #f0f0f0;
    border: 3px solid #000;
    box-shadow: 3px 3px 0px #000;
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: center;
}

.evo-side-title {
    font-family: var(--pixel-font);
    font-size: 6px;
    text-align: center;
    color: inherit;
    margin-bottom: 2px;
}

.evo-slot {
    width: 100%;
    background: #fff;
    border: 2px solid #000;
    text-align: center;
    padding: 6px 2px;
    font-size: 12px;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.evo-slot.unlocked {
    background: #c8f7c5;
    border-color: var(--secondary);
}

.evo-slot.locked {
    background: #e0e0e0;
}

.evo-slot-label {
    font-family: var(--pixel-font);
    font-size: 5px;
    color: inherit;
    margin-top: 2px;
    display: block;
}

.evo-slot .siluet {
    filter: brightness(0) opacity(0.25);
    font-size: 14px;
}

/* === DROPDOWN SECTIONS === */
.section-title {
    font-family: var(--pixel-font);
    font-size: 11px;
    text-transform: uppercase;
    text-align: center;
    background: #000;
    color: #fff;
    padding: 10px;
    box-shadow: 4px 4px 0px var(--primary);
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 16px 0 0 0;
}

.section-title .arrow {
    font-size: 10px;
    transition: transform 0.2s;
}

.section-title.open .arrow {
    transform: rotate(180deg);
}

.section-body {
    display: none;
    margin-bottom: 4px;
}

.section-body.open {
    display: block;
}

/* === GACHA GRID === */
.gacha-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 10px 0;
}

.bg-common {
    background: #e0e0e0;
}

.bg-rare {
    background: #81D4FA;
}

.bg-antique {
    background: #CE93D8;
}

.bg-legend {
    background: #FFE082;
    border-color: #FFB300;
}

.gacha-rate {
    font-size: 8px;
    font-family: var(--main-font);
    margin-top: 3px;
    opacity: 0.7;
}

/* === COLLECTION === */
.collection-wrapper {
    border: var(--border-thick);
    background: var(--pastel-blue);
    box-shadow: inset 4px 4px 0px rgba(0, 0, 0, 0.08);
    padding: 10px;
}

.collection-tier-label {
    font-family: var(--pixel-font);
    font-size: 7px;
    padding: 4px 8px;
    margin-bottom: 6px;
    display: inline-block;
    border: 2px solid #000;
    box-shadow: 2px 2px 0 #000;
}

.tier-common {
    background: #e0e0e0;
    color: #000;
}

.tier-rare {
    background: #81D4FA;
    color: #000;
}

.tier-antique {
    background: #CE93D8;
    color: #000;
}

.tier-legend {
    background: #FFE082;
    color: #000;
}

.collection-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
    margin-bottom: 12px;
}

.poke-box {
    aspect-ratio: 1;
    background: #fff;
    border: 2px solid #000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    cursor: pointer;
    box-shadow: 2px 2px 0px #000;
    transition: transform 0.1s;
    white-space: nowrap;
    overflow: hidden;
    position: relative;
}

.poke-box:active {
    transform: translate(2px, 2px);
    box-shadow: none;
}

.poke-box.owned {
    background: #fff9c4;
    border-color: var(--primary);
}

.poke-box.active-pet {
    background: #c8f7c5;
    border-color: var(--secondary);
    border-width: 3px;
}

.poke-box.locked .pet-icon {
    filter: brightness(0) opacity(0.2);
}

.poke-box-level {
    font-family: var(--pixel-font);
    font-size: 5px;
    color: inherit;
    margin-top: 2px;
}

.collection-scroll {
    max-height: 300px;
    overflow-y: auto;
}

/* === READ MODE === */
#read-mode {
    display: none;
    background: #FDF5E6;
    min-height: 100vh;
    padding: 20px;
    border: var(--border-thick);
}

.story-card {
    background: #fff;
    border: var(--border-thick);
    padding: 20px;
    box-shadow: var(--comic-shadow);
}

.story-title {
    font-family: var(--pixel-font);
    font-size: 16px;
    text-align: center;
    margin-bottom: 10px;
    line-height: 1.5;
    color: inherit;
    text-decoration: underline;
}

.story-img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border: 4px solid #000;
    margin-bottom: 20px;
    filter: grayscale(0.2) contrast(1.2);
}

.story-text {
    font-size: 20px;
    line-height: 1.8;
    text-align: justify;
}

.reading-timer-wrap {
    background: #111;
    border: 3px solid #000;
    padding: 10px 15px;
    margin-bottom: 12px;
    text-align: center;
}

.reading-timer-label {
    font-family: var(--pixel-font);
    font-size: 8px;
    color: var(--yellow);
    margin-bottom: 6px;
}

.reading-timer-bar-bg {
    width: 100%;
    height: 18px;
    background: #333;
    border: 2px solid #555;
    overflow: hidden;
}

.reading-timer-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #4CAF50, #FFEB3B);
    width: 0%;
    transition: width 0.5s linear;
}

.reading-timer-count {
    font-family: var(--pixel-font);
    font-size: 9px;
    color: #fff;
    margin-top: 5px;
}

.reading-cooldown-msg {
    font-family: var(--pixel-font);
    font-size: 8px;
    color: var(--primary);
    text-align: center;
    padding: 8px;
    background: #fff3e0;
    border: 2px solid var(--primary);
    margin-bottom: 10px;
    display: none;
}

/* === BEDTIME WARNING === */
#bedtime-overlay {
    position: fixed;
    inset: 0;
    background: rgba(5, 5, 25, 0.93);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    padding: 20px;
    box-sizing: border-box;
    flex-direction: column;
    text-align: center;
}

.bedtime-box {
    background: #0a0a2e;
    border: 5px solid #6666ff;
    padding: 30px;
    width: 100%;
    max-width: 340px;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.8);
    color: #fff;
}

.bedtime-title {
    font-family: var(--pixel-font);
    font-size: 14px;
    color: var(--yellow);
    margin-bottom: 15px;
    line-height: 1.6;
}

.bedtime-msg {
    font-size: 17px;
    margin-bottom: 20px;
    line-height: 1.7;
}

.bedtime-btn {
    font-family: var(--pixel-font);
    font-size: 9px;
    background: #6666ff;
    color: #fff;
    border: 3px solid #fff;
    padding: 12px;
    width: 100%;
    cursor: pointer;
    box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.5);
}

/* === DUPLICATE DIALOG === */
.dup-dialog {
    text-align: center;
}

.dup-dialog .dup-pet {
    font-size: 60px;
    margin: 10px 0;
}

.dup-btns {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

/* === OVERLAYS === */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 999;
    padding: 20px;
    box-sizing: border-box;
}

.dialog-box {
    background: #fff;
    border: 5px solid #000;
    padding: 25px;
    width: 100%;
    max-width: 350px;
    box-shadow: 10px 10px 0px var(--primary);
    text-align: center;
}

.dialog-title {
    font-family: var(--pixel-font);
    font-size: 14px;
    margin-bottom: 15px;
    color: inherit;
    line-height: 1.5;
}

.dialog-msg {
    font-size: 18px;
    margin-bottom: 20px;
    line-height: 1.5;
}

/* === ADMIN === */
#admin-panel {
    display: none;
    background: transparent;
    border: none;
    margin-top: 20px;
}

.admin-input {
    width: 100%;
    padding: 12px;
    margin-bottom: 10px;
    border: 3px solid #000;
    font-family: var(--main-font);
    font-size: 16px;
    box-sizing: border-box;
}

.story-list-item {
    background: #fff;
    border: 3px solid #000;
    padding: 10px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 2px 2px 0px #000;
}

.story-actions button {
    background: #000;
    color: #fff;
    border: 2px solid #000;
    padding: 5px 10px;
    cursor: pointer;
    margin-left: 5px;
    font-family: var(--pixel-font);
    font-size: 8px;
}

.hidden {
    display: none !important;
}
