* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #0d1329;
    --bg-secondary: #1a2140;
    --bg-card: #252b4a;
    --accent-pink: #ff3b6f;
    --accent-pink-dark: #cc2f59;
    --accent-blue: #4a6cf7;
    --text-primary: #ffffff;
    --text-secondary: #8892b0;
    --text-placeholder: #5a6380;
    --success: #4ade80;
    --error: #f87171;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: linear-gradient(180deg, var(--bg-primary) 0%, #0a0f1f 100%);
    min-height: 100vh;
    min-height: var(--app-height, 100dvh);
    color: var(--text-primary);
    overflow-x: hidden;
}

.app {
    max-width: 430px;
    margin: 0 auto;
    min-height: 100vh;
    min-height: var(--app-height, 100dvh);
    position: relative;
}

.screen {
    display: none;
    flex-direction: column;
    min-height: 100vh;
    min-height: var(--app-height, 100dvh);
    padding: 40px 24px;
    padding-top: calc(40px + env(safe-area-inset-top, 0px));
    padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
    animation: fadeIn 0.3s ease;
}

.screen.active {
    display: flex;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.title {
    font-size: 28px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 30px;
}

/* Back Button */
.btn-back {
    position: absolute;
    top: calc(40px + env(safe-area-inset-top, 0px));
    left: 24px;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 24px;
    cursor: pointer;
    padding: 8px;
    z-index: 10;
}

/* Bottom Section */
.bottom-section {
    padding: 20px 0;
    margin-top: auto;
}

/* Subtitle */
.subtitle {
    text-align: center;
    color: var(--accent-pink);
    font-size: 18px;
    margin-bottom: 30px;
}

/* ==================== */
/* Packs Screen         */
/* ==================== */
.packs-container {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 20px;
}

.packs-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.pack-card {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 20px 16px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

@media (hover: hover) {
    .pack-card:hover {
        transform: translateY(-2px);
        border-color: var(--accent-pink);
    }
}

.pack-card:active {
    transform: scale(0.97);
}

.pack-card.premium {
    border-color: rgba(255, 215, 0, 0.3);
    background: linear-gradient(135deg, var(--bg-card) 0%, rgba(255, 215, 0, 0.08) 100%);
}

.pack-card.locked {
    opacity: 0.7;
    cursor: not-allowed;
}

@media (hover: hover) {
    .pack-card.locked:hover {
        transform: none;
        border-color: rgba(255, 215, 0, 0.3);
    }
}

.pack-card.locked:active {
    transform: none;
}

.premium-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 14px;
}

.pack-icon {
    font-size: 36px;
    transition: transform 0.3s ease;
}

.pack-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.pack-count {
    font-size: 12px;
    color: var(--text-secondary);
}

.pack-lock {
    font-size: 20px;
    margin-top: 4px;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.pack-card.shake {
    animation: shake 0.3s ease;
}

/* ==================== */
/* Riddle List Screen   */
/* ==================== */
.riddle-list-container {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 20px;
}

.riddle-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.riddle-item {
    display: flex;
    align-items: center;
    background: var(--bg-card);
    border-radius: 12px;
    padding: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    gap: 12px;
}

.riddle-item:active {
    transform: scale(0.98);
}

.riddle-number {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    color: var(--accent-pink);
    flex-shrink: 0;
}

.riddle-name {
    flex: 1;
    font-size: 15px;
    color: var(--text-primary);
    line-height: 1.3;
}

.riddle-arrow {
    color: var(--text-secondary);
    font-size: 20px;
    flex-shrink: 0;
}

/* ==================== */
/* Riddle Card Screen   */
/* ==================== */
.riddle-card-title {
    font-size: 20px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 10px;
    color: var(--accent-pink);
    padding-top: 20px;
}

.card-scene {
    flex: 1;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    perspective: 1000px;
    padding: 20px 0;
    overflow-y: auto;
}

.flip-card {
    width: 100%;
    display: grid;
    transform-style: preserve-3d;
    transition: transform 0.6s ease;
}

.flip-card.flipped {
    transform: rotateY(180deg);
}

.flip-card-front,
.flip-card-back {
    grid-area: 1 / 1;
    width: 100%;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border-radius: 24px;
    padding: 30px 24px;
    display: flex;
    flex-direction: column;
}

.flip-card-front {
    background: linear-gradient(135deg, var(--bg-card) 0%, var(--bg-secondary) 100%);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.flip-card-back {
    transform: rotateY(180deg);
    background: linear-gradient(135deg, var(--accent-pink) 0%, var(--accent-pink-dark) 100%);
    box-shadow: 0 8px 32px rgba(255, 59, 111, 0.3);
}

.card-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 16px;
}

.card-text {
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-primary);
}

.flip-card-back .card-text {
    color: white;
}

/* Hint image (shown between card and buttons) */
.card-hint-img {
    width: 100%;
    max-height: 240px;
    object-fit: contain;
    border-radius: 16px;
    margin-bottom: 16px;
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    transform: rotateY(90deg) scale(0.8);
    transition: max-height 0.4s ease, opacity 0.3s ease, transform 0.4s ease, margin 0.4s ease;
    margin-bottom: 0;
}

.card-hint-img.visible {
    max-height: 300px;
    opacity: 1;
    transform: rotateY(0deg) scale(1);
    margin-bottom: 16px;
}

.card-hint-img.hiding {
    max-height: 0;
    opacity: 0;
    transform: rotateY(-90deg) scale(0.8);
    margin-bottom: 0;
}

/* Hint Button */
.btn-hint {
    width: 100%;
    background: transparent;
    border: 2px solid rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.7);
    padding: 14px;
    border-radius: 30px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s ease;
    margin-bottom: 10px;
}

