/* ==========================================================================
   SUPER MARIO PUSH-UP QUEST - MOBILE-FIRST AR ARCADE STYLES
   ========================================================================== */

:root {
    --mario-red: #E52521;
    --mario-red-dark: #A8100C;
    --mario-blue: #0026FF;
    --mario-sky: #6185F8;
    --mario-gold: #FFD700;
    --mario-green: #00A800;
    --mario-pipe: #00D000;
    --mario-dark: #0D0E15;
    --mario-card-bg: rgba(22, 24, 38, 0.92);
    --mario-border: rgba(255, 255, 255, 0.14);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

body {
    background-color: var(--mario-dark);
    color: #FFFFFF;
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    min-height: 100vh;
    height: 100vh;
    overflow: hidden;
    position: relative;
}

.pixel-font {
    font-family: 'Press Start 2P', monospace, sans-serif;
}

/* Telas (Lobby vs Game) */
.screen-view {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow-y: auto;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.screen-view.hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.98);
}

/* ==========================================================================
   TELA 1: LOBBY & PRE-GAME SETUP (MOBILE FIRST)
   ========================================================================== */
#lobby-screen {
    background: 
        radial-gradient(circle at 50% 10%, rgba(229, 37, 33, 0.25) 0%, transparent 60%),
        radial-gradient(circle at 50% 90%, rgba(0, 168, 0, 0.2) 0%, transparent 60%),
        linear-gradient(180deg, #090A12 0%, #151829 100%);
    padding-top: max(calc(env(safe-area-inset-top, 0px) + 26px), 76px);
    padding-left: max(env(safe-area-inset-left, 0px), 16px);
    padding-right: max(env(safe-area-inset-right, 0px), 16px);
    padding-bottom: calc(36px + env(safe-area-inset-bottom, 0px));
    display: flex;
    flex-direction: column;
    align-items: center;
}

.lobby-container {
    max-width: 480px;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Header & Logo */
.lobby-header {
    text-align: center;
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

/* Banner Animado com os 4 Personagens no Topo */
.title-banner-wrapper {
    width: 100%;
    max-width: 460px;
    height: 135px;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.6), 0 0 0 2.5px rgba(255, 215, 0, 0.5);
    position: relative;
    background: #3A68FF;
    cursor: pointer;
}

#titleBannerCanvas {
    width: 100%;
    height: 100%;
    display: block;
}

.banner-click-hint {
    position: absolute;
    bottom: 6px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 7.5px;
    color: #FFF;
    background: rgba(10, 12, 22, 0.75);
    border: 1px solid rgba(255, 215, 0, 0.6);
    padding: 3px 9px;
    border-radius: 12px;
    letter-spacing: 0.5px;
    pointer-events: none;
    white-space: nowrap;
}

.game-logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

/* Chips dos 4 Heróis Integrados ao Título */
.heroes-title-bar {
    display: flex;
    gap: 6px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 2px;
}

.hero-title-chip {
    font-family: 'Press Start 2P', monospace;
    font-size: 8px;
    padding: 5px 9px;
    border-radius: 8px;
    border: 1.5px solid rgba(255, 255, 255, 0.15);
    background: rgba(10, 12, 22, 0.85);
    color: #AAA;
    cursor: pointer;
    transition: all 0.2s ease;
}

.hero-title-chip:hover {
    border-color: rgba(255, 255, 255, 0.4);
    color: #FFF;
}

.hero-title-chip.active {
    border-color: var(--mario-gold);
    color: #FFF;
    background: rgba(255, 215, 0, 0.22);
    box-shadow: 0 0 12px rgba(255, 215, 0, 0.4);
    transform: translateY(-1px);
}

.logo-main {
    font-size: 21px;
    line-height: 1.25;
    color: #FFFFFF;
    text-shadow: 2px 2px 0 #E52521, 4px 4px 0 #000;
    letter-spacing: 0.5px;
}

.logo-accent {
    color: var(--mario-gold);
    text-shadow: 2px 2px 0 #D46B08, 4px 4px 0 #000;
}

.logo-tag {
    font-size: 11px;
    background: rgba(229, 37, 33, 0.2);
    border: 1px solid rgba(229, 37, 33, 0.5);
    padding: 4px 14px;
    border-radius: 20px;
    color: #FFB3B1;
}

/* Seções do Lobby */
.lobby-card {
    background: var(--mario-card-bg);
    border: 2px solid var(--mario-border);
    border-radius: 16px;
    padding: 16px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.card-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: nowrap;
}

.card-title {
    font-size: 9.5px;
    color: var(--mario-gold);
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    white-space: nowrap;
    flex-shrink: 0;
}

