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

:root {
    --bg-primary: #0d1329;
    --bg-secondary: #1a2140;
    --bg-card: #252b4a;
    --accent-pink: #ff3b6f;
    --accent-pink-dark: #cc2f59;
    --accent-blue: #4a6cf7;
    --text-primary: #ffffff;
    --text-secondary: #8892b0;
    --text-placeholder: #5a6380;
    --success: #4ade80;
    --error: #f87171;
    --settings-accent: var(--accent-pink);
    --settings-accent-dark: var(--accent-pink-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;
}

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

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

/* Toggle */
.toggle-container {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
    gap: 12px;
}

.toggle {
    position: relative;
    width: 52px;
    height: 28px;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-card);
    border-radius: 28px;
    transition: 0.3s;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 22px;
    width: 22px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: 0.3s;
}

.toggle input:checked + .toggle-slider {
    background: linear-gradient(135deg, var(--accent-blue) 0%, var(--accent-pink) 100%);
}

.toggle input:checked + .toggle-slider:before {
    transform: translateX(24px);
}

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

/* Play Button */
.btn-play {
    width: 100%;
    background: linear-gradient(135deg, var(--accent-pink) 0%, var(--accent-pink-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(255, 59, 111, 0.3);
}

@media (hover: hover) {
    .btn-play:hover {
        transform: translateY(-2px);
        box-shadow: 0 6px 25px rgba(255, 59, 111, 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;
}

/* 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;
}

/* Packs Screen */
.subtitle {
    text-align: center;
    color: var(--accent-pink);
    font-size: 18px;
    margin-bottom: 30px;
}

/* Ready Screen */
.explaining-player {
    text-align: center;
    font-size: 24px;
    font-weight: 600;
    color: var(--accent-pink);
    margin: 10px 0;
}

.guessing-player {
    text-align: center;
    color: var(--text-secondary);
    font-size: 16px;
}

/* Mode Selection Screen */
.mode-cards {
    display: flex;
    flex-direction: column;
    gap: 16px;
    flex: 1;
    justify-content: center;
    max-width: 400px;
    margin: 0 auto;
    width: 100%;
}

.mode-card {
    background: var(--bg-card);
    border-radius: 20px;
    padding: 28px 24px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    text-align: center;
}

@media (hover: hover) {
    .mode-card:hover {
        transform: translateY(-3px);
        border-color: var(--accent-pink);
        box-shadow: 0 8px 30px rgba(255, 59, 111, 0.2);
    }
}

.mode-card:active {
    transform: scale(0.98);
}

.mode-card-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.mode-card-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.mode-card-desc {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* Teams List */
.teams-list {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 20px;
}

/* Settings Row */
.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-pink);
    background: transparent;
    color: var(--accent-pink);
    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-pink);
        color: white;
    }
}

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

/* Turn Screen */
.team-turn-card {
    background: var(--bg-card);
    padding: 40px;
    border-radius: 24px;
    text-align: center;
    margin: 20px 0;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.team-turn-name {
    font-size: 32px;
    font-weight: 700;
}

.turn-words-left {
    text-align: center;
    color: var(--text-secondary);
    font-size: 16px;
    margin-top: 20px;
}

.turn-words-left strong {
    color: var(--accent-pink);
    font-size: 24px;
}

/* Game Header */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding-left: 48px;
}

.team-indicator {
    background: var(--accent-pink);
    color: white;
    padding: 8px 20px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
}

.team-indicator:empty {
    display: none;
}

.words-left-badge {
    background: var(--bg-card);
    color: var(--text-secondary);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
}

.words-left-badge:empty {
    display: none;
}

/* Game Screen */
#game-screen {
    align-items: center;
    justify-content: center;
    gap: 40px;
    position: relative;
}

.timer-container {
    position: relative;
    width: 150px;
    height: 150px;
}

.timer-svg {
    transform: rotate(-90deg);
    width: 100%;
    height: 100%;
}

.timer-bg {
    fill: none;
    stroke: var(--bg-card);
    stroke-width: 8;
}

.timer-progress {
    fill: none;
    stroke: url(#timer-gradient);
    stroke-width: 8;
    stroke-linecap: round;
    stroke-dasharray: 283;
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 1s linear;
}

.timer-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 48px;
    font-weight: 700;
}

.word-card {
    background: linear-gradient(135deg, var(--bg-card) 0%, var(--bg-secondary) 100%);
    padding: 40px 60px;
    border-radius: 24px;
    text-align: center;
    min-width: 280px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

#current-word {
    font-size: 28px;
    font-weight: 600;
}

.game-buttons {
    display: flex;
    gap: 40px;
}

