/* style.css */
:root {
    --color-orange: #E9782E;
    --color-pink: #F28AB0;
    --color-purple: #7C4598;
    --color-magenta: #EC5A91;
    --color-dark-brown: #4B3125;
    --color-bg-dark: #120A1A;
    --color-text-light: #FFFFFF;
    --color-text-muted: #D1C4E9;
    --font-primary: 'Outfit', sans-serif;
    --glass-bg: rgba(26, 15, 38, 0.65);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

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

body, html {
    width: 100%;
    height: 100%;
    height: 100dvh;
    min-height: -webkit-fill-available;
    overflow: hidden;
    background-color: var(--color-bg-dark);
    font-family: var(--font-primary);
    color: var(--color-text-light);
}

/* Container principal do jogo */
#game-container {
    position: relative;
    width: 100%;
    height: 100%;
    height: 100dvh;
    min-height: -webkit-fill-available;
}

/* Canvas do Three.js */
#three-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* Painéis de UI Genéricos */
.ui-panel {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    min-height: -webkit-fill-available;
    z-index: 10;
    display: none;
    justify-content: center;
    align-items: center;
    background: radial-gradient(circle at center, rgba(18, 10, 26, 0.45) 0%, rgba(10, 5, 15, 0.85) 100%);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    padding: 20px;
    transition: all 0.4s ease;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.ui-panel.active {
    display: flex;
}

/* Efeito Cartão de Vidro (Glassmorphism) */
.glass-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    box-shadow: var(--glass-shadow);
    padding: 40px;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    max-width: 550px;
    width: 100%;
    position: relative;
    z-index: 11;
    overflow: hidden;
}

.glass-card::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(242, 138, 176, 0.1) 0%, transparent 60%);
    pointer-events: none;
    z-index: -1;
}

/* Tela Inicial */
#start-screen.active {
    display: block;
}

#start-screen .glass-card {
    margin: 0 auto 24px auto;
    flex-shrink: 0;
}

.logo-container {
    text-align: center;
    margin-bottom: 30px;
}

.emoji-logo {
    font-size: 64px;
    display: inline-block;
    animation: bounce 2s infinite ease-in-out;
}

h1 {
    font-size: 40px;
    font-weight: 800;
    letter-spacing: -1px;
    margin-top: 10px;
    line-height: 1.1;
    text-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.gradient-text {
    background: linear-gradient(135deg, var(--color-orange) 0%, var(--color-pink) 50%, var(--color-magenta) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 800;
}

.subtitle {
    color: var(--color-text-muted);
    font-size: 16px;
    margin-top: 8px;
    font-weight: 400;
}

/* Input do Nome */
.input-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 25px;
    text-align: left;
}

.input-group label {
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--color-pink);
    padding-left: 4px;
}

.input-group input {
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 16px 20px;
    font-size: 18px;
    font-family: var(--font-primary);
    color: var(--color-text-light);
    outline: none;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.input-group input:focus {
    border-color: var(--color-pink);
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 0 15px rgba(242, 138, 176, 0.25);
}

/* Seleção de Controles */
.control-select-info {
    text-align: left;
    margin-bottom: 30px;
}

.control-select-info h3 {
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--color-text-muted);
    margin-bottom: 12px;
    padding-left: 4px;
}

.control-modes {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.control-mode {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 18px;
    background: rgba(255, 255, 255, 0.03);
    border: 2px solid rgba(255, 255, 255, 0.06);
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.control-mode:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
}

.control-mode.active {
    background: rgba(233, 120, 46, 0.12);
    border-color: var(--color-orange);
    box-shadow: 0 0 15px rgba(233, 120, 46, 0.2);
}

.control-mode.active .mode-icon {
    transform: scale(1.15);
}

.mode-icon {
    font-size: 28px;
    transition: transform 0.3s ease;
}

.mode-text {
    display: flex;
    flex-direction: column;
}

.mode-text strong {
    font-size: 16px;
    color: var(--color-text-light);
}

.mode-text span {
    font-size: 12px;
    color: var(--color-text-muted);
    margin-top: 2px;
}

/* Botões */
.btn {
    width: 100%;
    padding: 18px 28px;
    border-radius: 18px;
    border: none;
    font-family: var(--font-primary);
    font-size: 18px;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow: hidden;
}

.btn-primary {
    background: linear-gradient(135deg, var(--color-orange) 0%, var(--color-magenta) 100%);
    color: var(--color-text-light);
    box-shadow: 0 8px 24px rgba(233, 120, 46, 0.35);
}

.btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 28px rgba(233, 120, 46, 0.5);
    filter: brightness(1.1);
}

.btn-primary:active {
    transform: translateY(-1px);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: var(--color-text-light);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
}

.btn-danger {
    background: linear-gradient(135deg, #FF4B4B 0%, #D32F2F 100%);
    color: var(--color-text-light);
    box-shadow: 0 6px 18px rgba(211, 47, 47, 0.3);
}

.btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 22px rgba(211, 47, 47, 0.45);
}

