/* ============================================
   ARCADE - SHARED STYLES
   ============================================
   Common styles for all arcade games.
   Each game sets its own --accent-color variable.
   ============================================ */

/* --- CSS VARIABLES (Defaults) --- */
:root {
    --accent-color: #00ffff;        /* Default cyan, games override this */
    --accent-hover: #00cccc;        /* Darker accent for hover states */
    --bg-dark: #1a1a2e;             /* Page background */
    --bg-panel: #333;               /* Panel/card background */
    --bg-input: #333;               /* Input field background */
    --text-primary: white;
    --text-secondary: #ccc;
    --text-muted: #888;
    --text-dim: #555;
    --border-subtle: #444;
}

/* --- RESET AND BASE --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: Arial, sans-serif;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* --- MAIN CONTAINER --- */
.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
}

/* --- GAME TITLE --- */
h1 {
    font-size: 48px;
    margin-bottom: 20px;
    color: var(--accent-color);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

/* --- SCORE BOARD (above canvas) --- */
.score-board {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 40px;
    margin-bottom: 10px;
    font-size: 24px;
    padding: 15px 20px;
    background-color: var(--bg-panel);
    border-radius: 5px;
}

.score-board span {
    color: var(--text-secondary);
}

.score-board .score-value {
    color: var(--accent-color);
    font-weight: bold;
    font-size: 28px;
}

/* Player-specific colors (for vs games like Pong) */
.score-board .player-score {
    color: #00ff00;
}

.score-board .cpu-score {
    color: #ff6666;
}

.score-board .vs {
    color: var(--text-muted);
    font-weight: bold;
}

/* --- GAME AREA (canvas + leaderboard) --- */
.game-area {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    max-width: 100%;
    overflow: hidden;
}

/* --- CANVAS WRAPPER --- */
.canvas-wrapper {
    max-width: 100%;
    overflow: hidden;
    flex-shrink: 1;
    min-width: 0; /* Important for flex items to shrink below content size */
}

/* --- CANVAS --- */
.game-canvas {
    border: 4px solid var(--accent-color);
    border-radius: 5px;
    display: block;
    background-color: #000;
    max-width: 100%;
    height: auto;
}

/* --- LEADERBOARD PANEL --- */
.leaderboard {
    background-color: var(--bg-panel);
    border: 4px solid var(--accent-color);
    border-radius: 5px;
    padding: 20px;
    width: 220px;
}

.leaderboard h2 {
    color: var(--accent-color);
    text-align: center;
    margin-bottom: 10px;
    font-size: 24px;
}

.leaderboard-subtitle {
    color: var(--text-muted);
    text-align: center;
    font-size: 12px;
    margin-bottom: 15px;
}

.leaderboard ol {
    list-style: none;
    padding: 0;
}

.leaderboard li {
    display: flex;
    justify-content: space-between;
    padding: 8px 5px;
    border-bottom: 1px solid var(--border-subtle);
    font-size: 16px;
}

.leaderboard li:last-child {
    border-bottom: none;
}

.leaderboard .rank {
    color: var(--text-muted);
    width: 25px;
}

.leaderboard .initials {
    color: var(--accent-color);
    font-weight: bold;
    width: 45px;
    text-align: center;
}

.leaderboard .lb-score {
    color: var(--text-primary);
    width: 60px;
    text-align: right;
}

.leaderboard .empty {
    color: var(--text-dim);
    font-style: italic;
}

/* --- MODAL OVERLAY --- */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background-color: var(--bg-dark);
    border: 4px solid var(--accent-color);
    border-radius: 10px;
    padding: 40px;
    text-align: center;
}

.modal-content h2 {
    color: var(--accent-color);
    margin-bottom: 20px;
    font-size: 36px;
}

.modal-content p {
    margin: 10px 0;
    font-size: 20px;
}

.modal-content .final-score {
    color: var(--accent-color);
    font-weight: bold;
}

/* For Pong-style dual scores in modal */
.modal-content .score-player {
    color: #00ff00;
    font-weight: bold;
}

.modal-content .score-cpu {
    color: #ff6666;
    font-weight: bold;
}

/* --- INITIALS INPUT --- */
.initials-input {
    font-size: 36px;
    width: 120px;
    text-align: center;
    padding: 10px;
    margin: 20px 0;
    background-color: var(--bg-input);
    border: 2px solid var(--accent-color);
    border-radius: 5px;
    color: var(--accent-color);
    text-transform: uppercase;
}

.initials-input:focus {
    outline: none;
    border-color: var(--text-primary);
}

