body {
    /* Apply thematic font optionally to whole body or specific elements */
    /* font-family: 'Merriweather', serif; */
    font-family: sans-serif; /* Keep sans-serif for UI elements */
    background-color: #333;
    color: #f0f0f0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    overflow: hidden; /* Prevent scrolling */
}

.game-container {
    width: 90%;
    max-width: 400px;
    height: 80vh;
    max-height: 700px;
    background-color: #444;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    padding: 20px;
    box-sizing: border-box;
}

/* --- Stats Section --- */
.stats-container {
    display: flex;
    justify-content: space-around;
    margin-bottom: 20px;
}

.stat {
    text-align: center;
    width: 23%;
}

.stat-label {
    font-size: 0.8em;
    display: block;
    margin-bottom: 5px;
    color: #ccc; /* Lighter label */
}

.stat-bar {
    height: 12px;
    background-color: #666;
    border-radius: 6px;
    overflow: hidden;
    position: relative;
}

.stat-fill {
    height: 100%;
    background-color: #ddd;
    border-radius: 6px;
    width: 50%; /* Initial value */
    transition: width 0.4s ease, background-color 0.3s ease;
}

.stat-fill.low { background-color: #ff6b6b; }
.stat-fill.high { background-color: #feca57; }

.threshold-marker {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background-color: rgba(255, 255, 255, 0.5);
    display: none;
    transition: left 0.4s ease;
    pointer-events: none;
    z-index: 1;
}

.threshold-marker.next {
    background-color: rgba(152, 251, 152, 0.7);
    box-shadow: 0 0 3px rgba(152, 251, 152, 0.5);
}

.threshold-marker.prev {
    background-color: rgba(255, 160, 122, 0.7);
    box-shadow: 0 0 3px rgba(255, 160, 122, 0.5);
}

/* --- Current Class Display --- */
.current-class-display {
    text-align: center;
    margin-top: 10px;
    margin-bottom: 5px; /* Adjusted margin */
    font-size: 0.9em;
    color: #ccc;
}

/* --- Card Area and Card Styling --- */
.card-area {
    flex-grow: 1;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    /*overflow: hidden;  Hide card parts flying off */
    margin-top: 10px; /* Add some space above card */
}

.card {
    width: 90%; /* Slightly wider? */
    max-width: 380px; /* Optional max width */
    height: auto; /* Height determined by aspect ratio */
    aspect-ratio: 2 / 3; /* Enforce 2:3 aspect ratio */

    background-color: #222; /* Fallback color */
    border-radius: 12px; /* Smoother radius */
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);

    position: absolute; /* Keep for movement */
    cursor: grab;
    user-select: none;
    overflow: hidden; /* Clip contents (image) */

    /* Remove default padding */
    padding: 0;

    /* Set position context for absolute children */
    position: relative;

    /* Keep transitions */
    transition: transform 0.1s linear, opacity 0.3s ease-out;
}
.card.dragging {
     cursor: grabbing;
}

#card-image {
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover; /* Cover area, maintain aspect ratio, crop */
    border-radius: 12px; /* Match parent card */
    z-index: 1; /* Base layer */
    pointer-events: none;
}

/* Container for text overlay */
#card-text-container {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 2; /* Above image */
    /* Gradient from black (more opaque) to transparent */
    background: linear-gradient(to top, rgba(0,0,0,0.9) 0%, rgba(0,0,0,0.75) 50%, rgba(0,0,0,0) 100%);
    padding: 40px 20px 20px 20px; /* Adjust padding: Top, H, Bottom */
    border-radius: 0 0 12px 12px; /* Match bottom radius */
    pointer-events: none;
}

#card-text {
    /* Apply the thematic font */
    font-family: 'Merriweather', serif;
    font-size: 1.05em; /* Slightly larger */
    line-height: 1.5;
    color: #f5f5f5; /* Very light grey/off-white */
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8); /* Stronger shadow */
    margin: 0; /* Remove default paragraph margin */
    text-align: center; /* Center text within container */
}


/* Choice text hints (overlaying card) */
.choice-text {
    position: absolute;
    /* Position vertically near center/upper third */
    top: 45%;
    transform: translateY(-50%) rotate(0); /* Start rotation at 0 */
    width: auto; /* Fit content */
    max-width: 80%; /* Prevent overly wide text */
    font-size: 2.6em; /* Large hints */
    font-weight: bold;
    font-family: 'Merriweather', serif; /* Thematic font */
    color: rgba(255, 255, 255, 0.85); /* Bright text */
    /* Robust text shadow for outline effect */
    text-shadow:
        -1.5px -1.5px 0 #000,
         1.5px -1.5px 0 #000,
        -1.5px  1.5px 0 #000,
         1.5px  1.5px 0 #000, /* Outline */
         3px 3px 5px rgba(0,0,0,0.6); /* Drop shadow */

    opacity: 0; /* Controlled by JS */
    transition: opacity 0.2s ease-in-out, transform 0.2s ease-in-out; /* Add transform transition */
    pointer-events: none;
    z-index: 3; /* Above text container */
    padding: 5px 15px; /* Padding around text */
    text-align: center; /* Center align text within its box */
    /* Optional: subtle rotation on reveal */
    /* transform: translateY(-50%) rotate(-5deg); for left */
    /* transform: translateY(-50%) rotate(5deg); for right */
}

/* Horizontal positioning inside the card */
.choice-text-left {
    left: 50%; /* Start near center */
    transform: translateX(-50%) translateY(-50%) rotate(-8deg); /* Centered H, moved V, rotated */
    transform-origin: center center;
}
.choice-text-right {
    right: 50%; /* Start near center */
    transform: translateX(50%) translateY(-50%) rotate(8deg); /* Centered H, moved V, rotated */
    transform-origin: center center;
}


/* Swipe Feedback Overlays (outside card) */
.swipe-feedback {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 80px;
    height: 80px;
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.2s ease-out;
    pointer-events: none;
    z-index: 4; /* Above card if needed during overlap */
}

#swipe-feedback-left {
    left: -15px; /* Adjusted position */
    background-color: rgba(255, 100, 100, 0.3);
}
#swipe-feedback-right {
    right: -15px; /* Adjusted position */
    background-color: rgba(100, 200, 100, 0.3);
}


/* --- End Screen Styling --- */
.end-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    color: #fff;
    /* display: flex; /* JS controls this */
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 20px;
    box-sizing: border-box;
    z-index: 10;
}
#end-image { /* Style for image inside end screen */
    display: none; /* JS controls this */
    max-width: 60%;
    max-height: 40%;
    margin-bottom: 20px;
    object-fit: contain;
    border-radius: 5px; /* Optional rounding */
}
#end-title {
    font-family: 'Merriweather', serif; /* Thematic font for title */
    margin-bottom: 15px;
    font-size: 1.8em;
}
#end-message {
    font-family: 'Merriweather', serif; /* Thematic font for message */
    margin-bottom: 30px;
    max-width: 80%;
    line-height: 1.6;
    font-size: 1.1em;
}
#restart-button {
    padding: 12px 25px; /* Larger button */
    font-size: 1.1em;
    cursor: pointer;
    background-color: #eee;
    color: #333;
    border: none;
    border-radius: 5px;
    transition: background-color 0.2s;
}
#restart-button:hover {
    background-color: #ccc;
}