/* Game page specific styles (play/computer.html) */

canvas {
    background: var(--background-color);
}

.controls-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    height: calc(100vh - 2rem);
    width: 450px;
    min-width: 300px;
    background-color: var(--grey2-color);
    border-radius: var(--radius-l);
    box-sizing: border-box;
    overflow: hidden;
    flex-shrink: 0; /* Prevent the controls from shrinking */
}

.panel-header {
    background-color: var(--grey22-color);
    padding: 15px 20px;
    border-radius: var(--radius-m) var(--radius-m) 0 0;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

.panel-header h1 {
    margin: 0;
    font-size: 1.5rem;
}

.ai-controls, .setup-controls, .color-selection, .play-button-container {
    display: flex;
    flex: auto;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.color-selection {
    display: flex;
    flex-direction: row;
    gap: 0.5rem;
    align-items: center;
    justify-content: right;
    max-width: 400px;
    margin: 0 auto;
}

.difficulty-controls {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: center;
    width: 100%;
}

/* Selected Bot Info Panel */
.bot-info-content {
    text-align: center;
}

.bot-name {
    font-size: 1.25rem;
    font-weight: bold;
    color: var(--text-color);
    margin: 0 0 0.5rem 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.bot-level {
    font-size: 0.9rem;
    color: var(--text-secondary-color);
    font-weight: normal;
}

.bot-description {
    font-size: 0.9rem;
    color: var(--text-secondary-color);
    line-height: 1.4em;
    min-height: calc(3 * 1.4em);
    max-width: 400px;
    margin: 0;
}

/* Bot Avatar Grid - Fixed 4x2 layout */
.difficulty-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
    width: 100%;
    max-width: 400px;
}

.bot-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    background: transparent;
    border: 5px solid transparent;
    border-radius: var(--radius-xl);
    cursor: pointer;
    transition: all var(--transition-base);
    aspect-ratio: 1;
    width: 100%;
}

.bot-avatar:hover {
    background: var(--secondary-hover-color);
    border-color: var(--text-secondary-color);
}

.bot-avatar.selected {
    border: 5px solid var(--primary-button-color);
    background: var(--secondary-hover-color);
}

.avatar-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: var(--radius-m);
}

/* Board Setup Carousel */
.setup-carousel {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.setup-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    max-width: 300px;
}

#setup-thumbnail {
    width: 180px;
    height: 150px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-m);
    background: var(--background-color);
    cursor: default;
}

.setup-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-color);
    text-align: center;
    min-height: 1.5rem;
    letter-spacing: 0.02em;
}

.game-controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    padding: 0 24px;
    display: none;
}

.game-controls.hidden {
    display: none !important;
}

#game-big-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    height: 100%;
    max-width: 100%;
}

#game-container {
    flex-grow: 1;
    display: flex;
    flex-direction: row;
    align-items: center;
    position: relative;
    height: auto;
    justify-content: center;
    box-sizing: border-box;
}

#move-history,
#move-history-postgame {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-height: 0; /* Allow child elements to shrink */
}

#moves-list-container,
#moves-list-container-postgame {
    flex-grow: 1;
    overflow-y: auto;
    min-height: 0;
    font-size: 14px;
    scrollbar-width: thin;
    scrollbar-color: var(--grey22-color) var(--grey3-color);
    background-color: var(--grey3-color);
}

.moves-list {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    padding: 4px 0;
    color: var(--text-tertiary-color);
    font-weight: bold;
}

.move-history-controls {
    display: flex;
    justify-content: center;
    gap: 4px;
    padding-top: 24px;
    position: sticky;
    top: 0;
    z-index: 1;
    margin-top: auto;
}

.move-history-controls button {
    height: 48px;
    padding: 0;
    cursor: pointer;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
}

.move-history-controls button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#resignButton {
    flex: 1.7;
}

.move-pair {
    display: grid;
    grid-template-columns: 32px 1fr 1fr;
    padding: 2px 8px;
    align-items: center;
    min-height: 30px;
    line-height: 1.4;
    font-weight: bolder;
}

