/* ==========================================================================
   UI CSS - TIBIA CHESS ENGINE (MEDIEVAL RPG & KAWAII THEMES)
   ========================================================================== */

/* Ambient Particle Canvas */
#particle-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 0;
}

/* Main Layout Container */
.app-container {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
    gap: 28px;
    font-family: 'Cinzel', 'Times New Roman', serif;
    background: radial-gradient(circle at center, #1e140d 0%, #0d0805 70%, #040201 100%);
    transition: background 0.3s ease;
}

/* Game Header / Title */
.game-header {
    margin-bottom: 14px;
    text-align: center;
}

.game-title {
    font-family: 'Cinzel Decorative', 'Cinzel', serif;
    font-size: 2.1rem;
    font-weight: 900;
    letter-spacing: 3px;
    color: #f4cf66;
    text-transform: uppercase;
    text-shadow: 0 0 12px rgba(212, 175, 55, 0.5), 0 3px 6px rgba(0, 0, 0, 0.9);
}

.game-subtitle {
    font-size: 0.75rem;
    font-weight: 600;
    color: #bda282;
    text-transform: uppercase;
    letter-spacing: 2px;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
}

/* Main Sidebar Panel (Medieval Scroll / Oak Frame) */
.sidebar-panel {
    width: 290px;
    height: 520px;
    max-height: 85vh;
    background: linear-gradient(145deg, #1e140d 0%, #120b07 100%);
    border: 2px solid #8b5a2b;
    outline: 1px solid #3a2211;
    border-radius: 8px;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.9), inset 0 0 15px rgba(0, 0, 0, 0.8), 0 0 15px rgba(139, 90, 43, 0.2);
    display: flex;
    flex-direction: column;
    padding: 14px;
    gap: 10px;
    transition: all 0.3s ease;
    overflow-y: auto;
}


/* Visual Theme Selector Card */
.theme-select-card {
    background: #0e0906 linear-gradient(180deg, #150d09 0%, #0a0604 100%);
    border: 1px solid #5a3d1e;
    border-radius: 6px;
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.9);
}

.theme-header {
    font-size: 0.7rem;
    font-weight: 700;
    color: #d4af37;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.theme-toggle-group {
    display: flex;
    gap: 4px;
}

.btn-theme {
    flex: 1;
    padding: 6px 8px;
    font-family: 'Cinzel', serif;
    font-size: 0.7rem;
    font-weight: 700;
    border-radius: 4px;
    border: 1px solid #4a3217;
    background: #1a110a;
    color: #bda282;
    cursor: pointer;
    transition: all 0.15s ease;
    text-align: center;
}

.btn-theme.active {
    background: linear-gradient(180deg, #4a341a 0%, #281a0b 100%);
    color: #ffd700;
    border-color: #d4af37;
    box-shadow: 0 0 8px rgba(212, 175, 55, 0.4), inset 0 0 4px rgba(255, 215, 0, 0.3);
}

/* Turn Status Indicator Box */
.turn-status-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #0e0906 linear-gradient(180deg, #150d09 0%, #0a0604 100%);
    border: 1px solid #5a3d1e;
    border-radius: 6px;
    padding: 10px 14px;
    box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.9);
}

.turn-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: #d4af37;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.turn-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    font-weight: 700;
    color: #ffffff;
    padding: 4px 10px;
    border-radius: 4px;
    background-color: #261a10;
    border: 1px solid #5a3d1e;
}

.turn-badge .turn-indicator-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: #ffffff;
    box-shadow: 0 0 6px rgba(255, 255, 255, 0.8);
}

.turn-badge.turn-black .turn-indicator-dot {
    background-color: #111111;
    border: 1px solid #777;
    box-shadow: 0 0 6px rgba(0, 0, 0, 0.9);
}

/* Game Status Alert Text */
.game-status-banner {
    font-size: 0.8rem;
    font-weight: 700;
    text-align: center;
    padding: 7px;
    border-radius: 4px;
    background: rgba(212, 175, 55, 0.12);
    color: #f4cf66;
    border: 1px dashed rgba(212, 175, 55, 0.4);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9);
}

