:root {
    --bg-color: #0d0e12;
    --card-bg: rgba(30, 32, 40, 0.7);
    --primary: #c084fc;
    --primary-glow: rgba(192, 132, 252, 0.4);
    --secondary: #4ade80;
    --secondary-glow: rgba(74, 222, 128, 0.4);
    --danger: #f87171;
    --text-main: #f8fafc;
    --text-dim: #94a3b8;
    --glass-border: rgba(255, 255, 255, 0.1);
    --font-main: 'Outfit', sans-serif;
    --font-title: 'Bangers', cursive;
}

.game-subtitle {
    font-family: var(--font-title);
    font-size: 1.25rem;
    letter-spacing: 0.08em;
    color: #86efac;
    margin-top: -4px;
    margin-bottom: 16px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.game-title {
    font-family: var(--font-title);
    font-size: 2.75rem;
    font-weight: 400;
    letter-spacing: 0.02em;
    color: #fff;
    -webkit-text-stroke: 2px #dc2626;
    text-stroke: 2px #dc2626;
    text-shadow: 3px 3px 0 rgba(0, 0, 0, 0.4), 1px 1px 0 rgba(220, 38, 38, 0.3);
    margin-bottom: 8px;
    background: none;
    -webkit-text-fill-color: #fff;
}

/* Títulos significativos: misma fuente y estilo que el título principal */
.title-significant {
    font-family: var(--font-title);
    font-size: 2.75rem;
    font-weight: 400;
    letter-spacing: 0.02em;
    color: #fff;
    -webkit-text-stroke: 2px #dc2626;
    text-stroke: 2px #dc2626;
    text-shadow: 3px 3px 0 rgba(0, 0, 0, 0.4), 1px 1px 0 rgba(220, 38, 38, 0.3);
    background: none;
    -webkit-text-fill-color: #fff;
    margin-bottom: 8px;
}

.winner-name {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--secondary);
    margin-bottom: 24px !important;
    text-shadow: 0 0 12px var(--secondary-glow);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-color);
    color: var(--text-main);
    min-height: 100vh;
    min-height: 100dvh;
    background: radial-gradient(circle at top right, #1e1b4b, #0d0e12);
    background-attachment: fixed;
}


#app {
    min-height: 100vh;
    min-height: 100dvh;
    max-width: 500px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
}


.screen {
    flex: 1;
    display: none;
    flex-direction: column;
    padding: 24px;
    opacity: 0;
    transition: opacity 0.4s ease;
}


.screen.active {
    display: flex;
    opacity: 1;
}


.glass-card {
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 32px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    text-align: center;
}

h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 8px;
    background: linear-gradient(to right, var(--primary), var(--secondary));
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

h1.game-title {
    background: none;
    -webkit-text-fill-color: inherit;
}

p {
    color: var(--text-dim);
    margin-bottom: 32px;
}

.input-group {
    text-align: left;
    margin-bottom: 24px;
}

label {
    display: block;
    font-size: 0.875rem;
    color: var(--text-dim);
    margin-bottom: 8px;
    margin-left: 4px;
}

.flex-row {
    display: flex;
    gap: 12px;
}

input[type="text"],
input[type="number"] {
    flex: 1;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 10px 14px;
    color: white;
    font-family: inherit;
    font-size: 1rem;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: rgba(0, 0, 0, 0.1);
}


.btn-primary {
    width: 100%;
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    border: none;
    border-radius: 16px;
    padding: 16px;
    color: white;
    font-weight: 600;
    font-size: 1.1rem;
    cursor: pointer;
    box-shadow: 0 8px 20px var(--primary-glow);
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 0 20px;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
}

.btn-danger {
    width: 100%;
    background: transparent;
    border: 1px solid var(--danger);
    color: var(--danger);
    border-radius: 16px;
    padding: 14px;
    font-weight: 500;
    cursor: pointer;
    margin-top: 12px;
}

.btn-primary:active,
.btn-secondary:active {
    transform: scale(0.96);
}

.btn-primary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    box-shadow: none;
}

#players-list-container {
    margin: 24px 0;
    text-align: left;
}

#setup-players-list {
    list-style: none;
    margin-top: 12px;
}

.player-item {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    padding: 12px 16px;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-left: 4px solid var(--secondary);
    animation: slideIn 0.3s ease forwards;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Game Screen */
.game-header {
    text-align: center;
    margin-bottom: 12px;
}


.round-indicator {
    background: var(--primary-glow);
    color: var(--primary);
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
}

.scroll-area {
    flex: 1;
    overflow-y: auto;
    padding-right: 4px;
}

.round-input-row {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 12px 16px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 12px;
    border: 1px solid var(--glass-border);
}


.player-info {
    flex: 1;
}

.player-info .name {
    font-weight: 600;
    font-size: 1.1rem;
    display: block;
}

.player-info .total {
    font-size: 0.85rem;
    color: var(--text-dim);
}

.score-input-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
}

.score-input {
    width: 65px !important;
    text-align: center;
    font-weight: 700;
    padding: 8px 4px !important;
}



.game-footer {
    padding-top: 20px;
}

/* Results Screen */
.train-icon {
    font-size: 4rem;
    margin-bottom: 16px;
    filter: drop-shadow(0 0 10px var(--secondary-glow));
}

#final-scores-container {
    margin: 32px 0;
}

.final-score-item {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--glass-border);
}

.final-score-item:last-child {
    border-bottom: none;
}

.final-score-item .rank {
    width: 24px;
    color: var(--text-dim);
}

.final-score-item .name {
    flex: 1;
    text-align: left;
    margin-left: 12px;
}

.final-score-item .total {
    font-weight: 700;
    color: var(--secondary);
}

/* Modal de Cámara */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    z-index: 1000;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.active {
    display: flex;
}

.modal-content {
    width: 100%;
    max-width: 500px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.camera-container {
    width: 100%;
    aspect-ratio: 3/4;
    background: #000;
    border-radius: 20px;
    overflow: hidden;
    position: relative;
    border: 2px solid var(--primary);
}

#camera-feed {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#processing-canvas {
    /* Solo se usa para analizar el frame; no se muestra encima del video */
    position: absolute;
    left: -9999px;
    top: 0;
    width: 320px;
    height: 240px;
    pointer-events: none;
    visibility: hidden;
}

#ai-loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
    color: white;
    gap: 15px;
    font-weight: 500;
}

#ai-loading-overlay.active {
    display: flex;
}

.loader {
    width: 48px;
    height: 48px;
    border: 5px solid rgba(192, 132, 252, 0.2);
    border-radius: 50%;
    border-top-color: var(--primary);
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.camera-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.camera-controls button {
    flex: 1;
    min-width: 80px;
}

#camera-status {
    text-align: center;
    color: var(--text-dim);
    font-size: 0.9rem;
}

/* Botón de cámara en filas */
.camera-trigger-btn {
    background: rgba(192, 132, 252, 0.1);
    border: 1px solid var(--primary-glow);
    border-radius: 12px;
    padding: 8px;
    color: var(--primary);
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.camera-trigger-btn:active {
    transform: scale(0.9);
}