/* --- CUSTOM MODE STYLES --- */
.btn-small {
    background: #444;
    color: #eee;
    border: 1px solid #555;
    border-radius: 3px;
    padding: 3px 8px;
    font-size: 11px;
    cursor: pointer;
    transition: background 0.2s;
}
.btn-small:hover {
    background: #555;
}
.btn-small:active {
    background: #333;
}

/* Palette selection visual */
.palette-item {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    padding: 3px;
    transition: box-shadow 0.12s, transform 0.08s;
    min-width: 36px;
    min-height: 36px;
}
.palette-item:hover { transform: translateY(-1px); }
.palette-selected {
    box-shadow: 0 0 0 3px rgba(100,200,250,0.12), 0 0 0 1px rgba(100,200,250,0.18) inset;
    background: rgba(100,200,250,0.03);
}

/* Palette action buttons (delete and prefill) */
.palette-action-btn {
    position: absolute;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    font-size: 11px;
    line-height: 16px;
    text-align: center;
    cursor: pointer;
    z-index: 10;
    transition: transform 0.15s, opacity 0.15s;
    opacity: 0;
}

.palette-item:hover .palette-action-btn {
    opacity: 1;
}

.palette-action-btn:hover {
    transform: scale(1.15);
}

.palette-delete-btn {
    top: -3px;
    right: -3px;
    background: #e74c3c;
    color: white;
    font-size: 13px;
    font-weight: bold;
}

.palette-prefill-btn {
    top: -3px;
    left: -3px;
    background: #3399ff;
    color: white;
    font-size: 10px;
}

/* --- ANALYSIS MODE STYLES --- */

/* Analysis icon on piece (top-right corner) */
.analysis-icon {
    position: absolute;
    top: 2px;
    right: 2px;
    z-index: 10;
    pointer-events: none;
    filter: drop-shadow(1px 1px 2px rgba(0,0,0,0.5));
}

/* Analysis icon in move list */
.move-analysis-icon {
    width: 16px;
    height: 16px;
    margin-left: auto;
    flex-shrink: 0;
}