@media (hover: hover) {
    .btn-hint:hover {
        border-color: rgba(255, 255, 255, 0.4);
        color: rgba(255, 255, 255, 0.9);
    }
}

.btn-hint:active {
    transform: translateY(0);
}

.btn-hint.used {
    display: none;
}

/* Reveal Button */
.btn-reveal {
    width: 100%;
    background: linear-gradient(135deg, var(--accent-pink) 0%, var(--accent-pink-dark) 100%);
    border: none;
    color: white;
    padding: 18px;
    border-radius: 30px;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 20px rgba(255, 59, 111, 0.3);
}

@media (hover: hover) {
    .btn-reveal:hover {
        transform: translateY(-2px);
        box-shadow: 0 6px 25px rgba(255, 59, 111, 0.4);
    }
}

.btn-reveal:active {
    transform: translateY(0);
}

/* ==================== */
/* Mobile Responsive    */
/* ==================== */
@media (max-width: 480px) {
    .app {
        max-width: 100%;
    }

    .screen {
        padding: 20px 12px;
        padding-top: calc(20px + env(safe-area-inset-top, 0px));
        padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    }

    .title {
        font-size: 22px;
        margin-bottom: 20px;
    }

    .subtitle {
        font-size: 16px;
        margin-bottom: 20px;
    }

    .btn-back {
        top: calc(20px + env(safe-area-inset-top, 0px));
        left: 12px;
    }

    /* Packs */
    .packs-grid {
        gap: 10px;
    }

    .pack-card {
        padding: 16px 12px;
        border-radius: 12px;
    }

    .pack-icon {
        font-size: 30px;
    }

    .pack-name {
        font-size: 13px;
    }

    .pack-count {
        font-size: 11px;
    }

    .premium-badge {
        font-size: 12px;
        top: 6px;
        right: 6px;
    }

    /* Riddle List */
    .riddle-item {
        padding: 12px;
    }

    .riddle-number {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }

    .riddle-name {
        font-size: 14px;
    }

    /* Riddle Card */
    .riddle-card-title {
        font-size: 18px;
        padding-top: 16px;
    }

    .flip-card-front,
    .flip-card-back {
        padding: 24px 18px;
    }

    .card-text {
        font-size: 15px;
    }

    .btn-reveal {
        padding: 16px;
        font-size: 16px;
    }

    .card-hint-img {
        max-height: 200px;
        border-radius: 12px;
    }

    .btn-hint {
        padding: 12px;
        font-size: 14px;
    }

}

/* Responsive Height */
@media (max-height: 700px) {
    .screen {
        padding: 20px;
    }

    .title {
        font-size: 24px;
        margin-bottom: 20px;
    }

    .flip-card-front,
    .flip-card-back {
        padding: 24px 20px;
    }

    .card-text {
        font-size: 15px;
    }
}

/* Tablet and larger */
@media (min-width: 768px) {
    .app {
        max-width: 100%;
    }

    .screen {
        padding: 50px 40px;
    }

    .title {
        font-size: 32px;
        margin-bottom: 40px;
    }

    .packs-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 16px;
    }

    .pack-card {
        padding: 24px 20px;
    }

    .pack-icon {
        font-size: 42px;
    }

    .pack-name {
        font-size: 16px;
    }

    .pack-count {
        font-size: 13px;
    }

    .riddle-item {
        padding: 18px;
    }

    .riddle-name {
        font-size: 16px;
    }

    .flip-card-front,
    .flip-card-back {
        padding: 36px 30px;
    }

    .card-text {
        font-size: 18px;
    }

    .riddle-card-title {
        font-size: 24px;
    }

    .card-hint-img {
        max-height: 240px;
        border-radius: 18px;
    }
}
