/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #1e1e2e 0%, #2d3748 100%);
    color: #e2e8f0;
    min-height: 100vh;
    line-height: 1.6;
}

/* App Container */
.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding-bottom: 80px; /* Add padding to prevent content from being hidden behind fixed status bar */
}

/* Header */
.app-header {
    background: linear-gradient(135deg, #4a5568 0%, #2d3748 100%);
    padding: 1.5rem 2rem;
    text-align: center;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    border-bottom: 1px solid #4a5568;
}

.app-header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: #f7fafc;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

.app-header h1 i {
    color: #ffd700;
    font-size: 2.2rem;
}

.subtitle {
    font-size: 1.1rem;
    color: #cbd5e0;
    font-weight: 300;
    opacity: 0.9;
}

/* Main Content */
.main-content {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    padding: 2rem;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
}

/* Left Pane - Chat Interface */
.left-pane {
    background: rgba(45, 55, 72, 0.7);
    border-radius: 12px;
    border: 1px solid #4a5568;
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

.chat-container {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.chat-header {
    background: linear-gradient(135deg, #4a5568 0%, #2d3748 100%);
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #4a5568;
}

.chat-header h3 {
    font-size: 1.3rem;
    font-weight: 600;
    color: #f7fafc;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chat-header h3 i {
    color: #68d391;
}

.copy-btn {
    background: #4c51bf;
    border: none;
    color: white;
    padding: 0.5rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
}

.copy-btn:hover {
    background: #5a67d8;
    transform: translateY(-1px);
}

/* Chat Output (new) */
.chat-output {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
    min-height: 600px;
    max-height: 800px;
    background: rgba(26, 32, 44, 0.4);
}

.chat-message {
    margin-bottom: 1.5rem;
    padding: 1rem 1.2rem;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    background: linear-gradient(135deg, #4a5568 0%, #2d3748 100%);
    border-left: 4px solid #4a5568;
    position: relative;
    animation: fadeInUp 0.3s ease;
    line-height: 1.6;
    color: #e2e8f0;
}

/* LLM/AI coaching messages - green edge on left */
.chat-message.coaching-message {
    border-left-color: #28a745;
}

.chat-message.coach-answer {
    border-left-color: #28a745;
}

/* System messages - blue edge on left */
.chat-message.system-message {
    border-left-color: #007bff;
}

/* Error messages - red edge on left */
.chat-message.error-message {
    border-left-color: #dc3545;
}

/* User question messages - red edge on RIGHT */
.chat-message.user-question-message {
    border-left: none;
    border-right: 4px solid #dc3545;
    text-align: right;
    margin-left: 2rem;
    margin-right: 0;
}

.message-title {
    font-weight: 600;
    color: #f7fafc;
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

.message-content {
    /* Remove the nested styling - now just a text container */
    color: inherit;
    line-height: inherit;
}

.message-time {
    font-size: 0.8rem;
    color: #a0aec0;
    margin-top: 0.5rem;
    text-align: right;
}

/* Legacy chat messages support */
.chat-messages {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
    max-height: 500px;
    background: rgba(26, 32, 44, 0.4);
}

.coach-message {
    margin-bottom: 1.5rem;
    animation: fadeInUp 0.3s ease;
}

.verbosity-controls {
    padding: 1.5rem;
    background: rgba(26, 32, 44, 0.6);
    border-top: 1px solid #4a5568;
}

.control-section {
    margin-bottom: 1.5rem;
}

.control-section:last-child {
    margin-bottom: 0;
}

.verbosity-controls label {
    display: block;
    margin-bottom: 1rem;
    font-weight: 600;
    color: #cbd5e0;
    font-size: 0.95rem;
}

.radio-group {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.radio-group.difficulty-group {
    gap: 0.5rem;
}

.radio-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    transition: background-color 0.2s ease;
    border: 1px solid #4a5568;
    background: rgba(45, 55, 72, 0.5);
    min-width: 60px;
    justify-content: center;
}

.radio-option:hover {
    background: rgba(74, 85, 104, 0.7);
}

.radio-option input[type="radio"] {
    margin: 0;
    accent-color: #68d391;
}

.radio-option input[type="radio"]:checked ~ span {
    color: #68d391;
    font-weight: 600;
}

.radio-option span {
    font-size: 0.9rem;
    color: #e2e8f0;
    font-weight: 500;
}

/* Right Pane - Chess Board */
.right-pane {
    background: rgba(45, 55, 72, 0.7);
    border-radius: 12px;
    border: 1px solid #4a5568;
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    padding: 0.5rem;
    min-height: 650px; /* Increased for expanded board space */
}

.board-container {
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.board-header {
    background: linear-gradient(135deg, #4a5568 0%, #2d3748 100%);
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #4a5568;
}

.board-header-left {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.board-header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.board-header h3 {
    font-size: 1.3rem;
    font-weight: 600;
    color: #f7fafc;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.board-header h3 i {
    color: #ffd700;
}

.game-status {
    font-size: 0.95rem;
    color: #cbd5e0;
    font-weight: 500;
    opacity: 0.9;
}

.difficulty-control {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.difficulty-control label {
    font-size: 0.9rem;
    color: #cbd5e0;
    font-weight: 500;
}

.difficulty-control .difficulty-select,
.difficulty-control .radio-group {
    min-width: 200px;
}

.chess-board {
    width: calc(100% - 2rem); /* Use full width minus padding, touching the sides */
    margin: 0 auto 1rem auto;
    aspect-ratio: 1; /* Maintain square aspect ratio */
    background: #1a202c;
    border: 2px solid #4a5568;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Allow the board to expand but maintain square shape */
    max-width: none; /* Remove width constraints to allow full expansion */
}

/* Fallback Mode Warning */
.fallback-warning {
    background: rgba(239, 68, 68, 0.1);
    border: 2px solid #ef4444;
    border-radius: 8px;
    padding: 1rem;
    margin: 0 auto 1rem auto;
    width: calc(100% - 2rem); /* Match chess board width */
    text-align: center;
    color: #ef4444;
    font-weight: bold;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    animation: pulseWarning 2s infinite;
}

.fallback-warning i {
    font-size: 1.2rem;
    color: #ef4444;
}

@keyframes pulseWarning {
    0%, 100% {
        background: rgba(239, 68, 68, 0.1);
        border-color: #ef4444;
    }
    50% {
        background: rgba(239, 68, 68, 0.2);
        border-color: #dc2626;
    }
}

/* Game Controls (updated) */
.game-controls {
    padding: 1.5rem;
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: center;
    background: rgba(26, 32, 44, 0.6);
    border-top: 1px solid #4a5568;
}

.game-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    color: white;
    min-width: 140px;
    justify-content: center;
}

.game-btn.primary {
    background: linear-gradient(135deg, #38a169 0%, #2f855a 100%);
    border: 1px solid #38a169;
}

.game-btn.primary:hover:not(:disabled) {
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(56, 161, 105, 0.3);
}

.game-btn.secondary {
    background: linear-gradient(135deg, #e53e3e 0%, #c53030 100%);
    border: 1px solid #e53e3e;
}

.game-btn.secondary:hover:not(:disabled) {
    background: linear-gradient(135deg, #f56565 0%, #e53e3e 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(229, 62, 62, 0.3);
}

.game-btn.tertiary {
    background: linear-gradient(135deg, #4c51bf 0%, #4338ca 100%);
    border: 1px solid #4c51bf;
}

.game-btn.tertiary:hover:not(:disabled) {
    background: linear-gradient(135deg, #5a67d8 0%, #4c51bf 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(76, 81, 191, 0.3);
}

.game-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

.game-btn i {
    font-size: 0.9rem;
}

/* Legacy button styles */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary {
    background: linear-gradient(135deg, #38a169 0%, #2f855a 100%);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
}

.btn-danger {
    background: linear-gradient(135deg, #e53e3e 0%, #c53030 100%);
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background: linear-gradient(135deg, #f56565 0%, #e53e3e 100%);
}

.btn-secondary {
    background: linear-gradient(135deg, #4a5568 0%, #2d3748 100%);
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background: linear-gradient(135deg, #718096 0%, #4a5568 100%);
}

/* Move History */
.move-history-container {
    border-top: 1px solid #4a5568;
    padding: 1rem 1.5rem;
    background: rgba(26, 32, 44, 0.6);
}

.move-history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.move-history-header label {
    color: #cbd5e0;
    font-weight: 500;
    font-size: 0.9rem;
}

.move-history-input {
    width: 100%;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid #4a5568;
    border-radius: 6px;
    color: #e2e8f0;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    resize: vertical;
    padding: 0.75rem;
    min-height: 60px;
}

.move-history-input:focus {
    outline: none;
    border-color: #68d391;
}

/* Status Bar */
.status-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    background: rgba(26, 32, 44, 0.95);
    padding: 1rem 2rem;
    display: flex;
    justify-content: center;
    align-items: center;
    border-top: 1px solid #4a5568;
    backdrop-filter: blur(10px);
    z-index: 1000;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
}

.status-bar .engine-status {
    color: #e2e8f0;
    font-size: 0.9rem;
    text-align: center;
    background: none;
    border: none;
    padding: 0;
    margin: 0;
}

.status-bar .engine-status strong {
    color: #63b3ed;
    margin-right: 0.5rem;
}

.status-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: #cbd5e0;
}

.debug-mode-btn {
    background: #6c757d;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s ease;
}

.debug-mode-btn:hover {
    background: #5a6268;
}

.text-success {
    color: #68d391;
}

.text-warning {
    color: #fbd38d;
}

.text-danger {
    color: #f56565;
}

/* Debug Panel (updated) */
.debug-panel {
    position: fixed;
    bottom: 0;
    left: 2rem;
    right: 2rem;
    background: rgba(26, 32, 44, 0.95);
    border: 1px solid #4a5568;
    border-bottom: none;
    border-radius: 12px 12px 0 0;
    backdrop-filter: blur(10px);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    max-height: 50vh;
}

.debug-header {
    background: linear-gradient(135deg, #4a5568 0%, #2d3748 100%);
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #4a5568;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #f7fafc;
    font-weight: 600;
}

.debug-toggle-btn,
.debug-clear-btn {
    background: #4c51bf;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s ease;
    margin-left: 0.5rem;
}

.debug-toggle-btn:hover,
.debug-clear-btn:hover {
    background: #5a67d8;
}

.debug-details {
    padding: 1rem;
}

#debugOutput {
    width: 100%;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid #4a5568;
    border-radius: 6px;
    color: #e2e8f0;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    resize: vertical;
    padding: 1rem;
}

#debugOutput:focus {
    outline: none;
    border-color: #68d391;
}

/* Legacy debug styles */
.debug-panel.active {
    display: block;
}

.debug-toggle {
    cursor: pointer;
    user-select: none;
}

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

.debug-content {
    padding: 1rem;
    background: rgba(26, 32, 44, 0.6);
    border-top: 1px solid #4a5568;
    max-height: 300px;
    overflow-y: auto;
}

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

.debug-columns {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1.5rem;
}

.debug-column {
    background: rgba(45, 55, 72, 0.5);
    padding: 1rem;
    border-radius: 8px;
}

.debug-column-left {
    border-left: 3px solid #68d391;
}

.debug-column-center {
    border-left: 3px solid #4299e1;
}

.debug-column-right {
    border-left: 3px solid #ed8936;
}

.debug-section {
    margin-bottom: 1.5rem;
}

.debug-section:last-child {
    margin-bottom: 0;
}

.debug-section h4 {
    font-size: 1rem;
    font-weight: 600;
    color: #f7fafc;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #4a5568;
}

.debug-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(74, 85, 104, 0.3);
}

.debug-row:last-child {
    border-bottom: none;
}

.debug-row strong {
    font-size: 0.85rem;
    color: #cbd5e0;
    font-weight: 600;
    flex: 1;
}

.debug-row span {
    font-size: 0.8rem;
    color: #a0aec0;
    text-align: right;
    flex: 1;
    word-break: break-word;
    max-width: 150px;
}

#debugConsistencyStatus {
    font-weight: 600;
}

#debugLastError {
    color: #f56565;
}

#debugLastError.fatal-error {
    color: #feb2b2;
    background: rgba(229, 62, 62, 0.1);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-weight: 600;
}

/* Toggle Components */
.debug-toggle-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem;
    border-radius: 8px;
    transition: background-color 0.2s ease;
}

.debug-toggle-container input[type="checkbox"] {
    display: none;
}

.debug-toggle-slider {
    position: relative;
    width: 50px;
    height: 26px;
    background-color: #4a5568;
    border-radius: 26px;
    transition: background-color 0.2s ease;
    cursor: pointer;
}

.debug-toggle-slider:before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 22px;
    height: 22px;
    background-color: #e2e8f0;
    border-radius: 50%;
    transition: transform 0.2s ease;
}

.debug-toggle-slider:after {
    content: '';
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    left: 8px;
    font-size: 10px;
    color: #a0aec0;
}

.debug-toggle-container input[type="checkbox"]:checked + .debug-toggle-slider {
    background-color: #68d391;
}

.debug-toggle-container input[type="checkbox"]:checked + .debug-toggle-slider:before {
    transform: translateX(24px);
}

.debug-toggle-container:hover .debug-toggle-slider {
    background-color: #718096;
}

.debug-toggle-container input[type="checkbox"]:checked:hover + .debug-toggle-slider {
    background-color: #48bb78;
}

/* LLM Toggle */
.llm-toggle-container {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: rgba(45, 55, 72, 0.6);
    border: 1px solid #4a5568;
    border-radius: 10px;
    transition: all 0.2s ease;
    cursor: pointer;
    margin-bottom: 1rem;
}

.llm-toggle-container .toggle-text {
    font-size: 1rem;
    font-weight: 600;
    color: #e2e8f0;
    flex: 1;
    user-select: none;
}

.llm-toggle-container:hover {
    background: rgba(74, 85, 104, 0.7);
}

.llm-toggle-container input[type="checkbox"] {
    display: none;
}

.llm-toggle-slider {
    position: relative;
    width: 60px;
    height: 30px;
    background-color: #4a5568;
    border-radius: 30px;
    transition: background-color 0.3s ease;
    cursor: pointer;
    border: 2px solid #718096;
}

.llm-toggle-slider:before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 22px;
    height: 22px;
    background-color: #e2e8f0;
    border-radius: 50%;
    transition: transform 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.llm-toggle-slider:after {
    content: '✕';
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    right: 8px;
    font-size: 12px;
    color: #a0aec0;
    font-weight: bold;
}

.llm-toggle-container input[type="checkbox"]:checked + .llm-toggle-slider {
    background-color: #68d391;
    border-color: #38a169;
}

.llm-toggle-container input[type="checkbox"]:checked + .llm-toggle-slider:before {
    transform: translateX(26px);
}

.llm-toggle-container input[type="checkbox"]:checked + .llm-toggle-slider:after {
    content: '✓';
    left: 8px;
    right: auto;
    color: #f7fafc;
}

.llm-toggle-container.disabled {
    opacity: 0.6;
}

.llm-toggle-container.disabled .llm-toggle-slider {
    cursor: not-allowed;
}

/* Legacy selects */
.difficulty-select {
    background: rgba(45, 55, 72, 0.8);
    border: 1px solid #4a5568;
    border-radius: 8px;
    color: #e2e8f0;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.difficulty-select:focus {
    outline: none;
    border-color: #68d391;
    box-shadow: 0 0 0 2px rgba(104, 211, 145, 0.2);
}

.difficulty-select option {
    background: #2d3748;
    color: #e2e8f0;
    padding: 0.5rem;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: modalSlideIn 0.3s ease;
}

.modal-content {
    background: linear-gradient(135deg, #2d3748 0%, #4a5568 100%);
    border-radius: 12px;
    padding: 0;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    border: 1px solid #4a5568;
}

.modal-header {
    background: linear-gradient(135deg, #4a5568 0%, #2d3748 100%);
    padding: 1.5rem;
    border-bottom: 1px solid #4a5568;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h4 {
    font-size: 1.3rem;
    font-weight: 600;
    color: #f7fafc;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.close-modal {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #a0aec0;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.close-modal:hover {
    color: #e2e8f0;
    background: rgba(160, 174, 192, 0.1);
}

.modal-body {
    padding: 1.5rem;
}

.modal-body p {
    margin-bottom: 1rem;
    line-height: 1.6;
    color: #e2e8f0;
}

.modal-footer {
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

.error-modal .modal-header h4 {
    color: #feb2b2;
}

.success-modal .modal-header h4 {
    color: #9ae6b4;
}

/* Loading Spinner */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #68d391;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Responsive Design */
@media (max-width: 1200px) {
    .main-content {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .left-pane {
        order: 2;
    }
    
    .right-pane {
        order: 1;
    }
}

@media (max-width: 768px) {
    .app-header {
        padding: 1rem;
    }
    
    .app-header h1 {
        font-size: 2rem;
    }
    
    .main-content {
        padding: 1rem;
        gap: 1rem;
    }
    
    .right-pane {
        min-height: 600px;
    }
    
    .chess-board {
        min-height: 350px;
        max-height: calc(100vh - 350px);
    }
    
    .game-controls {
        flex-direction: column;
    }
    
    .status-bar {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .radio-group {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .debug-content {
        padding: 0.5rem;
    }
    
    .debug-columns {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .debug-column-left,
    .debug-column-center,
    .debug-column-right {
        border-left: none;
        border-top: 3px solid;
    }
    
    .debug-panel {
        left: 1rem;
        right: 1rem;
    }
    
    .debug-content {
        max-height: 200px;
    }
    
    .debug-toggle-container {
        justify-content: center;
    }
    
    .debug-toggle-slider {
        margin: 0 auto;
    }
    
    .board-header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .board-header-right {
        justify-content: center;
    }
    
    .difficulty-control {
        align-items: center;
    }
    
    .difficulty-control .difficulty-select {
        min-width: auto;
        width: 200px;
    }
    
    .game-mode-control {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .game-mode-select {
        min-width: auto;
    }
    
    .llm-toggle-container {
        flex-direction: column;
        text-align: center;
    }
    
    .llm-toggle-container .toggle-text {
        order: 2;
    }
}

@media (max-width: 1200px) and (min-width: 769px) {
    .debug-columns {
        grid-template-columns: 1fr 1fr;
    }
    
    .debug-column-center {
        grid-column: span 2;
    }
    
    .debug-column-right {
        grid-column: span 2;
    }
}

@media (max-width: 480px) {
    .app-header h1 {
        font-size: 1.5rem;
    }
    
    .subtitle {
        font-size: 0.9rem;
    }
    
    .main-content {
        padding: 0.5rem;
    }
    
    /* Further adjustments for very small screens */
    .right-pane {
        min-height: 500px;
        padding: 0.25rem;
    }
    
    .chess-board {
        width: calc(100% - 1rem); /* Slightly less padding on very small screens */
        min-height: 280px;
        max-height: calc(100vh - 300px);
    }
    
    .fallback-warning {
        width: calc(100% - 1rem); /* Match chess board width */
    }
    
    .modal-content {
        margin: 1rem;
        width: calc(100% - 2rem);
    }
}

/* Board Styles */
.chessboard-63f37 {
    border: 2px solid #4a5568;
    border-radius: 8px;
    width: 100% !important; /* Ensure chessboard library respects our container width */
    height: 100% !important; /* Ensure chessboard library respects our container height */
    max-width: none !important; /* Remove any maximum width constraints */
    min-width: unset !important; /* Remove any minimum width constraints */
    box-sizing: border-box !important; /* Ensure proper box model */
}

/* Scrollbar Styles */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(45, 55, 72, 0.5);
}

::-webkit-scrollbar-thumb {
    background: #4a5568;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #718096;
}

/* Animation for analysis */
#analyze-btn {
    transition: all 0.3s ease;
}

#analyze-btn:hover {
    box-shadow: 0 0 20px rgba(76, 81, 191, 0.4);
    transform: translateY(-2px);
}

#analyze-btn:disabled {
    opacity: 0.6;
    transform: none;
}

/* LLM Control Row Layout */
.llm-control-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 2rem;
}

.llm-toggle-section {
    flex-shrink: 0;
    margin-bottom: 0 !important;
}

/* Difficulty buttons - ensure single row */
.difficulty-group {
    gap: 0.3rem;
    flex-wrap: nowrap;
}

.difficulty-group .radio-option {
    min-width: 35px;
    padding: 0.4rem 0.6rem;
    font-size: 0.85rem;
}

/* LLM Toggle Enhanced Colors */
.llm-toggle-container {
    background: rgba(45, 55, 72, 0.6);
    border: 1px solid #4a5568;
    transition: all 0.3s ease;
}

.llm-toggle-container input[type="checkbox"]:checked {
    background: rgba(45, 55, 72, 0.6);
}

.llm-toggle-container:has(input[type="checkbox"]:checked) {
    background: rgba(45, 55, 72, 0.6);
    border-color: #4a5568;
}

.llm-toggle-slider {
    background-color: #ef4444;
    border: 2px solid #dc2626;
}

.llm-toggle-container input[type="checkbox"]:checked + .llm-toggle-slider {
    background-color: #22c55e;
    border-color: #16a34a;
}

/* Modern Toggle Switch */
.ai-coaching-control {
    display: flex;
    align-items: center;
    gap: 15px;
}

.modern-toggle {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 34px;
    cursor: pointer;
}

.modern-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #dc3545;
    transition: .4s;
    border-radius: 34px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 26px;
    width: 26px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

.modern-toggle input:checked + .toggle-slider {
    background-color: #28a745;
}

.modern-toggle input:focus + .toggle-slider {
    box-shadow: 0 0 1px #28a745;
}

.modern-toggle input:checked + .toggle-slider:before {
    transform: translateX(26px);
}

/* NEW: Chat Input Interface */
.chat-input-container {
    border-top: 1px solid #4a5568;
    background: rgba(26, 32, 44, 0.6);
    padding: 1rem 1.5rem;
}

.chat-input-wrapper {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.chat-input {
    flex: 1;
    background: rgba(45, 55, 72, 0.8);
    border: 1px solid #4a5568;
    border-radius: 8px;
    padding: 0.75rem 1rem;
    color: #e2e8f0;
    font-size: 0.95rem;
    transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease, height 0.15s ease;
    font-family: inherit;
    resize: none;
    overflow: hidden;
    min-height: 45px;
    max-height: 120px;
    line-height: 1.4;
}

.chat-input:focus {
    outline: none;
    border-color: #68d391;
    background: rgba(45, 55, 72, 0.95);
    box-shadow: 0 0 0 3px rgba(104, 211, 145, 0.1);
}

.chat-input::placeholder {
    color: #a0aec0;
}

.ask-coach-btn {
    background: #68d391;
    border: none;
    color: #1a202c;
    padding: 0.75rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 45px;
    height: 45px;
    font-size: 1rem;
}

.ask-coach-btn:hover:not(:disabled) {
    background: #48bb78;
    transform: translateY(-1px);
}

.ask-coach-btn:disabled {
    background: #4a5568;
    color: #718096;
    cursor: not-allowed;
    transform: none;
}

.ask-coach-btn:active:not(:disabled) {
    transform: translateY(0);
}

.chat-input-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.75rem;
    font-size: 0.85rem;
    color: #a0aec0;
}

.chat-input-status i {
    color: #68d391;
    font-size: 0.8rem;
}

.chat-input-status.warning {
    color: #f6ad55;
}

.chat-input-status.warning i {
    color: #f6ad55;
}

.chat-input-status.error {
    color: #f56565;
}

.chat-input-status.error i {
    color: #f56565;
}

/* User question message styling */
.chat-message.user-question-message .message-content {
    background: linear-gradient(135deg, #2d3748 0%, #4a5568 100%);
}

.chat-message.coach-answer .message-content {
    background: linear-gradient(135deg, #2a4365 0%, #2c5282 100%);
} 