/* styles.css - Main stylesheet */

/* --- Fonts and Body --- */
@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

body {
    background-color: #2a1b18;
    color: #fff;
    font-family: 'Press Start 2P', 'Courier New', monospace;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    padding: 10px;
    -webkit-font-smoothing: none;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* --- Game Layout --- */
.game-wrapper {
    width: 100%;
    max-width: 800px; 
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    width: 100%;
}

#board-container {
    position: relative;
    border: 4px solid #000;
    box-shadow: 8px 8px 0 #000;
}

/* --- HUD (Heads-Up Display) --- */
.hud {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    background: #3d2b1f;
    padding: 12px; /* Increased padding */
    border: 3px solid #000;
    box-sizing: border-box;
    gap: 20px; /* Add gap between player/engine sections */
}

.player-stats, .engine-stats {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-basis: 50%; /* Each side takes up half the space */
    min-width: 0; /* Allow flex items to shrink */
}

.engine-stats {
    justify-content: flex-end;
    text-align: right;
}

.stats-text {
    display: flex;
    flex-direction: column;
    gap: 6px;
    line-height: 1.5; /* Increased line height */
    width: 100%;
    font-size: clamp(10px, 1.8vw, 14px); /* Fluid font size */
    word-break: break-word; /* Prevent text overflow */
}

.hud-label {
    color: #b0a08a;
}

.hud-icon {
    width: 52px; /* Slightly larger icon */
    height: 52px;
    border: 2px solid #000;
    flex-shrink: 0; /* Prevent icon from shrinking */
}

#player-color-indicator, #engine-color-indicator {
    color: #fbbf24;
}

/* --- Status and Controls --- */
#status {
    width: 100%;
    text-align: center;
    font-size: 14px;
    color: #fbbf24;
    text-shadow: 2px 2px 0 #000;
    padding: 5px 0;
    min-height: 20px;
}

.game-controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}

.control-button {
    background: #3a8b5f;
    color: #fff;
    border: 3px solid #000;
    padding: 10px 18px;
    font-size: 12px;
    font-family: 'Press Start 2P', monospace;
    text-transform: uppercase;
    cursor: pointer;
    box-shadow: inset 3px 3px 0 rgba(255,255,255,0.4), inset -3px -3px 0 rgba(0,0,0,0.4);
}

.control-button:active {
    transform: translateY(2px);
    box-shadow: inset -3px -3px 0 rgba(255,255,255,0.4), inset 3px 3px 0 rgba(0,0,0,0.4);
}

.control-button:disabled {
    background: #555;
    color: #888;
    cursor: not-allowed;
}

.resign-button { background-color: #c53030; }
.hint-button { background-color: #4a5568; }
.share-button { background-color: #2b6cb0; }
.next-game-button { background-color: #3a8b5f; }

/* --- Highlights --- */
.highlight-move {
    box-shadow: inset 0 0 3px 3px yellow;
}
.highlight-hint {
    box-shadow: inset 0 0 3px 3px #34d399;
}

/* --- Replay --- */
.replay-meta {
    display: none;
    font-size: 10px;
    color: #b0a08a;
    text-align: center;
    gap: 15px;
}

/* --- Loading and Popups --- */
#loading-screen {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: #000; display: flex; justify-content: center;
    align-items: center; font-size: 24px; z-index: 1000;
}
.popup-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.7); display: none; justify-content: center;
    align-items: center; z-index: 900; padding: 15px; box-sizing: border-box;
}
.retro-popup {
    background: #3d2b1f; border: 4px solid #000; box-shadow: 8px 8px 0 #000;
    padding: 20px; text-align: center; width: 100%; max-width: 400px;
}
.highscore-title {
    color: #fbbf24; font-size: 20px; margin: 0 0 15px 0; text-shadow: 3px 3px 0 #000;
}
.popup-elo-display {
    font-size: 18px; color: #4ade80; margin-bottom: 20px;
}
.popup-elo-breakdown {
    margin-bottom: 20px; line-height: 1.8;
}
.retro-input {
    width: 100%; padding: 10px; margin-bottom: 10px;
    font-family: 'Press Start 2P', monospace; font-size: 12px;
    background: #2a1b18; border: 2px solid #000; color: #fff; box-sizing: border-box;
}
.popup-buttons {
    margin-top: 20px; display: flex; justify-content: center; gap: 10px;
}
.retro-button {
    background: #3a8b5f; color: #fff; border: 3px solid #000;
    padding: 10px 18px; font-size: 12px; text-transform: uppercase;
    cursor: pointer; font-family: 'Press Start 2P', monospace;
}
.dismiss-button { background-color: #c53030; }

/* --- Opponent Select Screen from index.php --- */
.opponent-select-wrapper {
    padding: 20px; width: 100%;
    max-width: 800px; box-sizing: border-box;
}
.opponent-select-container {
    text-align: center; padding: 20px; background: #3d2b1f;
    border: 4px solid #000; box-shadow: 8px 8px 0 #000;
}
.arcade-title {
    color: #fbbf24; font-size: clamp(1.25rem, 4vw, 1.5rem);
    margin-bottom: 20px; text-shadow: 3px 3px 0 #000;
}
.opponent-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 15px; margin: 0 auto;
}
.opponent-card-wrapper {
    aspect-ratio: 1 / 1;
}
.opponent-card {
    position: relative; border: 4px solid #000; width: 100%;
    height: 100%; text-decoration: none; color: #fff;
    display: flex; flex-direction: column; box-sizing: border-box;
    overflow: hidden;
}
.opponent-card.opponent:hover {
    border-color: #fbbf24; transform: scale(1.05); transition: all 0.2s ease-in-out;
}
.opponent-image {
    width: 100%; height: 100%; object-fit: cover;
}
.opponent-info {
    position: absolute; bottom: 0; left: 0; width: 100%;
    background: rgba(0,0,0,0.7); padding: 5px; box-sizing: border-box;
    text-align: center; font-size: 10px; line-height: 1.4;
}
.opponent-name { font-size: 12px; color: #fbbf24; }
.opponent-moves { color: #b0a08a; }
.opponent-elo-change { color: #4ade80; }

.opponent-card.locked {
    pointer-events: none; filter: grayscale(1);
}
.lock-icon {
    position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%); font-size: 40px;
    color: rgba(255,255,255,0.7); display: none;
}
.opponent-card.locked .lock-icon { display: block; }

.arcade-button {
    background: #3a8b5f; color: #fff; border: 3px solid #000;
    padding: 12px 28px; font-size: 14px; text-transform: uppercase;
    cursor: pointer; text-decoration: none;
}

/* --- Desktop & Tablet Layout Adjustments --- */
@media (min-width: 768px) {
    /* Restore 3x3 grid for opponent select screen */
    .opponent-grid {
        grid-template-columns: repeat(3, 1fr);
        max-width: 600px;
    }
    /* Increase font size on opponent cards for readability */
    .opponent-info {
        font-size: 12px;
        line-height: 1.5;
        padding: 8px;
    }
    .opponent-name {
        font-size: 14px;
    }
}

/* --- Mobile-Specific Layout Adjustments --- */
@media (max-width: 600px) {
    /* Reduce font size on small mobile screens for opponent cards */
    .opponent-info {
        padding: 4px;
        font-size: 10px;
        line-height: 1.3;
    }
    .opponent-name {
        font-size: 11px;
    }
}

@media (max-height: 820px) {
    .game-wrapper {
        align-items: flex-start;
        padding-top: 15px;
        padding-bottom: 80px; /* Lifts content up from bottom */
    }
    .game-container {
        gap: 10px;
    }
}