.card-hint-badge {
    font-size: 7.5px;
    padding: 3px 7px;
    border-radius: 6px;
    border: 1px solid rgba(255, 215, 0, 0.4);
    background: rgba(255, 215, 0, 0.1);
    color: var(--mario-gold);
    white-space: nowrap;
    flex-shrink: 0;
}

/* SELETOR DE PERSONAGENS (4 CARDS COM SPRITES VIVOS) */
.char-selector-list {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 12px;
}

.char-choice-card {
    background: rgba(14, 16, 28, 0.85);
    border: 2px solid rgba(255, 255, 255, 0.12);
    border-radius: 14px;
    padding: 8px 4px 6px 4px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 3px;
    position: relative;
    overflow: hidden;
}

.char-mini-canvas {
    width: 56px;
    height: 56px;
    display: block;
}

.char-choice-name {
    font-size: 9px;
    font-weight: bold;
    white-space: nowrap;
}

.char-perk-pill {
    font-size: 7px;
    color: #AAA;
    background: rgba(255, 255, 255, 0.08);
    padding: 2px 4px;
    border-radius: 4px;
    white-space: nowrap;
    font-weight: 600;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

.char-selected-badge {
    font-size: 7px;
    color: #FFD700;
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid rgba(255, 215, 0, 0.6);
    border-radius: 4px;
    padding: 1px 4px;
    margin-top: 2px;
    opacity: 0;
    transition: opacity 0.2s ease;
    white-space: nowrap;
}

.char-choice-card.active .char-selected-badge {
    opacity: 1;
}

.char-choice-card:hover {
    border-color: rgba(255, 255, 255, 0.35);
}

.char-choice-card.active {
    border-color: var(--mario-gold);
    background: rgba(255, 215, 0, 0.15);
    box-shadow: 0 0 18px rgba(255, 215, 0, 0.4);
    transform: translateY(-3px);
}

/* SHOWCASE PEDESTAL DO PERSONAGEM SELECIONADO */
.char-showcase-container {
    display: flex;
    align-items: center;
    gap: 14px;
    background: rgba(10, 12, 22, 0.9);
    border: 2px solid rgba(255, 215, 0, 0.3);
    border-radius: 14px;
    padding: 12px;
    position: relative;
    overflow: hidden;
}

.char-pedestal-box {
    width: 90px;
    height: 90px;
    flex-shrink: 0;
    position: relative;
}

#charShowcaseCanvas {
    width: 100%;
    height: 100%;
    display: block;
}

.char-showcase-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.showcase-name-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.showcase-char-name {
    font-size: 15px;
    font-weight: bold;
}

.showcase-badge {
    font-size: 9px;
    padding: 3px 8px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.12);
    color: #FFF;
}

.showcase-title {
    font-size: 11px;
    color: #AAA;
}

.showcase-quote {
    font-size: 11px;
    font-style: italic;
    color: var(--mario-gold);
    margin-top: 2px;
    line-height: 1.3;
}

/* 2. SELEÇÃO DA TRILHA SONORA (1 LINHA POR FAIXA - ZERO QUEBRAS) */
.music-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

.music-btn {
    width: 100%;
    height: 44px;
    padding: 0 12px;
    background: rgba(14, 16, 28, 0.85);
    border: 1.5px solid rgba(255, 255, 255, 0.14);
    border-radius: 12px;
    color: #FFF;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.music-btn-left {
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    overflow: hidden;
}

.music-icon {
    font-size: 17px;
    flex-shrink: 0;
}

.music-name {
    font-size: 9px;
    color: #FFF;
    white-space: nowrap;
}

.music-desc {
    font-size: 9px;
    color: #888;
    white-space: nowrap;
}

.music-eq-tag {
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    flex-shrink: 0;
}

.music-status-tag {
    font-size: 7.5px;
    color: #AAA;
    white-space: nowrap;
}

.music-btn.active {
    border-color: #00FF66;
    background: rgba(0, 255, 102, 0.14);
    box-shadow: 0 0 14px rgba(0, 255, 102, 0.25);
}

.music-btn.active .music-name {
    color: #00FF66;
}

.music-btn.active .music-desc {
    color: #99FFBB;
}

.music-btn.active .music-status-tag {
    color: #00FF66;
}

/* Barras do Equalizador Animadas */
.eq-bars {
    display: inline-flex;
    align-items: flex-end;
    gap: 2px;
    height: 10px;
}

.eq-bars span {
    width: 2.5px;
    background: #00FF66;
    border-radius: 1px;
    height: 4px;
}

