/* ========== Base Styles ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px;
    overflow-x: hidden;
}

/* ========== Loading Screen ========== */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #0a0a1a 0%, #1a1a3e 50%, #0f0f2e 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.loading-screen.hidden {
    opacity: 0;
    visibility: hidden;
}

.loading-content {
    width: 800px;
    height: 600px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
}

.loading-logo {
    font-size: 3.5rem;
    margin-bottom: 15px;
    animation: bounce 1s ease infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-15px); }
}

.loading-title {
    font-size: 2.5rem;
    color: #fff;
    margin-bottom: 8px;
    text-shadow: 0 0 20px rgba(233, 69, 96, 0.5);
    animation: glow 2s ease-in-out infinite;
}

@keyframes glow {
    0%, 100% { text-shadow: 0 0 20px rgba(233, 69, 96, 0.5); }
    50% { text-shadow: 0 0 40px rgba(233, 69, 96, 0.8), 0 0 60px rgba(233, 69, 96, 0.4); }
}

.loading-subtitle {
    font-size: 1.1rem;
    color: #888;
    margin-bottom: 30px;
}

.loading-presidents {
    display: flex;
    gap: 12px;
    margin-bottom: 30px;
}

.loading-president {
    width: 55px;
    height: 55px;
    border-radius: 50%;
    border: 3px solid #e94560;
    animation: fadeInUp 0.5s ease forwards;
    opacity: 0;
    object-fit: cover;
    background: #333;
}

.loading-president:nth-child(1) { animation-delay: 0.1s; }
.loading-president:nth-child(2) { animation-delay: 0.2s; }
.loading-president:nth-child(3) { animation-delay: 0.3s; }
.loading-president:nth-child(4) { animation-delay: 0.4s; }
.loading-president:nth-child(5) { animation-delay: 0.5s; }

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.loading-bar-container {
    width: 280px;
    height: 6px;
    background: rgba(255,255,255,0.1);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 20px;
}