.btn-pulse {
    animation: btn-pulse 2s infinite;
}

/* Instruções Card */
.instructions-card {
    max-width: 650px;
    padding: 30px;
}

.instructions-card h3 {
    font-size: 16px;
    color: var(--color-pink);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 20px;
    text-align: center;
}

.instruction-steps {
    display: flex;
    gap: 15px;
    justify-content: space-between;
}

.step {
    flex: 1;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 16px;
    padding: 15px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.step-visual {
    background: rgba(255, 255, 255, 0.05);
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 24px;
    color: var(--color-orange);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.step p {
    font-size: 12px;
    line-height: 1.4;
    color: var(--color-text-muted);
}

.step p strong {
    color: var(--color-text-light);
    font-size: 13px;
}

/* Spinner de Carregamento */
.spinner {
    width: 70px;
    height: 70px;
    border: 5px solid rgba(255, 255, 255, 0.1);
    border-top: 5px solid var(--color-orange);
    border-radius: 50%;
    animation: spin 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
    margin: 0 auto 30px auto;
}

.tip-box {
    background: rgba(242, 138, 176, 0.08);
    border: 1px solid rgba(242, 138, 176, 0.15);
    border-radius: 16px;
    padding: 16px;
    font-size: 14px;
    line-height: 1.5;
    color: var(--color-text-muted);
    margin: 24px 0;
    text-align: left;
}

.tip-box strong {
    color: var(--color-pink);
    display: block;
    margin-bottom: 4px;
}

/* HUD Overlay */
.ui-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 5;
    pointer-events: none; /* Deixa cliques passarem para o canvas 3D */
    padding: 24px;
    display: none;
    flex-direction: column;
    justify-content: space-between;
}

.ui-overlay.active {
    display: flex;
}

.hud-left, .hud-right {
    display: flex;
    gap: 16px;
    pointer-events: auto; /* Reativa cliques para os botões do HUD */
}

.hud-left {
    align-self: flex-start;
}

.hud-right {
    align-self: flex-start;
    margin-left: auto;
}

.hud-item {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 12px 20px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    gap: 10px;
}

.player-tag {
    border-left: 4px solid var(--color-pink);
}

.score-box {
    border-left: 4px solid var(--color-orange);
}

.highscore-box {
    border-left: 4px solid var(--color-magenta);
}

.hud-icon {
    font-size: 18px;
}

.hud-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--color-text-muted);
}

.hud-value {
    font-size: 20px;
    font-weight: 800;
    color: var(--color-text-light);
}

#hud-player-name {
    font-weight: 600;
}

.hud-controls {
    display: flex;
    gap: 8px;
}

.hud-btn {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    width: 48px;
    height: 48px;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s ease;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.hud-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.05);
}

/* Indicador de Status da Câmera */
.camera-indicator {
    position: absolute;
    bottom: 24px;
    left: 24px;
    background: rgba(18, 10, 26, 0.8);
    border: 1px solid var(--glass-border);
    border-radius: 30px;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    font-weight: 600;
}

.indicator-dot {
    width: 10px;
    height: 10px;
    background-color: #4CAF50;
    border-radius: 50%;
    box-shadow: 0 0 8px #4CAF50;
}

.camera-indicator.calibrating .indicator-dot {
    background-color: #FFC107;
    box-shadow: 0 0 8px #FFC107;
    animation: flash 1s infinite alternate;
}

.camera-indicator.disconnected .indicator-dot {
    background-color: #F44336;
    box-shadow: 0 0 8px #F44336;
}

/* Tela de Game Over */
#game-over-screen h1.game-over-title {
    font-size: 48px;
    font-weight: 800;
    margin-bottom: 8px;
}

.red-text {
    color: #FF4B4B;
}

.score-report {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 20px;
    padding: 24px;
    margin: 30px 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}

.final-score {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.final-score span {
    font-size: 14px;
    text-transform: uppercase;
    color: var(--color-text-muted);
    letter-spacing: 1px;
}

.final-score h2 {
    font-size: 44px;
    font-weight: 800;
    color: var(--color-orange);
}

.new-record {
    background: linear-gradient(90deg, var(--color-orange), var(--color-magenta));
    color: white;
    padding: 6px 16px;
    border-radius: 30px;
    font-size: 14px;
    font-weight: 800;
    letter-spacing: 1px;
    box-shadow: 0 4px 10px rgba(233, 120, 46, 0.3);
}

.game-over-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Quadro de Vídeo Picture-in-Picture */
.camera-pip {
    position: absolute;
    top: 96px; /* Posicionado no canto superior direito abaixo do HUD */
    right: 24px;
    width: 320px;
    background: var(--glass-bg);
    border: 2px solid var(--color-pink);
    border-radius: 20px;
    box-shadow: 0 8px 30px rgba(242, 138, 176, 0.25);
    z-index: 8;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.2);
    display: none;
}

.camera-pip.active {
    display: block;
}

.camera-pip.minimized {
    width: 180px;
    height: 40px;
}

.camera-pip.minimized .pip-body {
    display: none;
}

