:root {
    --bg-dark: #050510;
    --bg-gradient: radial-gradient(circle at center, #1a1a2e 0%, #050510 100%);
    --card-glass: rgba(255, 255, 255, 0.03);
    --border-glass: rgba(255, 215, 0, 0.15);
    --accent-gold: #D4AF37;
    --accent-glow: 0 0 20px rgba(212, 175, 55, 0.2);
    --text-main: #f0f0f0;
    --text-sub: #a0a0a0;
    --font-title: 'Playfair Display', serif;
    --font-body: 'Noto Sans KR', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

.hidden {
    display: none !important;
}

body {
    font-family: var(--font-body);
    background: transparent !important;
    color: var(--text-main);
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    justify-content: center;
    overflow-x: hidden;
    position: relative;
    z-index: 1;
}

#bg-image {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    object-fit: cover;
    opacity: 0.8;
}

.video-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
    z-index: -1;
    pointer-events: none;
}

.app-container {
    width: 100%;
    max-width: 480px;
    padding: 20px 15px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

header {
    margin-top: 10px;
    margin-bottom: 30px;
    width: 100%;
}

header h1 {
    font-family: var(--font-title);
    font-size: 3.8rem;
    line-height: 1.1;
    font-weight: 800;
    letter-spacing: 2px;
    margin-bottom: 10px;
    background: linear-gradient(to right, #FFD700 0%, #FFA500 20%, #FFFFE0 40%, #FFD700 50%, #FFFFE0 60%, #FFA500 80%, #FFD700 100%);
    background-size: 200% auto;
    color: transparent;
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: fireFlow 3s linear infinite;
    filter: drop-shadow(0 0 5px rgba(255, 215, 0, 0.6)) drop-shadow(0 0 15px rgba(255, 140, 0, 0.4));
}

@keyframes fireFlow {
    to {
        background-position: 200% center;
    }
}

header p {
    color: #fff;
    font-size: 1.15rem;
    font-weight: 300;
    letter-spacing: 0.1em;
    text-shadow: 0 0 10px rgba(0, 0, 0, 0.8);
}

.wavy-char {
    display: inline-block;
    opacity: 0;
    transform: translateY(10px);
    animation: waveReveal 0.5s forwards, floatWave 3s ease-in-out infinite, fireShimmer 3s ease-in-out infinite;
}

@keyframes waveReveal {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes floatWave {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-5px);
    }
}

@keyframes fireShimmer {

    0%,
    80%,
    100% {
        color: #ffecd2;
        text-shadow: 0 0 5px rgba(255, 69, 0, 0.5);
    }

    10% {
        color: #fff;
        text-shadow: 0 0 10px #ffae00, 0 0 20px #ff4500;
    }

    20% {
        color: #ff4500;
        text-shadow: 0 0 10px #ff4500, 0 0 20px #ff8c00, 0 0 40px #ff0000;
    }
}

#question-section {
    width: 100%;
    margin-bottom: 30px;
}

#user-question {
    width: 85%;
    max-width: 500px;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50px;
    padding: 8px 25px;
    color: #fff;
    font-size: 0.95rem;
    font-weight: 300;
    text-align: center;
    transition: all 0.3s;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
    margin: 0 auto;
}

#user-question:focus {
    outline: none;
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.3);
}

/* Mode Selection (Radio) */
.card-count-selector {
    display: flex;
    justify-content: center;
    gap: 10px;
    padding: 0;
    background: transparent;
    border: none;
    margin-bottom: 20px;
}

.card-count-selector label {
    padding: 8px 20px;
    cursor: pointer;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.8);
    border: 0.5px solid rgba(255, 255, 255, 0.5);
    border-radius: 50px;
    transition: all 0.3s;
    background: rgba(0, 0, 0, 0.7);
    font-weight: 300;
}

.card-count-selector label:has(input:checked) {
    background: rgba(212, 175, 55, 0.95);
    border-color: var(--accent-gold);
    color: #fff;
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.6);
    font-weight: 400;
}

/* Grid Layouts - Reverted to simpler original feel */
.result-grid {
    display: grid;
    gap: 15px;
    /* Reverted to 15px */
    width: 100%;
    margin-bottom: 30px;
}

.result-grid[data-count="1"] {
    grid-template-columns: 1fr;
    max-width: 200px;
    margin: 0 auto;
}

.result-grid[data-count="3"] {
    grid-template-columns: repeat(3, 1fr);
}

/* Original was likely list-style */
.result-grid[data-count="6"] {
    grid-template-columns: repeat(3, 1fr);
}

/* Original was list-style */