.loading-bar {
    height: 100%;
    background: linear-gradient(90deg, #e94560, #ff6b6b, #e94560);
    background-size: 200% 100%;
    border-radius: 10px;
    width: 0%;
    animation: loading 2s ease-out forwards, shimmer 1s linear infinite;
}

@keyframes loading {
    0% { width: 0%; }
    100% { width: 100%; }
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.loading-text {
    color: #e94560;
    font-size: 0.85rem;
    margin-bottom: 25px;
    animation: pulse 1s ease infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.start-btn {
    background: linear-gradient(145deg, #e94560, #c73e54);
    color: #fff;
    border: none;
    padding: 15px 50px;
    font-size: 1.2rem;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 8px 25px rgba(233, 69, 96, 0.4);
    opacity: 0;
    transform: translateY(20px);
    animation: showButton 0.5s ease forwards;
    animation-delay: 2.2s;
    text-transform: uppercase;
    letter-spacing: 2px;
    font-weight: bold;
}

.start-btn:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 12px 35px rgba(233, 69, 96, 0.6);
}

@keyframes showButton {
    to { opacity: 1; transform: translateY(0); }
}

.loading-tips {
    position: absolute;
    bottom: 20px;
    color: #666;
    font-size: 0.75rem;
}

/* ========== Game Wrapper - 800x600 Container ========== */
.game-wrapper {
    width: 800px;
    height: 600px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.game-container {
    width: 100%;
    height: 100%;
    background: linear-gradient(145deg, #0f1a2e, #162035);
    border-radius: 20px;
    box-shadow: 0 15px 50px rgba(0,0,0,0.5);
    display: none;
    flex-direction: column;
    padding: 15px 20px;
    overflow: hidden;
}

.game-container.active {
    display: flex;
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

/* ========== Game Header ========== */
.game-header {
    text-align: center;
    padding-bottom: 10px;
}

.game-header h1 {
    color: #fff;
    font-size: 1.6rem;
    margin-bottom: 3px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}

.subtitle {
    color: #888;
    font-size: 0.8rem;
}

/* ========== Game Main Area ========== */
.game-main {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    flex: 1;
    padding: 10px 0;
}

/* ========== Side Panels ========== */
.side-panel {
    width: 120px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* ========== Current President ========== */
.current-president {
    background: rgba(233, 69, 96, 0.15);
    border-radius: 12px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.current-president img {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 2px solid #e94560;
    object-fit: cover;
    margin-bottom: 8px;
}

.current-president-info {
    color: #fff;
}

.current-label {
    font-size: 0.65rem;
    color: #888;
    margin-bottom: 2px;
}

.current-president-name {
    font-weight: bold;
    color: #e94560;
    font-size: 0.85rem;
    margin-bottom: 4px;
}

.goal-text {
    font-size: 0.6rem;
    color: #888;
}

/* ========== Score Box ========== */
.score-box {
    background: linear-gradient(145deg, #0f3460, #1a1a2e);
    padding: 12px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.score-label {
    font-size: 0.7rem;
    color: #888;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.score-value {
    font-size: 1.5rem;
    font-weight: bold;
    color: #e94560;
}

/* ========== Game Board ========== */
.game-center {
    display: flex;
    justify-content: center;
    align-items: center;
}

.game-board {
    background: linear-gradient(145deg, #0f3460, #1a1a2e);
    border-radius: 12px;
    padding: 10px;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.4);
    touch-action: none;
}

.cell {
    width: 95px;
    height: 100px;
    background: #16213e;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
    transition: all 0.15s ease;
}

.cell.filled {
    animation: pop 0.2s ease;
}

@keyframes pop {
    0% { transform: scale(0); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.president-img {
    width: 55px;
    height: 55px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #e94560;
    background: #333;
}

.president-name {
    font-size: 0.6rem;
    color: #fff;
    margin-top: 4px;
    text-align: center;
}

.president-number {
    position: absolute;
    top: 4px;
    right: 6px;
    font-size: 0.65rem;
    color: #e94560;
    font-weight: bold;
}

.president-years {
    font-size: 0.5rem;
    color: #888;
}

/* ========== Controls ========== */
.controls {
    display: flex;
    justify-content: center;
    gap: 12px;
    padding: 12px 0;
}

.btn {
    background: linear-gradient(145deg, #e94560, #c73e54);
    color: #fff;
    border: none;
    padding: 10px 25px;
    font-size: 0.9rem;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(233, 69, 96, 0.4);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(233, 69, 96, 0.6);
}

.btn.secondary {
    background: linear-gradient(145deg, #0f3460, #1a1a2e);
}

.btn.more-games {
    background: linear-gradient(145deg, #ffd700, #ffaa00);
    color: #333;
    font-weight: bold;
    position: relative;
}

.btn.more-games:hover {
    box-shadow: 0 6px 18px rgba(255, 215, 0, 0.6);
}

.btn.more-games .badge {
    position: absolute;
    top: -6px;
    right: -6px;
    background: #e94560;
    color: #fff;
    font-size: 0.55rem;
    padding: 2px 6px;
    border-radius: 8px;
    font-weight: bold;
    animation: pulse 1s ease infinite;
}

/* ========== Game Footer ========== */
.game-footer {
    text-align: center;
    padding-top: 5px;
}

.game-footer p {
    color: #666;
    font-size: 0.75rem;
}

/* ========== Game Over Modal ========== */
.game-over {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.85);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.game-over-content {
    background: linear-gradient(145deg, #0f3460, #1a1a2e);
    padding: 35px;
    border-radius: 20px;
    text-align: center;
    color: #fff;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    max-width: 400px;
    width: 90%;
}

.game-over h2 {
    font-size: 1.8rem;
    margin-bottom: 15px;
    color: #e94560;
}

.final-score {
    font-size: 1.3rem;
    margin-bottom: 15px;
}

.winner-img {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 3px solid gold;
    margin: 15px auto;
    display: block;
    object-fit: cover;
}

.game-over-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 20px;
}

/* ========== Responsive Design ========== */
@media (max-width: 820px) {
    .game-wrapper {
        width: 100%;
        height: auto;
        min-height: 100vh;
    }

    .game-container {
        width: 100%;
        height: auto;
        min-height: 100vh;
        border-radius: 0;
        padding: 10px 15px;
    }

    .game-main {
        flex-direction: column;
        gap: 10px;
    }

    .side-panel {
        width: 100%;
        flex-direction: row;
        justify-content: center;
    }

    .left-panel {
        order: 1;
    }

    .game-center {
        order: 2;
    }

    .right-panel {
        order: 3;
    }

    .current-president {
        flex-direction: row;
        gap: 10px;
        padding: 10px 15px;
    }

    .current-president img {
        margin-bottom: 0;
    }

    .current-president-info {
        text-align: left;
    }

    .score-box {
        padding: 10px 20px;
    }
}

@media (max-width: 500px) {
    .cell {
        width: 70px;
        height: 75px;
    }
    
    .president-img {
        width: 42px;
        height: 42px;
    }
    
    .president-name {
        font-size: 0.5rem;
    }
    
    .president-number {
        font-size: 0.55rem;
    }

    .president-years {
        display: none;
    }
    
    .game-header h1 {
        font-size: 1.3rem;
    }
    
    .game-board {
        gap: 5px;
        padding: 8px;
    }

    .loading-content {
        width: 100%;
        height: 100%;
        padding: 20px;
    }

    .loading-title {
        font-size: 1.8rem;
    }

    .loading-president {
        width: 45px;
        height: 45px;
    }

    .start-btn {
        padding: 12px 35px;
        font-size: 1rem;
    }

    .btn {
        padding: 8px 18px;
        font-size: 0.85rem;
    }

    .controls {
        flex-wrap: wrap;
    }
}

@media (max-width: 380px) {
    .cell {
        width: 60px;
        height: 65px;
    }
    
    .president-img {
        width: 36px;
        height: 36px;
    }

    .game-board {
        gap: 4px;
        padding: 6px;
    }

    .president-name {
        font-size: 0.45rem;
    }

    .president-number {
        font-size: 0.5rem;
        top: 2px;
        right: 4px;
    }
}