/* Game Mode & AI Selection Card */
.mode-select-card {
    background: #0e0906 linear-gradient(180deg, #150d09 0%, #0a0604 100%);
    border: 1px solid #5a3d1e;
    border-radius: 6px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.9);
}

.mode-header {
    font-size: 0.75rem;
    font-weight: 700;
    color: #d4af37;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.mode-toggle-group, .difficulty-toggle-group, .color-toggle-group {
    display: flex;
    gap: 4px;
}

.btn-toggle, .btn-diff, .btn-color {
    flex: 1;
    padding: 6px 8px;
    font-family: 'Cinzel', serif;
    font-size: 0.7rem;
    font-weight: 700;
    border-radius: 4px;
    border: 1px solid #4a3217;
    background: #1a110a;
    color: #bda282;
    cursor: pointer;
    transition: all 0.15s ease;
    text-align: center;
}

.btn-toggle.active, .btn-diff.active, .btn-color.active {
    background: linear-gradient(180deg, #4a341a 0%, #281a0b 100%);
    color: #ffd700;
    border-color: #d4af37;
    box-shadow: 0 0 8px rgba(212, 175, 55, 0.4), inset 0 0 4px rgba(255, 215, 0, 0.3);
}

.ai-settings-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-top: 6px;
    border-top: 1px dashed #4a3217;
}

.setting-label {
    font-size: 0.65rem;
    font-weight: 700;
    color: #9a7b56;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.hidden {
    display: none !important;
}

/* Captured Pieces Container */
.captured-container {
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: #0e0906 linear-gradient(180deg, #150d09 0%, #0a0604 100%);
    border: 1px solid #5a3d1e;
    border-radius: 6px;
    padding: 8px 10px;
    box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.9);
}

.captured-section {
    display: flex;
    align-items: center;
    min-height: 26px;
}

.captured-label {
    font-size: 0.7rem;
    font-weight: 700;
    color: #9a7b56;
    width: 50px;
    text-transform: uppercase;
}

.captured-list {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px;
}

/* History Log Box (Fixed Height Scroll Window) */
.history-container {
    height: 110px;
    max-height: 110px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: #0e0906 linear-gradient(180deg, #150d09 0%, #0a0604 100%);
    border: 1px solid #5a3d1e;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.9);
}

.history-header {
    font-size: 0.75rem;
    font-weight: 700;
    color: #d4af37;
    padding: 5px 10px;
    background: #18100a;
    border-bottom: 1px solid #4a3217;
    text-transform: uppercase;
    letter-spacing: 1px;
    flex-shrink: 0;
}

.history-list {
    flex: 1;
    height: 75px;
    max-height: 75px;
    overflow-y: auto;
    padding: 4px 6px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.78rem;
    display: flex;
    flex-direction: column;
    gap: 2px;
}


/* Custom Scrollbar for History */
.history-list::-webkit-scrollbar {
    width: 5px;
}

.history-list::-webkit-scrollbar-track {
    background: #0a0604;
}

.history-list::-webkit-scrollbar-thumb {
    background: #4a3217;
    border-radius: 3px;
}

.history-row {
    display: grid;
    grid-template-columns: 32px 1fr 1fr;
    padding: 3px 6px;
    border-radius: 3px;
    color: #d4c5b3;
}

.history-row:nth-child(even) {
    background-color: rgba(255, 255, 255, 0.02);
}

.history-row.latest {
    background-color: rgba(212, 175, 55, 0.15);
    color: #ffd700;
    font-weight: bold;
}

.history-move-num {
    color: #7a5e3f;
}

/* Control Action Buttons */
.controls-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.btn {
    padding: 9px 12px;
    font-family: 'Cinzel', serif;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-radius: 5px;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
}