.move-pair:nth-child(odd) {
    background-color: var(--grey3-color);
}

.move-number {
    color: var(--text-secondary-color);
    font-size: 0.9em;
    user-select: none;
}

.move {
    padding: 2px 8px;
    border-radius: 2px;
    cursor: pointer;
    margin-right: 4px;
    transition: background-color 0.1s;
}

.move.current {
    background-color: var(--secondary-hover-color);
}

.move:empty {
    cursor: default;
}

.move:empty:hover {
    background-color: transparent;
}

/* Move content and indicators */
.move-content {
    display: inline-flex;
    align-items: center;
}

.marble-dots {
    display: inline-flex;
    gap: 2px;
}

.marble-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--text-secondary-color);
    display: inline-block;
}

.move-notation {
    font-weight: bold;
    font-family: monospace;
    margin-left: 5px;
}

.push-indicator {
    color: var(--text-secondary-color);
    font-size: 0.85em;
}

.capture-indicator {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent-color);
    margin-left: 2px;
}

.score-box {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 0; 
}

/* Player Card Styling */
.player-card {
    background: var(--grey4-color);
    border-radius: var(--radius-m);
    padding: 12px;
    min-width: 200px;
}

.player-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.player-avatar {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-s);
    overflow: hidden;
    background: var(--grey3-color);
    flex-shrink: 0;
}

.avatar-img,
.player-avatar-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.player-details {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.player-name-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

#opponent-player-level {
    color: var(--text-secondary-color);
}

.hourglass {
    display: none;
    width: 16px;
    height: 20px;
    position: relative;
    flex-shrink: 0;
}

.hourglass.active {
    display: block;
    animation: rotate 2s linear infinite;
}

.hourglass-top,
.hourglass-bottom {
    position: absolute;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
}

.hourglass-top {
    top: 0;
    border-top: 10px solid var(--accent-color);
}

.hourglass-bottom {
    bottom: 0;
    border-bottom: 10px solid var(--accent-color);
}

@keyframes rotate {
    0%, 10% {
        transform: rotate(0deg);
    }
    90%, 100% {
        transform: rotate(180deg);
    }
}

.player-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.captured-marbles {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    align-items: center;
}

.captured-marble {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    flex-shrink: 0;
}

.black-marble {
    background-color: var(--black-marble-color);
}

.white-marble {
    background-color: var(--white-marble-color);
}

.captured-count {
    font-size: 14px;
    color: var(--text-color);
    margin-left: 4px;
    font-weight: 500;
}

#pregame-controls, #ingame-controls, #postgame-controls {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    flex-grow: 1;
    padding: 0.2rem 1rem;
}

.game-info-section {
    width: calc(100% - 40px);
    background: var(--grey4-color);
    padding: 0 20px;
    border-radius: var(--radius-m);
    display: none;
}

#pregame-controls {
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--grey1-color) var(--grey2-color);
}    

#ingame-controls {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    flex-grow: 1;
    min-height: 0; /* Allow child elements to shrink */
}

#postgame-controls {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    flex-grow: 1;
    min-height: 0;
}

#turn-indicator {
    text-align: center;
    font-size: 1.1rem;
    font-weight: 600;
    padding: 0.75rem;
    background: var(--grey4-color);
    border-radius: var(--radius-m);
    color: var(--text-color);
    margin: 0 1rem;
    transition: all var(--transition-slow);
}

.thinking-dots {
    display: inline-block;
    margin-left: 2px;
}

.thinking-dots span {
    animation: wave 1.4s ease-in-out infinite;
    display: inline-block;
}

.thinking-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.thinking-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes wave {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 1;
    }
    30% {
        transform: translateY(-8px);
        opacity: 0.7;
    }
}

#eval-bar-container {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 0 10px;
    height: 700px; /* Default height matching the canvas */
    flex-shrink: 0; /* Prevent shrinking */
}

