@font-face {
    font-family: 'DaxPro';
    src: url('../fonts/DaxPro-Light.otf') format('opentype');
    font-weight: 300;
    font-display: swap;
}
@font-face {
    font-family: 'DaxPro';
    src: url('../fonts/DaxPro-Medium.otf') format('opentype');
    font-weight: 500;
    font-display: swap;
}

* {
    margin: 0; padding: 0; box-sizing: border-box;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}
html, body { height: 100%; }
html { background: #00234b; }
body {
    font-family: 'DaxPro', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #00234b;
    color: #fff;
    min-height: 100vh;
    overflow: hidden;
}
img {
    -webkit-user-drag: none;
    user-drag: none;
    pointer-events: none;
}
::selection { background: transparent; }

/* --- Mobile-only error --- */
.page-error {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 32px 28px;
    text-align: center;
    color: #fff;
    flex-direction: column;
}
.page-error .error-card {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 20px;
    padding: 32px 24px;
    max-width: 320px;
}
.page-error .icon { font-size: 48px; margin-bottom: 16px; }
.page-error h1 { font-size: 22px; margin-bottom: 14px; font-weight: 500; }
.page-error p { font-size: 15px; line-height: 1.6; color: rgba(255,255,255,0.8); font-weight: 300; }

/* --- Code entry section --- */
#code-entry {
    position: relative;
    z-index: 60;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
    text-align: center;
}
#code-entry h1 {
    font-size: clamp(28px, 7vw, 42px);
    font-weight: 800;
    margin-bottom: 4px;
}
#code-entry h1 span { color: #e63946; }
#code-entry .subtitle {
    font-size: 16px;
    font-weight: 300;
    color: rgba(255,255,255,0.65);
    margin-bottom: 40px;
}

.lang-toggle {
    position: fixed;
    top: 16px;
    right: 16px;
    color: rgba(255,255,255,0.5);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    padding: 6px 14px;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 20px;
    transition: color 0.2s, border-color 0.2s;
    z-index: 300;
}
.lang-toggle:hover { color: #fff; border-color: rgba(255,255,255,0.5); }

.code-form { width: 100%; max-width: 360px; }
.code-input {
    width: 100%;
    padding: 16px 20px;
    font-size: 22px;
    font-family: 'DaxPro', monospace;
    font-weight: 500;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 4px;
    border: 2px solid rgba(255,255,255,0.2);
    border-radius: 14px;
    background: rgba(255,255,255,0.08);
    color: #fff;
    outline: none;
    transition: border-color 0.3s;
}
.code-input::placeholder {
    color: rgba(255,255,255,0.3);
    letter-spacing: 1px;
    font-size: 16px;
    text-transform: none;
}
.code-input:focus { border-color: rgba(255,255,255,0.5); }

.btn-play {
    width: 100%;
    margin-top: 16px;
    padding: 14px;
    font-size: 20px;
    font-family: inherit;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 2px;
    border: none;
    border-radius: 14px;
    background: #e63946;
    color: #fff;
    cursor: pointer;
    transition: transform 0.2s, opacity 0.2s;
}
.btn-play:hover { opacity: 0.9; }
.btn-play:active { transform: scale(0.97); }
.btn-play:disabled { opacity: 0.5; cursor: not-allowed; }

.error-msg {
    margin-top: 16px;
    padding: 12px 16px;
    background: rgba(230, 57, 70, 0.2);
    border: 1px solid rgba(230, 57, 70, 0.4);
    border-radius: 10px;
    font-size: 15px;
    color: #ff8a8a;
    display: none;
}
.error-msg.visible { display: block; }

/* --- Game area (hidden by default) --- */
#game-area { display: none; }
#game-area.active { display: block; }

/* --- 3D scene --- */
#scene-canvas {
    position: fixed;
    inset: 0;
    display: block;
    width: 100vw;
    height: 100vh;
    touch-action: none;
    z-index: 55;
    pointer-events: none;
}

/* --- Loading overlay --- */
#loading {
    position: fixed;
    inset: 0;
    background: #00234b;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
    transition: opacity 0.5s;
}
#loading.hidden { opacity: 0; pointer-events: none; }
#loading .spinner {
    width: 48px; height: 48px;
    border: 4px solid rgba(255,255,255,0.2);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
#loading p { color: #fff; margin-top: 16px; font-size: 14px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Intro background --- */
#intro-bg {
    position: fixed;
    inset: 0;
    z-index: 0;
    background: #00234b;
    transition: opacity 0.8s ease-out;
}
#intro-bg.hidden { opacity: 0; pointer-events: none; }

/* --- Game background (field) --- */
#bg-image {
    position: fixed;
    inset: 0;
    background: url('../../BMO_Background.jpg') center/cover no-repeat;
    z-index: 0;
    transition: opacity 0.8s ease-out, transform 0.8s ease-out;
}
#bg-image.intro-hidden { opacity: 0; }
#bg-image.zooming { transform: scale(4); }
#bg-image.hidden { opacity: 0; }

