@font-face {
  font-family: 'AbbottWallaceSans-Regular';
  src: url('Fonts/AbbottWallaceSans-Regular.otf') format('opentype');
  font-weight: 400;
  font-style: normal;
}

@font-face {
  font-family: 'AbbottWallaceSans-Light';
  src: url('Fonts/AbbottWallaceSans-Light.otf') format('opentype');
  font-weight: 300;
  font-style: light;
}

@font-face {
  font-family: 'AbbottWallaceSerif-Bold';
  src: url('Fonts/AbbottWallaceSerif-Bold.otf') format('opentype');
  font-weight: 700;
  font-style: bold;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    height: 100%;
    height: -webkit-fill-available;
}

body {
    background-color: #360D18;
    margin: 0;
    padding: 0;
    color: #fff;
    font-family: 'AbbottWallaceSans-Regular';
    min-height: 100vh;
    min-height: 100dvh;
    min-height: -webkit-fill-available;
    width: 100vw;
    overflow: hidden;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    overscroll-behavior: none;
}

/* Contenedor principal de los CTAs (overlay de bienvenida) */
.ctaDiv {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: fixed;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    z-index: 99;
    padding: 24px;
    /* Soporte para iPhone con notch / cutouts */
    padding-top: max(24px, env(safe-area-inset-top));
    padding-right: max(24px, env(safe-area-inset-right));
    padding-bottom: max(24px, env(safe-area-inset-bottom));
    padding-left: max(24px, env(safe-area-inset-left));
    gap: 16px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    text-align: center;
}

.ctaDiv p {
    font-family: 'AbbottWallaceSans-Light';
    font-size: clamp(14px, 4vw, 17px);
    line-height: 1.45;
    text-align: center;
    width: 100%;
    max-width: 340px;
    color: white;
    margin: 0;
}

.ctaDiv h2 {
    font-family: 'AbbottWallaceSerif-Bold';
    font-size: clamp(20px, 6vw, 28px);
    line-height: 1.2;
    text-align: center;
    width: 100%;
    max-width: 360px;
    margin: 0;
}

/* Círculo con icono de cámara */
.cameraSVGFondo {
    width: clamp(80px, 24vw, 120px);
    height: clamp(80px, 24vw, 120px);
    margin-bottom: 4px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #ffffff20;
    flex-shrink: 0;
}

.cameraSVGFondo img {
    width: 50%;
    height: 50%;
}

/* Selector de cámara: tamaño táctil adecuado en móvil */
#chooseCamSel {
    width: 100%;
    max-width: 320px;
    min-height: 48px;
    padding: 12px 44px 12px 16px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 10px;
    background-color: rgba(255, 255, 255, 0.08);
    color: white;
    font-family: 'AbbottWallaceSans-Regular';
    font-size: clamp(15px, 4vw, 17px);
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23ffffff' d='M1.41 0L6 4.58 10.59 0 12 1.41l-6 6-6-6z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    background-size: 12px 8px;
    cursor: pointer;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

#chooseCamSel:focus {
    outline: none;
    border-color: #E73156;
    background-color: rgba(255, 255, 255, 0.12);
}

#chooseCamSel option {
    background-color: #360D18;
    color: white;
}

/* Botón principal: target táctil generoso */
#startARButton {
    display: none;
    justify-content: center;
    align-items: center;
    gap: 10px;
    width: 100%;
    max-width: 320px;
    min-height: 52px;
    padding: 14px 24px;
    background-color: #E73156;
    border: none;
    border-radius: 12px;
    color: white;
    font-family: 'AbbottWallaceSans-Regular';
    font-size: clamp(16px, 4.5vw, 18px);
    font-weight: 500;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(231, 49, 86, 0.4);
    transition: transform 0.1s ease, box-shadow 0.1s ease, opacity 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}

#startARButton:active {
    transform: scale(0.97);
    box-shadow: 0 2px 8px rgba(231, 49, 86, 0.3);
}

#startARButton:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.cameraSVG {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}

/* Logo mosca posicionado de forma segura en pantallas con notch */
.mosca {
    position: absolute;
    top: max(20px, env(safe-area-inset-top));
    right: max(20px, env(safe-area-inset-right));
    width: clamp(60px, 22vw, 120px);
    z-index: 1;
    pointer-events: none;
}