@media (min-width: 400px) {

    .result-grid[data-count="3"],
    .result-grid[data-count="6"] {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Interpretation Box - Reverted to Original Compact Style */
.interpretation-box {
    background: linear-gradient(160deg, rgba(255, 255, 255, 0.03) 0%, rgba(255, 255, 255, 0.01) 100%);
    border: 1px solid var(--border-glass);
    border-left: 2px solid var(--accent-gold);
    padding: 20px;
    /* Reverted to 20px */
    text-align: left;
    margin-bottom: 30px;
    backdrop-filter: blur(10px);
    border-radius: 0;
    /* Original sharp style */
}

#result-text {
    line-height: 1.7;
    /* Reverted to 1.7 */
    font-size: 0.95rem;
    color: #ddd;
    white-space: pre-wrap;
}

/* Luna Portrait Integration (Compact Version) */
#char-portrait-container {
    display: flex;
    align-items: center;
    margin-bottom: 15px;
    background: rgba(197, 160, 89, 0.05);
    /* Subtle highlight */
    padding: 10px;
    border-radius: 12px;
}

#char-portrait {
    width: 65px;
    height: 65px;
    border-radius: 50%;
    border: 1.5px solid var(--accent-gold);
    margin-right: 15px;
    object-fit: cover;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    display: none;
}

#char-portrait-container h3 {
    margin: 0;
    color: var(--accent-gold);
    font-size: 1.1rem;
    font-family: var(--font-title);
}

#char-portrait-container p {
    margin: 2px 0 0;
    font-size: 0.8rem;
    color: #a0a0a0;
    font-style: italic;
    line-height: 1.3;
}

/* Action Buttons */
.action-btn {
    background: rgba(0, 0, 0, 0.5);
    color: var(--accent-gold);
    border: 1px solid var(--accent-gold);
    padding: 8px 25px;
    font-size: 0.95rem;
    border-radius: 50px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.action-btn:hover {
    background: var(--accent-gold);
    color: #050510;
    box-shadow: 0 0 20px rgba(212, 175, 55, 0.4);
}

/* Kakao & Reset */
#kakao-share-btn {
    background: #FEE500 !important;
    color: #000 !important;
    border: none;
    width: 100%;
    max-width: 350px;
    border-radius: 50px;
    padding: 12px;
    margin-bottom: 10px;
    font-weight: 700;
}

#reset-btn {
    background: transparent;
    color: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.2);
    width: 100%;
    max-width: 350px;
    border-radius: 50px;
    padding: 10px;
    cursor: pointer;
    margin: 0 auto;
    /* Added for centering */
}

/* Status Msg */
#status-message {
    color: var(--accent-gold);
    font-size: 0.8rem;
    margin-top: 5px;
}

/* Music btn baseline */
.music-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.4);
    font-size: 1.2rem;
    cursor: pointer;
    margin-right: 8px;
    transition: color 0.3s;
}

.music-btn:hover {
    color: #fff;
}

input[type=range] {
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    width: 100%;
}

input[type=range]::-webkit-slider-runnable-track {
    height: 1px;
    background: rgba(255, 255, 255, 0.2);
}

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    height: 8px;
    width: 8px;
    border-radius: 50%;
    background: #fff;
    margin-top: -3.5px;
}

/* Deck Stacks */
.card-stack {
    position: relative;
    width: 90px;
    height: 150px;
    margin: 0 auto 30px auto;
    perspective: 1000px;
}

.card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    background: #1a1a2e url('https://raw.githubusercontent.com/wonseokjung/solopreneur-ai-agents/main/agents/kodari/assets/tarot_back_pattern.png') center/cover;
    border: 1px solid var(--accent-gold);
    border-radius: 12px;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.5);
    transition: transform 0.6s;
}

.shuffling .card-back:nth-child(1) {
    animation: shuffleTop 0.8s infinite;
}

@keyframes shuffleTop {

    0%,
    100% {
        transform: translate(0, 0);
    }

    25% {
        transform: translate(-40px, 0) rotate(-5deg);
    }

    75% {
        transform: translate(40px, 0) rotate(5deg);
    }
}

/* Card Display Result */
.card-display img {
    width: 100%;
    border-radius: 8px;
    border: 1px solid var(--accent-gold);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
}

.card-label {
    color: var(--accent-gold);
    font-size: 0.9rem;
    margin-top: 8px;
    font-family: var(--font-title);
}

.card-sub-label {
    font-size: 0.75rem;
    color: var(--text-sub);
}

/* Removed top-bar-controls as it's now handled inline in index.html */

#api-key-input {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.3);
    font-size: 0.7rem;
    width: 80px;
}

#api-key-input:focus {
    color: #fff;
    outline: none;
}

#result-name {
    display: block;
    margin-bottom: 20px;
    font-family: var(--font-title);
    color: var(--accent-gold);
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(15px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100000;
}

.modal-content {
    background: rgba(20, 20, 40, 0.95);
    padding: 40px;
    border-radius: 20px;
    border: 1px solid var(--accent-gold);
    max-width: 400px;
    width: 90%;
    text-align: center;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 20px;
}

.auth-form input {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 12px;
    border-radius: 8px;
    color: #fff;
    width: 100%;
}

.auth-btn {
    background: var(--accent-gold);
    color: #000;
    border: none;
    padding: 12px;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
}

.auth-switch {
    margin-top: 15px;
    font-size: 0.85rem;
    color: #a0a0a0;
}

.auth-switch span {
    color: var(--accent-gold);
    cursor: pointer;
    text-decoration: underline;
}