:root {
    --bg-color: #FFFBF0;
    /* Cream */
    --text-color: #5D5D5D;
    --card-bg: #FFFFFF;

    --primary-color: #B5EAD7;
    /* Pastel Green */
    --secondary-color: #87CEEB;
    /* Sky Blue */
    --accent-color: #FFB7B2;
    /* Pastel Red/Pink */
    --peach: #FFDAC1;
    /* Peach */
    --lavender: #C3B1E1;
    /* Pastel Purple */

    --shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
    --radius: 24px;
}

body {
    margin: 0;
    font-family: 'Nunito', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    height: 100vh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Screens & Layers */
.modal {
    display: none;
    /* Hidden by default */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    z-index: 200;
    /* Ensure on top */
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
    /* Only show when active */
}

.modal.hidden {
    display: none !important;
}

.screen {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    align-items: center;
    justify-content: center;
    z-index: 50;
    background: rgba(255, 251, 240, 0.9);
    /* Slight transparency */
}

.screen.active {
    display: flex;
}

.game-layer {
    display: none;
    /* Hidden by default */
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 10;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.game-layer.active {
    display: flex;
}

/* Common Card Styles */
.card {
    background: var(--card-bg);
    padding: 40px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-align: center;
    max-width: 400px;
    width: 90%;
    position: relative;
    border: 4px solid #fff;
    /* White border for depth */
}

h1 {
    margin: 0;
    color: var(--peach);
    font-size: 3rem;
    text-shadow: 2px 2px 0px var(--accent-color);
    line-height: 1.2;
}

.subtitle {
    margin-top: 5px;
    color: var(--primary-color);
    font-weight: 800;
    letter-spacing: 1px;
    text-transform: uppercase;
    font-size: 0.9rem;
}

/* Login specifics */
.form-group {
    margin: 20px 0;
    text-align: left;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 800;
    color: #999;
    font-size: 0.9rem;
}

input {
    width: 100%;
    padding: 15px;
    border: 3px solid #EEE;
    border-radius: 16px;
    font-size: 1.1rem;
    font-family: inherit;
    font-weight: bold;
    color: #555;
    box-sizing: border-box;
    transition: border-color 0.3s;
    outline: none;
    text-align: center;
}

input:focus {
    border-color: var(--primary-color);
}

.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 20px;
}

.join-section {
    display: flex;
    gap: 10px;
}

button {
    border: none;
    padding: 15px 20px;
    font-size: 1rem;
    font-family: 'Nunito', sans-serif;
    font-weight: 800;
    border-radius: 50px;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
}

button:hover {
    transform: scale(1.02);
}

button:active {
    transform: scale(0.98);
}

.btn-primary {
    background: var(--primary-color);
    color: #555;
    width: auto;
    min-width: 150px;
    box-shadow: none;
}

.btn-secondary {
    background: #EEE;
    color: #777;
    width: auto;
    min-width: 150px;
    box-shadow: none;
}

.btn-small {
    padding: 5px 15px;
    font-size: 0.8rem;
    background: #EEE;
    border-radius: 12px;
}

.divider {
    margin: 25px 0;
    position: relative;
    text-align: center;
}

.divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    width: 100%;
    height: 2px;
    background: #F0F0F0;
    z-index: 0;
}

.divider span {
    background: var(--card-bg);
    padding: 0 10px;
    color: #D3C4BE;
    position: relative;
    z-index: 1;
    font-size: 0.8rem;
    font-weight: bold;
}

.error-msg {
    color: var(--accent-color);
    font-weight: bold;
    font-size: 0.9rem;
    min-height: 1.2em;
    margin-top: 10px;
}

.code-display {
    background: #F9F9F9;
    padding: 15px;
    border-radius: 16px;
    margin: 15px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: monospace;
    font-size: 1.5rem;
    border: 3px dashed #EEE;
    color: #555;
}

/* Game Interface */
.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    /* Anchor to top */
    padding-top: 10vh;
    /* Push down to visual center */
    gap: 10px;
    width: 100%;
    height: 100%;
    max-width: 600px;
    padding-left: 20px;
    padding-right: 20px;
    padding-bottom: 20px;
    box-sizing: border-box;
    overflow-y: auto;
}

/* Renaming .game-header to not conflict if possible, or just removing */
/* .game-header { ... } REMOVED */

.game-title-header {
    font-size: 2.5rem;
    color: var(--peach);
    text-shadow: 2px 2px 0 var(--accent-color);
    margin-bottom: 2px;
    margin-top: -10px;
    /* Pull it up a bit */
    text-align: center;
    width: 100%;
}

.score-pill {
    background: #FFF;
    padding: 10px 25px;
    border-radius: 50px;
    font-weight: 800;
    color: var(--text-color);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
    display: inline-flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 20px;
    font-size: 1.1rem;
    border: 2px solid #F0F0F0;
}

#currentScore {
    color: var(--secondary-color);
    font-size: 1.3rem;
}

.card-area {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex: 0 0 auto;
    /* Stop stretching */
}

.game-card {
    background: #FFF;
    min-height: 300px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
    padding: 50px 30px;
    margin-top: 0;
    /* Let flex gap handle spacing */
}

.category-tag {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #F5F5F5;
    color: #AAA;
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 800;
    text-transform: uppercase;
}

#phraseText {
    font-size: 2rem;
    color: #444;
    font-weight: 800;
    margin: 20px 0;
    line-height: 1.4;
}

.answer-section {
    margin-top: 20px;
    width: 100%;
    animation: fadeIn 0.5s ease;
}

.answer-text {
    color: var(--secondary-color);
    font-size: 1.5rem;
    margin: 10px 0;
}

/* Controls */
.controls-area {
    width: 100%;
    margin-bottom: 0;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
    width: 100%;
}

.scoring-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
    width: 100%;
}

.btn-action {
    padding: 12px 24px;
    font-size: 1rem;
    width: auto;
    min-width: 120px;
    box-shadow: none;
}

.btn-action.reveal {
    background: var(--lavender);
    color: #FFF;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    width: auto;
    min-width: 150px;
    padding-left: 20px;
    padding-right: 20px;
}

.btn-action.correct {
    background: var(--primary-color);
    color: #444;
    box-shadow: none;
}

.btn-action.wrong {
    background: var(--accent-color);
    color: #FFF;
    box-shadow: none;
}

.btn-action.next {
    background: var(--peach);
    color: #555;
    border: 2px solid #FFF;
}

/* Utilities */
.hidden {
    display: none !important;
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.loader {
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

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

.status-text {
    font-weight: bold;
    color: #BBB;
    font-style: italic;
}