/* Quien Soy - Mobile-first styles */

:root {
    --color-primary: #6C5CE7;
    --color-primary-dark: #5B4CD4;
    --color-secondary: #A29BFE;
    --color-correct: #00B894;
    --color-correct-dark: #00A080;
    --color-pass: #E17055;
    --color-pass-dark: #D35845;
    --color-warning: #FDCB6E;
    --color-bg: #1A1A2E;
    --color-bg-light: #16213E;
    --color-card: #0F3460;
    --color-text: #FFFFFF;
    --color-text-muted: #A0A0A0;

    --transition-speed: 0.2s;
    --border-radius: 12px;
    --border-radius-large: 20px;
}

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

html, body {
    height: 100%;
    height: 100dvh;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Screens */
.screen {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 20px;
    overflow-y: auto;
}

.screen.active {
    display: flex;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.screen-content {
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
}

.screen-content.centered {
    justify-content: center;
    align-items: center;
    text-align: center;
    min-height: 100%;
}

/* Typography */
.title {
    font-size: 2.5rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 8px;
}

.subtitle {
    font-size: 1rem;
    color: var(--color-text-muted);
    text-align: center;
    margin-bottom: 32px;
}

.section-title {
    font-size: 1.25rem;
    font-weight: 600;
    text-align: center;
    margin-bottom: 20px;
    color: var(--color-secondary);
}

/* Setup Screen */
.setup-section {
    margin-bottom: 24px;
}

.label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--color-text-muted);
}

.input, .select {
    width: 100%;
    padding: 14px 16px;
    font-size: 1rem;
    border: 2px solid var(--color-card);
    border-radius: var(--border-radius);
    background: var(--color-bg-light);
    color: var(--color-text);
    transition: border-color var(--transition-speed);
}

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

.input::placeholder {
    color: var(--color-text-muted);
}

.select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23A0A0A0' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 44px;
}

/* Player Input */
.player-input-row {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.player-input-row .input {
    flex: 1;
}

.btn-icon-only {
    width: 48px;
    height: 48px;
    padding: 0;
    font-size: 1.5rem;
    border-radius: var(--border-radius);
    background: var(--color-primary);
    color: white;
    border: none;
    cursor: pointer;
    flex-shrink: 0;
}

.players-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 200px;
    overflow-y: auto;
}

.player-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--color-bg-light);
    border-radius: var(--border-radius);
    border: 2px solid var(--color-card);
}

.player-item-name {
    font-size: 1rem;
    font-weight: 500;
}

.player-item-remove {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--color-pass);
    font-size: 1.25rem;
    cursor: pointer;
    border-radius: 50%;
    transition: background var(--transition-speed);
}

.player-item-remove:hover {
    background: rgba(225, 112, 85, 0.2);
}

.hint {
    text-align: center;
    font-size: 0.875rem;
    color: var(--color-text-muted);
    margin-top: 16px;
}

/* Buttons */
.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 24px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all var(--transition-speed);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    min-height: 48px;
}

.btn:active {
    transform: scale(0.98);
}

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

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

.btn-primary:active:not(:disabled) {
    background: var(--color-primary-dark);
}

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

.btn-secondary:active {
    background: var(--color-card);
}

.btn-large {
    padding: 18px 32px;
    font-size: 1.125rem;
    border-radius: var(--border-radius-large);
    width: 100%;
}

/* Category Screen */
.turn-header {
    text-align: center;
    padding: 20px;
    background: var(--color-bg-light);
    border-radius: var(--border-radius);
    margin-bottom: 24px;
}

.turn-label {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    margin-bottom: 4px;
}

.turn-player-name {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--color-primary);
    margin-bottom: 4px;
}

.turn-score {
    font-size: 1rem;
    color: var(--color-secondary);
}

.category-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}

.btn-category {
    flex-direction: column;
    padding: 20px 16px;
    background: var(--color-card);
    border-radius: var(--border-radius);
}

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

.category-icon {
    font-size: 2rem;
    margin-bottom: 8px;
}

.category-name {
    font-size: 0.875rem;
    font-weight: 500;
}

/* Ready Screen */
.ready-phone {
    font-size: 5rem;
    margin-bottom: 16px;
    animation: bounce 2s infinite;
}

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

.ready-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.ready-subtitle {
    font-size: 1rem;
    color: var(--color-text-muted);
    margin-bottom: 24px;
}

.instructions-box {
    width: 100%;
    margin-bottom: 32px;
}

.instruction {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    border-radius: var(--border-radius);
    margin-bottom: 12px;
}

.instruction.correct {
    background: rgba(0, 184, 148, 0.2);
    border: 2px solid var(--color-correct);
}

.instruction.pass {
    background: rgba(225, 112, 85, 0.2);
    border: 2px solid var(--color-pass);
}

.instruction-icon {
    font-size: 1.5rem;
    font-weight: bold;
}

.instruction.correct .instruction-icon {
    color: var(--color-correct);
}

.instruction.pass .instruction-icon {
    color: var(--color-pass);
}

.pulse {
    animation: pulse 2s infinite;
}

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

.permission-status {
    font-size: 0.875rem;
    color: var(--color-warning);
    margin-top: 16px;
    min-height: 20px;
}

/* Playing Screen - Landscape optimized */
#screen-playing {
    background: var(--color-bg);
    padding: 0;
}

#screen-playing.correct {
    background: var(--color-correct);
}

#screen-playing.pass {
    background: var(--color-pass);
}

