* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { width: 100vw; height: 100vh; overflow: hidden; font-family: 'Nunito', sans-serif; }
body {
    background: linear-gradient(135deg, #FFE5EC 0%, #E5F4FF 35%, #F0FFE5 70%, #FFF5E5 100%);
    display: flex; align-items: center; justify-content: center;
}

.start-container {
    width: 98vw; height: 96vh; max-width: 1200px; max-height: 800px;
    background: linear-gradient(145deg, #ffffff, #fafaff);
    border-radius: 30px; padding: 18px;
    box-shadow: 0 15px 50px rgba(0,0,0,0.12), 0 0 0 5px #FFD700;
    position: relative; display: flex; align-items: center; justify-content: center;
    overflow: hidden;
}

.floating-shapes { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 1; }
.floating-shape {
    position: absolute; opacity: 0.5;
    animation: floatShape 18s infinite ease-in-out;
}
.floating-shape.tri {
    width: 0; height: 0;
    border-left: 15px solid transparent; border-right: 15px solid transparent;
    border-bottom: 26px solid var(--c, #ff6b6b);
}
@keyframes floatShape {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-25px) rotate(180deg); }
}

.main-content {
    position: relative; z-index: 10;
    display: flex; flex-direction: column; align-items: center;
    justify-content: center; gap: 10px; padding: 8px; max-width: 95%;
    max-height: 95vh; overflow-y: auto;
}

.game-branding { text-align: center; animation: fadeInDown 0.7s ease; }
@keyframes fadeInDown { from { opacity: 0; transform: translateY(-20px); } to { opacity: 1; transform: translateY(0); } }

.logo-icon { margin-bottom: 8px; animation: iconFloat 3s infinite ease-in-out; }
@keyframes iconFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

.game-title {
    font-family: 'Fredoka One', cursive;
    font-size: 2.2em; color: #5D4037;
    text-shadow: 3px 3px 0 #FFD700, 5px 5px 0 rgba(0,0,0,0.08);
    margin: 4px 0;
}

.game-by {
    font-family: 'Patrick Hand', cursive;
    font-size: 1.3em;
    color: #8B6914;
    margin: -4px 0 6px;
    letter-spacing: 1px;
    opacity: 0.9;
}

/* ===== SECCIÓN TUTORIAL ===== */
.tutorial-section {
    width: 100%;
    max-width: 520px;
    background: linear-gradient(145deg, #FFF9E6, #F0E6FF);
    border: 3px solid #FFB347;
    border-radius: 22px;
    padding: 16px 20px;
    animation: fadeIn 0.8s ease 0.2s both;
    box-shadow: 0 6px 20px rgba(255,179,71,0.15);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.tutorial-title {
    text-align: center;
    font-family: 'Fredoka One', cursive;
    color: #6D4C41;
    font-size: 1.3em;
    margin-bottom: 14px;
    text-shadow: 1px 1px 2px rgba(255,255,255,0.8);
}

.tutorial-stage {
    position: relative;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tutorial-step {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    animation: stepAppear 0.4s ease;
}
.tutorial-step.active {
    display: flex;
}
@keyframes stepAppear {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

.step-badge {
    background: linear-gradient(135deg, #FF6B9D, #C471ED);
    color: white;
    padding: 4px 16px;
    border-radius: 12px;
    font-family: 'Fredoka One', cursive;
    font-size: 0.9em;
    box-shadow: 0 3px 10px rgba(0,0,0,0.15);
}

.step-text {
    color: #5D4037;
    font-size: 1em;
    font-weight: 600;
    text-align: center;
    line-height: 1.4;
}

/* ===== DEMO CELDA CON BORDES ===== */
.demo-cell, .demo-cell-small, .demo-cell-success {
    position: relative;
    width: 120px;
    height: 120px;
    background: #fafafa;
    border: 2px solid #cbd5e1;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.demo-border {
    position: absolute;
    z-index: 5;
    border-radius: 6px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}
.demo-top { top: -8px; left: 8px; right: 8px; height: 8px; }
.demo-right { right: -8px; top: 8px; bottom: 8px; width: 8px; }
.demo-bottom { bottom: -8px; left: 8px; right: 8px; height: 8px; }
.demo-left { left: -8px; top: 8px; bottom: 8px; width: 8px; }

.demo-inner {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hint-arrow {
    position: absolute;
    font-size: 0.7em;
    font-weight: 700;
    opacity: 0;
    animation: hintFade 3s infinite ease-in-out;
}
.hint-top { top: 8px; left: 50%; transform: translateX(-50%); animation-delay: 0.3s; }
.hint-right { right: 8px; top: 50%; transform: translateY(-50%); animation-delay: 0.6s; }
.hint-bottom { bottom: 8px; left: 50%; transform: translateX(-50%); animation-delay: 0.9s; }
.hint-left { left: 8px; top: 50%; transform: translateY(-50%); animation-delay: 1.2s; }
@keyframes hintFade {
    0%, 100% { opacity: 0; }
    30%, 70% { opacity: 0.8; }
}

/* ===== PIEZA DEMO ===== */
.demo-piece-area {
    display: flex;
    align-items: center;
    gap: 16px;
}

.demo-piece-wrapper {
    position: relative;
    width: 80px;
    height: 80px;
}

.demo-piece {
    position: relative;
    width: 100%;
    height: 100%;
    background: white;
    border: 3px solid #3498db;
    border-radius: 14px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    transition: transform 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.demo-piece.rotating {
    transform: rotate(90deg);
}

.demo-piece.correct-rotation {
    transform: rotate(0deg);
}

.piece-triangle {
    position: absolute;
    width: 0;
    height: 0;
    border: 10px solid transparent;
    filter: drop-shadow(0 2px 3px rgba(0,0,0,0.12));
}
.piece-top {
    top: 4px; left: 50%; transform: translateX(-50%);
    border-bottom: 18px solid;
}
.piece-right {
    right: 4px; top: 50%; transform: translateY(-50%);
    border-left: 18px solid;
}
.piece-bottom {
    bottom: 4px; left: 50%; transform: translateX(-50%);
    border-top: 18px solid;
}
.piece-left {
    left: 4px; top: 50%; transform: translateY(-50%);
    border-right: 18px solid;
}

.rotate-hint {
    position: absolute;
    bottom: -18px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 1.2em;
    opacity: 0;
    animation: hintBounce 2s infinite ease-in-out;
}
@keyframes hintBounce {
    0%, 100% { opacity: 0; transform: translateX(-50%) translateY(0); }
    50% { opacity: 0.7; transform: translateX(-50%) translateY(-3px); }
}

.arrow-indicator {
    font-size: 2em;
    opacity: 0;
    animation: arrowSpin 1s ease forwards;
}
@keyframes arrowSpin {
    0% { opacity: 0; transform: rotate(-180deg); }
    100% { opacity: 1; transform: rotate(0deg); }
}

/* ===== ÁREA DE COLOCACIÓN ===== */
.demo-place-area {
    display: flex;
    align-items: center;
    gap: 12px;
}

.demo-cell-small {
    width: 90px;
    height: 90px;
    opacity: 0.7;
}

.demo-arrow {
    font-size: 1.8em;
    opacity: 0;
    animation: slideRight 0.5s ease forwards;
}
@keyframes slideRight {
    from { opacity: 0; transform: translateX(-10px); }
    to { opacity: 1; transform: translateX(0); }
}

.demo-piece-small {
    width: 70px;
    height: 70px;
    position: relative;
    background: white;
    border: 3px solid #3498db;
    border-radius: 12px;
    box-shadow: 0 3px 10px rgba(0,0,0,0.1);
    opacity: 0;
    animation: flyIn 0.6s ease forwards;
}
@keyframes flyIn {
    from { opacity: 0; transform: translateX(20px) scale(0.8); }
    to { opacity: 1; transform: translateX(0) scale(1); }
}

/* ===== ÉXITO ===== */
.demo-success {
    display: flex;
    align-items: center;
    gap: 16px;
    position: relative;
}

.demo-cell-success {
    background: #d5f4e6;
    border-color: #27ae60;
    animation: popSuccess 0.3s ease;
}
@keyframes popSuccess {
    0% { transform: scale(0.8); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.success-piece {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.checkmark {
    font-size: 3em;
    opacity: 0;
    animation: checkPop 0.4s ease 0.2s forwards;
}
@keyframes checkPop {
    0% { opacity: 0; transform: scale(0); }
    50% { transform: scale(1.3); }
    100% { opacity: 1; transform: scale(1); }
}

/* Confeti */
.confetti-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: visible;
}

.confetti-piece {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 2px;
    animation: confettiFall 1.5s ease forwards;
}
@keyframes confettiFall {
    0% { transform: translateY(-20px) rotate(0deg); opacity: 1; }
    100% { transform: translateY(80px) rotate(360deg); opacity: 0; }
}

/* ===== INDICADORES DE PASO ===== */
.step-indicators {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 16px;
}

.step-dot {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #e0e0e0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #999;
    font-size: 0.9em;
    border: 3px solid #bdbdbd;
    transition: all 0.3s ease;
}

.step-dot.active {
    background: linear-gradient(135deg, #4ECDC4, #44A08D);
    color: white;
    border-color: #3EB8A8;
    box-shadow: 0 3px 12px rgba(78,205,196,0.4);
    transform: scale(1.1);
}

/* ===== BOTÓN INICIO ===== */
.start-btn {
    background: linear-gradient(135deg, #FF6B9D 0%, #FF8E8E 50%, #FFB347 100%);
    color: white; border: none; border-radius: 25px;
    padding: 14px 36px; font-family: 'Fredoka One', cursive;
    font-size: 1.4em; cursor: pointer;
    display: flex; align-items: center; gap: 10px;
    box-shadow: 0 10px 30px rgba(255,107,157,0.4), 0 0 0 4px rgba(255,255,255,0.3);
    transition: all 0.25s ease;
    animation: pulseBtn 2.5s infinite ease-in-out;
    margin: 6px 0;
}
.start-btn:hover { transform: translateY(-3px) scale(1.02); box-shadow: 0 14px 40px rgba(255,107,157,0.55); }
.start-btn:active { transform: translateY(0) scale(0.98); }
@keyframes pulseBtn {
    0%, 100% { box-shadow: 0 10px 30px rgba(255,107,157,0.4), 0 0 0 4px rgba(255,255,255,0.3); }
    50% { box-shadow: 0 10px 30px rgba(255,107,157,0.6), 0 0 0 6px rgba(255,255,255,0.5); }
}
.btn-icon { font-size: 1.3em; animation: bounceIcon 1.5s infinite ease; }
@keyframes bounceIcon { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
.btn-text { text-shadow: 2px 2px 4px rgba(0,0,0,0.2); }
.btn-sparkles { animation: sparkle 1.8s infinite ease-in-out; }
@keyframes sparkle { 0%, 100% { opacity: 1; } 50% { opacity: 0.6; } }

/* ===== NIVELES ===== */
.levels-preview {
    display: flex; align-items: center; gap: 8px;
    background: rgba(255,255,255,0.7); padding: 8px 18px;
    border-radius: 16px; margin: 4px 0; animation: fadeIn 0.8s ease 0.5s both;
}
.level-dot {
    width: 32px; height: 32px; border-radius: 50%;
    background: #e0e0e0; display: flex; align-items: center; justify-content: center;
    font-weight: 700; color: #757575; font-size: 0.9em; border: 3px solid #bdbdbd;
}
.level-dot.active {
    background: linear-gradient(135deg, #4ECDC4, #44A08D);
    color: white; border-color: #3EB8A8;
    box-shadow: 0 3px 12px rgba(78,205,196,0.4);
}
.level-more { color: #757575; font-weight: 600; font-size: 0.9em; opacity: 0.8; }

.credits { margin-top: 4px; opacity: 0.7; animation: fadeIn 0.8s ease 0.8s both; }
.credits p { color: #6D4C41; font-size: 0.9em; font-weight: 500; }

.corner-decoration {
    position: absolute; font-size: 2em; opacity: 0.7; z-index: 5;
    animation: floatCorner 4s infinite ease-in-out; pointer-events: none;
}
.corner-decoration.top-left { top: 20px; left: 20px; }
.corner-decoration.top-right { top: 20px; right: 20px; animation-delay: 1s; }
.corner-decoration.bottom-left { bottom: 20px; left: 20px; animation-delay: 2s; }
.corner-decoration.bottom-right { bottom: 20px; right: 20px; animation-delay: 3s; }
@keyframes floatCorner { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .game-title { font-size: 1.8em; }
    .game-by { font-size: 1.1em; }
    .tutorial-section { padding: 14px 16px; }
    .tutorial-title { font-size: 1.1em; }
    .demo-cell, .demo-cell-small, .demo-cell-success { width: 100px; height: 100px; }
    .demo-piece-wrapper { width: 70px; height: 70px; }
    .demo-cell-small { width: 80px; height: 80px; }
    .demo-piece-small { width: 60px; height: 60px; }
    .start-btn { font-size: 1.2em; padding: 12px 28px; width: 90%; justify-content: center; }
    .hint-arrow { font-size: 0.6em; }
    .piece-triangle { border-width: 8px; }
    .piece-top { border-bottom-width: 14px; }
    .piece-right { border-left-width: 14px; }
    .piece-bottom { border-top-width: 14px; }
    .piece-left { border-right-width: 14px; }
}

@media (max-width: 480px) {
    .game-title { font-size: 1.5em; }
    .tutorial-section { padding: 12px 14px; }
    .demo-cell, .demo-cell-small, .demo-cell-success { width: 85px; height: 85px; }
    .demo-piece-wrapper { width: 60px; height: 60px; }
    .step-badge { font-size: 0.8em; }
    .step-text { font-size: 0.9em; }
}

/* ===== ACCESIBILIDAD ===== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

.start-btn:focus { outline: 3px solid #FFD700; outline-offset: 4px; }