#eval-bar-container.hidden {
    display: none;
}

#eval-bar {
    width: 35px;
    height: 100%;
    background-color: var(--black-marble-color);
    position: relative;
}

#eval-bar-fill {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 50%;  
    background: var(--white-marble-color);
    transition: height 0.3s ease;
}

#eval-text {
    position: absolute;
    top: 0;
    font-size: 0.8rem;
    font-weight: 700;
    padding: 0.5rem 0;
    color: var(--text-color);
}

.color-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}

#gameBoard {
    max-width: 100%;
    height: auto;
    -webkit-tap-highlight-color: transparent; /* Prevent blue highlight on touch */
    user-select: none; /* Prevent text selection */
    -webkit-user-select: none; /* For Safari */
    -moz-user-select: none; /* For Firefox */
    -ms-user-select: none; /* For IE/Edge */
}

/* Media queries for responsive design */
@media screen and (max-width: 1530px) and (min-width: 1001px) {
    .controls-container {
        width: 300px;
    }

    .difficulty-grid {
        gap: 0.2rem;
    }
    
    #game-big-container {
        flex-shrink: 1;
        width: calc(100% - 300px - 1rem); /* Account for controls width and gap */
        min-width: 500px;
    }
    
    #gameBoard {
        max-width: 100%;
    }
    
    #game-container {
        height: auto;
    }
    
    #eval-bar-container {
        height: auto;
    }
}

@media screen and (max-width: 1280px) and (min-width: 1001px) {
    .controls-container {
        height: calc(100vh - 2rem - 40px);
    }
}


@media screen and (max-width: 1000px) {
    /* Hide mobile header ONLY during pregame on play/computer page */
    .game-page .mobile-header.hidden-during-pregame {
        display: none !important;
    }
    
    /* Show back button in panel header ONLY during pregame on play/computer page */
    .game-page.pregame-state .panel-back-button {
        display: flex;
    }
    
    .controls-container {
        width: 100%;
        order: 2;
        height: auto; /* Override the 100vh height on smaller screens */
        border-radius: 0;
    }
}

@media screen and (max-width: 1000px) and (min-width: 501px)  {
    #game-big-container {
        width: 100%;
        order: 1;
        min-width: auto; /* Allow it to be smaller on mobile */
    }
    
    #game-big-container.hidden-pregame {
        display: none;
    }
    
    #game-container {
        justify-content: center;
        height: auto;
    }
    
    #eval-bar-container {
        height: auto;
        margin: 0 10px;
    }
    
    #eval-bar {
        height: 100%;
    }
}

@media screen and (max-width: 500px) {
    #game-big-container.hidden-pregame {
        display: none;
    }

    .controls-container:has(#ingame-controls[style*="display: flex"]) .panel-header,
    .controls-container:has(#postgame-controls[style*="display: flex"]) .panel-header {
        display: none;
    }

    .difficulty-grid {
        gap: 0.2rem;
    }

    .player-card {
        min-width: 180px;
        padding: 10px;
    }

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

    /* Hide turn indicator on mobile during gameplay */
    #turn-indicator {
        display: none;
    }

    /* Hide move history lists on mobile */
    #moves-list-container,
    #moves-list-container-postgame {
        display: none;
    }

    /* Compact in-game and post-game controls layout */
    #ingame-controls,
    #postgame-controls {
        padding: 0.5rem;
        gap: 0;
        min-height: auto;
    }

    /* Compact button layout for move history controls */
    .move-history-controls {
        padding: 12px;
        gap: 8px;
        margin-top: 0;
    }

    .move-history-controls button {
        width: 80px;
        height: 44px;
        flex: 1;
    }

    .move-history-controls button svg {
        width: 28px;
        height: 28px;
    }

    /* Show postgame buttons on mobile */
    .postgame-buttons {
        display: flex !important;
        flex-direction: column;
        padding: 0 12px 12px 12px;
    }

    .postgame-buttons button {
        width: 100%;
        height: 50px;
    }

}
