/* Games.so.nu - Shared Styles */
:root {
    --bg-primary: #0f0f1a;
    --bg-secondary: #1a1a2e;
    --bg-card: #16213e;
    --accent: #00d4aa;
    --accent-hover: #00e8bb;
    --text-primary: #eaeaea;
    --text-secondary: #a0a0b0;
    --text-muted: #606070;
    --border: #2a2a4a;
    --danger: #ff4757;
    --warning: #ffa502;
    --success: #2ed573;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    line-height: 1.6;
}

/* Header */
.header {
    padding: 2rem 1rem;
    text-align: center;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(180deg, var(--bg-secondary) 0%, var(--bg-primary) 100%);
}

.header-content {
    max-width: 800px;
    margin: 0 auto;
}

.logo {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.tagline {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* Games Grid */
.games-grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    padding: 2rem 1rem;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

.game-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.5rem;
    text-decoration: none;
    color: inherit;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.game-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
    border-color: var(--accent);
}

.game-card:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.game-icon {
    width: 64px;
    height: 64px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, var(--accent), #0099cc);
}

.game-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.game-desc {
    color: var(--text-secondary);
    font-size: 0.9rem;
    flex: 1;
    margin-bottom: 1rem;
}

.game-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.game-tag {
    background: var(--bg-secondary);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    border: 1px solid var(--border);
}

/* Footer */
.footer {
    padding: 2rem 1rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    border-top: 1px solid var(--border);
}

.footer a {
    color: var(--accent);
    text-decoration: none;
}

.footer a:hover {
    text-decoration: underline;
}

/* Game Page Styles */
.game-header {
    padding: 1.5rem 1rem;
    text-align: center;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
}

.game-header h1 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.game-header .back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--accent);
    text-decoration: none;
    font-size: 0.9rem;
}

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

.game-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2rem 1rem;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}

.game-canvas {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    touch-action: none;
    max-width: 100%;
    height: auto;
}

.game-controls {
    margin-top: 1.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: center;
    width: 100%;
    max-width: 500px;
}

.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    touch-action: manipulation;
}

.btn-primary {
    background: var(--accent);
    color: var(--bg-primary);
}

.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--bg-secondary);
    border-color: var(--accent);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.game-stats {
    display: flex;
    gap: 2rem;
    margin-bottom: 1rem;
    font-size: 1.1rem;
    font-weight: 600;
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-value {
    color: var(--accent);
}

/* Mobile Touch Controls */
.touch-controls {
    display: none;
    gap: 0.5rem;
    justify-content: center;
    margin-top: 1rem;
}

.touch-btn {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    font-size: 1.5rem;
    touch-action: manipulation;
    user-select: none;
    transition: all 0.1s ease;
}

.touch-btn:active {
    background: var(--accent);
    color: var(--bg-primary);
    transform: scale(0.95);
}

.touch-controls-row {
    display: flex;
    gap: 0.5rem;
}

@media (max-width: 768px) {
    .touch-controls {
        display: flex;
    }
    
    .header {
        padding: 1.5rem 1rem;
    }
    
    .logo {
        font-size: 1.5rem;
    }
    
    .games-grid {
        grid-template-columns: 1fr;
        padding: 1rem;
    }
    
    .game-stats {
        gap: 1rem;
        font-size: 1rem;
    }
    
    .game-controls {
        gap: 0.5rem;
    }
    
    .btn {
        padding: 0.6rem 1rem;
        font-size: 0.9rem;
    }
}

/* Game-specific canvas sizing */
#game2048 { width: 100%; max-width: 400px; aspect-ratio: 1; }
#gameSnake { width: 100%; max-width: 400px; aspect-ratio: 1; }
#gameTetris { width: 100%; max-width: 320px; aspect-ratio: 9/20; }
#gameWordle { width: 100%; max-width: 360px; }
#gameMemory { width: 100%; max-width: 400px; aspect-ratio: 1; }
#gameMinesweeper { width: 100%; max-width: 400px; aspect-ratio: 1; }

/* Wordle specific */
.wordle-grid {
    display: grid;
    gap: 4px;
    margin: 0 auto;
}

.wordle-row {
    display: flex;
    gap: 4px;
    justify-content: center;
}

.wordle-tile {
    width: 56px;
    height: 56px;
    border: 2px solid var(--border);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 700;
    text-transform: uppercase;
    background: var(--bg-card);
    transition: all 0.2s ease;
}

.wordle-tile.filled {
    border-color: var(--text-secondary);
}

.wordle-tile.correct {
    background: var(--success);
    border-color: var(--success);
    color: var(--bg-primary);
}

.wordle-tile.present {
    background: var(--warning);
    border-color: var(--warning);
    color: var(--bg-primary);
}

.wordle-tile.absent {
    background: #3a3a4a;
    border-color: #3a3a4a;
    color: var(--text-muted);
}

.wordle-keyboard {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 1rem;
    max-width: 500px;
}

.wordle-keyboard-row {
    display: flex;
    gap: 4px;
    justify-content: center;
}

.wordle-key {
    min-width: 36px;
    height: 48px;
    border-radius: 6px;
    border: none;
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    touch-action: manipulation;
    transition: all 0.1s ease;
}

.wordle-key:active {
    transform: scale(0.95);
}

.wordle-key.correct {
    background: var(--success);
    color: var(--bg-primary);
}

.wordle-key.present {
    background: var(--warning);
    color: var(--bg-primary);
}

.wordle-key.absent {
    background: #3a3a4a;
    color: var(--text-muted);
}

.wordle-key.wide {
    min-width: 72px;
}

/* 2048 specific */
.grid-2048 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    width: 100%;
    aspect-ratio: 1;
}