.playing-container {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    height: 100%;
    padding: 20px;
    position: relative;
}

.playing-timer {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 2rem;
    font-weight: 700;
    padding: 12px 24px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: var(--border-radius-large);
}

.playing-timer.warning {
    background: var(--color-warning);
    color: var(--color-bg);
}

.playing-timer.critical {
    background: var(--color-pass);
    animation: timerPulse 0.5s infinite;
}

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

.timer-icon {
    font-size: 1.5rem;
}

.playing-word-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.playing-word {
    font-size: 3.5rem;
    font-weight: 800;
    text-align: center;
    line-height: 1.2;
    padding: 20px;
    text-transform: uppercase;
    letter-spacing: 2px;
    word-break: break-word;
}

.playing-category {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.7);
    text-transform: uppercase;
    letter-spacing: 2px;
}

/* Fallback buttons */
.fallback-buttons {
    display: flex;
    gap: 16px;
    width: 100%;
    max-width: 400px;
    margin-top: 20px;
}

.fallback-buttons.hidden {
    display: none;
}

.btn-correct, .btn-pass {
    flex: 1;
    flex-direction: column;
    padding: 20px;
    font-size: 1rem;
}

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

.btn-correct:active {
    background: var(--color-correct-dark);
}

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

.btn-pass:active {
    background: var(--color-pass-dark);
}

/* Feedback overlay */
.feedback-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: none;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 100;
}

.feedback-overlay.show {
    display: flex;
    animation: feedbackPop 0.5s ease-out;
}

.feedback-overlay.correct {
    background: var(--color-correct);
}

.feedback-overlay.pass {
    background: var(--color-pass);
}

@keyframes feedbackPop {
    0% { opacity: 0; transform: scale(0.8); }
    50% { opacity: 1; transform: scale(1.1); }
    100% { opacity: 1; transform: scale(1); }
}

.feedback-text {
    font-size: 4rem;
    font-weight: 800;
    text-transform: uppercase;
}

/* Turn End Screen */
.turn-end-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--color-secondary);
}

.turn-end-player {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 32px;
}

.turn-end-stats {
    display: flex;
    gap: 32px;
    margin-bottom: 24px;
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 32px;
    border-radius: var(--border-radius);
}

.stat.correct {
    background: rgba(0, 184, 148, 0.2);
    border: 2px solid var(--color-correct);
}

.stat.pass {
    background: rgba(225, 112, 85, 0.2);
    border: 2px solid var(--color-pass);
}

.stat-icon {
    font-size: 1.5rem;
    margin-bottom: 4px;
}

.stat.correct .stat-icon {
    color: var(--color-correct);
}

.stat.pass .stat-icon {
    color: var(--color-pass);
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 700;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--color-text-muted);
}

.turn-end-points {
    display: flex;
    align-items: baseline;
    gap: 8px;
    font-size: 2rem;
    font-weight: 700;
    color: var(--color-correct);
    margin-bottom: 32px;
}

/* Results Screen */
.results-title {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 32px;
}

.results-list {
    width: 100%;
    max-width: 320px;
    margin-bottom: 32px;
}

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

.result-item.first {
    background: linear-gradient(135deg, #FFD700 0%, #B8860B 100%);
    color: var(--color-bg);
}

.result-item.second {
    background: linear-gradient(135deg, #C0C0C0 0%, #808080 100%);
    color: var(--color-bg);
}

.result-item.third {
    background: linear-gradient(135deg, #CD7F32 0%, #8B4513 100%);
    color: var(--color-bg);
}

.result-rank {
    font-size: 1.5rem;
    font-weight: 700;
    min-width: 40px;
    text-align: center;
}

.result-name {
    flex: 1;
    font-size: 1.125rem;
    font-weight: 600;
}

.result-score {
    font-size: 1.25rem;
    font-weight: 700;
}

.results-actions {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Landscape mode for playing screen */
@media (orientation: landscape) {
    #screen-playing .playing-container {
        flex-direction: row;
        padding: 10px 20px;
    }

    #screen-playing .playing-timer {
        position: absolute;
        top: 10px;
        left: 50%;
        transform: translateX(-50%);
    }

    #screen-playing .playing-word {
        font-size: 5rem;
    }

    #screen-playing .playing-category {
        position: absolute;
        bottom: 10px;
        left: 50%;
        transform: translateX(-50%);
    }

    #screen-playing .fallback-buttons {
        position: absolute;
        bottom: 10px;
        left: 50%;
        transform: translateX(-50%);
        margin-top: 0;
    }
}

/* Large screens in landscape */
@media (orientation: landscape) and (min-width: 600px) {
    #screen-playing .playing-word {
        font-size: 6rem;
    }
}

/* Tablet and desktop */
@media (min-width: 768px) {
    .title {
        font-size: 3rem;
    }

    .category-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .playing-word {
        font-size: 4rem;
    }
}

/* Prevent text selection during game */
#screen-playing,
#screen-ready {
    user-select: none;
    -webkit-user-select: none;
}

/* Focus styles for accessibility */
.btn:focus-visible,
.input:focus-visible,
.select:focus-visible {
    outline: 2px solid var(--color-secondary);
    outline-offset: 2px;
}

/* Hide scrollbar but keep functionality */
.players-list::-webkit-scrollbar {
    width: 4px;
}

.players-list::-webkit-scrollbar-track {
    background: var(--color-bg);
}

.players-list::-webkit-scrollbar-thumb {
    background: var(--color-card);
    border-radius: 2px;
}
