:root {
    --bg-color: #0f172a;
    --panel-bg: rgba(255, 255, 255, 0.1);
    --text-color: #f8fafc;
    --red: #ef4444;
    --blue: #3b82f6;
    --green: #22c55e;
    --yellow: #eab308;
    --cell-empty: #ffffff;
    --cell-border: #94a3b8;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    touch-action: manipulation; /* Prevent zoom */
}

/* Login Screen */
#login-screen {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100vh;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 10;
}

.glass-panel {
    background: var(--panel-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 2rem;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    width: 90%;
    max-width: 350px;
}

.glass-panel h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    background: linear-gradient(to right, #f8fafc, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.glass-panel p {
    margin-bottom: 1.5rem;
    color: #cbd5e1;
}

.glass-panel input {
    width: 100%;
    padding: 12px;
    margin-bottom: 1rem;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: rgba(0, 0, 0, 0.2);
    color: white;
    font-size: 1rem;
}

.glass-panel button {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 8px;
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s;
}

.glass-panel button:active {
    transform: scale(0.95);
}

.login-error {
    color: #ef4444;
    font-size: 0.9rem;
    margin-bottom: 1rem;
    min-height: 1.2em;
}

.logout-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 6px 12px;
    background: rgba(239, 68, 68, 0.8);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.8rem;
    cursor: pointer;
    z-index: 100;
    transition: background 0.2s;
}

.logout-btn:hover {
    background: rgba(220, 38, 38, 1);
}

.hidden {
    display: none !important;
}

/* Game display */
#game-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 600px;
    height: 100vh;
    padding: 1rem;
}

.top-bar {
    width: 100%;
    display: flex;
    justify-content: space-between;
    padding: 10px;
    background: rgba(0,0,0,0.3);
    border-radius: 8px;
    margin-bottom: 10px;
}

.color-badge {
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: bold;
    text-transform: uppercase;
}

.message-box {
    width: 100%;
    background: rgba(255,255,255,0.1);
    padding: 12px;
    border-radius: 8px;
    text-align: center;
    margin-bottom: 15px;
    min-height: 48px;
    font-weight: 500;
}

/* The Board */
.board-wrapper {
    width: 100%;
    aspect-ratio: 1; /* Keep it square */
    max-width: 450px;
    max-height: 450px;
    margin: 0 auto 20px auto;
    position: relative;
    background: white;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    overflow: hidden;
}

#ludo-board {
    display: grid;
    grid-template-columns: repeat(15, 1fr);
    grid-template-rows: repeat(15, 1fr);
    width: 100%;
    height: 100%;
    border: 2px solid #333;
}

.cell {
    border: 1px solid rgba(0,0,0,0.2);
    position: relative;
    background: #ffffff;
}

.cell.safe {
    background: #f5f5dc;
}

.cell.safe::after {
    content: '⭐';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 9px;
    pointer-events: none;
    z-index: 1;
}

.yard {
    grid-column: span 6;
    grid-row: span 6;
    display: flex;
    justify-content: center;
    align-items: center;
}
.yard-inner {
    width: 70%;
    height: 70%;
    background: white;
    border-radius: 10px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 10%;
    padding: 10%;
}
.base-slot {
    border-radius: 50%;
    background: rgba(0,0,0,0.1);
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.2);
    position: relative;
    overflow: hidden;
}

/* Colors */
.bg-red { background-color: var(--red); }
.bg-blue { background-color: var(--blue); }
.bg-green { background-color: var(--green); }
.bg-yellow { background-color: var(--yellow); }
.bg-safe { background-color: #e2e8f0; }

.yard.red    { background-color: var(--red); }
.yard.blue   { background-color: var(--blue); }
.yard.yellow { background-color: var(--yellow); }
.yard.green  { background-color: var(--green); }

.center-home {
    grid-area: 7 / 7 / 10 / 10;
    position: relative;
    overflow: hidden;

    background: transparent;
}

/* Pieces - Fichas Pingüino SVG */
.piece {
    width: 90%;
    height: 90%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 5;
    cursor: pointer;
    filter: drop-shadow(0 2px 3px rgba(0,0,0,0.4));
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.piece:hover {
    transform: translate(-50%, -50%) scale(1.15);
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.5));
}

.piece svg {
    width: 100%;
    height: 100%;
}

/* Animación del corazón pulsante */
.heart-pulse {
    display: inline-block;
    animation: heartbeat 1.2s ease-in-out infinite;
}

@keyframes heartbeat {
    0%, 100% { transform: scale(1); }
    25% { transform: scale(1.2); }
    50% { transform: scale(1); }
    75% { transform: scale(1.3); }
}


/* Controls */
.controls {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}
.dice-container {
    display: flex;
    align-items: center;
    gap: 20px;
}
#roll-btn {
    padding: 12px 24px;
    background: #10b981;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(16, 185, 129, 0.4);
}
#roll-btn:disabled {
    background: #64748b;
    cursor: not-allowed;
    box-shadow: none;
}
.dice {
    width: 50px;
    height: 50px;
    background: white;
    color: black;
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 24px;
    font-weight: bold;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.2), 0 4px 10px rgba(0,0,0,0.5);
}

/* ===== PANTALLA DE VICTORIA ===== */
#victory-overlay {
    position: fixed;
    inset: 0;
    z-index: 999;
    display: flex;
    justify-content: center;
    align-items: center;
}

#confetti-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

#victory-modal {
    position: relative;
    z-index: 1000;
    background: rgba(15, 23, 42, 0.92);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 2px solid rgba(255, 255, 255, 0.25);
    border-radius: 24px;
    padding: 2.5rem 2rem;
    text-align: center;
    max-width: 340px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7);
    animation: modal-pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes modal-pop {
    from { opacity: 0; transform: scale(0.5); }
    to   { opacity: 1; transform: scale(1); }
}

#victory-trophy {
    font-size: 4rem;
    animation: trophy-bounce 0.8s ease-in-out infinite alternate;
    display: block;
    margin-bottom: 0.5rem;
}

@keyframes trophy-bounce {
    from { transform: translateY(0) rotate(-5deg); }
    to   { transform: translateY(-10px) rotate(5deg); }
}

#victory-title {
    font-size: 1.6rem;
    font-weight: 900;
    color: #f8fafc;
    margin-bottom: 0.4rem;
    line-height: 1.2;
    text-shadow: 0 0 20px currentColor;
}

#victory-subtitle {
    color: #94a3b8;
    font-size: 0.95rem;
    margin-bottom: 1.8rem;
}

.victory-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

#restart-btn {
    padding: 14px;
    border: none;
    border-radius: 10px;
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    font-size: 1rem;
    font-weight: 800;
    cursor: pointer;
    letter-spacing: 0.05em;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4);
    transition: transform 0.15s, box-shadow 0.15s;
}

#restart-btn:active {
    transform: scale(0.96);
    box-shadow: none;
}

#exit-btn {
    padding: 12px;
    border: 1px solid rgba(239, 68, 68, 0.5);
    border-radius: 10px;
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

#exit-btn:active {
    background: rgba(239, 68, 68, 0.35);
}

/* Animación de brillo para fichas ganadoras */
@keyframes winner-glow {
    0%, 100% { filter: drop-shadow(0 0 4px #fff) drop-shadow(0 0 8px currentColor); transform: translate(-50%, -50%) scale(1); }
    50%       { filter: drop-shadow(0 0 10px #fff) drop-shadow(0 0 20px currentColor); transform: translate(-50%, -50%) scale(1.2); }
}

.piece.winner-celebrate {
    animation: winner-glow 0.7s ease-in-out infinite;
}
