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

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --secondary: #8b5cf6;
    --accent: #ec4899;
    --bg-dark: #0a0a0a;
    --bg-card: rgba(30, 30, 46, 0.7);
    --text-primary: #ffffff;
    --text-secondary: #a1a1aa;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: linear-gradient(135deg, #0a0a0a 0%, #1a1a2e 50%, #16213e 100%);
    color: #fff;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.container {
    max-width: 1200px;
    width: 100%;
    text-align: center;
}

.arcade-title {
    font-size: 3.5rem;
    font-weight: 800;
    margin-bottom: 10px;
    background: linear-gradient(135deg, var(--primary-light), var(--secondary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
}

@keyframes glow {
    from {
        text-shadow: 0 0 10px var(--primary), 0 0 20px var(--primary);
    }
    to {
        text-shadow: 0 0 20px var(--primary), 0 0 30px var(--primary);
    }
}

.sort-btn {
    background: var(--bg-card);
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 12px;
    padding: 12px 24px;
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    margin: 0 8px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(10px);
}

.sort-btn:hover {
    transform: translateY(-2px);
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.15);
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.25);
}

.sort-btn:active {
    transform: translateY(0);
}

.subtitle {
    font-size: 1.125rem;
    font-weight: 400;
    margin-bottom: 30px;
    color: var(--text-secondary);
}

.search-container {
    margin-bottom: 40px;
    display: flex;
    justify-content: center;
}

.search-box {
    width: 100%;
    max-width: 500px;
    padding: 16px 24px;
    font-family: 'Inter', sans-serif;
    font-size: 0.9375rem;
    background: var(--bg-card);
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 16px;
    color: var(--text-primary);
    text-align: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    outline: none;
    backdrop-filter: blur(10px);
}

.search-box::placeholder {
    color: var(--text-secondary);
    opacity: 0.8;
}

.search-box:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1), 0 8px 24px rgba(99, 102, 241, 0.2);
    background: rgba(99, 102, 241, 0.1);
}

.game-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 30px;
    margin-bottom: 40px;
}

.game-card {
    background: var(--bg-card);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 20px;
    padding: 28px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(10px);
}

.game-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary), var(--secondary), var(--accent));
    opacity: 0;
    transition: opacity 0.3s;
}

.game-card:hover::before {
    opacity: 1;
}

@keyframes shine {
    0% {
        top: -50%;
        left: -50%;
    }
    100% {
        top: 150%;
        left: 150%;
    }
}

.game-card:hover {
    transform: translateY(-8px);
    border-color: var(--primary);
    box-shadow: 0 20px 40px rgba(99, 102, 241, 0.25);
    background: rgba(99, 102, 241, 0.08);
}

.game-icon {
    font-size: 4rem;
    margin-bottom: 15px;
}

.game-card h2 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.game-card p {
    font-size: 0.875rem;
    line-height: 1.6;
    margin-bottom: 16px;
    color: var(--text-secondary);
}

.play-btn {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border: none;
    color: #fff;
    padding: 12px 28px;
    font-family: 'Inter', sans-serif;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: 12px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 5px 15px rgba(155, 135, 245, 0.3);
}

.play-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.4);
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
}

footer {
    margin-top: 60px;
    padding: 20px;
    border-top: 1px solid rgba(99, 102, 241, 0.2);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    opacity: 0.8;
}

/* Game Page Styles */
body.game-page {
    padding: 80px 20px 20px 20px;
}

.game-container {
    max-width: 1000px;
    width: 100%;
    margin: 0 auto;
    padding: 20px;
}

.back-btn {
    position: fixed;
    top: 20px;
    left: 20px;
    padding: 12px 25px;
    background: rgba(15, 18, 25, 0.9);
    color: var(--ochre);
    text-decoration: none;
    border: 3px solid var(--ochre);
    border-radius: 10px;
    font-size: 0.7rem;
    transition: all 0.3s;
    z-index: 1000;
    box-shadow: 0 4px 15px rgba(155, 135, 245, 0.3);
}

