* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #0d1329;
    --bg-secondary: #1a2140;
    --bg-card: #252b4a;
    --accent-green: #16a34a;
    --accent-green-dark: #15803d;
    --accent-yellow: #f59e0b;
    --accent-yellow-dark: #d97706;
    --text-primary: #ffffff;
    --text-secondary: #8892b0;
    --text-placeholder: #5a6380;
    --success: #4ade80;
    --error: #f87171;

    --onboarding-accent: var(--accent-green);
    --onboarding-accent-dark: var(--accent-green-dark);
    --onboarding-shadow: rgba(22, 163, 74, 0.3);
    --onboarding-shadow-hover: rgba(22, 163, 74, 0.4);
    --settings-accent: var(--accent-green);
    --settings-accent-dark: var(--accent-green-dark);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: linear-gradient(180deg, var(--bg-primary) 0%, #0a0f1f 100%);
    min-height: 100vh;
    min-height: var(--app-height, 100dvh);
    color: var(--text-primary);
    overflow-x: hidden;
}

.app {
    max-width: 430px;
    margin: 0 auto;
    min-height: 100vh;
    min-height: var(--app-height, 100dvh);
    position: relative;
}

.screen {
    display: none;
    flex-direction: column;
    min-height: 100vh;
    min-height: var(--app-height, 100dvh);
    padding: 40px 24px;
    padding-top: calc(40px + env(safe-area-inset-top, 0px));
    padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
    animation: fadeIn 0.3s ease;
}

.screen.active {
    display: flex;
}

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

.title {
    font-size: 28px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 30px;
}

/* Back Button */
.btn-back {
    position: absolute;
    top: calc(40px + env(safe-area-inset-top, 0px));
    left: 24px;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 24px;
    cursor: pointer;
    padding: 8px;
    z-index: 10;
}

/* ===== Players Setup ===== */
.players-list {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 20px;
}

/* ===== Settings ===== */
.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding: 0 10px;
}

.settings-label {
    color: var(--text-secondary);
    font-size: 16px;
}

.score-selector {
    display: flex;
    align-items: center;
    gap: 16px;
}

.score-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid var(--accent-green);
    background: transparent;
    color: var(--accent-green);
    font-size: 24px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

@media (hover: hover) {
    .score-btn:hover {
        background: var(--accent-green);
        color: white;
    }
}

.score-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    min-width: 40px;
    text-align: center;
}

/* ===== Bottom Section & Play Button ===== */
.bottom-section {
    padding: 20px 0;
    margin-top: auto;
}

.btn-play {
    width: 100%;
    background: linear-gradient(135deg, var(--accent-green) 0%, var(--accent-green-dark) 100%);
    border: none;
    color: white;
    padding: 18px;
    border-radius: 30px;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 20px rgba(22, 163, 74, 0.3);
}

@media (hover: hover) {
    .btn-play:hover {
        transform: translateY(-2px);
        box-shadow: 0 6px 25px rgba(22, 163, 74, 0.4);
    }
}

.btn-play:active {
    transform: translateY(0);
}

.btn-play:disabled {
    background: var(--bg-card);
    box-shadow: none;
    cursor: not-allowed;
}

.play-icon {
    font-size: 20px;
}

/* ===== Round Screen ===== */
.game-header {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
    padding-left: 48px;
    padding-right: 48px;
}

.round-indicator {
    background: var(--bg-card);
    color: var(--text-secondary);
    padding: 8px 24px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
}

.card-reveal {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    gap: 20px;
    padding: 20px 0;
}