.music-btn.active .eq-bars span:nth-child(1) {
    animation: eq-bounce 0.8s infinite ease-in-out;
}
.music-btn.active .eq-bars span:nth-child(2) {
    animation: eq-bounce 0.8s infinite ease-in-out 0.2s;
}
.music-btn.active .eq-bars span:nth-child(3) {
    animation: eq-bounce 0.8s infinite ease-in-out 0.4s;
}

@keyframes eq-bounce {
    0%, 100% { height: 3px; }
    50% { height: 10px; }
}

/* 3. METAS DE FLEXÃO (NÍVEIS E MEDALHAS) */
.goals-row {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
}

.goal-pill {
    background: rgba(14, 16, 28, 0.85);
    border: 1.5px solid rgba(255, 255, 255, 0.14);
    border-radius: 12px;
    padding: 10px 2px;
    text-align: center;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    transition: all 0.2s ease;
}

.goal-medal {
    font-size: 15px;
}

.goal-val {
    font-size: 11px;
    color: #FFF;
}

.goal-sub {
    font-size: 8px;
    color: #888;
}

.goal-pill.active {
    border-color: var(--mario-gold);
    background: linear-gradient(180deg, rgba(255, 215, 0, 0.28) 0%, rgba(255, 215, 0, 0.08) 100%);
    box-shadow: 0 0 16px rgba(255, 215, 0, 0.4);
    transform: translateY(-2px);
}

.goal-pill.active .goal-val {
    color: var(--mario-gold);
    font-weight: bold;
}

.goal-pill.active .goal-sub {
    color: #FFF;
}

.goal-hint-banner {
    background: rgba(0, 0, 0, 0.4);
    border-left: 3px solid var(--mario-gold);
    border-radius: 6px;
    padding: 8px 12px;
    margin-top: 10px;
    font-size: 11px;
    color: #DDD;
    line-height: 1.4;
}

/* 4. NOME DO JOGADOR (ARCADE GAMER TAG) */
.arcade-name-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.arcade-name-input-box {
    display: flex;
    align-items: center;
    background: rgba(10, 12, 22, 0.95);
    border: 2px solid var(--mario-gold);
    border-radius: 12px;
    padding: 6px 12px;
    min-height: 52px;
    box-shadow: 0 0 14px rgba(255, 215, 0, 0.25);
    transition: all 0.2s ease;
    cursor: text;
}

.arcade-name-input-box:focus-within {
    border-color: #00FF66;
    box-shadow: 0 0 18px rgba(0, 255, 102, 0.4);
}

.arcade-name-icon {
    font-size: 22px;
    margin-right: 10px;
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.arcade-name-input-box:hover .arcade-name-icon {
    transform: scale(1.15);
}

.arcade-name-field-wrap {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
    justify-content: center;
}

.arcade-name-sublabel {
    font-size: 8px;
    color: var(--mario-gold);
    letter-spacing: 1px;
    margin-bottom: 2px;
}

.arcade-name-input {
    width: 100%;
    min-width: 0;
    background: transparent;
    border: none;
    outline: none;
    color: #FFFFFF;
    font-size: 16px; /* 16px prevents iOS Safari auto-zoom on input focus */
    font-weight: bold;
    letter-spacing: 1px;
    padding: 0;
    -webkit-user-select: text;
    user-select: text;
    caret-color: var(--mario-gold);
}

.arcade-name-input::placeholder {
    color: #666;
    font-size: 11px;
}

.arcade-name-edit-btn {
    background: rgba(255, 215, 0, 0.15);
    border: 1px solid var(--mario-gold);
    border-radius: 6px;
    padding: 6px 10px;
    color: var(--mario-gold);
    cursor: pointer;
    flex-shrink: 0;
    margin-left: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.arcade-name-edit-btn:hover, .arcade-name-edit-btn:active {
    background: var(--mario-gold);
    color: #12101C;
    transform: scale(0.96);
}

.edit-btn-text {
    font-size: 9px;
    white-space: nowrap;
}

/* 4 Sugestões em Grade de 1 Linha (Zero Quebras) */
.quick-names-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    width: 100%;
}

.quick-name-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1.5px solid rgba(255, 255, 255, 0.18);
    border-radius: 8px;
    padding: 8px 2px;
    color: #FFF;
    font-size: 11px;
    font-weight: 600;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.quick-name-btn:hover {
    background: rgba(255, 215, 0, 0.18);
    border-color: var(--mario-gold);
    color: var(--mario-gold);
}

.quick-name-btn.active {
    background: rgba(255, 215, 0, 0.25);
    border-color: var(--mario-gold);
    color: var(--mario-gold);
    font-weight: bold;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
}

/* BOTÃO START QUEST (CTA) */
.btn-start-quest {
    background: linear-gradient(135deg, #FF3B37 0%, #E52521 100%);
    border: 3px solid #FFA1A1;
    border-radius: 16px;
    padding: 16px 20px;
    color: #FFFFFF;
    font-size: 13px;
    font-weight: bold;
    letter-spacing: 0.5px;
    cursor: pointer;
    box-shadow: 0 8px 30px rgba(229, 37, 33, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.2s ease;
    margin-top: 6px;
    text-shadow: 1px 1px 0 #000;
    animation: cta-pulse 2.2s infinite ease-in-out;
    white-space: nowrap;
    width: 100%;
}

.btn-start-quest:active {
    transform: scale(0.97);
}

@keyframes cta-pulse {
    0%, 100% {
        box-shadow: 0 8px 30px rgba(229, 37, 33, 0.6);
    }
    50% {
        box-shadow: 0 10px 40px rgba(229, 37, 33, 0.85), 0 0 15px rgba(255, 215, 0, 0.4);
    }
}

.cta-subtitle {
    font-size: 10px;
    color: #AAA;
    text-align: center;
    margin-top: -8px;
    margin-bottom: 4px;
}

/* ==========================================================================
   TELA 2: JOGO EM REALIDADE AUMENTADA (AR SCREEN)
   ========================================================================== */
#game-screen {
    background: #000;
    overflow: hidden;
}

.ar-viewport {
    position: relative;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

/* Camada 0: Feed da Câmera em Tela Cheia */
#cameraVideo {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1); /* Espelhamento frontal */
    z-index: 1;
}

/* Camada 1: Retículo e Calibração da Pose */
#poseCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    pointer-events: none;
}

/* Camada 2: Engine do Mario e Elementos Gráficos */
#gameCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 3;
    pointer-events: none;
}

