:root {
    --color-bg: #1a1a2e;
    --color-surface: #16213e;
    --color-primary: #e94560;
    --color-secondary: #0f3460;
    --color-text: #ffffff;
    --color-text-dim: #a0a0a0;
    --color-win: #4ade80;
    --color-lose: #f87171;
    --color-tie: #fbbf24;
    --transition-speed: 0.3s;
}

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

html, body {
    height: 100%;
    width: 100%;
    overflow: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    color: var(--color-text);
    background-color: var(--color-bg);
    transition: background-color var(--transition-speed) ease;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100%;
    min-width: 320px;
    padding: 20px;
    text-align: center;
}

/* Screens */
.screen {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    width: 100%;
    max-width: 400px;
}

.screen.active {
    display: flex;
}

/* Typography */
h1 {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 0;
}

h2 {
    font-size: 1.75rem;
    font-weight: 600;
}

.subtitle {
    font-size: 1rem;
    color: var(--color-text-dim);
}

/* Home Screen */
.home-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.game-icons {
    display: flex;
    gap: 12px;
    margin-bottom: 8px;
}

.game-icon {
    font-size: 2.8rem;
    animation: bounce 2s ease-in-out infinite;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
}

.game-icon[data-icon="rock"] {
    animation-delay: 0s;
}

.game-icon[data-icon="paper"] {
    animation-delay: 0.2s;
}

.game-icon[data-icon="scissors"] {
    animation-delay: 0.4s;
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-8px);
    }
}

.how-to-play {
    display: flex;
    gap: 16px;
    padding: 16px 20px;
    background: linear-gradient(135deg, var(--color-surface) 0%, rgba(22, 33, 62, 0.7) 100%);
    border-radius: 12px;
    border: 1px solid rgba(233, 69, 96, 0.2);
}

.step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--color-text-dim);
}

.step-num {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-primary);
    color: white;
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: 700;
}

@media (max-width: 360px) {
    .how-to-play {
        flex-direction: column;
        gap: 10px;
        padding: 12px 16px;
    }

    .step {
        flex-direction: row;
        gap: 10px;
    }
}

/* Buttons */
.btn-primary,
.btn-secondary {
    min-width: 200px;
    min-height: 48px;
    padding: 14px 28px;
    font-size: 1.1rem;
    font-weight: 600;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: transform 0.15s ease, opacity 0.15s ease;
    touch-action: manipulation;
}

.btn-primary {
    background-color: var(--color-primary);
    color: var(--color-text);
}

.btn-secondary {
    background-color: var(--color-secondary);
    color: var(--color-text);
    border: 2px solid var(--color-primary);
}

.btn-primary:active,
.btn-secondary:active {
    transform: scale(0.95);
    opacity: 0.9;
}

.btn-primary:disabled,
.btn-secondary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-link {
    background: none;
    border: none;
    color: var(--color-text-dim);
    font-size: 1rem;
    cursor: pointer;
    padding: 10px;
    transition: color 0.2s;
}

.btn-link:hover {
    color: var(--color-text);
}

.btn-group {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
}

.btn-group.vertical {
    flex-direction: column;
    align-items: center;
}

/* Room Code */
.room-code {
    font-size: 3rem;
    font-weight: 700;
    letter-spacing: 0.5rem;
    padding: 20px 30px;
    background-color: var(--color-surface);
    border-radius: 16px;
    font-family: 'Courier New', monospace;
}

/* Input Code */
.input-code {
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: 0.5rem;
    padding: 15px 25px;
    background-color: var(--color-surface);
    border: 2px solid var(--color-secondary);
    border-radius: 12px;
    color: var(--color-text);
    text-align: center;
    width: 200px;
    font-family: 'Courier New', monospace;
    text-transform: uppercase;
}

.input-code:focus {
    outline: none;
    border-color: var(--color-primary);
}

.input-code::placeholder {
    color: var(--color-text-dim);
    opacity: 0.5;
}

/* Input Name */
.input-name {
    font-size: 1.2rem;
    font-weight: 500;
    padding: 12px 20px;
    background-color: var(--color-surface);
    border: 2px solid var(--color-secondary);
    border-radius: 12px;
    color: var(--color-text);
    text-align: center;
    width: 100%;
    max-width: 250px;
}