.letter-display {
    font-size: 120px;
    font-weight: 900;
    color: var(--accent-yellow);
    text-align: center;
    text-shadow: 0 0 40px rgba(245, 158, 11, 0.5);
    line-height: 1;
    animation: letterReveal 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes letterReveal {
    from { transform: scale(0.3) rotate(-10deg); opacity: 0; }
    to { transform: scale(1) rotate(0deg); opacity: 1; }
}

.category-display {
    font-size: 28px;
    font-weight: 600;
    color: var(--text-primary);
    text-align: center;
    background: var(--bg-card);
    padding: 16px 24px;
    border-radius: 16px;
    border-left: 4px solid var(--accent-green);
    animation: categorySlide 0.3s ease 0.15s both;
}

@keyframes categorySlide {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* ===== Timer Bar ===== */
.timer-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
}

.timer-bar-track {
    width: 100%;
    height: 8px;
    background: var(--bg-card);
    border-radius: 4px;
    overflow: hidden;
}

.timer-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-green), var(--accent-green-dark));
    border-radius: 4px;
    transition: width 0.1s linear;
}

.timer-bar-fill.urgent {
    background: linear-gradient(90deg, var(--error), #dc2626);
}

.timer-text {
    font-size: 24px;
    font-weight: 700;
    color: var(--accent-green);
    text-align: center;
}

.timer-text.urgent {
    color: var(--error);
    animation: pulse 0.5s ease infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* ===== Player Answer Buttons ===== */
.players-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.player-answer-btn {
    background: linear-gradient(135deg, var(--bg-card) 0%, var(--bg-secondary) 100%);
    border: 2px solid var(--accent-green);
    color: var(--text-primary);
    padding: 20px 16px;
    border-radius: 16px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

@media (hover: hover) {
    .player-answer-btn:hover {
        background: linear-gradient(135deg, var(--accent-green) 0%, var(--accent-green-dark) 100%);
        transform: scale(1.02);
    }
}

.player-answer-btn:active {
    transform: scale(0.95);
}

.btn-skip-round {
    width: 100%;
    background: transparent;
    border: 2px solid var(--text-secondary);
    color: var(--text-secondary);
    padding: 14px;
    border-radius: 30px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 16px;
    transition: all 0.3s ease;
}

@media (hover: hover) {
    .btn-skip-round:hover {
        border-color: var(--error);
        color: var(--error);
    }
}

/* ===== Result Screen ===== */
.result-icon {
    font-size: 100px;
    text-align: center;
    margin: 20px 0;
}

.result-icon.success {
    color: var(--success);
}

.result-icon.neutral {
    color: var(--text-secondary);
}

.result-title {
    font-size: 36px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 10px;
}

.result-player {
    text-align: center;
    color: var(--accent-yellow);
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
}

.result-word-hint {
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 24px;
}

.result-word-hint strong {
    color: var(--accent-yellow);
}

/* ===== Scoreboard ===== */
.scoreboard {
    background: var(--bg-card);
    border-radius: 20px;
    padding: 20px;
    margin: 20px 0;
}

.scoreboard-title {
    font-size: 18px;
    font-weight: 600;
    text-align: center;
    margin-bottom: 16px;
    color: var(--text-secondary);
}

.scoreboard-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.score-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-radius: 12px;
}

.score-item.leading {
    background: linear-gradient(135deg, rgba(22, 163, 74, 0.2) 0%, rgba(22, 163, 74, 0.1) 100%);
    border: 1px solid var(--accent-green);
}

.score-player-name {
    font-size: 16px;
    font-weight: 600;
}

.score-points {
    font-size: 24px;
    font-weight: 700;
    color: var(--accent-green);
}

/* ===== Final Screen ===== */
.winner-icon {
    font-size: 100px;
    text-align: center;
    margin: 20px 0;
}

.winner-name {
    font-size: 32px;
    font-weight: 700;
    text-align: center;
    color: var(--accent-yellow);
    margin-bottom: 30px;
}

.final-scores {
    flex: 1;
    overflow-y: auto;
}

.final-score-item {
    display: flex;
    align-items: center;
    padding: 16px;
    background: var(--bg-card);
    border-radius: 16px;
    margin-bottom: 12px;
}

.final-position {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    margin-right: 16px;
}

.final-position.gold {
    background: linear-gradient(135deg, #ffd700 0%, #ffb700 100%);
    color: #1a1a1a;
}

.final-position.silver {
    background: linear-gradient(135deg, #c0c0c0 0%, #a0a0a0 100%);
    color: #1a1a1a;
}

.final-position.bronze {
    background: linear-gradient(135deg, #cd7f32 0%, #a05a20 100%);
    color: #1a1a1a;
}

.final-position.other {
    background: var(--bg-secondary);
    color: var(--text-secondary);
}

.final-player-name {
    flex: 1;
    font-size: 18px;
}

.final-score {
    font-size: 24px;
    font-weight: 700;
    color: var(--accent-green);
}

/* ===== Pause Button & Overlay ===== */
.btn-pause {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--text-secondary);
    padding: 6px 16px;
    border-radius: 16px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    align-self: center;
}

@media (hover: hover) {
    .btn-pause:hover {
        background: rgba(255, 255, 255, 0.2);
        color: var(--text-primary);
    }
}

#round-screen {
    position: relative;
}

.pause-overlay {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(13, 19, 41, 0.95);
    z-index: 50;
    align-items: center;
    justify-content: center;
}

.pause-overlay.active {
    display: flex;
    cursor: pointer;
}

.pause-overlay-text {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-secondary);
}

.player-answer-btn:disabled,
.btn-skip-round:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* ===== Responsive: Mobile ===== */
@media (max-width: 480px) {
    .app {
        max-width: 100%;
    }

    .screen {
        padding: 20px 12px;
        padding-top: calc(20px + env(safe-area-inset-top, 0px));
        padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    }

    .title {
        font-size: 22px;
        margin-bottom: 20px;
    }

    .btn-play {
        padding: 16px;
        font-size: 16px;
    }

    .letter-display {
        font-size: 90px;
    }

    .category-display {
        font-size: 22px;
        padding: 14px 20px;
    }

    .player-answer-btn {
        padding: 16px 12px;
        font-size: 14px;
    }

    .result-icon {
        font-size: 60px;
        margin: 12px 0;
    }

    .result-title {
        font-size: 24px;
        margin-bottom: 8px;
    }

    .result-player {
        font-size: 20px;
    }

    .scoreboard {
        border-radius: 16px;
        padding: 16px;
        margin: 16px 0;
    }

    .scoreboard-title {
        font-size: 16px;
        margin-bottom: 12px;
    }

    .scoreboard-list {
        gap: 10px;
    }

    .score-item {
        padding: 10px 12px;
    }

    .score-player-name {
        font-size: 14px;
    }

    .score-points {
        font-size: 18px;
    }

    .winner-icon {
        font-size: 60px;
        margin: 12px 0;
    }

    .winner-name {
        font-size: 24px;
        margin-bottom: 20px;
    }

    .final-score-item {
        padding: 12px;
        margin-bottom: 10px;
    }

    .final-position {
        width: 36px;
        height: 36px;
        font-size: 13px;
        margin-right: 12px;
    }

    .final-player-name {
        font-size: 16px;
    }

    .final-score {
        font-size: 18px;
    }
}

/* ===== Responsive: Short viewport ===== */
@media (max-height: 700px) {
    .screen {
        padding: 20px;
    }

    .title {
        font-size: 24px;
        margin-bottom: 20px;
    }

    .letter-display {
        font-size: 90px;
    }

    .category-display {
        font-size: 24px;
    }

    .card-reveal {
        gap: 12px;
        padding: 10px 0;
    }
}

/* ===== Responsive: Tablet+ ===== */
@media (min-width: 768px) {
    .app {
        max-width: 100%;
    }

    .screen {
        padding: 50px 40px;
    }

    .title {
        font-size: 32px;
        margin-bottom: 40px;
    }

    .letter-display {
        font-size: 140px;
    }

    .category-display {
        font-size: 32px;
        padding: 20px 30px;
    }

    .player-answer-btn {
        padding: 24px 20px;
        font-size: 18px;
    }

    .winner-name {
        font-size: 40px;
    }
}