.pip-header {
    background: rgba(0,0,0,0.3);
    padding: 8px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--glass-border);
}

.pip-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--color-text-muted);
}

.pip-toggle {
    background: transparent;
    border: none;
    color: var(--color-text-light);
    cursor: pointer;
    font-size: 14px;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.pip-toggle:hover {
    background: rgba(255,255,255,0.1);
}

.pip-body {
    width: 100%;
    height: 240px;
    position: relative;
    background: #000;
}

#pip-canvas {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1); /* Espelha o vídeo para ficar intuitivo */
}

/* Ações de Pausa */
.pause-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 30px;
}

/* Animações */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes bounce {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-12px) scale(1.05); }
}

@keyframes btn-pulse {
    0% { transform: scale(1); box-shadow: 0 8px 24px rgba(233, 120, 46, 0.35); }
    50% { transform: scale(1.02); box-shadow: 0 12px 32px rgba(233, 120, 46, 0.55); }
    100% { transform: scale(1); box-shadow: 0 8px 24px rgba(233, 120, 46, 0.35); }
}

@keyframes flash {
    0% { opacity: 0.4; }
    100% { opacity: 1; }
}

/* Classes utilitárias de animação para transições de UI */
.animate-fade-in {
    animation: fadeIn 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
}

.animate-slide-up {
    animation: slideUp 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
}

.animate-slide-down {
    animation: slideDown 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
}

.animate-scale-up {
    animation: scaleUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.animate-bounce-in {
    animation: bounceIn 0.7s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
}

.text-center {
    text-align: center;
}

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

@keyframes slideUp {
    from { transform: translateY(50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes slideDown {
    from { transform: translateY(-30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes scaleUp {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

@keyframes bounceIn {
    0% { transform: scale(0.3); opacity: 0; }
    50% { transform: scale(1.05); }
    70% { transform: scale(0.9); }
    100% { transform: scale(1); opacity: 1; }
}

/* Responsividade Avançada e Correções de Layout */
@media (min-width: 992px) {
    #start-screen.active {
        display: flex;
        flex-direction: row;
        justify-content: center;
        align-items: center;
        gap: 32px;
        padding: 40px;
    }
    
    .glass-card.main-card {
        max-width: 500px;
        margin: 0;
    }
    
    .glass-card.instructions-card {
        max-width: 520px;
        margin: 0;
    }
}

/* Responsividade Básica (Mobile/Tablet) */
@media (max-width: 600px) {
    .glass-card {
        padding: 18px 14px;
        border-radius: 20px;
    }
    
    .logo-container {
        margin-bottom: 12px;
    }
    
    .emoji-logo {
        font-size: 44px;
    }
    
    h1 {
        font-size: 24px;
    }
    
    .subtitle {
        font-size: 13px;
        margin-top: 4px;
    }
    
    .input-group {
        margin-bottom: 14px;
        gap: 6px;
    }
    
    .input-group label {
        font-size: 11px;
        padding-left: 2px;
    }
    
    .input-group input {
        padding: 10px 14px;
        font-size: 15px;
        border-radius: 12px;
    }
    
    .control-select-info {
        margin-bottom: 16px;
    }
    
    .control-select-info h3 {
        font-size: 11px;
        margin-bottom: 8px;
        padding-left: 2px;
    }
    
    .control-modes {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }
    
    .control-mode {
        padding: 8px 10px;
        border-radius: 12px;
        gap: 8px;
        align-items: center;
        justify-content: flex-start;
    }
    
    .mode-icon {
        font-size: 20px;
    }
    
    .mode-text strong {
        font-size: 12px;
        line-height: 1.2;
    }
    
    .mode-text span {
        display: none; /* Oculta a descrição detalhada para economizar espaço vertical */
    }
    
    .btn {
        padding: 12px 20px;
        font-size: 16px;
        border-radius: 12px;
    }
    
    .instructions-card {
        padding: 16px 14px;
    }
    
    .instruction-steps {
        flex-direction: column;
        gap: 8px;
    }
    
    .step {
        padding: 10px;
        flex-direction: row;
        text-align: left;
        gap: 12px;
        border-radius: 12px;
    }
    
    .step-visual {
        width: 36px;
        height: 36px;
        font-size: 16px;
        flex-shrink: 0;
    }
    
    .step p {
        font-size: 11px;
        margin: 0;
        line-height: 1.3;
    }
    
    .step p strong {
        font-size: 11px;
    }
    
    .camera-pip {
        top: 80px; /* Alinhado ao topo abaixo do HUD no mobile */
        right: 12px;
        width: 200px;
    }
    
    .pip-body {
        height: 150px;
    }

    .camera-pip.minimized {
        width: 140px;
        height: 40px;
    }
    
    .ui-overlay {
        padding: 12px;
    }
    
    .hud-item {
        padding: 8px 12px;
        gap: 6px;
    }
    
    .hud-value {
        font-size: 16px;
    }
    
    .hud-btn {
        width: 40px;
        height: 40px;
    }
}