.back-btn:hover {
    background: var(--ochre);
    color: #fff;
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(155, 135, 245, 0.5);
}

.game-container h1 {
    font-size: 2rem;
    margin-bottom: 30px;
    text-align: center;
    color: var(--ochre);
    text-shadow: 0 0 10px var(--ochre), 0 0 20px var(--ochre);
}

/* Common Game Board Styles */
.game-board {
    background: rgba(15, 18, 25, 0.8);
    border: 4px solid var(--ochre);
    border-radius: 15px;
    padding: 20px;
    margin: 30px auto;
    box-shadow: 0 0 40px rgba(155, 135, 245, 0.4);
    max-width: 100%;
}

/* Common Cell/Tile Styles */
.cell, .tile, .block, .card {
    background: rgba(255, 255, 255, 0.05);
    border: 3px solid var(--wattle);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    cursor: pointer;
}

.cell:hover, .tile:hover, .block:hover, .card:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(155, 135, 245, 0.3);
}

/* Common Button Styles */
button {
    background: linear-gradient(135deg, var(--ochre), var(--wattle));
    border: 3px solid var(--ochre);
    color: #fff;
    padding: 15px 30px;
    font-family: 'Press Start 2P', cursive;
    font-size: 0.8rem;
    cursor: pointer;
    border-radius: 10px;
    transition: all 0.3s;
    box-shadow: 0 5px 15px rgba(155, 135, 245, 0.3);
}

button:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(155, 135, 245, 0.5);
}

button:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 3px 10px rgba(155, 135, 245, 0.3);
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Common Info/Stats Panels */
.info-panel, .stats-panel {
    background: rgba(15, 18, 25, 0.8);
    border: 3px solid var(--wattle);
    border-radius: 10px;
    padding: 15px;
    margin: 15px 0;
    box-shadow: 0 4px 15px rgba(126, 105, 171, 0.3);
}

.info-panel h2, .stats-panel h2 {
    color: var(--ochre);
    font-size: 1.2rem;
    margin-bottom: 15px;
    text-align: center;
}

.score-board {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.score {
    font-size: 0.8rem;
    color: #fff;
    background: rgba(15, 18, 25, 0.8);
    padding: 15px 25px;
    border-radius: 10px;
    border: 3px solid var(--wattle);
    box-shadow: 0 4px 15px rgba(126, 105, 171, 0.3);
    transition: all 0.3s;
}

.score:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(126, 105, 171, 0.5);
}

.score span {
    color: var(--ochre);
    margin-left: 10px;
    font-weight: bold;
}

.high-score {
    font-size: 0.8rem;
    color: #fff;
    background: rgba(15, 18, 25, 0.8);
    padding: 15px 25px;
    border-radius: 10px;
    border: 3px solid var(--ochre);
    box-shadow: 0 4px 15px rgba(155, 135, 245, 0.3);
    transition: all 0.3s;
}

.high-score:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(155, 135, 245, 0.5);
}

.high-score span {
    color: var(--wattle);
    margin-left: 10px;
    font-weight: bold;
}

canvas {
    display: block;
    margin: 30px auto;
    border: 4px solid var(--ochre);
    border-radius: 15px;
    box-shadow: 0 0 40px rgba(155, 135, 245, 0.4);
    background: var(--sand);
    max-width: 100%;
}

.controls {
    margin-top: 30px;
    text-align: center;
}

.controls p {
    font-size: 0.7rem;
    margin-bottom: 20px;
    color: var(--wattle);
}

.control-btn {
    background: linear-gradient(135deg, var(--ochre), var(--wattle));
    border: 3px solid var(--ochre);
    color: #fff;
    padding: 15px 40px;
    font-family: 'Press Start 2P', cursive;
    font-size: 0.8rem;
    cursor: pointer;
    border-radius: 10px;
    transition: all 0.3s;
    box-shadow: 0 5px 15px rgba(155, 135, 245, 0.3);
    margin: 10px;
}