/* Gold Forged Button */
.btn-primary {
    background: linear-gradient(180deg, #d4af37 0%, #8b6214 100%);
    color: #1a0f05;
    border: 1px solid #ffd700;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.6), 0 0 8px rgba(212, 175, 55, 0.3);
    text-shadow: 0 1px 0 rgba(255, 235, 175, 0.4);
}

.btn-primary:hover {
    background: linear-gradient(180deg, #f4cf66 0%, #a6761c 100%);
    box-shadow: 0 0 14px rgba(255, 215, 0, 0.6);
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: translateY(1px);
}

/* Steel Iron Button */
.btn-secondary {
    background: linear-gradient(180deg, #382c23 0%, #211812 100%);
    color: #d4c5b3;
    border: 1px solid #5a422e;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.5);
}

.btn-secondary:hover {
    background: linear-gradient(180deg, #48392e 0%, #2c2018 100%);
    color: #ffffff;
    border-color: #8b6214;
}

.btn-secondary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none !important;
}

/* Game Over Celebration Modal Overlay */
.game-over-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.82);
    backdrop-filter: blur(6px);
    padding: 20px;
    animation: fadeInModal 0.3s ease-out;
}

.game-over-card {
    background: linear-gradient(145deg, #241910 0%, #150c07 100%);
    border: 3px solid #d4af37;
    outline: 2px solid #8b5a2b;
    border-radius: 12px;
    padding: 30px 40px;
    text-align: center;
    max-width: 420px;
    width: 90%;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.95), 0 0 30px rgba(212, 175, 55, 0.3), inset 0 0 15px rgba(0, 0, 0, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    animation: popModalCard 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.game-over-icon {
    font-size: 3.2rem;
    filter: drop-shadow(0 0 10px rgba(255, 215, 0, 0.8));
    animation: bounceIcon 1.5s infinite alternate ease-in-out;
}

.game-over-title {
    font-family: 'Cinzel Decorative', 'Cinzel', serif;
    font-size: 2.2rem;
    font-weight: 900;
    letter-spacing: 3px;
    color: #ffd700;
    text-transform: uppercase;
    text-shadow: 0 0 15px rgba(255, 215, 0, 0.7), 0 3px 6px rgba(0, 0, 0, 0.9);
    margin: 0;
}

.game-over-subtitle {
    font-family: 'Cinzel', serif;
    font-size: 0.95rem;
    font-weight: 600;
    color: #d4c5b3;
    line-height: 1.4;
    margin: 0;
}

.btn-modal {
    margin-top: 10px;
    padding: 12px 28px;
    font-size: 0.85rem;
    width: 100%;
}

@keyframes fadeInModal {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes popModalCard {
    from { opacity: 0; transform: scale(0.7) translateY(30px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes bounceIcon {
    from { transform: translateY(0); }
    to { transform: translateY(-8px); }
}

/* ==========================================================================
   KAWAII DREAM THEME OVERRIDES (body.theme-kawaii)
   ========================================================================== */
body.theme-kawaii {
    font-family: 'Fredoka', 'Nunito', sans-serif;
}

body.theme-kawaii .app-container {
    background: radial-gradient(circle at center, #ffe4e1 0%, #f3e5f5 65%, #e1bee7 100%);
    font-family: 'Fredoka', 'Nunito', sans-serif;
}

body.theme-kawaii .game-title {
    font-family: 'Fredoka', sans-serif;
    font-size: 2.3rem;
    font-weight: 700;
    color: #ff4081;
    text-shadow: 0 0 15px rgba(255, 64, 129, 0.4), 0 2px 6px rgba(255, 255, 255, 0.9);
    letter-spacing: 1px;
}

body.theme-kawaii .game-subtitle {
    font-family: 'Nunito', sans-serif;
    color: #ab47bc;
    font-weight: 800;
    letter-spacing: 1px;
    text-shadow: none;
}

body.theme-kawaii .sidebar-panel {
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(10px);
    border: 3px solid #ff80ab;
    outline: none;
    border-radius: 16px;
    box-shadow: 0 14px 35px rgba(255, 128, 171, 0.35);
}

body.theme-kawaii .turn-status-card,
body.theme-kawaii .mode-select-card,
body.theme-kawaii .theme-select-card,
body.theme-kawaii .captured-container,
body.theme-kawaii .history-container {
    background: #ffffff;
    border: 2px solid #ffccd5;
    border-radius: 12px;
    box-shadow: 0 4px 14px rgba(255, 182, 193, 0.25);
}

body.theme-kawaii .turn-label,
body.theme-kawaii .mode-header,
body.theme-kawaii .theme-header,
body.theme-kawaii .history-header,
body.theme-kawaii .setting-label,
body.theme-kawaii .captured-label {
    color: #ff4081;
    font-family: 'Fredoka', sans-serif;
    font-weight: 700;
}

body.theme-kawaii .history-header {
    background: #fff5f7;
    border-bottom: 1px solid #ffccd5;
}

body.theme-kawaii .turn-badge {
    background: #fff0f3;
    border: 1px solid #ff80ab;
    color: #d81b60;
    font-weight: 700;
}

body.theme-kawaii .btn-toggle,
body.theme-kawaii .btn-diff,
body.theme-kawaii .btn-color,
body.theme-kawaii .btn-theme {
    font-family: 'Fredoka', sans-serif;
    background: #fff5f7;
    border: 1px solid #ffccd5;
    color: #ab47bc;
    border-radius: 10px;
    font-size: 0.72rem;
    font-weight: 600;
}

body.theme-kawaii .btn-toggle.active,
body.theme-kawaii .btn-diff.active,
body.theme-kawaii .btn-color.active,
body.theme-kawaii .btn-theme.active {
    background: linear-gradient(180deg, #ff80ab 0%, #ff4081 100%);
    color: #ffffff;
    border-color: #ff4081;
    box-shadow: 0 0 10px rgba(255, 64, 129, 0.5);
}

body.theme-kawaii .btn-primary {
    background: linear-gradient(180deg, #ff80ab 0%, #ff4081 100%);
    color: #ffffff;
    font-family: 'Fredoka', sans-serif;
    border-radius: 12px;
    border: none;
    box-shadow: 0 4px 14px rgba(255, 64, 129, 0.4);
    text-shadow: none;
}

body.theme-kawaii .btn-primary:hover {
    background: linear-gradient(180deg, #ff94ba 0%, #ff528f 100%);
    box-shadow: 0 0 18px rgba(255, 64, 129, 0.6);
}

body.theme-kawaii .btn-secondary {
    background: linear-gradient(180deg, #e1bee7 0%, #ba68c8 100%);
    color: #ffffff;
    font-family: 'Fredoka', sans-serif;
    border-radius: 12px;
    border: none;
    box-shadow: 0 4px 14px rgba(186, 104, 200, 0.4);
}

body.theme-kawaii .btn-secondary:hover {
    background: linear-gradient(180deg, #eacaf0 0%, #c27ba0 100%);
}

body.theme-kawaii .game-status-banner {
    background: #fff0f5;
    color: #d81b60;
    border: 1px dashed #ff80ab;
    font-family: 'Fredoka', sans-serif;
    text-shadow: none;
}

body.theme-kawaii .history-row {
    color: #8e24aa;
}

body.theme-kawaii .history-move-num {
    color: #f48fb1;
}

/* Kawaii Game Over Celebration Modal */
body.theme-kawaii .game-over-card {
    background: #ffffff;
    border: 3px solid #ff80ab;
    outline: none;
    border-radius: 20px;
    box-shadow: 0 20px 50px rgba(255, 64, 129, 0.35);
}

body.theme-kawaii .game-over-title {
    font-family: 'Fredoka', sans-serif;
    color: #ff4081;
    text-shadow: 0 0 12px rgba(255, 64, 129, 0.3);
}

body.theme-kawaii .game-over-subtitle {
    font-family: 'Nunito', sans-serif;
    color: #8e24aa;
}
