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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 10px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

.container {
    max-width: 100%;
    margin: 0 auto;
    background: rgba(255, 255, 255, 0.95);
    padding: 20px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(10px);
}

h1 {
    text-align: center;
    color: #333;
    margin-bottom: 20px;
    font-size: 1.8rem;
    background: linear-gradient(45deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Status bar */
.status-bar {
    background: linear-gradient(135deg, #e0e0ff 0%, #d0d0ff 100%);
    padding: 12px;
    border-radius: 10px;
    margin: 15px 0;
    text-align: center;
    font-weight: bold;
    font-size: 1rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.5);
}

/* Stats bar */
.stats-bar {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    padding: 12px;
    border-radius: 10px;
    margin: 15px 0;
    display: flex;
    justify-content: space-around;
    flex-wrap: wrap;
    gap: 15px;
    font-size: 0.95rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.5);
}

/* Chess board */
.chess-board {
    width: 100%;
    max-width: 400px;
    margin: 20px auto;
    border: 3px solid #333;
    border-radius: 5px;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    aspect-ratio: 1/1;
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

/* Squares */
.square {
    width: 100%;
    aspect-ratio: 1/1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: pointer;
    transition: all 0.2s ease;
}

.square-light {
    background-color: #f0d9b5;
}

.square-dark {
    background-color: #b58863;
}

.square:hover {
    transform: scale(1.05);
    z-index: 2;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
}

.square.selected {
    background: linear-gradient(135deg, #ffff00 0%, #ffcc00 100%) !important;
    box-shadow: 0 0 15px rgba(255, 204, 0, 0.7);
}

.square.valid-move::after {
    content: '';
    position: absolute;
    width: 30%;
    height: 30%;
    background: radial-gradient(circle, #808080 0%, #606060 100%);
    border-radius: 50%;
    opacity: 0.8;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
}

.square.check {
    background: linear-gradient(135deg, #ff0000 0%, #cc0000 100%) !important;
    opacity: 0.7;
}

/* Piece */
.piece {
    width: 90%;
    height: 90%;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    transition: transform 0.2s ease;
}

.piece:hover {
    transform: scale(1.1);
}

/* Controls */
.controls {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin: 20px 0;
    flex-wrap: wrap;
}

button {
    padding: 12px 18px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    font-size: 0.95rem;
    min-width: 140px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
}

button::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: all 0.5s ease;
}

button:hover::after {
    left: 100%;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

button:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

#newGameBtn { 
    background: linear-gradient(135deg, #90EE90 0%, #32CD32 100%);
    color: #fff;
}

#recordBtn { 
    background: linear-gradient(135deg, #87CEEB 0%, #4682B4 100%);
    color: #fff;
}

#trainBtn { 
    background: linear-gradient(135deg, #FFA500 0%, #FF8C00 100%);
    color: #fff;
}

#switchSideBtn { 
    background: linear-gradient(135deg, #D3D3D3 0%, #A9A9A9 100%);
    color: #333;
}

#hintBtn { 
    background: linear-gradient(135deg, #FFFFE0 0%, #F0E68C 100%);
    color: #333;
}

/* Navigation controls - ПЕРЕМЕЩЕНЫ ВНИЗ */
.navigation-controls {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin: 20px 0;
    flex-wrap: wrap;
}

.nav-btn {
    min-width: 160px;
    padding: 14px 20px;
    font-size: 1rem;
    border-radius: 10px;
}

#prevMoveBtn {
    background: linear-gradient(135deg, #6A89CC 0%, #4A69BD 100%);
    color: white;
}

#nextMoveBtn {
    background: linear-gradient(135deg, #82CCDD 0%, #60A3BC 100%);
    color: white;
}

#startTrainingBtn {
    background: linear-gradient(135deg, #F8C471 0%, #F39C12 100%);
    color: white;
}

/* Blocked board */
.chess-board.blocked {
    opacity: 0.7;
    pointer-events: none;
    cursor: not-allowed;
    filter: grayscale(0.3);
}

/* Modal windows */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 15px;
    backdrop-filter: blur(5px);
}

.modal-content {
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    padding: 25px;
    border-radius: 15px;
    width: 100%;
    max-width: 450px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.5);
}

.modal-content h3 {
    margin-bottom: 20px;
    text-align: center;
    color: #333;
    font-size: 1.4rem;
}

.modal-content input {
    width: 100%;
    padding: 12px;
    margin: 10px 0;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.modal-content input:focus {
    border-color: #667eea;
    outline: none;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

.modal-buttons {
    display: flex;
    justify-content: space-between;
    margin-top: 20px;
    gap: 15px;
}

.modal-buttons button {
    flex: 1;
    min-width: auto;
    padding: 12px;
}

.trap-item {
    padding: 15px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 8px;
    margin: 5px 0;
}

.trap-item:hover {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    transform: translateX(5px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.trap-item strong {
    color: #333;
    font-size: 1.1rem;
}

.trap-item small {
    color: #666;
}

/* Медиа-запросы для мобильных устройств */
@media (max-width: 768px) {
    body {
        margin: 5px;
        padding: 5px;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    }
    
    .container {
        padding: 15px;
        margin: 5px;
    }
    
    h1 {
        font-size: 1.5rem;
        margin-bottom: 15px;
    }
    
    .status-bar {
        font-size: 0.9rem;
        padding: 10px;
    }
    
    .stats-bar {
        font-size: 0.9rem;
        padding: 10px;
        gap: 12px;
    }
    
    .controls {
        gap: 8px;
        margin: 15px 0;
    }
    
    button {
        padding: 10px 14px;
        font-size: 0.9rem;
        min-width: 120px;
    }
    
    .chess-board {
        max-width: 350px;
        margin: 15px auto;
    }
    
    .navigation-controls {
        gap: 10px;
        margin: 15px 0;
    }
    
    .nav-btn {
        min-width: 140px;
        padding: 12px 16px;
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 1.3rem;
    }
    
    .status-bar {
        font-size: 0.85rem;
    }
    
    .stats-bar {
        flex-direction: column;
        align-items: center;
        gap: 8px;
    }
    
    .controls {
        flex-direction: column;
        align-items: center;
    }
    
    button {
        width: 100%;
        max-width: 250px;
    }
    
    .navigation-controls {
        flex-direction: column;
        align-items: center;
    }
    
    .nav-btn {
        width: 100%;
        max-width: 250px;
    }
    
    .chess-board {
        max-width: 300px;
    }
    
    .modal-content {
        padding: 20px;
        margin: 10px;
    }
    
    .modal-buttons {
        flex-direction: column;
    }
}

/* Для очень маленьких экранов */
@media (max-width: 320px) {
    .chess-board {
        max-width: 280px;
    }
    
    button {
        font-size: 0.85rem;
        padding: 8px 12px;
    }
    
    .nav-btn {
        font-size: 0.85rem;
        padding: 10px 14px;
    }
}

/* Горизонтальная ориентация */
@media (max-height: 500px) and (orientation: landscape) {
    .container {
        display: flex;
        flex-direction: column;
        max-height: 100vh;
    }
    
    .chess-board {
        max-width: 300px;
        max-height: 300px;
    }
    
    .controls {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding: 8px 0;
    }
    
    button {
        min-width: 110px;
        flex-shrink: 0;
    }
    
    .navigation-controls {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding: 8px 0;
    }
    
    .nav-btn {
        min-width: 130px;
        flex-shrink: 0;
    }
}

/* Улучшение для iOS */
@supports (-webkit-touch-callout: none) {
    .chess-board {
        max-width: 95vw;
    }
    
    button {
        -webkit-tap-highlight-color: transparent;
    }
}

/* Улучшение скролла на мобильных */
.modal-content {
    -webkit-overflow-scrolling: touch;
}

/* Предотвращение масштабирования при фокусе на iOS */
input, textarea {
    font-size: 16px !important;
}

/* Добавляем в конец файла */

/* Стили для форм авторизации */
.auth-form {
    max-width: 400px;
    margin: 0 auto;
    padding: 20px;
}

.form-group {
    margin-bottom: 15px;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.form-group input:focus {
    border-color: #667eea;
    outline: none;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

.auth-btn {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.auth-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

.auth-links {
    text-align: center;
    margin-top: 20px;
}

.auth-links a {
    color: #667eea;
    text-decoration: none;
    margin: 0 10px;
}

.auth-links a:hover {
    text-decoration: underline;
}

.auth-message {
    text-align: center;
    margin-top: 15px;
    font-weight: bold;
}

/* Стили для панели пользователя */
.user-panel {
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    padding: 10px 15px;
    border-radius: 10px;
    margin: 10px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-actions {
    display: flex;
    gap: 10px;
}

.user-btn {
    padding: 8px 12px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
}

.admin-panel {
    background: linear-gradient(135deg, #ffebee 0%, #ffcdd2 100%);
    padding: 15px;
    border-radius: 10px;
    margin: 10px 0;
}

.admin-panel h3 {
    margin-bottom: 10px;
    color: #d32f2f;
}

/* Модальное окно для выбора типа ловушки */
.trap-type-selector {
    margin: 15px 0;
}

.trap-type-buttons {
    display: flex;
    gap: 10px;
    margin: 10px 0;
}

.trap-type-btn {
    flex: 1;
    padding: 10px;
    border: 2px solid #ddd;
    border-radius: 8px;
    background: white;
    cursor: pointer;
    transition: all 0.3s ease;
}

.trap-type-btn.selected {
    border-color: #667eea;
    background: #667eea;
    color: white;
}

.trap-type-btn:hover {
    border-color: #667eea;
}

.user-item {
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 15px;
    margin: 10px 0;
    background: white;
}

.user-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.admin-badge {
    background: #f44336;
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
}

.user-details {
    color: #666;
    margin-bottom: 10px;
}

.user-actions {
    display: flex;
    gap: 10px;
}

.user-actions button {
    padding: 5px 10px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.user-actions button.danger {
    background: #f44336;
    color: white;
}

.loading, .no-users {
    text-align: center;
    padding: 20px;
    color: #666;
}

/* Добавляем в конец файла */

.auth-panel {
    background: linear-gradient(135deg, #e8f5e8 0%, #c8e6c9 100%);
    padding: 10px 15px;
    border-radius: 10px;
    margin: 10px 0;
    display: block;
}

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

.auth-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

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

/* Стили для страницы управления пользователями */
.admin-users-page {
    max-width: 800px;
    margin: 0 auto;
}

.user-item {
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 15px;
    margin: 10px 0;
    background: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.user-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.admin-badge {
    background: #f44336;
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: bold;
}

.user-details {
    color: #666;
    margin-bottom: 10px;
    line-height: 1.4;
}

.user-actions {
    display: flex;
    gap: 10px;
}

.user-actions button {
    padding: 8px 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.user-actions button:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.user-actions button.danger {
    background: #f44336;
    color: white;
}

.user-actions button.primary {
    background: #2196f3;
    color: white;
}

.loading, .no-users {
    text-align: center;
    padding: 30px;
    color: #666;
    font-size: 1.1rem;
}

.admin-controls {
    margin-bottom: 20px;
}

.admin-controls a {
    display: inline-block;
    padding: 10px 15px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    text-decoration: none;
    border-radius: 6px;
    transition: all 0.3s ease;
}

.admin-controls a:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* Добавляем в конец файла */

.train-type-buttons {
    display: flex;
    gap: 15px;
    margin: 20px 0;
    justify-content: center;
}

.train-type-btn {
    padding: 20px 30px;
    border: 2px solid #ddd;
    border-radius: 10px;
    background: white;
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: bold;
    transition: all 0.3s ease;
    min-width: 120px;
}

.train-type-btn:hover {
    border-color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.train-type-btn.selected {
    border-color: #667eea;
    background: #667eea;
    color: white;
}

/* Улучшаем отображение количества ходов */
.trap-item small {
    color: #666;
    display: block;
    margin-top: 5px;
}

.trap-moves {
    font-weight: bold;
    color: #2196f3;
}

/* Стили для заголовков в списке ловушек */
.trap-list-header {
    font-size: 1.2rem;
    font-weight: bold;
    margin: 15px 0 10px 0;
    padding-bottom: 5px;
    border-bottom: 2px solid #667eea;
    color: #333;
}

/* Стили для элементов ловушек */
.trap-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.delete-trap-btn {
    background: #ff4757;
    color: white;
    border: none;
    border-radius: 50%;
    width: 25px;
    height: 25px;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.delete-trap-btn:hover {
    background: #ff3742;
    transform: scale(1.1);
}

.trap-item {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 15px;
    margin: 10px 0;
    background: white;
    transition: all 0.3s ease;
}

.trap-item:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
}

.trap-visibility {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #f0f0f0;
}

.trap-visibility label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: #666;
}

.trap-visibility input[type="checkbox"] {
    margin: 0;
}

/* Стили для статистики */
.statistics-content {
    margin: 15px 0;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    margin: 8px 0;
    padding: 8px;
    background: #f8f9fa;
    border-radius: 6px;
}

.stat-item span:first-child {
    font-weight: bold;
    color: #333;
}

.stat-item span:last-child {
    color: #667eea;
    font-weight: bold;
}

.no-stats {
    text-align: center;
    padding: 20px;
    color: #666;
    font-style: italic;
}

/* Стили для пользовательской статистики */
.user-stats-list {
    max-height: 400px;
    overflow-y: auto;
}

.stats-type-header {
    font-size: 1.1rem;
    font-weight: bold;
    margin: 15px 0 10px 0;
    padding-bottom: 5px;
    border-bottom: 2px solid #667eea;
    color: #333;
}

.user-stat-item {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 12px;
    margin: 8px 0;
    background: white;
    transition: all 0.3s ease;
}

.user-stat-item:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
}

.stat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.success-rate {
    background: #28a745;
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: bold;
}

.stat-details {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: #666;
}

.stat-details span {
    margin-right: 10px;
}

/* Кнопка статистики в списке ловушек */
.stats-btn {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 5px;
    border-radius: 4px;
    transition: all 0.3s ease;
    min-width: auto;
    width: auto;
}

.stats-btn:hover {
    background: #f0f0f0;
    transform: scale(1.1);
}

.trap-info {
    flex: 1;
}

.trap-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 8px;
    margin: 5px 0;
}

.trap-item:hover {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    transform: translateX(5px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

/* === Mobile-first unified button style & layout tweaks === */
:root{
  --primary:#4f46e5;
  --primary-contrast:#ffffff;
  --accent:#22c55e;
  --danger:#ef4444;
}

button {
  background: var(--primary);
  color: var(--primary-contrast);
}

button.primary{ background: var(--primary); color: var(--primary-contrast); }
button.secondary{ background: #e5e7eb; color:#111827; }
button.success{ background: var(--accent); color:#062412; }
button.danger{ background: var(--danger); color:#fff; }

/* Ensure toolbars wrap instead of overflowing */
.controls, .navigation-controls, .auth-buttons, .user-actions, .train-type-buttons, .trap-type-buttons, .modal-buttons {
  display:flex;
  flex-wrap:wrap;
  gap:8px;
}

/* Make overflowing button rows scrollable horizontally if needed */
.user-actions, .train-type-buttons, .trap-type-buttons {
  overflow-x:auto;
  -webkit-overflow-scrolling: touch;
}

/* Top bar */
.topbar{
  position: sticky;
  top: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: rgba(255,255,255,0.8);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(0,0,0,0.06);
}
.topbar .brand{
  font-weight: 700;
  letter-spacing: .3px;
}

/* Icon button */
.btn-icon{
  min-width: auto;
  padding: 8px 12px;
  line-height: 1;
  border-radius: 10px;
  font-size: 20px;
  background: #111827;
  color: #fff;
}

/* Reduce button min-width so they fit on phones */
@media (max-width: 600px){
  button { min-width: auto; padding: 10px 12px; font-size: .95rem; }
  input, select { font-size: 16px; } /* avoid iOS zoom */
  .container{ margin: 8px; }
  
  /* Collapsible menu behavior */
  body.menu-collapsible:not(.menu-open) #mobilePanels .controls,
  body.menu-collapsible:not(.menu-open) #mobilePanels .fen-pgn,
  body.menu-collapsible:not(.menu-open) #mobilePanels .navigation-controls,
  body.menu-collapsible:not(.menu-open) #mobilePanels .trap-type-selector,
  body.menu-collapsible:not(.menu-open) #mobilePanels .user-panel,
  body.menu-collapsible:not(.menu-open) #mobilePanels .auth-panel,
  body.menu-collapsible:not(.menu-open) #mobilePanels .stats-bar,
  body.menu-collapsible:not(.menu-open) #mobilePanels .admin-panel {
     display: none !important;
  }
  
  /* Make board scale to screen width */
  .chess-board{
    max-width: 100%;
    width: 100%;
    height: auto;
    aspect-ratio: 1/1;
  }

  /* Space for a thumb-friendly bottom area */
  .status-bar { position: sticky; bottom: 0; background: rgba(255,255,255,0.9); backdrop-filter: blur(6px); }
}

/* Slightly tighter gaps overall */
.container { gap: 12px; }
.fen-pgn h3 { margin-bottom: 8px; }


/* Mobile-friendly trap list styling */
#trapList, #userTrapList{
  display:flex;
  flex-direction:column;
  gap:8px;
}
#trapList .trap-item, #userTrapList .trap-item{
  flex-wrap:wrap;
  word-break:break-word;
  white-space:normal;
  overflow:hidden;
}
#trapList .trap-info, #userTrapList .trap-info{
  flex:1 1 100%;
  font-size:0.95rem;
  line-height:1.3;
  overflow-wrap:break-word;
}


/* Ensure train type buttons visible */
.train-type-btn, .trap-type-btn{
  background: var(--primary);
  color: #fff;
  border-radius:8px;
  padding:12px 16px;
  min-width:120px;
  text-align:center;
  font-weight:600;
}
.train-type-btn:hover, .trap-type-btn:hover{
  background: #4338ca;
}


/* Bigger trap list items for touch devices */
#trapList .trap-item, #userTrapList .trap-item{
  padding:16px;
  font-size:1rem;
  border:1px solid #e5e7eb;
  border-radius:10px;
  background:#fafafa;
}
#trapList .trap-item:hover, #userTrapList .trap-item:hover{
  background:#f0f0f0;
}


/* Restyle trap delete buttons to be more minimal */
.trap-item button.delete-trap{
  background:#ef4444;
  color:#fff;
  border:none;
  border-radius:6px;
  padding:6px 10px;
  font-size:0.85rem;
  font-weight:600;
  cursor:pointer;
  transition: background 0.2s ease;
}
.trap-item button.delete-trap:hover{
  background:#dc2626;
}
.trap-item button.delete-trap:active{
  background:#b91c1c;
}


/* Trash icon delete buttons */
.trap-item button.delete-trap{
  background:none;
  border:none;
  color:#ef4444;
  font-size:1.2rem;
  cursor:pointer;
  padding:4px;
  display:flex;
  align-items:center;
  justify-content:center;
}
.trap-item button.delete-trap:hover{
  color:#dc2626;
}
.trap-item button.delete-trap:active{
  color:#b91c1c;
}


/* Override delete button: plain trash icon, no background oval */
.delete-trap-btn{
  background:none !important;
  border:none !important;
  padding:4px !important;
  margin:0;
  font-size:1.2rem !important;
  line-height:1;
  color:#ef4444 !important;
  border-radius:0 !important;
}
.delete-trap-btn:hover{
  color:#dc2626 !important;
}


/* Final cleanup: only the trash icon remains, no rect, no shadow */
.delete-trap-btn{
  all: unset;
  cursor: pointer;
  font-size: 1.2rem;
  color: #ef4444;
  line-height: 1;
}
.delete-trap-btn:hover{
  color:#dc2626;
}


/* Arrange trap items in a row: name left, delete icon right */
.trap-item{
  display:flex;
  justify-content:space-between;
  align-items:center;
}
.trap-item .trap-info{
  flex:1;
  margin-right:8px;
}
.trap-item .delete-trap-btn{
  flex-shrink:0;
}


/* Force trap items into two-column grid: text left, icon right */
.trap-item{
  display:grid !important;
  grid-template-columns: 1fr auto;
  align-items:center;
  gap:8px;
  width:100%;
}
.trap-item .trap-info{
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}
.trap-item .delete-trap-btn{
  justify-self:end;
}
