:root {
    --bg-color: #f7f7f7;
    --card-black: #1a1a1a;
    --card-white: #ffffff;
    --text-on-black: #ffffff;
    --text-on-white: #1a1a1a;
    --shadow: 0 10px 24px rgba(0, 0, 0, 0.12);
    --font-stack: 'Roboto', sans-serif;
    --success: #1f9d55;
}

body {
    font-family: var(--font-stack);
    background: var(--bg-color);
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    color: #222;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

.hidden {
    display: none !important;
}

.screen {
    display: none;
    flex-direction: column;
    width: 100%;
    max-width: 1040px;
    padding: 20px;
    box-sizing: border-box;
    align-items: center;
}

.screen.active {
    display: flex;
}

#login-screen,
#lobby-screen {
    background: #fff;
    padding: 40px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    text-align: center;
}

#winner-screen {
    background: #fff;
    border-radius: 12px;
    box-shadow: var(--shadow);
    text-align: center;
    max-width: 520px;
}

#restart-actions {
    display: flex;
    gap: 10px;
}

input {
    padding: 12px;
    margin: 10px 0;
    width: 100%;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 16px;
    box-sizing: border-box;
}

button {
    background: var(--card-black);
    color: #fff;
    border: none;
    padding: 12px 24px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    transition: transform 0.15s ease, background 0.2s ease;
    margin-top: 10px;
}

button:hover {
    transform: translateY(-2px);
    background: #333;
}

.room-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 10px;
    width: 100%;
    margin-top: 20px;
}

.room-btn {
    padding: 14px;
    background: #eee;
    color: #333;
}

.room-btn:hover {
    background: #ddd;
}

#game-screen {
    height: 100vh;
    justify-content: flex-start;
    gap: 10px;
    padding: 14px 16px 28px;
    position: relative;
}

.top-bar {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px 10px;
    padding: 8px 10px;
    font-weight: 700;
    font-size: 0.95rem;
    box-sizing: border-box;
    z-index: 20;
}

#timer {
    background: var(--card-black);
    color: #fff;
    padding: 6px 16px;
    border-radius: 24px;
    min-width: 52px;
    text-align: center;
}

#question-area {
    width: 100%;
    min-height: 340px;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

#question-area.minimized {
    align-items: flex-start;
    min-height: 100px;
}

#question-area.minimized .black-card {
    width: 100%;
    max-width: 100%;
    height: auto;
    min-height: 88px;
    padding: 14px 18px;
    font-size: 1.2rem;
    border-radius: 12px;
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.2);
}

.card {
    width: 200px;
    height: 280px;
    padding: 20px;
    box-sizing: border-box;
    border-radius: 10px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    text-align: left;
    font-size: 1.32rem;
    line-height: 1.3;
    font-weight: 700;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    cursor: pointer;
    user-select: none;
    margin: 6px;
    flex-shrink: 0;
}

.black-card {
    background-color: var(--card-black);
    color: var(--text-on-black);
    width: 250px;
    height: 350px;
    font-size: 1.5rem;
    line-height: 1.25;
    cursor: default;
}

.white-card {
    background-color: var(--card-white);
    color: var(--text-on-white);
    border: 1px solid #ddd;
}

.white-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 14px 28px rgba(0, 0, 0, 0.18);
}

.white-card.selected {
    border: 3px solid var(--card-black);
    transform: translateY(-12px);
}

#game-status {
    width: 100%;
    text-align: center;
    font-weight: 700;
    min-height: 28px;
}

#answers-title {
    margin: 0;
    font-size: 1rem;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

#round-winner-banner {
    background: #fff;
    border: 2px solid var(--success);
    color: #0a6a36;
    border-radius: 10px;
    padding: 10px 16px;
    font-weight: 700;
    box-shadow: var(--shadow);
}

#submitted-answers-area {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    width: 100%;
    padding: 6px 6px 12px;
    max-width: 1100px;
    min-height: 100px;
    box-sizing: border-box;
}

.answers-empty {
    margin: 0;
    opacity: 0.7;
    font-style: italic;
}

.submitted-card {
    opacity: 0;
    transform: translateY(24px) scale(0.97);
    animation: answerReveal 0.35s ease forwards;
    animation-delay: var(--reveal-delay, 0ms);
}

.submitted-card.pickable {
    cursor: pointer;
}

.submitted-card.pickable:hover {
    border-color: #777;
}

.submitted-card.winner {
    border: 4px solid var(--success);
    box-shadow: 0 0 0 4px rgba(31, 157, 85, 0.2), 0 14px 26px rgba(0, 0, 0, 0.2);
    transform: translateY(-8px) scale(1.03);
    opacity: 1;
    animation: none;
}

@keyframes answerReveal {
    from {
        opacity: 0;
        transform: translateY(24px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

#hand-area {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 8px 4px 16px;
    width: 100%;
    gap: 10px;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    min-height: 300px;
    align-items: center;
    box-sizing: border-box;
}

#hand-area::-webkit-scrollbar {
    display: none;
}

#hand-area .card {
    scroll-snap-align: center;
}

#confirm-selection-btn {
    position: fixed;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 130;
}

#start-next-round-btn {
    position: fixed;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 130;
}

#leader-controls {
    position: fixed;
    top: 86px;
    right: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 90;
}

#scoreboard {
    margin-left: auto;
    max-width: 70%;
    overflow: hidden;
}

#score-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 2px 8px;
    font-size: 0.66rem;
    line-height: 1.2;
    opacity: 0.85;
}

#score-list li {
    white-space: nowrap;
}

#score-list li.leader::after {
    content: ' L';
    font-size: 0.6rem;
    opacity: 0.7;
}

#score-list li.czar {
    font-weight: 700;
}

.round-transition {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.56);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.round-transition.active {
    opacity: 1;
}

.round-transition-content {
    background: #fff;
    padding: 20px 24px;
    border-radius: 14px;
    text-align: center;
    max-width: 560px;
    margin: 0 16px;
    box-shadow: var(--shadow);
}

#transition-title {
    margin: 0;
    font-size: 1.3rem;
    font-weight: 700;
}

#transition-subtitle {
    margin: 8px 0 0;
    opacity: 0.8;
}

@media (min-width: 768px) {
    #game-screen {
        padding: 16px 20px 28px;
    }

    #question-area {
        min-height: 370px;
    }

    #hand-area {
        flex-wrap: wrap;
        justify-content: center;
        overflow-x: visible;
        min-height: 0;
    }

    #question-area.minimized .black-card {
        width: 250px;
        height: 350px;
        min-height: 350px;
        padding: 20px;
        font-size: 1.5rem;
        border-radius: 10px;
    }

    #score-list {
        font-size: 0.7rem;
    }
}

@media (max-width: 767px) {
    body {
        align-items: flex-start;
    }

    #game-screen {
        padding-top: 8px;
    }

    .top-bar {
        font-size: 0.85rem;
    }

    .card {
        width: 180px;
        height: 250px;
        font-size: 1.15rem;
    }

    .black-card {
        width: 220px;
        height: 300px;
        font-size: 1.25rem;
    }

    #scoreboard {
        width: 100%;
        max-width: 100%;
        order: 3;
        margin-left: 0;
    }

    #score-list {
        justify-content: flex-start;
        font-size: 0.6rem;
    }

    #leader-controls {
        top: auto;
        bottom: 72px;
        right: 10px;
    }
}
