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

:root {
    --bg-primary: #0d1329;
    --bg-secondary: #1a2140;
    --bg-card: #252b4a;
    --accent-cyan: #06b6d4;
    --accent-cyan-dark: #0891b2;
    --accent-purple: #8b5cf6;
    --accent-purple-dark: #7c3aed;
    --text-primary: #ffffff;
    --text-secondary: #8892b0;
    --text-placeholder: #5a6380;
    --success: #4ade80;
    --error: #f87171;
    --warning: #fbbf24;
    --team-color-start: #06b6d4;
    --team-color-end: #0891b2;
    --team-shadow: rgba(6, 182, 212, 0.3);
    --onboarding-accent: var(--accent-cyan);
    --onboarding-accent-dark: var(--accent-cyan-dark);
    --onboarding-shadow: rgba(6, 182, 212, 0.3);
    --onboarding-shadow-hover: rgba(6, 182, 212, 0.4);
    --settings-accent: var(--accent-cyan);
    --settings-accent-dark: var(--accent-cyan-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;
}

/* 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-cyan);
    background: transparent;
    color: var(--accent-cyan);
    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-cyan);
        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(--team-color-start) 0%, var(--team-color-end) 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 var(--team-shadow);
}

@media (hover: hover) {
    .btn-play:hover {
        transform: translateY(-2px);
        box-shadow: 0 6px 25px var(--team-shadow);
    }
}

.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(--team-color-start) 0%, var(--team-color-end) 100%);
    padding: 40px;
    border-radius: 24px;
    text-align: center;
    margin: 40px 0;
    box-shadow: 0 8px 32px var(--team-shadow);
}

.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;
    margin-bottom: 10px;
}

.turn-hint.secondary {
    color: var(--team-color-start);
    font-weight: 600;
}

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

.team-indicator {
    background: linear-gradient(135deg, var(--team-color-start) 0%, var(--team-color-end) 100%);
    color: white;
    padding: 8px 20px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
}

/* Clue Instruction */
.clue-instruction {
    text-align: center;
    margin: 20px 0;
}

.clue-instruction p {
    font-size: 18px;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* Spectrum Card */
.spectrum-card,
.result-spectrum-card {
    background: var(--bg-card);
    border-radius: 20px;
    padding: 24px;
    margin: 20px 0;
}

.spectrum-labels {
    display: flex;
    justify-content: space-between;
    margin-bottom: 16px;
    gap: 12px;
}

.spectrum-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    max-width: 45%;
}

.spectrum-label.left {
    text-align: left;
    color: var(--accent-cyan);
}

.spectrum-label.right {
    text-align: right;
    color: var(--accent-purple);
}

.spectrum-label.left::before {
    content: "← ";
}

.spectrum-label.right::after {
    content: " →";
}

.spectrum-bar {
    position: relative;
    margin: 16px 0;
}

.spectrum-track {
    height: 12px;
    border-radius: 6px;
    background: linear-gradient(90deg, var(--accent-cyan) 0%, var(--accent-purple) 100%);
    position: relative;
}

.spectrum-marker {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 3px solid white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    z-index: 2;
    background: var(--success);
}

.spectrum-marker.target {
    background: var(--success);
}

.spectrum-marker.guess {
    background: var(--warning);
}

.spectrum-numbers {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
}

.spectrum-numbers span {
    font-size: 12px;
    color: var(--text-secondary);
    width: 20px;
    text-align: center;
}

.target-number {
    text-align: center;
    font-size: 64px;
    font-weight: 800;
    color: var(--success);
    margin-top: 16px;
}

/* Guess Screen */
.guess-instruction {
    text-align: center;
    margin: 20px 0;
}

.guess-instruction p {
    font-size: 18px;
    color: var(--text-secondary);
}

.guess-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-top: 20px;
}

.guess-btn {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: 2px solid var(--text-secondary);
    background: transparent;
    color: var(--text-primary);
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

@media (hover: hover) {
    .guess-btn:hover {
        border-color: var(--team-color-start);
        color: var(--team-color-start);
    }
}

.guess-btn.selected {
    background: linear-gradient(135deg, var(--team-color-start) 0%, var(--team-color-end) 100%);
    border-color: transparent;
    color: white;
    transform: scale(1.15);
    box-shadow: 0 4px 15px var(--team-shadow);
}

/* Result Screen */
.result-summary {
    background: var(--bg-card);
    border-radius: 20px;
    padding: 24px;
    text-align: center;
    margin-bottom: 20px;
}

.result-team-name {
    font-size: 24px;
    font-weight: 700;
    color: var(--team-color-start);
    margin-bottom: 8px;
}

.result-points {
    font-size: 36px;
    font-weight: 800;
    color: var(--success);
}

.result-points.zero {
    color: var(--text-secondary);
}

.result-values {
    display: flex;
    justify-content: space-between;
    margin-top: 16px;
}

.result-target-value {
    color: var(--success);
    font-size: 14px;
}

.result-guess-value {
    color: var(--warning);
    font-size: 14px;
}

/* 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: var(--bg-secondary);
    border: 1px solid var(--team-color-start);
}

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

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

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

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

    .spectrum-card,
    .result-spectrum-card {
        padding: 16px 12px;
    }

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

    .spectrum-marker {
        width: 24px;
        height: 24px;
    }

    .target-number {
        font-size: 48px;
    }

    .guess-btn {
        width: 44px;
        height: 44px;
        font-size: 16px;
    }

    .guess-buttons {
        gap: 8px;
    }

    .clue-instruction p,
    .guess-instruction p {
        font-size: 16px;
    }

    .result-summary {
        border-radius: 16px;
        padding: 16px;
        margin-bottom: 16px;
    }

    .result-team-name {
        font-size: 18px;
        margin-bottom: 6px;
    }

    .result-points {
        font-size: 28px;
    }

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

    .spectrum-card,
    .result-spectrum-card {
        padding: 16px;
    }

    .target-number {
        font-size: 48px;
        margin-top: 10px;
    }
}

@media (max-height: 600px) {
    .spectrum-label {
        font-size: 12px;
    }

    .target-number {
        font-size: 40px;
        margin-top: 8px;
    }

    .guess-btn {
        width: 40px;
        height: 40px;
        font-size: 14px;
    }
}

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

    .screen {
        padding: 50px 40px;
    }

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

    .spectrum-card,
    .result-spectrum-card {
        padding: 32px;
    }

    .spectrum-label {
        font-size: 16px;
    }

    .spectrum-track {
        height: 16px;
        border-radius: 8px;
    }

    .spectrum-marker {
        width: 32px;
        height: 32px;
    }

    .target-number {
        font-size: 80px;
    }

    .guess-btn {
        width: 60px;
        height: 60px;
        font-size: 20px;
    }

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