/* Move classification colors in move list */
.move-item[data-classification="brilliant"] { border-left-color: #1baca6 !important; }
.move-item[data-classification="great"] { border-left-color: #5c93bb !important; }
.move-item[data-classification="best"] { border-left-color: #96bc4b !important; }
.move-item[data-classification="excellent"] { border-left-color: #96bc4b !important; }
.move-item[data-classification="good"] { border-left-color: #95af8a !important; }
.move-item[data-classification="inaccuracy"] { border-left-color: #f7c631 !important; }
.move-item[data-classification="mistake"] { border-left-color: #e6912c !important; }
.move-item[data-classification="miss"] { border-left-color: #e68a8a !important; }
.move-item[data-classification="blunder"] { border-left-color: #ca3431 !important; }

/* Viewing analysis indicator */
.viewing-analysis {
    font-style: normal !important;
}

/* Analysis loading indicator */
#status-text.analyzing {
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* Move item hover with classification */
.move-item[data-classification]:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* Active move with classification */
.move-item[data-classification].active {
    background: rgba(255, 255, 255, 0.2);
}

/* --- MODAL STYLES --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(5px);
    opacity: 0;
    animation: fadeIn 0.2s forwards;
}

.modal-content {
    background: #2c2c2c;
    width: 90%;
    max-width: 500px;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    border: 1px solid #444;
    transform: scale(0.9);
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    position: relative;
    color: #eee;
}

.modal-header {
    font-size: 24px;
    font-weight: bold;
    margin-bottom: 20px;
    color: #eee;
    border-bottom: 1px solid #444;
    padding-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-close {
    cursor: pointer;
    font-size: 28px;
    color: #aaa;
    line-height: 1;
    transition: color 0.2s;
}
.modal-close:hover { color: #fff; }

.modal-body {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.modal-footer {
    margin-top: 25px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.plus-btn {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: transparent;
    color: #3399ff;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    border: 2px solid #3399ff;
    transition: all 0.2s;
    margin: 2px;
    vertical-align: middle;
}
.plus-btn:hover {
    background: #3399ff;
    color: white;
    transform: scale(1.1) rotate(90deg);
    box-shadow: 0 0 15px rgba(51, 153, 255, 0.6);
}

.btn-primary {
    background: #3399ff;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s;
}
.btn-primary:hover { background: #2288ee; }

.btn-secondary {
    background: #444;
    color: #ccc;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
}
.btn-secondary:hover { background: #555; color: white; }

/* --- INFO TOOLTIP --- */
.info-tooltip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #555;
    color: #fff;
    font-size: 10px;
    font-weight: bold;
    cursor: help;
    margin-left: 4px;
    position: relative;
    transition: all 0.2s;
    vertical-align: baseline;
    transform: translateY(-1px);
    flex-shrink: 0;
}

.info-tooltip::before {
    content: '?';
}

.info-tooltip:hover {
    background: #3399ff;
    transform: scale(1.1);
    z-index: 99999;
}

.info-tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 20%;
    transform: translateX(-20%);
    background: #2c2c2c;
    color: #eee;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: normal;
    white-space: nowrap;
    max-width: 300px;
    white-space: normal;
    width: max-content;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
    border: 1px solid #444;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 99999;
    line-height: 1.4;
}

.info-tooltip:hover::after {
    opacity: 1;
}

/* Tooltip arrow */
.info-tooltip::before {
    content: '?';
}

.info-tooltip[data-tooltip]::after {
    content: attr(data-tooltip);
}

/* Alternative position: right side */
.info-tooltip.tooltip-right::after {
    bottom: auto;
    left: calc(100% + 8px);
    top: 50%;
    transform: translateY(-50%);
}

/* Alternative position: left side */
.info-tooltip.tooltip-left::after {
    bottom: auto;
    right: calc(100% + 8px);
    left: auto;
    top: 50%;
    transform: translateY(-50%);
}

/* A touch screen cannot hover the question bubbles. Make each explanation an
   in-flow row so it stays within the settings panel at every phone width. This
   must follow the desktop tooltip rules above to win the cascade. */
@media (max-width: 900px) {
    body.is-mobile .info-tooltip {
        display: grid;
        grid-template-columns: 18px minmax(0, 1fr);
        align-items: start;
        gap: 6px;
        width: 100%;
        height: auto;
        margin: 6px 0 0;
        border-radius: 0;
        background: transparent;
        transform: none;
    }

    body.is-mobile .info-tooltip::before {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 18px;
        height: 18px;
        border-radius: 50%;
        background: #555;
        line-height: 1;
    }

    body.is-mobile .info-tooltip::after,
    body.is-mobile .info-tooltip.tooltip-right::after,
    body.is-mobile .info-tooltip.tooltip-left::after {
        position: static;
        display: block;
        width: auto;
        max-width: none;
        box-sizing: border-box;
        margin: 0;
        transform: none;
        white-space: normal;
        opacity: 1;
    }
}

@keyframes fadeIn { to { opacity: 1; } }
@keyframes popIn { to { transform: scale(1); } }
/* --- EVAL BAR --- */
#eval-bar-container {
    width: 30px;
    height: 560px;
    background: #1a1a1a;
    border: 2px solid #444;
    border-radius: 4px;
    position: relative;
    overflow: hidden;
    display: none;
    flex-direction: column;
    box-shadow: 0 4px 10px rgba(0,0,0,0.4);
}

#eval-bar-container.visible {
    display: flex;
}

#eval-bar-white {
    width: 100%;
    background: linear-gradient(180deg, #f0f0f0 0%, #d0d0d0 100%);
    transition: height 0.3s ease;
    position: relative;
}

#eval-bar-black {
    width: 100%;
    background: linear-gradient(180deg, #3a3a3a 0%, #1a1a1a 100%);
    flex: 1;
    position: relative;
}

#eval-bar-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 11px;
    font-weight: bold;
    color: #fff;
    text-shadow: 0 0 3px #000;
    z-index: 10;
    white-space: nowrap;
}

/* Board area with eval bar */
#game-area.evalbar-left #board-column,
#game-area.evalbar-right #board-column {
    flex-direction: row;
    align-items: flex-start;
}

#game-area.evalbar-left #eval-bar-container {
    order: 1;
    margin-right: 15px;
}

#game-area.evalbar-left #board-wrapper {
    order: 2;
}

#game-area.evalbar-right #eval-bar-container {
    order: 2;
    margin-left: 15px;
}

#game-area.evalbar-right #board-wrapper {
    order: 1;
}

/* Board wrapper to contain board and related elements */
#board-wrapper {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}

    /* Eval bar mobile support */
    #eval-bar-container {
        width: 20px;
        height: 100%;
        margin-right: 10px !important;
        margin-left: 10px !important;
    }
    #eval-bar-text {
        font-size: 9px;
    }