/* --- BUTTONS --- */
.btn {
    font-size: 20px;
    padding: 10px 30px;
    background-color: var(--accent-color);
    color: var(--bg-dark);
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
}

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

/* --- CONTROLS INFO --- */
.controls {
    margin-top: 15px;
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
}

.controls p {
    margin: 5px 0;
}

.controls strong {
    color: var(--text-secondary);
}

/* --- BACK LINK --- */
.back-link {
    position: absolute;
    top: 20px;
    left: 20px;
    color: var(--accent-color);
    text-decoration: none;
    font-size: 18px;
}

.back-link:hover {
    color: var(--text-primary);
}

/* ============================================
   ARCADE MENU STYLES (index.html)
   ============================================ */

/* Body override for arcade menu - allow scrolling */
body.arcade-menu {
    display: block;
    min-height: 100vh;
}

.arcade-container {
    text-align: center;
    padding: 40px 20px;
    max-width: 1000px;
    margin: 0 auto;
}

/* --- ARCADE HEADER WITH PROFILE --- */
.arcade-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.arcade-title {
    text-align: left;
}

.arcade-container h1 {
    font-size: 72px;
    margin-bottom: 5px;
}

.arcade-subtitle {
    color: var(--text-muted);
    font-size: 18px;
    margin: 0;
}

/* --- PROFILE LINK --- */
.profile-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 15px 20px;
    background-color: var(--bg-panel);
    border: 2px solid var(--border-subtle);
    border-radius: 10px;
    text-decoration: none;
    color: var(--text-primary);
    transition: border-color 0.2s, transform 0.2s;
}

.profile-link:hover {
    border-color: var(--accent-color);
    transform: translateY(-2px);
}

.profile-icon {
    font-size: 28px;
}

.profile-name {
    font-weight: bold;
    font-size: 18px;
    color: var(--accent-color);
}

.profile-credits {
    font-size: 14px;
    color: gold;
}

/* --- USER CONTROLS (profile + logout) --- */
.user-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logout-btn {
    background: rgba(139, 0, 0, 0.3);
    border: 2px solid #8b0000;
    border-radius: 8px;
    padding: 10px 15px;
    font-size: 20px;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
}

.logout-btn:hover {
    background: rgba(139, 0, 0, 0.6);
    transform: translateY(-2px);
}

/* --- CATEGORY SECTIONS --- */
.categories {
    text-align: left;
}

.category {
    margin-bottom: 15px;
    border: 2px solid var(--border-subtle);
    border-radius: 8px;
    overflow: hidden;
}

.category-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 20px;
    background-color: var(--bg-panel);
    cursor: pointer;
    user-select: none;
    transition: background-color 0.2s;
}

.category-header:hover {
    background-color: #3a3a3a;
}