.control-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(155, 135, 245, 0.5);
}

.control-btn:active {
    transform: translateY(0);
    box-shadow: 0 3px 10px rgba(155, 135, 245, 0.3);
}

.game-over {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(15, 18, 25, 0.98);
    padding: 50px;
    border: 4px solid var(--ochre);
    border-radius: 20px;
    box-shadow: 0 0 60px rgba(155, 135, 245, 0.6);
    z-index: 1000;
    animation: slideIn 0.5s ease-out;
    text-align: center;
    max-width: 90%;
}

@keyframes slideIn {
    from {
        transform: translate(-50%, -60%);
        opacity: 0;
    }
    to {
        transform: translate(-50%, -50%);
        opacity: 1;
    }
}

.game-over.hidden {
    display: none;
}

.game-over h2 {
    font-size: 1.8rem;
    margin-bottom: 25px;
    color: var(--ochre);
    text-shadow: 0 0 15px var(--ochre), 0 0 30px var(--ochre);
}

.game-over p {
    font-size: 0.9rem;
    margin-bottom: 30px;
    color: var(--wattle);
    line-height: 1.6;
}

/* Responsive Design */

/* Tablet and below */
@media (max-width: 1024px) {
    .arcade-title {
        font-size: 3rem;
    }
    
    .game-grid {
        grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
        gap: 20px;
    }
}

/* Mobile landscape and below */
@media (max-width: 768px) {
    .arcade-title {
        font-size: 2.5rem;
    }
    
    .subtitle {
        font-size: 1rem;
    }
    
    .search-box {
        font-size: 0.875rem;
        padding: 14px 20px;
        max-width: 100%;
    }
    
    .sort-btn {
        font-size: 0.8rem;
        padding: 10px 20px;
    }
    
    .game-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 16px;
    }
    
    .game-card {
        padding: 20px;
    }
    
    .game-card h2 {
        font-size: 1.1rem;
    }
    
    .game-card p {
        font-size: 0.8rem;
    }
    
    .play-btn {
        font-size: 0.8rem;
        padding: 10px 20px;
    }
    
    canvas {
        max-width: 100%;
        height: auto;
    }
    
    .game-container h1 {
        font-size: 1.75rem;
    }
    
    .score-board {
        gap: 12px;
    }
    
    .score, .high-score {
        font-size: 0.7rem;
        padding: 8px 12px;
    }
    
    .control-btn {
        font-size: 0.75rem;
        padding: 10px 20px;
    }
    
    .game-over {
        padding: 25px;
        max-width: 90%;
    }
}

/* Mobile portrait */
@media (max-width: 480px) {
    .arcade-title {
        font-size: 1.75rem;
    }
    
    .subtitle {
        font-size: 0.875rem;
    }
    
    .search-container {
        margin-bottom: 20px;
    }
    
    .search-box {
        font-size: 0.8rem;
        padding: 12px 16px;
    }
    
    .sort-btn {
        font-size: 0.75rem;
        padding: 10px 16px;
        margin: 0 4px;
    }
    
    .game-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .game-card {
        padding: 16px;
    }
    
    .game-icon {
        font-size: 2rem;
    }
    
    .game-card h2 {
        font-size: 1rem;
    }
    
    .game-card p {
        font-size: 0.75rem;
        margin-bottom: 12px;
    }
    
    .play-btn {
        font-size: 0.75rem;
        padding: 10px 20px;
    }
    
    .game-container {
        padding: 60px 15px 15px 15px;
    }
    
    .game-container h1 {
        font-size: 1.5rem;
    }
    
    .back-btn {
        font-size: 0.7rem;
        padding: 8px 12px;
    }
    
    .control-btn {
        font-size: 0.7rem;
        padding: 10px 18px;
    }
    
    footer {
        font-size: 0.5rem;
    }
}
