* {
    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;
    --accent-orange: #ff9500;
    --accent-orange-dark: #e68600;
    --onboarding-accent: var(--accent-orange);
    --onboarding-accent-dark: var(--accent-orange-dark);
    --onboarding-shadow: rgba(255, 149, 0, 0.3);
    --onboarding-shadow-hover: rgba(255, 149, 0, 0.4);
    --text-primary: #ffffff;
    --text-secondary: #8892b0;
    --text-placeholder: #5a6380;
    --success: #4ade80;
    --error: #f87171;
    --settings-accent: var(--accent-orange);
    --settings-accent-dark: var(--accent-orange-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;
}

.subtitle {
    text-align: center;
    color: var(--accent-pink);
    font-size: 18px;
    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;
}


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

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

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

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

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

/* Turn Screen */
.team-turn-card {
    background: linear-gradient(135deg, var(--accent-orange) 0%, var(--accent-orange-dark) 100%);
    padding: 40px;
    border-radius: 24px;
    text-align: center;
    margin: 40px 0;
    box-shadow: 0 8px 32px rgba(255, 149, 0, 0.3);
}

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

.turn-hint {
    text-align: center;
    color: var(--text-secondary);
    font-size: 16px;
    line-height: 1.5;
}

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

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

.question-card {
    background: linear-gradient(135deg, var(--bg-card) 0%, var(--bg-secondary) 100%);
    padding: 30px;
    border-radius: 24px;
    text-align: center;
    margin: 20px 0;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.question-prefix {
    display: block;
    font-size: 18px;
    color: var(--accent-orange);
    margin-bottom: 12px;
}

.question-text {
    display: block;
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.4;
}

/* Timer */
.timer-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 30px 0;
}

.timer-balls {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
}

.timer-ball {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent-orange);
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(255, 149, 0, 0.4);
}

.timer-ball.empty {
    background: var(--bg-card);
    box-shadow: none;
}

.timer-text {
    font-size: 72px;
    font-weight: 700;
    color: var(--accent-orange);
}

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

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

/* Game Buttons */
.game-buttons {
    display: flex;
    gap: 20px;
    margin-top: 20px;
}

.btn-fail, .btn-success {
    flex: 1;
    padding: 18px;
    border-radius: 16px;
    border: none;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

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

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

@media (hover: hover) {
    .btn-fail:hover, .btn-success:hover {
        transform: scale(1.02);
    }
}

.btn-fail:active, .btn-success:active {
    transform: scale(0.98);
}

/* Start Timer Section */
.start-timer-section {
    margin-top: auto;
    padding: 20px 0;
}

.btn-start-timer {
    width: 100%;
    background: linear-gradient(135deg, var(--accent-orange) 0%, var(--accent-orange-dark) 100%);
    border: none;
    color: white;
    padding: 20px;
    border-radius: 30px;
    font-size: 20px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 20px rgba(255, 149, 0, 0.3);
}

@media (hover: hover) {
    .btn-start-timer:hover {
        transform: translateY(-2px);
        box-shadow: 0 6px 25px rgba(255, 149, 0, 0.4);
    }
}

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

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

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

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

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

.result-title.fail {
    color: var(--error);
}

.result-team {
    text-align: center;
    color: var(--text-secondary);
    font-size: 18px;
    margin-bottom: 30px;
}

/* 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(255, 149, 0, 0.2) 0%, rgba(255, 149, 0, 0.1) 100%);
    border: 1px solid var(--accent-orange);
}

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

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

/* 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-orange);
    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-team-name {
    flex: 1;
    font-size: 18px;
}

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

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

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

    .timer-ball {
        width: 28px;
        height: 28px;
    }

    .timer-ball.filled {
        width: 28px;
        height: 28px;
    }

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

    .question-card {
        padding: 20px 16px;
        margin-bottom: 20px;
    }

    .question-text {
        font-size: 18px;
        line-height: 1.3;
    }

    .game-buttons {
        gap: 16px;
        margin-top: 16px;
    }

    .btn-fail, .btn-success {
        padding: 14px;
        border-radius: 12px;
        font-size: 14px;
    }

    .btn-start-timer {
        padding: 16px;
        border-radius: 24px;
        font-size: 16px;
    }

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

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

    .result-team {
        font-size: 14px;
        margin-bottom: 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-team-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-team-name {
        font-size: 16px;
    }

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

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

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

    .timer-ball {
        width: 32px;
        height: 32px;
    }

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

    .question-card {
        padding: 20px;
    }

    .question-text {
        font-size: 20px;
    }
}

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

    .screen {
        padding: 50px 40px;
    }

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

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

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

    .question-text {
        font-size: 28px;
    }

    .btn-fail, .btn-success {
        padding: 24px;
        font-size: 20px;
    }

    .btn-start-timer {
        padding: 24px;
        font-size: 22px;
    }

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