/* Contenedor de Unity */
#unity-container {
    position: fixed;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    height: -webkit-fill-available;
}

#unity-container.unity-desktop {
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 80%;
    height: 80%;
}

#unity-container.unity-mobile {
    width: 100%;
    height: 100%;
    height: 100dvh;
    height: -webkit-fill-available;
}

#unity-canvas {
    background: #231F20;
    width: 100%;
    height: 100%;
}

.unity-mobile #unity-canvas {
    width: 100%;
    height: 100%
}

/* Video oculto que provee el stream al ARCamera */
#webcam-video {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

/* Canvas donde se renderiza el feed de la cámara (detrás del canvas de Unity) */
#video-canvas {
    position: fixed;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    height: -webkit-fill-available;
    object-fit: cover;
    z-index: 0;
}

#unity-loading-bar {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    display: none;
    z-index: 100;
}

#unity-loading-bar .loading-bar-content {
    background-color: #ffffff;
    padding: 32px 28px;
    border-radius: 14px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: min(80vw, 320px);
    box-sizing: border-box;
}

#unity-logo {
    width: 100%;
    max-width: 240px;
    height: 80px;
    background: url('Logo.png') no-repeat center;
    background-size: contain;
}

#unity-progress-bar-empty {
    width: 100%;
    height: 8px;
    margin-top: 24px;
    background-color: #f0e0e0;
    border-radius: 4px;
    overflow: hidden;
}

#unity-progress-bar-full {
    width: 0%;
    height: 100%;
    background-color: #360D18;
    border-radius: 4px;
    transition: width 0.25s ease-out;
}

#unity-footer {
    position: relative
}

.unity-mobile #unity-footer {
    display: none
}

#unity-build-title {
    float: right;
    margin-right: 10px;
    line-height: 38px;
    font-family: arial;
    font-size: 18px
}

#unity-warning {
    position: absolute;
    left: 50%;
    top: 5%;
    transform: translate(-50%);
    background: white;
    padding: 10px;
    display: none
}

/* Pantalla de error */
#errorDiv {
    background: rgba(0, 0, 0, 0.78);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

#errorText {
    width: 100%;
    max-width: 320px;
    text-align: center;
    color: white;
    font-family: 'AbbottWallaceSans-Regular';
    font-size: clamp(14px, 4vw, 16px);
    line-height: 1.5;
    margin: 0;
    padding: 20px;
}

/* Ajustes para pantallas muy pequeñas */
@media (max-width: 360px) {
    .ctaDiv {
        padding: 16px;
        padding-top: max(16px, env(safe-area-inset-top));
        padding-right: max(16px, env(safe-area-inset-right));
        padding-bottom: max(16px, env(safe-area-inset-bottom));
        padding-left: max(16px, env(safe-area-inset-left));
        gap: 12px;
    }

    .ctaDiv h2 {
        font-size: 18px;
    }

    .ctaDiv p {
        font-size: 13px;
    }
}

/* Landscape en móvil: layout más horizontal */
@media (max-height: 500px) and (orientation: landscape) {
    .ctaDiv {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        align-content: center;
        padding: 12px;
        padding-top: max(12px, env(safe-area-inset-top));
        padding-right: max(12px, env(safe-area-inset-right));
        padding-bottom: max(12px, env(safe-area-inset-bottom));
        padding-left: max(12px, env(safe-area-inset-left));
        gap: 10px;
    }

    .cameraSVGFondo {
        width: 56px;
        height: 56px;
        margin: 0;
    }

    .ctaDiv h2 {
        font-size: 18px;
        width: auto;
        max-width: 100%;
    }

    .ctaDiv p {
        font-size: 13px;
        width: auto;
        max-width: 100%;
    }

    #chooseCamSel,
    #startARButton {
        width: auto;
        min-width: 200px;
        max-width: 280px;
    }

    .mosca {
        width: 50px;
        top: max(10px, env(safe-area-inset-top));
        right: max(10px, env(safe-area-inset-right));
    }
}