.btn-wrong, .btn-correct {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: none;
    font-size: 36px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-wrong {
    background: var(--error);
    color: white;
}

.btn-correct {
    background: var(--success);
    color: white;
}

@media (hover: hover) {
    .btn-wrong:hover, .btn-correct:hover {
        transform: scale(1.1);
    }
}

.btn-wrong:active, .btn-correct:active {
    transform: scale(0.95);
}

/* Round Results */
.round-stats {
    display: flex;
    justify-content: center;
    gap: 60px;
    margin: 30px 0;
}

.stat {
    text-align: center;
}

.stat-value {
    display: block;
    font-size: 48px;
    font-weight: 700;
    color: var(--accent-pink);
}

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

.guessed-words {
    flex: 1;
    overflow-y: auto;
    margin: 20px 0;
}

.guessed-word-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-card);
    border-radius: 12px;
    margin-bottom: 8px;
}

.guessed-word-item.correct {
    border-left: 3px solid var(--success);
}

.guessed-word-item.skipped {
    border-left: 3px solid var(--error);
}

.word-status {
    font-size: 18px;
}

/* Final Results */
.final-results {
    flex: 1;
    overflow-y: auto;
}

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

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

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

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

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

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

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

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

/* Round Results - Team Label */
.round-team-label {
    font-size: 24px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 10px;
}

.round-team-label:empty {
    display: none;
}

.words-remaining-info {
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
    margin: 10px 0;
}

.words-remaining-info strong {
    color: var(--accent-pink);
}

/* Scoreboard */
.scoreboard {
    background: var(--bg-card);
    border-radius: 20px;
    padding: 20px;
    margin: 16px 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: 10px;
}

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

.score-item.leading {
    background: linear-gradient(135deg, rgba(255, 59, 111, 0.2) 0%, rgba(255, 59, 111, 0.1) 100%);
    border: 1px solid var(--accent-pink);
}

.score-team-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 12px;
    flex-shrink: 0;
}

.score-team-name {
    flex: 1;
    font-size: 16px;
    font-weight: 600;
}

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

/* Winner Display */
.winner-icon {
    font-size: 80px;
    text-align: center;
    margin-bottom: 10px;
}

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

.winner-name:empty {
    display: none;
}

/* Gradient for timer */
svg defs {
    position: absolute;
}


/* ===== 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);
    }
}

.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);
}

.btn-correct:disabled,
.btn-wrong:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* Mobile Responsive */
@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;
    }

    .mode-card {
        padding: 22px 20px;
    }

    .mode-card-icon {
        font-size: 40px;
        margin-bottom: 8px;
    }

    .mode-card-title {
        font-size: 18px;
    }

    .mode-card-desc {
        font-size: 13px;
    }

    .settings-label {
        font-size: 14px;
    }

    .score-value {
        font-size: 20px;
    }

    .score-btn {
        width: 36px;
        height: 36px;
        font-size: 20px;
    }

    .team-turn-card {
        padding: 30px;
    }

    .team-turn-name {
        font-size: 26px;
    }

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

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

    .subtitle {
        font-size: 16px;
        margin-bottom: 20px;
    }

    .timer-container {
        width: 100px;
        height: 100px;
    }

    .timer-text {
        font-size: 32px;
    }

    .word-card {
        padding: 30px 20px;
        min-width: auto;
        margin: 10px;
    }

    #current-word {
        font-size: 20px;
    }

    .game-buttons {
        gap: 20px;
    }

    .btn-wrong, .btn-correct {
        width: 70px;
        height: 70px;
        font-size: 30px;
    }

    .round-stats {
        gap: 30px;
        margin: 20px 0;
    }

    .stat-value {
        font-size: 40px;
    }

    .stat-label {
        font-size: 12px;
    }

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

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

    .result-name {
        font-size: 16px;
    }

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

    .toggle-label {
        font-size: 13px;
    }

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

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

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

    .timer-container {
        width: 120px;
        height: 120px;
    }

    .timer-text {
        font-size: 36px;
    }

    .word-card {
        padding: 30px 40px;
    }

    #current-word {
        font-size: 24px;
    }
}

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

    .screen {
        padding: 50px 40px;
    }

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

    .timer-container {
        width: 180px;
        height: 180px;
    }

    .timer-text {
        font-size: 56px;
    }

    .word-card {
        padding: 50px 80px;
        min-width: 400px;
    }

    #current-word {
        font-size: 36px;
    }

    .game-buttons {
        gap: 60px;
    }

    .btn-wrong, .btn-correct {
        width: 100px;
        height: 100px;
        font-size: 44px;
    }

}