/* --- Intro overlay --- */
#intro-overlay {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0 28px;
    transition: opacity 0.8s ease-out;
    gap: 32px;
}
#intro-overlay.hidden { opacity: 0; pointer-events: none; }
#intro-overlay h1 {
    font-size: clamp(28px, 7vw, 42px);
    font-weight: 800;
    color: #fff;
}
#intro-overlay h1 span { color: #e63946; }
#intro-overlay .intro-sub {
    font-size: 16px;
    font-weight: 300;
    color: rgba(255,255,255,0.65);
}
#intro-overlay .btn-game {
    background: #e63946;
    color: #fff;
    border: none;
    padding: 12px 48px;
    font-size: 22px;
    font-weight: 500;
    border-radius: 30px;
    cursor: pointer;
    letter-spacing: 2px;
    text-transform: uppercase;
    transition: transform 0.2s;
    font-family: inherit;
}
#intro-overlay .btn-game:active { transform: scale(0.95); }

/* --- Swipe hint --- */
#swipe-hint {
    position: fixed;
    bottom: 4vh;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255,255,255, .85);
    font-size: 18px;
    font-weight: 600;
    text-align: center;
    z-index: 10;
    animation: hintFadeIn 0.6s ease-out forwards, hintPulse 2s ease-in-out 0.6s infinite;
    pointer-events: none;
    display: none;
    opacity: 0;
    text-shadow: 0 1px 6px rgba(0,0,0,0.5);
}
#swipe-hint.hidden-temp { visibility: hidden; }
#swipe-hint .arrow {
    font-size: 32px;
    display: block;
    margin-bottom: 4px;
    transform: rotate(90deg);
    letter-spacing: -4px;
}
@keyframes hintFadeIn {
    from { opacity: 0; transform: translateX(-50%) translateY(20px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}
@keyframes hintPulse {
    0%, 100% { opacity: 0.4; transform: translateX(-50%) translateY(0); }
    50% { opacity: 1; transform: translateX(-50%) translateY(-10px); }
}

/* --- Swipe feedback --- */
#swipe-feedback {
    position: fixed;
    top: 25vh;
    left: 50%;
    transform: translateX(-50%);
    color: #fff;
    font-size: 24px;
    max-width: 80vw;
    font-weight: 700;
    text-align: center;
    z-index: 60;
    pointer-events: none;
    opacity: 0;
    background: rgba(230, 57, 70, 0.9);
    padding: 12px 24px;
    border-radius: 18px;
    transition: opacity 0.3s;
    width: 100%;
}
#swipe-feedback.visible { opacity: 1; }

/* --- Confetti canvas --- */
#confetti-canvas {
    position: fixed;
    inset: 0;
    z-index: 250;
    pointer-events: none;
}

/* --- Win overlay --- */
#win-overlay {
    position: fixed;
    inset: 0;
    background: #00234b;
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s;
    overflow: hidden;
}
#win-overlay.visible { opacity: 1; pointer-events: auto; }

#win-overlay .win-red-circle {
    position: absolute;
    width: 75vw;
    height: 75vw;
    max-width: 380px;
    max-height: 380px;
    top: 0;
    left: 50%;
    transform: translate(-50%, -40%);
    border-radius: 50%;
    background: #e63946;
    border: 12px solid #00234b;
    box-shadow: 0 0 0 1px rgba(255,255,255,1);
}

#win-ball-canvas {
    width: 85vw;
    max-width: 420px;
    height: 85vw;
    max-height: 420px;
    margin-top: 0;
    position: relative;
    z-index: 1;
    flex-shrink: 0;
}

#win-overlay .line {
    opacity: 0;
    transform: translateY(20px) scale(0.9);
    transition: opacity 0.5s ease-out, transform 0.5s ease-out;
}
#win-overlay .line.show {
    opacity: 1;
    transform: translateY(0) scale(1);
}
#win-overlay h1 {
    color: #fff;
    font-size: 64px;
    font-weight: 800;
    text-align: center;
    margin-bottom: 16px;
    text-transform: uppercase;
}
#win-overlay h1 .hola {
    display: inline-block;
    animation: hola 4s ease-in-out calc(var(--i) * 0.1s) infinite;
}
@keyframes hola {
    0% { transform: scale(1); text-shadow: none; }
    3% { transform: scale(1.5); text-shadow: 0 0 8px #fff6; }
    6% { transform: scale(1); text-shadow: none; }
    100% { transform: scale(1); }
}
#win-overlay .subtitle {
    color: #fff;
    font-size: 20px;
    font-weight: 500;
    margin-bottom: 8px;
    text-align: center;
}
#win-overlay .prize-name {
    color: #fff;
    font-size: 28px;
    font-weight: 800;
    margin-bottom: 12px;
    text-align: center;
}
#win-overlay .ambassador-msg {
    color: #fff;
    font-size: 18px;
    font-weight: 500;
    text-align: center;
    line-height: 1.4;
}

/* --- Barcode display --- */
#barcode-container {
    margin-top: 16px;
    background: #fff;
    border-radius: 12px;
    padding: 12px 20px;
    display: none;
}
#barcode-container.visible { display: block; }
#barcode-container svg { display: block; margin: 0 auto; }
.btn-save-barcode {
    display: block;
    width: 100%;
    margin-top: 10px;
    padding: 8px;
    background: #00234b;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
}
.btn-save-barcode:active { opacity: 0.8; }
#barcode-number {
    text-align: center;
    font-size: 14px;
    color: #333;
    margin-top: 4px;
    font-weight: 600;
    letter-spacing: 2px;
}