.input-name:focus {
    outline: none;
    border-color: var(--color-primary);
}

.input-name::placeholder {
    color: var(--color-text-dim);
    opacity: 0.7;
}

/* Waiting Indicator */
.waiting-indicator {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--color-text-dim);
    font-size: 1.1rem;
}

.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--color-secondary);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Round Info */
.round-info {
    font-size: 1.2rem;
    color: var(--color-text-dim);
}

/* Scoreboard */
.scoreboard {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 15px 30px;
    background-color: var(--color-surface);
    border-radius: 12px;
}

.scoreboard.small {
    padding: 10px 20px;
    font-size: 1rem;
}

.score-player {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.score-label {
    font-size: 0.9rem;
    color: var(--color-text-dim);
    font-weight: 500;
}

.score-value {
    font-size: 2rem;
    font-weight: 700;
}

.score-separator {
    font-size: 1.5rem;
    color: var(--color-text-dim);
}

/* Choice Buttons */
.choices {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.choice-btn {
    width: 80px;
    height: 80px;
    font-size: 2.5rem;
    background-color: var(--color-surface);
    border: 3px solid var(--color-secondary);
    border-radius: 16px;
    cursor: pointer;
    transition: transform 0.15s ease, border-color 0.15s ease, background-color 0.15s ease;
    touch-action: manipulation;
    display: flex;
    align-items: center;
    justify-content: center;
}

.choice-btn:active {
    transform: scale(0.9);
}

.choice-btn:hover {
    border-color: var(--color-primary);
}

.choice-btn.selected {
    border-color: var(--color-primary);
    background-color: var(--color-secondary);
}

.choice-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Status Indicator */
.status-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--color-text-dim);
    font-size: 1rem;
    min-height: 30px;
}

.status-indicator.waiting .spinner {
    display: inline-block;
}

/* Reveal Screen */
.reveal-choices {
    display: flex;
    align-items: center;
    gap: 20px;
}

.reveal-player {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.reveal-label {
    font-size: 0.9rem;
    color: var(--color-text-dim);
}

.reveal-choice {
    font-size: 4rem;
    padding: 15px;
    background-color: var(--color-surface);
    border-radius: 16px;
}

.reveal-vs {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-text-dim);
}

.round-result {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    padding: 15px 30px;
    border-radius: 12px;
}

.round-result.win {
    background-color: rgba(74, 222, 128, 0.2);
}

.round-result.lose {
    background-color: rgba(248, 113, 113, 0.2);
}

.round-result.tie {
    background-color: rgba(251, 191, 36, 0.2);
}

.result-emoji {
    font-size: 2rem;
}

.result-text {
    font-size: 1.5rem;
    font-weight: 700;
}

.round-result.win .result-text {
    color: var(--color-win);
}

.round-result.lose .result-text {
    color: var(--color-lose);
}

.round-result.tie .result-text {
    color: var(--color-tie);
}

.next-round-text {
    color: var(--color-text-dim);
    font-size: 1rem;
}

/* Finished Screen */
.final-result {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.final-emoji {
    font-size: 4rem;
}

.final-text {
    font-size: 2rem;
    font-weight: 700;
}

.final-result.win .final-text {
    color: var(--color-win);
}

.final-result.lose .final-text {
    color: var(--color-lose);
}

.final-score {
    font-size: 3rem;
    font-weight: 700;
    padding: 15px 40px;
    background-color: var(--color-surface);
    border-radius: 12px;
}

/* Error Screen */
.error-icon {
    font-size: 4rem;
}

.error-message {
    color: var(--color-text-dim);
    font-size: 1.1rem;
    max-width: 280px;
}

/* Media queries */
@media (min-width: 768px) {
    h1 {
        font-size: 3rem;
    }

    .room-code {
        font-size: 4rem;
    }

    .choice-btn {
        width: 100px;
        height: 100px;
        font-size: 3rem;
    }

    .reveal-choice {
        font-size: 5rem;
    }
}
