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

:root {
    --masculine: #2563eb;
    --masculine-light: #3b82f6;
    --masculine-bg: #dbeafe;
    --feminine: #7c3aed;
    --feminine-light: #8b5cf6;
    --feminine-bg: #ede9fe;
    --word-bg: #fef3c7;
    --word-border: #f59e0b;
    --success: #059669;
    --error: #dc2626;
    --gold: #ca8a04;
    --gold-light: #fef08a;
    /* Playero / tropical */
    --playa-cielo: #38bdf8;
    --playa-mar: #0ea5e9;
    --playa-arena: #fcd34d;
    --playa-coral: #fb7185;
    --playa-verde: #34d399;
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Nunito', sans-serif;
    margin: 0;
    min-height: 100vh;
    background: linear-gradient(180deg, #bae6fd 0%, #7dd3fc 25%, #0ea5e9 50%, #38bdf8 75%, #fef3c7 100%);
    padding: 20px;
    color: #1f2937;
}

/* ========== PORTADA PLAYERA ========== */
.portada {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}
.portada--hide {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}
.portada-bg {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, #7dd3fc 0%, #38bdf8 20%, #0ea5e9 45%, #0284c7 70%, #fde68a 85%, #fcd34d 100%);
    opacity: 0.95;
}
.portada-content {
    position: relative;
    z-index: 1;
    text-align: center;
    max-width: 380px;
    width: 100%;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 28px;
    padding: 36px 32px 40px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.2), 0 0 0 4px rgba(253, 224, 71, 0.5);
    border: 3px solid rgba(254, 243, 199, 0.9);
}
.portada-logo {
    width: 120px;
    height: auto;
    margin: 0 auto 20px;
    display: block;
    object-fit: contain;
}
.portada-title {
    margin: 0 0 8px 0;
    font-size: 1.85rem;
    font-weight: 800;
    color: #0c4a6e;
    letter-spacing: -0.02em;
}
.portada-subtitle {
    margin: 0 0 24px 0;
    font-size: 1rem;
    color: #0369a1;
    font-weight: 600;
}
.portada-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 16px;
}
.portada-label {
    font-size: 0.9rem;
    font-weight: 700;
    color: #0c4a6e;
    text-align: left;
}
.portada-input {
    width: 100%;
    padding: 14px 18px;
    font-family: inherit;
    font-size: 1.05rem;
    border: 3px solid #bae6fd;
    border-radius: 14px;
    background: #f0fdfa;
    color: #0c4a6e;
    font-weight: 600;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.portada-input::placeholder {
    color: #7dd3fc;
}
.portada-input:focus {
    outline: none;
    border-color: #0ea5e9;
    box-shadow: 0 0 0 4px rgba(14, 165, 233, 0.25);
}
.portada-btn {
    padding: 16px 28px;
    font-family: inherit;
    font-size: 1.2rem;
    font-weight: 800;
    border: none;
    border-radius: 16px;
    cursor: pointer;
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: #fff;
    box-shadow: 0 6px 20px rgba(245, 158, 11, 0.45);
    transition: transform 0.2s, box-shadow 0.2s;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.portada-btn:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 10px 28px rgba(245, 158, 11, 0.5);
}
.portada-hint {
    margin: 0;
    font-size: 0.8rem;
    color: #64748b;
    font-weight: 600;
}
.portada-deco {
    position: absolute;
    font-size: 3rem;
    opacity: 0.35;
    pointer-events: none;
}
.portada-deco--palms { bottom: 15%; left: 8%; }
.portada-deco--sun { top: 12%; right: 10%; font-size: 4rem; opacity: 0.5; }

/* Game wrap: oculto hasta que el usuario inicia */
.game-wrap {
    display: none;
    min-height: 100vh;
}
.game-wrap.game-wrap--show {
    display: block;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 600px;
    margin: 0 auto 16px;
    padding: 14px 24px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 4px 14px rgba(0,0,0,0.08);
}

.header-logo {
    width: 44px;
    height: auto;
    margin-bottom: 6px;
    display: block;
    object-fit: contain;
}
.header-left, .header-right {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}
.header-player {
    font-size: 0.75rem;
    font-weight: 600;
    color: #0ea5e9;
    margin-top: 2px;
}

.level-label, .score-label {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    color: #6b7280;
}

.level-value, .score-value {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--masculine);
}