.tile-2048 {
    background: #3a3a4a;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 2rem;
    transition: all 0.15s ease;
}

.tile-2048[data-value="2"] { background: #eee4da; color: #776e65; }
.tile-2048[data-value="4"] { background: #ede0c8; color: #776e65; }
.tile-2048[data-value="8"] { background: #f2b179; color: #f9f6f2; }
.tile-2048[data-value="16"] { background: #f59563; color: #f9f6f2; }
.tile-2048[data-value="32"] { background: #f67c5f; color: #f9f6f2; }
.tile-2048[data-value="64"] { background: #f65e3b; color: #f9f6f2; }
.tile-2048[data-value="128"] { background: #edcf72; color: #f9f6f2; font-size: 1.75rem; }
.tile-2048[data-value="256"] { background: #edcc61; color: #f9f6f2; font-size: 1.75rem; }
.tile-2048[data-value="512"] { background: #edc850; color: #f9f6f2; font-size: 1.75rem; }
.tile-2048[data-value="1024"] { background: #edc53f; color: #f9f6f2; font-size: 1.5rem; }
.tile-2048[data-value="2048"] { background: #edc22e; color: #f9f6f2; font-size: 1.5rem; }
.tile-2048[data-value="4096"] { background: #3c3a32; color: #f9f6f2; font-size: 1.5rem; }
.tile-2048[data-value="8192"] { background: #3c3a32; color: #f9f6f2; font-size: 1.25rem; }

/* Memory game */
.memory-grid {
    display: grid;
    gap: 8px;
    width: 100%;
    aspect-ratio: 1;
}

.memory-card {
    aspect-ratio: 1;
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    perspective: 1000px;
    touch-action: manipulation;
}

.memory-card.flipped {
    background: var(--bg-primary);
    border-color: var(--accent);
}

.memory-card.matched {
    border-color: var(--success);
    cursor: default;
}

.memory-card .card-front,
.memory-card .card-back {
    backface-visibility: hidden;
    position: absolute;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
}

.memory-card .card-back {
    background: linear-gradient(135deg, var(--bg-card), var(--bg-secondary));
    transform: rotateY(0deg);
    z-index: 2;
}

.memory-card .card-front {
    background: var(--bg-primary);
    transform: rotateY(180deg);
}

.memory-card.flipped .card-back {
    transform: rotateY(-180deg);
}

.memory-card.flipped .card-front {
    transform: rotateY(0deg);
}

/* Minesweeper */
.minesweeper-grid {
    display: grid;
    gap: 1px;
    background: var(--border);
    border: 2px solid var(--border);
    border-radius: 4px;
    width: fit-content;
    margin: 0 auto;
}

.minesweeper-cell {
    width: 32px;
    height: 32px;
    background: #c0c0c0;
    border: 1px solid #fff;
    border-bottom: 1px solid #808080;
    border-right: 1px solid #808080;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    cursor: pointer;
    user-select: none;
    touch-action: manipulation;
}

.minesweeper-cell.revealed {
    background: #c0c0c0;
    border: 1px solid #808080;
    border-top: 1px solid #fff;
    border-left: 1px solid #fff;
}

.minesweeper-cell.mine {
    background: #ff4757;
}

.minesweeper-cell.flagged {
    background: #c0c0c0;
}

.minesweeper-cell.flagged::after {
    content: '🚩';
    font-size: 1rem;
}

.minesweeper-cell[data-number="1"] { color: #0000ff; }
.minesweeper-cell[data-number="2"] { color: #008000; }
.minesweeper-cell[data-number="3"] { color: #ff0000; }
.minesweeper-cell[data-number="4"] { color: #000080; }
.minesweeper-cell[data-number="5"] { color: #800000; }
.minesweeper-cell[data-number="6"] { color: #008080; }
.minesweeper-cell[data-number="7"] { color: #000000; }
.minesweeper-cell[data-number="8"] { color: #808080; }

/* Snake */
#gameSnake {
    background: #0f0f1a;
}

/* Tetris */
#gameTetris {
    background: #0f0f1a;
}