/* Camada 3: HUD e Controles Flutuantes */
.ar-hud-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding-top: max(calc(env(safe-area-inset-top, 0px) + 24px), 78px);
    padding-left: max(env(safe-area-inset-left, 0px), 14px);
    padding-right: max(env(safe-area-inset-right, 0px), 14px);
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
}

.ar-hud-overlay > * {
    pointer-events: auto;
}

/* Top HUD Compacto */
.ar-top-hud {
    background: rgba(10, 12, 22, 0.85);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 14px;
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
}

.ar-hud-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ar-hud-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.ar-stat-val {
    font-size: 14px;
    font-weight: bold;
}

.ar-big-reps {
    display: flex;
    align-items: baseline;
    gap: 4px;
}

.ar-big-reps .current {
    font-size: 26px;
    color: #00FF66;
    font-weight: bold;
    text-shadow: 2px 2px 0 #000;
}

.ar-big-reps .goal {
    font-size: 13px;
    color: #AAA;
}

/* Barra de Progresso da Meta */
.progress-bar-container {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #FFD700 0%, #00FF66 100%);
    border-radius: 4px;
    transition: width 0.3s ease;
}

/* Badge de Postura Centralizado */
.posture-feedback-pill {
    align-self: center;
    background: rgba(0, 0, 0, 0.82);
    border: 2px solid #00FF66;
    border-radius: 20px;
    padding: 8px 18px;
    font-size: 11px;
    font-weight: bold;
    color: #00FF66;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
    text-shadow: 1px 1px 0 #000;
}

/* Rodapé com Controles Flutuantes da Câmera */
.ar-bottom-dock {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    padding-bottom: max(env(safe-area-inset-bottom, 0px), 8px);
}

/* Botão de Conclusão / Vitória Compacto */
.btn-win-action {
    width: 100%;
    max-width: 260px;
    padding: 14px 18px;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    box-shadow: 0 4px 18px rgba(229, 37, 33, 0.6);
}

/* Barra Secundária com Botões Utilitários */
.ar-secondary-bar {
    display: flex;
    gap: 8px;
    width: 100%;
}

.ar-mini-btn {
    flex: 1;
    background: rgba(18, 22, 38, 0.88);
    backdrop-filter: blur(8px);
    border: 1.5px solid rgba(255, 255, 255, 0.18);
    border-radius: 12px;
    padding: 8px 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    font-size: 10px;
    color: #DDD;
    cursor: pointer;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.35);
    transition: all 0.15s ease;
}

.ar-mini-btn span {
    font-size: 16px;
}

.ar-mini-btn:active {
    transform: scale(0.94);
    background: rgba(30, 36, 60, 0.95);
    border-color: rgba(255, 255, 255, 0.4);
}

/* Modal de Parabéns ao Concluir Treino */
.win-modal {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #181A29;
    border: 3px solid var(--mario-gold);
    border-radius: 20px;
    padding: 24px;
    width: 90%;
    max-width: 380px;
    text-align: center;
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    z-index: 100;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.9);
}

.win-modal.active {
    display: flex;
}