.level-title {
    font-size: 0.7rem;
    font-weight: 600;
    color: #6b7280;
    display: block;
    margin-top: 2px;
}

.lives-label {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    color: #6b7280;
}
.lives-hearts {
    font-size: 1.25rem;
    line-height: 1;
    letter-spacing: 2px;
}
.lives-hearts.lives--2 { color: #f59e0b; }
.lives-hearts.lives--1 { color: var(--error); }
.score-value { color: var(--feminine); }

.header-center h1 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 800;
    color: #111827;
}

.instruction {
    text-align: center;
    max-width: 520px;
    margin: 0 auto 24px;
    font-size: 1rem;
    color: #4b5563;
}

.game-board {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 20px;
    align-items: center;
    max-width: 720px;
    margin: 0 auto;
    min-height: 280px;
}

.target-box {
    min-height: 160px;
    border-radius: 20px;
    border: 4px dashed rgba(255,255,255,0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}

.target-box.drag-over {
    transform: scale(1.02);
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    border-color: #fff;
}

.target-masculine {
    background: linear-gradient(145deg, var(--masculine) 0%, #1d4ed8 100%);
    color: #fff;
}

.target-feminine {
    background: linear-gradient(145deg, var(--feminine) 0%, #5b21b6 100%);
    color: #fff;
}

.target-title {
    font-size: 1.35rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.target-sub {
    font-size: 0.95rem;
    opacity: 0.9;
}

.word-slot {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 140px;
}

.draggable-word {
    padding: 18px 28px;
    font-size: 1.6rem;
    font-weight: 800;
    color: #1f2937;
    background: var(--word-bg);
    border: 3px solid var(--word-border);
    border-radius: 16px;
    cursor: grab;
    user-select: none;
    box-shadow: 0 4px 14px rgba(245, 158, 11, 0.3);
    transition: transform 0.15s, box-shadow 0.15s;
}

.draggable-word:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(245, 158, 11, 0.4);
}

.draggable-word:active {
    cursor: grabbing;
}

.draggable-word.dragging {
    opacity: 0.85;
    transform: scale(1.08);
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
}

.draggable-word.correct-flash {
    animation: correctPulse 0.4s ease;
}

@keyframes correctPulse {
    0% { transform: scale(1); background: var(--word-bg); }
    50% { transform: scale(1.1); background: #bbf7d0; border-color: var(--success); }
    100% { transform: scale(1); background: var(--word-bg); }
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-overlay.show {
    display: flex;
    animation: fadeIn 0.25s ease;
}

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

.modal {
    background: #fff;
    border-radius: 20px;
    padding: 28px 32px;
    max-width: 420px;
    width: 100%;
    text-align: center;
    box-shadow: 0 20px 50px rgba(0,0,0,0.25);
    animation: modalIn 0.3s ease;
}

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

.modal-icon {
    font-size: 3rem;
    margin-bottom: 8px;
}

.modal-title {
    margin: 0 0 12px 0;
    font-size: 1.4rem;
    color: var(--error);
}

.modal-message {
    margin: 0 0 20px 0;
    font-size: 1rem;
    line-height: 1.6;
    color: #374151;
}

.btn-modal {
    padding: 12px 28px;
    border: none;
    border-radius: 12px;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    background: var(--masculine);
    color: #fff;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
    transition: transform 0.2s;
}

.btn-modal:hover {
    transform: translateY(-2px);
}

/* Game Over */
.gameover-screen {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.85);
    align-items: center;
    justify-content: center;
    z-index: 998;
    padding: 24px;
}
.gameover-screen.show {
    display: flex;
    animation: fadeIn 0.4s ease;
}
.gameover-card {
    background: #fff;
    border-radius: 24px;
    padding: 40px 36px;
    text-align: center;
    max-width: 380px;
    width: 100%;
    box-shadow: 0 25px 60px rgba(0,0,0,0.35);
    border: 3px solid #fecaca;
}
.gameover-icon { font-size: 4rem; margin-bottom: 12px; }
.gameover-title {
    margin: 0 0 12px 0;
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--error);
}
.gameover-text {
    margin: 0 0 16px 0;
    font-size: 1rem;
    color: #475569;
    line-height: 1.5;
}
.gameover-score {
    margin: 0 0 24px 0;
    font-size: 1.15rem;
    font-weight: 700;
    color: #0c4a6e;
}

/* Diploma */
.diploma-screen {
    display: none;
    position: fixed;
    inset: 0;
    background: linear-gradient(160deg, #fef3c7 0%, #fef9c3 50%, #fef08a 100%);
    align-items: center;
    justify-content: center;
    z-index: 999;
    padding: 24px;
}

.diploma-screen.show {
    display: flex;
    animation: fadeIn 0.5s ease;
}

.diploma {
    position: relative;
    width: 100%;
    max-width: 480px;
    background: linear-gradient(180deg, #fffbeb 0%, #fef3c7 100%);
    border: 6px solid var(--gold);
    border-radius: 12px;
    padding: 48px 36px 40px;
    box-shadow: 0 20px 60px rgba(202, 138, 4, 0.35), inset 0 1px 0 rgba(255,255,255,0.8);
}

.diploma-ribbon {
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 2.5rem;
    color: var(--gold);
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.diploma-inner {
    text-align: center;
}

.diploma-title {
    margin: 0 0 8px 0;
    font-size: 1.6rem;
    font-weight: 800;
    color: #92400e;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}
.diploma-name {
    margin: 0 0 12px 0;
    font-size: 1.4rem;
    font-weight: 800;
    color: #0c4a6e;
    letter-spacing: 0.02em;
}

.diploma-text {
    margin: 0 0 8px 0;
    font-size: 1.2rem;
    color: #1f2937;
    line-height: 1.5;
}

.diploma-text strong {
    color: #b45309;
}

.diploma-sub {
    margin: 0 0 28px 0;
    font-size: 0.95rem;
    color: #6b7280;
}

.diploma-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
}

.btn-diploma {
    padding: 14px 28px;
    border: none;
    border-radius: 12px;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-play {
    background: linear-gradient(145deg, var(--masculine) 0%, #1d4ed8 100%);
    color: #fff;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.4);
}

.btn-print {
    background: linear-gradient(145deg, var(--gold) 0%, #a16207 100%);
    color: #fff;
    box-shadow: 0 4px 14px rgba(202, 138, 4, 0.4);
}

.btn-diploma:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.2);
}

/* Level complete toast + confetti */
.level-toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    color: #fff;
    padding: 20px 32px;
    border-radius: 16px;
    font-weight: 800;
    font-size: 1.25rem;
    box-shadow: 0 12px 40px rgba(5, 150, 105, 0.5);
    z-index: 1100;
    display: flex;
    align-items: center;
    gap: 12px;
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    pointer-events: none;
}
.level-toast.show {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
    animation: toastPop 0.4s ease;
}
.level-toast-icon { font-size: 1.8rem; }
@keyframes toastPop {
    0% { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
    60% { transform: translate(-50%, -50%) scale(1.08); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

.game-footer {
    text-align: center;
    margin-top: 32px;
    padding: 16px;
}

.back-link {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--masculine);
    text-decoration: none;
}

.back-link:hover {
    text-decoration: underline;
}

@media (max-width: 600px) {
    .game-board {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
        gap: 16px;
    }

    .word-slot { order: -1; }

    .draggable-word { font-size: 1.4rem; padding: 14px 22px; }

    .target-box { min-height: 120px; }
}

@media print {
    body { background: #fff; }
    .game-header, .instruction, .game-board, .modal-overlay { display: none !important; }
    .diploma-screen { display: flex !important; position: static; background: #fff; padding: 0; }
    .diploma { box-shadow: none; max-width: none; }
    .btn-diploma { display: none; }
}
