* {
    box-sizing: border-box;
}

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

body {
    margin: 0;
    min-height: 100vh;
    font-family: 'Baloo 2', sans-serif;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(10px, 4vw, 24px);
}

.page-bg {
    position: fixed;
    inset: -60px;
    z-index: -1;
    background:
        radial-gradient(circle at 15% 20%, #ff8fc7 0%, transparent 40%),
        radial-gradient(circle at 85% 15%, #ffd166 0%, transparent 35%),
        radial-gradient(circle at 20% 85%, #8bd450 0%, transparent 40%),
        radial-gradient(circle at 80% 80%, #6fb7ff 0%, transparent 40%),
        linear-gradient(135deg, #a86bd6 0%, #7a4fc4 50%, #5b3aa0 100%);
    filter: blur(28px);
    transform: scale(1.1);
}

.hidden {
    display: none !important;
}

/* ---------- Panel principal ---------- */

.gift-panel {
    width: min(94vw, 640px);
    max-width: 100%;
    background: #1b0f33;
    border: 4px solid #7c3fe0;
    border-radius: 22px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

.gift-header {
    position: relative;
    padding: clamp(14px, 4vw, 22px) clamp(50px, 14vw, 70px);
    text-align: center;
    background-color: #2a1750;
    background-image:
        linear-gradient(#2e1a5c 2px, transparent 2px),
        linear-gradient(90deg, #2e1a5c 2px, transparent 2px);
    background-size: 28px 28px;
    border-bottom: 4px solid #7c3fe0;
}

.gift-header h1 {
    margin: 0;
    color: #fff;
    font-size: clamp(1.3rem, 7vw, 2.6rem);
    font-weight: 800;
    letter-spacing: 1px;
    text-shadow:
        -3px -3px 0 #000,
        3px -3px 0 #000,
        -3px 3px 0 #000,
        3px 3px 0 #000,
        0 6px 0 #000;
}

.close-btn {
    position: absolute;
    top: 50%;
    right: clamp(10px, 3vw, 18px);
    transform: translateY(-50%);
    width: clamp(34px, 9vw, 46px);
    height: clamp(34px, 9vw, 46px);
    border-radius: 12px;
    background: #e6392f;
    border: 3px solid #000;
    color: #fff;
    font-size: clamp(1rem, 3vw, 1.4rem);
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 5px 0 #8f1c15;
    transition: transform 0.08s ease, box-shadow 0.08s ease;
}

.close-btn:active {
    transform: translateY(calc(-50% + 4px));
    box-shadow: 0 1px 0 #8f1c15;
}

.gift-body {
    padding: clamp(16px, 5vw, 26px) clamp(14px, 5vw, 26px) clamp(18px, 5vw, 30px);
}

.section-label {
    display: block;
    color: #fff;
    font-weight: 700;
    font-size: clamp(0.8rem, 3vw, 1rem);
    letter-spacing: 0.5px;
    margin-bottom: 10px;
    text-align: center;
}

/* ---------- Buscador ---------- */

.search-box {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #130a25;
    border: 2px solid #4b2a7a;
    border-radius: 14px;
    padding: clamp(9px, 3vw, 12px) clamp(12px, 4vw, 18px);
    margin-bottom: 8px;
}

.search-icon {
    font-size: clamp(0.95rem, 3vw, 1.1rem);
    opacity: 0.8;
    flex-shrink: 0;
}

.search-box input {
    flex: 1;
    min-width: 0;
    width: 100%;
    background: transparent;
    border: none;
    outline: none;
    color: #fff;
    font-family: 'Baloo 2', sans-serif;
    font-size: clamp(0.9rem, 3.2vw, 1.1rem);
}

.search-box input::placeholder {
    color: #8b7aa8;
}

.search-status {
    min-height: 22px;
    margin: 0 0 14px;
    text-align: center;
    font-size: clamp(0.8rem, 2.8vw, 0.9rem);
    font-weight: 700;
}

.search-status.error {
    color: #ff6b5a;
}

.search-status.ok {
    color: #7ee08a;
}

.search-status.loading {
    color: #c9b6ff;
}

/* ---------- Vista previa ---------- */

.preview-box {
    display: flex;
    align-items: center;
    justify-content: space-around;
    gap: clamp(6px, 2.5vw, 12px);
    background: #170c2e;
    border: 2px solid #4b2a7a;
    border-radius: 18px;
    padding: clamp(14px, 4vw, 24px) clamp(8px, 3vw, 16px);
    margin-bottom: 18px;
}

.preview-side {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(6px, 2vw, 12px);
    width: 42%;
    min-width: 0;
}

.item-image {
    width: 100%;
    max-width: clamp(70px, 26vw, 170px);
    filter: drop-shadow(0 0 18px rgba(230, 57, 47, 0.55));
}

.arrow-icon {
    color: #fff;
    font-size: clamp(1.1rem, 4vw, 1.8rem);
    text-shadow: 0 0 10px #6fb7ff, 0 0 4px #3a7bd5;
    flex-shrink: 0;
}

.avatar-frame {
    width: clamp(70px, 26vw, 130px);
    height: clamp(70px, 26vw, 130px);
    border-radius: 50%;
    background: #1c1033;
    border: 4px solid #7c3fe0;
    box-shadow: 0 0 22px rgba(124, 63, 224, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

.avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.pill {
    display: inline-block;
    min-width: clamp(70px, 26vw, 150px);
    max-width: 100%;
    min-height: 20px;
    padding: clamp(6px, 2vw, 8px) clamp(10px, 3.5vw, 18px);
    border-radius: 999px;
    background: linear-gradient(#8b4fe8, #6425bd);
    border: 3px solid #000;
    color: #fff;
    font-weight: 700;
    font-size: clamp(0.72rem, 2.8vw, 0.95rem);
    text-align: center;
    text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
    box-shadow: 0 4px 0 #000;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-pill {
    background: linear-gradient(#241340, #1a0e2f);
}

/* ---------- Aviso ---------- */

.warning-text {
    color: #ff6b5a;
    font-weight: 700;
    font-size: clamp(0.7rem, 2.6vw, 0.85rem);
    text-align: center;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    margin: 0 0 20px;
    line-height: 1.4;
}

/* ---------- Botón enviar ---------- */

.send-btn {
    display: block;
    width: 100%;
    padding: clamp(12px, 4vw, 16px);
    font-family: 'Baloo 2', sans-serif;
    font-size: clamp(1rem, 4.5vw, 1.3rem);
    font-weight: 800;
    color: #fff;
    text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
    background: linear-gradient(#6dd13f, #3f9c1e);
    border: 3px solid #000;
    border-radius: 999px;
    box-shadow: 0 6px 0 #245c11;
    cursor: pointer;
    transition: transform 0.08s ease, box-shadow 0.08s ease, filter 0.15s ease;
}

.send-btn:not(:disabled):active {
    transform: translateY(5px);
    box-shadow: 0 1px 0 #245c11;
}

.send-btn:disabled {
    filter: grayscale(0.7) brightness(0.7);
    cursor: not-allowed;
    box-shadow: 0 6px 0 #333;
}

/* ---------- Overlays ---------- */

.overlay {
    position: fixed;
    inset: 0;
    background: rgba(5, 2, 15, 0.72);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    padding: 20px;
    animation: fadeIn 0.15s ease;
}

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

.modal {
    width: min(90vw, 420px);
    background: #1b0f33;
    border: 4px solid #7c3fe0;
    border-radius: 20px;
    padding: clamp(18px, 5vw, 26px) clamp(16px, 5vw, 24px);
    text-align: center;
    animation: popIn 0.18s ease;
}

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

.modal h2 {
    color: #fff;
    margin: 0 0 12px;
    font-size: clamp(1.2rem, 5vw, 1.5rem);
    text-shadow: -2px -2px 0 #000, 2px -2px 0 #000, -2px 2px 0 #000, 2px 2px 0 #000;
}

.modal p {
    color: #d9cdf2;
    font-size: clamp(0.85rem, 3vw, 0.95rem);
    line-height: 1.5;
    margin: 0 0 22px;
}

.modal p strong,
.modal p span {
    color: #fff;
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.btn-secondary,
.btn-primary {
    font-family: 'Baloo 2', sans-serif;
    font-weight: 700;
    font-size: 1rem;
    padding: 10px 22px;
    border-radius: 999px;
    border: 3px solid #000;
    cursor: pointer;
    color: #fff;
    text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
    transition: transform 0.08s ease;
}

.btn-secondary {
    background: linear-gradient(#5a4a80, #3e3160);
    box-shadow: 0 5px 0 #241a3d;
}

.btn-primary {
    background: linear-gradient(#6dd13f, #3f9c1e);
    box-shadow: 0 5px 0 #245c11;
}

.btn-secondary:active,
.btn-primary:active {
    transform: translateY(4px);
}

/* ---------- Notificación de éxito estilo battle-royale ---------- */

.success-banner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: clamp(10px, 3vw, 18px);
    background: linear-gradient(#1b0f33, #120a24);
    border: 3px solid #ffd166;
    border-radius: 16px;
    padding: clamp(14px, 4vw, 18px) clamp(16px, 5vw, 26px);
    box-shadow: 0 0 40px rgba(255, 209, 102, 0.35);
    animation: dropIn 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.3);
    width: min(92vw, 480px);
}

@keyframes dropIn {
    from { transform: translateY(-40px) scale(0.9); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}

.success-icon {
    font-size: clamp(1.8rem, 7vw, 2.6rem);
    flex-shrink: 0;
}

.success-text {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    flex: 1 1 180px;
    text-align: center;
}

.success-title {
    color: #ffd166;
    font-weight: 800;
    font-size: clamp(1.05rem, 4.5vw, 1.3rem);
    text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
}

.success-desc {
    color: #fff;
    font-size: clamp(0.8rem, 3.2vw, 0.95rem);
}

.btn-retry {
    flex-shrink: 0;
    font-family: 'Baloo 2', sans-serif;
    font-weight: 700;
    font-size: clamp(0.8rem, 3vw, 0.95rem);
    padding: clamp(8px, 2.5vw, 10px) clamp(14px, 4vw, 18px);
    border-radius: 999px;
    border: 3px solid #000;
    color: #fff;
    text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
    background: linear-gradient(#8b4fe8, #6425bd);
    box-shadow: 0 5px 0 #3d1a75;
    cursor: pointer;
    transition: transform 0.08s ease;
}

.btn-retry:active {
    transform: translateY(4px);
}

@media (max-width: 360px) {
    .preview-side {
        width: 40%;
    }
}
