@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

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

html, body {
    width: 100%;
    overflow-x: hidden;
}

:root {
    --bg: #0a0c10;
    --panel: #1a1c23;
    --panel-2: #22242c;
    --border: rgba(255,255,255,0.08);
    --border-strong: rgba(255,255,255,0.14);
    --text: #e9eaee;
    --text-dim: #9aa0ac;
    --text-mute: #6b7280;

    --primary: #e9eaee;
    --gray: #9aa0ac;
    --border-radius: 16px;
    --shadow: 0 20px 50px rgba(0,0,0,0.5);
    --shadow-sm: 0 6px 20px rgba(0,0,0,0.3);

    /* Un solo acento: cian/teal. Todo lo interactivo usa este color. */
    --accent: #2dd4d0;
    --accent-soft: rgba(45,212,208,0.14);
    --glow-accent: 0 0 20px rgba(45,212,208,0.35);

    --success: #34d399;
    --danger: #f87171;
    --warning: #fbbf24;
    --gold: #fbbf24;

    --gradient-brand: linear-gradient(135deg, #2dd4d0, #22b8c4);
    --gradient-bg: radial-gradient(circle at 20% 0%, #12151c 0%, #0a0c10 55%), #0a0c10;

    --btn-bg: var(--gradient-brand);
    --btn-bg-hover: linear-gradient(135deg, #3fe0dc, #2dd4d0);
    --btn-text: #06110f;
    --btn-border: transparent;
}

body {
    font-family: 'Inter', 'Segoe UI', -apple-system, system-ui, sans-serif;
    background: var(--gradient-bg);
    background-attachment: fixed;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    color: var(--text);
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(circle at 12% 15%, rgba(45,212,208,0.10), transparent 42%),
        radial-gradient(circle at 88% 85%, rgba(45,212,208,0.06), transparent 40%);
    pointer-events: none;
    z-index: 0;
}

.container {
    width: 100%;
    max-width: 460px;
    position: relative;
    z-index: 1;
}

.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    padding: 38px 28px 30px;
    box-shadow: var(--shadow);
    text-align: center;
    position: relative;
    overflow: hidden;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--accent);
    opacity: 0.9;
}

.logo {
    font-family: 'Inter', sans-serif;
    font-size: 28px;
    font-weight: 800;
    color: var(--text);
    margin-bottom: 6px;
    letter-spacing: -0.3px;
}

.logo span {
    color: var(--accent);
}

.subtitle {
    color: var(--text-dim);
    font-size: 13.5px;
    font-weight: 500;
    margin-bottom: 28px;
}

.loading-spinner {
    width: 52px;
    height: 52px;
    border: 3px solid var(--border);
    border-top: 3px solid var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 20px auto;
    filter: drop-shadow(0 0 8px rgba(45,212,208,0.4));
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.hidden {
    display: none !important;
}

.icon-circle {
    width: 76px;
    height: 76px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    font-size: 34px;
    animation: popIn 0.35s cubic-bezier(.34,1.56,.64,1);
}

@keyframes popIn {
    from { transform: scale(0.6); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.icon-circle.success {
    background: rgba(52,211,153,0.12);
    border: 1px solid rgba(52,211,153,0.3);
    color: #34d399;
    box-shadow: 0 0 24px rgba(52,211,153,0.25);
}

.icon-circle.danger {
    background: rgba(248,113,113,0.12);
    border: 1px solid rgba(248,113,113,0.3);
    color: #f87171;
    box-shadow: 0 0 24px rgba(248,113,113,0.2);
}

.icon-circle.warning {
    background: rgba(251,191,36,0.12);
    border: 1px solid rgba(251,191,36,0.3);
    color: #fbbf24;
    box-shadow: 0 0 24px rgba(251,191,36,0.22);
}

.result-title {
    font-size: 21px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text);
}

.result-title.success {
    color: #34d399;
}

.result-title.danger {
    color: #f87171;
}

.result-title.warning {
    color: #fbbf24;
}

.result-message {
    font-size: 14.5px;
    color: var(--text-dim);
    line-height: 1.6;
    margin-bottom: 20px;
}

.carton-number {
    display: inline-block;
    background: var(--panel-2);
    border: 1px solid var(--border-strong);
    color: var(--text);
    padding: 7px 20px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.5px;
    margin: 10px 0;
    font-family: ui-monospace, 'SF Mono', Consolas, monospace;
}

.premio-card {
    background: rgba(251,191,36,0.08);
    border-radius: 12px;
    padding: 18px;
    margin: 15px 0;
    border: 1px solid rgba(251,191,36,0.3);
}

.premio-card .premio-nombre {
    font-size: 17px;
    font-weight: 700;
    color: #fbbf24;
    margin-bottom: 5px;
}

.premio-card .premio-desc {
    font-size: 13.5px;
    color: var(--text-dim);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 12px 26px;
    border-radius: 11px;
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.2s ease;
    cursor: pointer;
    border: none;
    font-family: 'Inter', sans-serif;
    box-sizing: border-box;
}

.btn-stack {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    border-radius: 11px;
}

.btn-stack .btn-icon {
    width: 16px;
    height: 16px;
    font-size: 16px;
    line-height: 16px;
    display: inline-block;
    overflow: hidden;
}

.btn-span2 {
    grid-column: 1 / -1;
}

.btn-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    justify-items: stretch;
    gap: 10px;
}

.btn-grid .btn {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    text-align: center;
    white-space: normal;
    overflow-wrap: break-word;
}

.btn-grid .btn + .btn {
    margin-left: 0;
}

.btn-primary {
    background: var(--gradient-brand);
    color: var(--btn-text);
    border: 1px solid transparent;
    box-shadow: 0 4px 16px rgba(45,212,208,0.28);
}

.btn-primary:hover {
    background: var(--btn-bg-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(45,212,208,0.4);
}

.btn-secondary {
    background: var(--panel-2);
    color: var(--text);
    border: 1px solid var(--border-strong);
}

.btn-secondary:hover {
    background: #282a33;
    border-color: var(--accent);
    color: var(--accent);
}

.btn + .btn {
    margin-left: 8px;
}

/* Modal "Confirmar venta" / "Confirmar entrega de premio": el número de
   cartón es el elemento más grande de la pantalla a propósito — en un
   entorno con ruido y apuro, tiene que reconocerse sin leer nada. El botón
   de acción ocupa todo el ancho y va solo, separado verticalmente de
   "Cancelar" (que es un texto, no un botón), para que un toque apurado con
   el pulgar no pueda confundir uno con el otro. */
.cv-etiqueta {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-dim);
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.cv-numero {
    font-family: ui-monospace, 'SF Mono', Consolas, monospace;
    font-size: 44px;
    font-weight: 800;
    color: var(--text);
    line-height: 1;
    margin-bottom: 16px;
    word-break: break-word;
}

.cv-aviso {
    font-size: 12.5px;
    color: var(--text-dim);
    line-height: 1.5;
    text-align: left;
    margin-bottom: 14px;
}

.cv-advertencia {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    background: rgba(251,191,36,0.1);
    border: 1px solid rgba(251,191,36,0.35);
    border-radius: 10px;
    padding: 10px 12px;
    text-align: left;
    margin-bottom: 18px;
    color: var(--gold);
    font-size: 12px;
    font-weight: 600;
    line-height: 1.35;
}

.cv-btn-primario {
    display: block;
    width: 100%;
    box-sizing: border-box;
    border: none;
    border-radius: 12px;
    padding: 16px;
    font-family: 'Inter', sans-serif;
    font-size: 15px;
    font-weight: 700;
    color: #06110f;
    cursor: pointer;
    margin-bottom: 12px;
}

.cv-btn-primario.cv-venta {
    background: var(--success);
}

.cv-btn-primario.cv-regalo {
    background: var(--gold);
}

.cv-cancelar {
    font-size: 12.5px;
    color: var(--text-dim);
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
    padding: 6px;
}

.scanner-view {
    margin-top: 15px;
}

.scanner-video-wrap {
    position: relative;
    width: 100%;
    max-width: 300px;
    margin: 0 auto;
    border-radius: 14px;
    overflow: hidden;
    background: #000;
    aspect-ratio: 1 / 1;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    border: 1px solid var(--border-strong);
}

.scanner-video-wrap video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.scanner-frame {
    position: absolute;
    top: 12%;
    left: 12%;
    right: 12%;
    bottom: 12%;
    border: 2px solid var(--accent);
    border-radius: 14px;
    pointer-events: none;
    box-shadow: var(--glow-accent), inset var(--glow-accent);
    animation: framePulse 2s ease-in-out infinite;
}

@keyframes framePulse {
    0%, 100% { opacity: 0.65; }
    50% { opacity: 1; }
}

.scanner-hint {
    font-size: 13px;
    color: var(--text-dim);
    margin: 12px 0;
    font-weight: 500;
}

.scanner-error {
    font-size: 13px;
    color: #f87171;
    font-weight: 600;
    margin: 12px 0;
}

.footer-text {
    color: rgba(255,255,255,0.35);
    font-size: 12px;
    text-align: center;
    margin-top: 20px;
    position: relative;
    z-index: 1;
    letter-spacing: 0.3px;
}

/* Momento de expectativa antes de revelar el resultado al comprador */
.suspense-view {
    padding: 30px 0 20px;
}

.suspense-icon {
    font-size: 48px;
    animation: suspenseSpin 1.6s ease-in-out infinite;
    filter: drop-shadow(0 0 14px rgba(45,212,208,0.4));
}

@keyframes suspenseSpin {
    0%, 100% { transform: scale(1) rotate(-6deg); }
    50% { transform: scale(1.12) rotate(6deg); }
}

.suspense-texto {
    color: var(--text-dim);
    font-size: 14px;
    font-weight: 600;
    margin-top: 16px;
    animation: suspenseFade 1.4s ease-in-out infinite;
}

@keyframes suspenseFade {
    0%, 100% { opacity: 0.55; }
    50% { opacity: 1; }
}

/* Entrada del resultado ya revelado */
.result-content.reveal-pop .icon-circle,
.result-content.reveal-pop .result-title,
.result-content.reveal-pop .result-message,
.result-content.reveal-pop .carton-number,
.result-content.reveal-pop .premio-card {
    animation: revealPop 0.5s cubic-bezier(.34,1.56,.64,1) both;
}

.result-content.reveal-pop .result-title { animation-delay: 0.06s; }
.result-content.reveal-pop .result-message { animation-delay: 0.12s; }
.result-content.reveal-pop .carton-number { animation-delay: 0.18s; }
.result-content.reveal-pop .premio-card { animation-delay: 0.24s; }

@keyframes revealPop {
    from { transform: scale(0.7) translateY(10px); opacity: 0; }
    to { transform: scale(1) translateY(0); opacity: 1; }
}

/* Confeti liviano para la revelación de un cartón ganador: unos spans con
   emoji que caen y rotan, generados/eliminados por JS, sin librerías. */
.confetti-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 5;
}

.confetti-piece {
    position: absolute;
    top: -10%;
    font-size: 20px;
    animation: confettiFall linear forwards;
}

@keyframes confettiFall {
    from { transform: translateY(0) rotate(0deg); opacity: 1; }
    to { transform: translateY(420px) rotate(540deg); opacity: 0; }
}

/* Variante "casino" para la pantalla de Ganador del vendedor: estrellas,
   monedas y gemas con brillo dorado y una leve deriva lateral (--drift, seteada
   por JS por pieza) en vez de caer siempre derecho — más vivo, tipo tragamonedas. */
.confetti-piece.casino {
    top: -12%;
    animation-name: confettiFallCasino;
    animation-timing-function: cubic-bezier(.25,.46,.45,.94);
    filter: drop-shadow(0 0 6px rgba(255,215,0,0.55));
}

@keyframes confettiFallCasino {
    0% { transform: translate(0, 0) rotate(0deg) scale(0.5); opacity: 0; }
    12% { opacity: 1; }
    100% { transform: translate(var(--drift, 0px), 480px) rotate(720deg) scale(1); opacity: 0; }
}

/* Resplandor dorado pulsante para el ícono de la pantalla de Ganador —
   sensación de "jackpot" sin depender de ninguna imagen externa. */
.icon-circle.jackpot {
    animation: jackpotGlow 0.9s ease-in-out infinite;
}

@keyframes jackpotGlow {
    0%, 100% { box-shadow: 0 0 22px rgba(251,191,36,0.35); }
    50% { box-shadow: 0 0 40px rgba(251,191,36,0.75), 0 0 65px rgba(251,191,36,0.3); }
}
