:root {
    --card-width: 100px;
    --card-height: 170px; 
    --bg-color: #1a1a1a;
    --card-back-pattern: repeating-linear-gradient(45deg, #2c3e50, #2c3e50 10px, #34495e 10px, #34495e 20px);
    --accent-color: #f1c40f;
    --panel-bg: #262626;
}

/* Mobile Adjustments (Phones) */
@media (max-width: 600px) {
    :root {
        --card-width: 50px; /* Slightly smaller cards */
        --card-height: 85px;
        --dashboard-height: 140px;
    }
    
    body { padding: 5px; } /* More room for cards */
    
    .card-spread {
        gap: 4px; /* Tighter gaps for small screens */
    }

    #reading-log {
        height: 50px; /* Slimmer log to save vertical space */
        font-size: 12px;
    }
    
    button {
        padding: 10px 12px; /* Bigger tap targets for fingers */
        font-size: 13px;
        flex: 1; /* Buttons grow to fill the row */
    }
}

body {
    font-family: 'Georgia', serif;
    background-color: var(--bg-color);
    color: #ecf0f1;
    margin: 0;
    padding: 20px;
}

/* --- STICKY DASHBOARD --- */
.dashboard {
    position: sticky;
    top: 10px;
    z-index: 1000;
    background-color: var(--panel-bg);
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.8);
    max-width: 800px;
    margin: 0 auto 30px auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.controls {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

/* --- THE LOG AREA --- */
.log-container {
    width: 100%;
}

#reading-log {
    width: 100%;
    height: 80px;
    background: #111;
    color: var(--accent-color);
    border: 1px solid #444;
    border-radius: 6px;
    padding: 10px;
    font-family: 'Courier New', monospace;
    resize: none;
    box-sizing: border-box;
}

button {
    background-color: var(--accent-color);
    border: none;
    padding: 10px 20px;
    font-size: 0.9rem;
    cursor: pointer;
    border-radius: 6px;
    color: #1a1a1a;
    font-weight: 800;
    transition: all 0.2s;
}

button.secondary {
    background-color: #444;
    color: white;
}

button:hover {
    opacity: 0.9;
    transform: translateY(-2px);
}

/* --- THE GRID LAYOUT --- */
.card-spread {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(var(--card-width), 1fr));
    gap: 15px;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    perspective: 1000px;
}

/* --- CARD STYLES --- */
.card {
    height: var(--card-height);
    border-radius: 8px;
    cursor: pointer;
    position: relative;
    transition: transform 0.6s;
    transform-style: preserve-3d;
    box-shadow: 0 4px 8px rgba(0,0,0,0.5);
}

.card.flipped {
    transform: rotateY(180deg);
    cursor: default;
}

.card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid #34495e;
    box-sizing: border-box;
}

.card-back { background: var(--card-back-pattern); }

.card-front {
    background-color: #fff;
    color: #222;
    transform: rotateY(180deg);
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.card-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-text { display: none; padding: 10px; font-size: 0.8rem; font-weight: bold; }

/* Fallback */
.card-front.image-failed .card-img { display: none; }
.card-front.image-failed .card-text { display: block; }