.category-header h2 {
    font-size: 22px;
    color: var(--accent-color);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.category-toggle {
    font-size: 14px;
    color: var(--text-muted);
    transition: transform 0.3s;
}

.category.collapsed .category-toggle {
    transform: rotate(-90deg);
}

.category-count {
    font-size: 14px;
    color: var(--text-muted);
    font-weight: normal;
}

.category-count .available {
    color: #00ff00;
}

.category-count .coming-soon {
    color: var(--text-dim);
}

/* --- GAMES GRID INSIDE CATEGORY --- */
.category-content {
    padding: 20px;
    background-color: rgba(0, 0, 0, 0.2);
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
}

.category.collapsed .category-content {
    display: none;
}

/* --- GAME CARDS --- */
.game-card {
    background-color: var(--bg-panel);
    border: 2px solid var(--border-subtle);
    border-radius: 8px;
    padding: 20px 15px;
    text-decoration: none;
    color: var(--text-primary);
    transition: border-color 0.2s, transform 0.2s;
    text-align: center;
    position: relative;
}

/* Player count badges */
.player-badge {
    position: absolute;
    top: 5px;
    right: 5px;
    background: #444;
    color: #aaa;
    font-size: 10px;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 3px;
}

.player-badge.two-player {
    background: #2a4a2a;
    color: #6f6;
}

.game-card:hover {
    border-color: var(--accent-color);
    transform: translateY(-3px);
}

.game-card h3 {
    color: var(--accent-color);
    margin-bottom: 5px;
    font-size: 18px;
}

.game-card p {
    color: var(--text-muted);
    font-size: 12px;
    margin: 0;
}

.game-card.coming-soon {
    opacity: 0.4;
    pointer-events: none;
}

.game-card.coming-soon h3 {
    color: var(--text-muted);
}

/* --- EXPAND/COLLAPSE ALL --- */
.menu-controls {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-bottom: 20px;
}

.menu-controls button {
    background: none;
    border: 1px solid var(--border-subtle);
    color: var(--text-muted);
    padding: 8px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    transition: border-color 0.2s, color 0.2s;
}

.menu-controls button:hover {
    border-color: var(--accent-color);
    color: var(--text-primary);
}

/* ============================================
   RESPONSIVE STYLES
   ============================================ */

/* --- TABLET (max-width: 768px) --- */
@media (max-width: 768px) {
    /* Game area - stack vertically on mobile */
    .game-area {
        flex-direction: column;
        align-items: center;
        width: 100%;
    }

    .canvas-wrapper {
        width: 100%;
        max-width: calc(100vw - 30px);
    }

    .game-canvas {
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
    }

    .game-container {
        width: 100%;
        max-width: 100vw;
        overflow-x: hidden;
    }

    /* Arcade Menu */
    .arcade-container h1 {
        font-size: 48px;
    }

    .arcade-header {
        flex-direction: column;
        gap: 20px;
        text-align: center;
    }

    .arcade-title {
        text-align: center;
    }

    .user-controls {
        width: 100%;
        justify-content: center;
    }

    .profile-link {
        flex: 1;
        justify-content: center;
    }

    .category-header {
        flex-direction: column;
        gap: 8px;
        text-align: center;
    }

    .category-header h2 {
        font-size: 18px;
    }

    .category-content {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        padding: 15px;
        gap: 10px;
    }

    .game-card {
        padding: 15px 10px;
    }

    .game-card h3 {
        font-size: 14px;
    }

    /* Game pages */
    h1 {
        font-size: 36px;
    }

    .game-area {
        flex-direction: column;
        align-items: center;
    }

    .leaderboard {
        width: 100%;
        max-width: 400px;
    }

    .score-board {
        gap: 20px;
        font-size: 18px;
        padding: 10px 15px;
    }

    .score-board .score-value {
        font-size: 22px;
    }

    .modal-content {
        padding: 25px;
        margin: 15px;
        max-width: calc(100vw - 30px);
    }

    .modal-content h2 {
        font-size: 28px;
    }

    .modal-content p {
        font-size: 16px;
    }

    .back-link {
        font-size: 14px;
        top: 10px;
        left: 10px;
    }

    .controls {
        font-size: 12px;
    }
}

/* --- MOBILE (max-width: 480px) --- */
@media (max-width: 480px) {
    /* Arcade Menu */
    .arcade-container {
        padding: 20px 10px;
    }

    .arcade-container h1 {
        font-size: 36px;
    }

    .arcade-subtitle {
        font-size: 14px;
    }

    .profile-link {
        padding: 10px 15px;
        gap: 8px;
    }

    .profile-icon {
        font-size: 22px;
    }

    .profile-name {
        font-size: 14px;
    }

    .profile-credits {
        font-size: 12px;
    }

    .logout-btn {
        padding: 8px 12px;
        font-size: 16px;
    }

    .menu-controls {
        justify-content: center;
    }

    .menu-controls button {
        font-size: 12px;
        padding: 6px 10px;
    }

    .category-header {
        padding: 12px 15px;
    }

    .category-header h2 {
        font-size: 16px;
        gap: 8px;
    }

    .category-count {
        font-size: 11px;
    }

    .category-content {
        grid-template-columns: repeat(2, 1fr);
        padding: 10px;
        gap: 8px;
    }

    .game-card {
        padding: 12px 8px;
    }

    .game-card h3 {
        font-size: 13px;
        margin-bottom: 3px;
    }

    .game-card p {
        font-size: 10px;
    }

    /* Game pages */
    h1 {
        font-size: 28px;
        margin-bottom: 15px;
    }

    .game-container {
        padding: 10px;
    }

    .score-board {
        gap: 15px;
        font-size: 14px;
        padding: 8px 12px;
        flex-wrap: wrap;
    }

    .score-board .score-value {
        font-size: 18px;
    }

    .leaderboard {
        padding: 15px;
    }

    .leaderboard h2 {
        font-size: 20px;
    }

    .leaderboard li {
        font-size: 14px;
        padding: 6px 3px;
    }

    .modal-content {
        padding: 20px 15px;
    }

    .modal-content h2 {
        font-size: 24px;
        margin-bottom: 15px;
    }

    .modal-content p {
        font-size: 14px;
    }

    .btn {
        font-size: 16px;
        padding: 10px 20px;
    }

    .initials-input {
        font-size: 28px;
        width: 100px;
        padding: 8px;
    }

    .controls {
        display: none; /* Hide keyboard controls on mobile */
    }
}
