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

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    direction: rtl;
}

.screen {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

.container {
    background: white;
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    width: 90%;
    max-width: 800px;
}

h1 {
    color: #333;
    margin-bottom: 30px;
    font-size: 2.5em;
    text-align: center;
}

/* עיצוב הגדרות שחקן */
.player-setup {
    background: #f8f9fa;
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 25px;
    text-align: center;
}

.name-input-container {
    display: flex;
    gap: 10px;
    justify-content: center;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.name-input-container label {
    font-weight: bold;
    color: #555;
    font-size: 1.1em;
}

.name-input-container input {
    padding: 10px 15px;
    border: 2px solid #dee2e6;
    border-radius: 25px;
    font-size: 1em;
    width: 200px;
    text-align: center;
    transition: border-color 0.3s;
    font-family: 'Arial', sans-serif;
}

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

.btn-save {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 10px 25px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 1em;
    transition: transform 0.2s, box-shadow 0.2s;
    font-family: 'Arial', sans-serif;
}

.btn-save:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.rating-display {
    margin: 10px 0;
    font-size: 1.2em;
}

.rating-label {
    color: #666;
    margin-left: 10px;
}

.rating-value {
    font-weight: bold;
    color: #667eea;
    font-size: 1.3em;
}

.rating-icon {
    margin-right: 5px;
    font-size: 1.2em;
}

.display-name {
    color: #28a745;
    font-weight: bold;
    font-size: 1.1em;
    min-height: 24px;
}

/* עיצוב לובי */
.create-room {
    text-align: center;
    margin-bottom: 30px;
}

.btn-create {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 15px 40px;
    font-size: 1.3em;
    border-radius: 30px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
    font-family: 'Arial', sans-serif;
}

.btn-create:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.6);
}

.rooms-container h2 {
    color: #555;
    margin-bottom: 20px;
    font-size: 1.8em;
}

.rooms-list {
    display: grid;
    gap: 15px;
}

.no-rooms {
    text-align: center;
    color: #999;
    font-size: 1.2em;
    padding: 40px;
    background: #f8f9fa;
    border-radius: 10px;
}

.room-card {
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 15px;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s;
}

.room-card:hover:not(.full) {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    border-color: #667eea;
}

.room-card.full {
    opacity: 0.6;
}

.room-info {
    flex: 1;
}

.room-id {
    font-size: 1.2em;
    font-weight: bold;
    color: #333;
    margin-bottom: 5px;
}

.room-players {
    color: #666;
    font-size: 0.9em;
}

.room-status {
    padding: 8px 20px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 0.9em;
    margin: 0 15px;
}

.status-waiting {
    background: #fff3cd;
    color: #856404;
}

.status-playing {
    background: #d4edda;
    color: #155724;
}

.btn-join {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 10px 25px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 1em;
    transition: transform 0.2s;
    font-family: 'Arial', sans-serif;
}

.btn-join:hover:not(:disabled) {
    transform: scale(1.05);
}

.btn-join:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* עיצוב משחק */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    gap: 10px;
    flex-wrap: wrap;
}

.btn-back, .btn-copy {
    background: #f8f9fa;
    border: 2px solid #dee2e6;
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.2s;
    font-family: 'Arial', sans-serif;
    white-space: nowrap;
}

.btn-back:hover, .btn-copy:hover {
    background: #e9ecef;
    border-color: #667eea;
}

.btn-copy {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
}

.room-code {
    font-size: 0.9em;
    color: #666;
    background: #f8f9fa;
    padding: 5px 10px;
    border-radius: 10px;
}

.players-info {
    display: flex;
    justify-content: space-around;
    align-items: center;
    margin: 20px 0;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 15px;
}

.player-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.player-color {
    font-size: 1.5em;
}

.player-name {
    font-weight: bold;
    color: #333;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ccc;
}

.status-dot.connected {
    background: #28a745;
    animation: pulse 2s infinite;
}

.vs {
    font-size: 1.5em;
    font-weight: bold;
    color: #667eea;
}

.game-info {
    margin-bottom: 20px;
}

.player-turn {
    font-size: 1.3em;
    font-weight: bold;
    color: #555;
    margin-bottom: 10px;
}

.game-status {
    font-size: 1.1em;
    color: #e74c3c;
    min-height: 25px;
}

.board-container {
    display: inline-block;
    margin: 20px 0;
}

.board-labels {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.col-labels {
    display: grid;
    grid-template-columns: repeat(8, 60px);
    gap: 0;
    margin-bottom: 2px;
    direction: ltr;
}
.col-labels span {
    text-align: center;
    font-weight: bold;
    color: #333;
    font-size: 0.9em;
}

.board-wrapper {
    display: flex;
    gap: 5px;
}

.row-labels {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
}

.row-labels span {
    height: 60px;
    display: flex;
    align-items: center;
    font-weight: bold;
    color: #333;
    font-size: 0.9em;
    padding: 0 5px;
}

.board {
    display: grid;
    grid-template-columns: repeat(8, 60px);
    grid-template-rows: repeat(8, 60px);
    border: 3px solid #333;
    border-radius: 5px;
    overflow: hidden;
    transition: transform 0.3s ease;
    direction: ltr;
}
.cell {
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.3s ease;
    user-select: none;
}

.cell.white {
    background-color: #f0d9b5;
}

.cell.black {
    background-color: #b58863;
}

.cell.selected {
    background-color: #ffff00 !important;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.3);
}

.cell.possible-move {
    background-color: #90ee90 !important;
}

.captured-pieces {
    display: flex;
    justify-content: space-around;
    margin: 20px 0;
    font-size: 1.1em;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 10px;
}

.notification {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #28a745;
    color: white;
    padding: 15px 30px;
    border-radius: 25px;
    font-weight: bold;
    display: none;
    z-index: 1000;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}

.notification.show {
    display: block;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        transform: translateX(-50%) translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}

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

/* התאמה למובייל */
@media (max-width: 768px) {
    .container {
        padding: 20px;
        width: 95%;
    }
    
    h1 {
        font-size: 1.8em;
    }
    
    .board {
        grid-template-columns: repeat(8, 40px);
        grid-template-rows: repeat(8, 40px);
    }
    
    .cell {
        width: 40px;
        height: 40px;
        font-size: 30px;
    }
    
    .col-labels {
        grid-template-columns: repeat(8, 40px);
    }
    
    .row-labels span {
        height: 40px;
    }
    
    .players-info {
        flex-direction: column;
        gap: 10px;
    }
    
    .game-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .name-input-container {
        flex-direction: column;
    }
    
    .name-input-container input {
        width: 100%;
    }
}

/* עיצוב מידע מארח בחדרים */
.room-hosts {
    margin-top: 8px;
    font-size: 0.85em;
}

.host-info {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 3px;
    background: rgba(102, 126, 234, 0.1);
    padding: 3px 8px;
    border-radius: 10px;
}

.host-label {
    color: #888;
    font-weight: bold;
}

.host-name {
    color: #333;
    font-weight: bold;
}

.host-rating {
    color: #667eea;
    font-weight: bold;
}

/* וידוא שהלוח במרכז */
.board-container {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
}

/* עיצוב הודעת שגיאה בתיבת שם */
#playerName.error {
    border-color: #dc3545;
    animation: shake 0.5s;
}

#playerName.success {
    border-color: #28a745;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

/* שיפור מרכז המשחק */
#gameScreen {
    display: flex;
    justify-content: center;
    align-items: center;
}

#gameScreen .container {
    margin: 0 auto;
}

/* עיצוב חלון קופץ להכנסת שם */
.popup-overlay {
    animation: fadeIn 0.3s ease;
}

.popup-overlay > div {
    animation: slideIn 0.3s ease;
}

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

@keyframes slideIn {
    from { 
        transform: translateY(-50px);
        opacity: 0;
    }
    to { 
        transform: translateY(0);
        opacity: 1;
    }
}

/* עיצוב חלון קופץ */
#popupNameInput:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

#popupSubmit:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
    transition: all 0.2s;
}

/* עיצוב התראת שח */
.notification.check-alert {
    background: #ff6b6b !important;
    animation: pulse-notification 1s infinite;
    font-size: 1.3em;
}

@keyframes pulse-notification {
    0%, 100% { 
        transform: translateX(-50%) scale(1);
        box-shadow: 0 5px 15px rgba(255, 107, 107, 0.4);
    }
    50% { 
        transform: translateX(-50%) scale(1.05);
        box-shadow: 0 8px 25px rgba(255, 107, 107, 0.6);
    }
}

/* סימון מלך בשח */
.cell.in-check {
    background-color: #ff4444 !important;
    animation: check-pulse 0.5s infinite;
    box-shadow: inset 0 0 20px rgba(255, 0, 0, 0.8);
}

@keyframes check-pulse {
    0%, 100% { 
        background-color: #ff4444;
    }
    50% { 
        background-color: #ff0000;
    }
}

/* עיצוב כפתורי פעולות משחק - גודל אחיד */
.game-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin: 15px 0;
    flex-wrap: wrap;
}

.btn-action {
    padding: 12px 20px;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-size: 1em;
    font-family: 'Arial', sans-serif;
    transition: transform 0.2s, box-shadow 0.2s;
    min-width: 180px;
    flex: 1;
    max-width: 220px;
    text-align: center;
    white-space: nowrap;
}

.btn-action:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

.btn-resign {
    background: #dc3545;
    color: white;
}

.btn-resign:hover {
    background: #c82333;
}

.btn-draw {
    background: #ffc107;
    color: #333;
}

.btn-draw:hover {
    background: #e0a800;
}

.btn-undo {
    background: #17a2b8;
    color: white;
}

.btn-undo:hover {
    background: #138496;
}

/* חלון אישור */
.confirm-dialog {
    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;
}

.confirm-content {
    background: white;
    border-radius: 15px;
    padding: 30px;
    text-align: center;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}

.confirm-content p {
    font-size: 1.2em;
    color: #333;
    margin-bottom: 20px;
}

.confirm-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.btn-confirm-yes {
    background: #28a745;
    color: white;
    border: none;
    padding: 10px 30px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 1em;
    font-family: 'Arial', sans-serif;
}

.btn-confirm-no {
    background: #dc3545;
    color: white;
    border: none;
    padding: 10px 30px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 1em;
    font-family: 'Arial', sans-serif;
}

.btn-confirm-yes:hover, .btn-confirm-no:hover {
    opacity: 0.9;
}

/* כפתורים בראש המשחק */
.game-header .btn-back,
.game-header .btn-copy {
    flex: 1;
    max-width: 220px;
    text-align: center;
    white-space: nowrap;
}


/* ============ מסך יצירת משחק + שעוני משחק ============ */
.hidden { display: none !important; }

.create-game-panel {
    max-width: 520px;
    margin: 0 auto 30px;
    padding: 22px;
    border-radius: 18px;
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    box-shadow: 0 8px 24px rgba(0,0,0,0.10);
    text-align: right;
}

.create-game-panel h2 {
    color: #333;
    text-align: center;
    margin-bottom: 18px;
    font-size: 1.6em;
}

.setting-row { margin-bottom: 20px; }

.setting-row label {
    display: block;
    color: #444;
    font-size: 1.1em;
    margin-bottom: 10px;
}

.setting-row input[type="range"] {
    width: 100%;
    accent-color: #667eea;
    cursor: pointer;
}

.setting-help {
    color: #777;
    font-size: 0.9em;
    margin-top: 6px;
    line-height: 1.4;
}

.create-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 12px;
}

.btn-confirm-create,
.btn-cancel-create {
    border: none;
    padding: 12px 28px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 1.05em;
    font-weight: bold;
    font-family: 'Arial', sans-serif;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-confirm-create {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.35);
}

.btn-cancel-create {
    background: #e9ecef;
    color: #333;
}

.btn-confirm-create:hover,
.btn-cancel-create:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.18);
}

.room-time-control {
    color: #667eea;
    font-weight: bold;
    margin-top: 6px;
    font-size: 0.9em;
}

.time-control-info {
    text-align: center;
    color: #555;
    background: #f8f9fa;
    border-radius: 12px;
    padding: 8px 12px;
    margin: -8px 0 15px;
    font-weight: bold;
}

.player-clock {
    display: inline-block;
    min-width: 74px;
    text-align: center;
    padding: 6px 10px;
    border-radius: 12px;
    background: #f1f3f5;
    color: #333;
    font-weight: bold;
    direction: ltr;
    border: 2px solid transparent;
}

.player-clock.active-clock {
    background: #e7f5ff;
    color: #0b7285;
    border-color: #15aabf;
    box-shadow: 0 0 10px rgba(21, 170, 191, 0.35);
}

.player-clock.low-time {
    background: #fff3cd;
    color: #856404;
    border-color: #ffc107;
}

.player-clock.danger-time {
    background: #f8d7da;
    color: #842029;
    border-color: #dc3545;
    animation: pulse-clock 0.8s infinite;
}

@keyframes pulse-clock {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

@media (max-width: 768px) {
    .create-game-panel { padding: 16px; }
    .player-clock {
        min-width: 68px;
        padding: 5px 8px;
        font-size: 0.95em;
    }
    .create-actions button { width: 100%; }
}


/* עיצוב בחירת משחק מדורג / לא מדורג */
.rated-setting { background: rgba(102, 126, 234, 0.08); border: 1px solid rgba(102, 126, 234, 0.18); border-radius: 14px; padding: 12px; }
.rated-toggle-label { display: flex !important; align-items: center; gap: 10px; cursor: pointer; font-weight: bold; color: #333; }
.rated-toggle-label input[type="checkbox"] { width: 20px; height: 20px; accent-color: #667eea; cursor: pointer; }
.room-game-type { display: inline-block; margin-top: 6px; padding: 4px 10px; border-radius: 999px; font-size: 0.85em; font-weight: bold; }
.room-game-type.rated { background: #e7f5ff; color: #1864ab; }
.room-game-type.unrated { background: #f1f3f5; color: #495057; }
.game-meta-row { display: flex; justify-content: center; align-items: center; gap: 10px; flex-wrap: wrap; margin: 10px 0 15px; }
.game-type-info { display: inline-block; background: #e7f5ff; color: #1864ab; border-radius: 999px; padding: 8px 14px; font-weight: bold; border: 1px solid #a5d8ff; }
.game-type-info.unrated { background: #f1f3f5; color: #495057; border-color: #dee2e6; }


/* עיצוב בחירת צבע במסך יצירת משחק */
.color-choice-setting {
    background: rgba(118, 75, 162, 0.08);
    border: 1px solid rgba(118, 75, 162, 0.18);
    border-radius: 14px;
    padding: 12px;
}

.color-choice-select {
    width: 100%;
    padding: 12px 14px;
    border-radius: 14px;
    border: 2px solid #dee2e6;
    background: white;
    color: #333;
    font-size: 1.05em;
    font-family: 'Arial', sans-serif;
    cursor: pointer;
}

.color-choice-select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.12);
}

.room-color-choice {
    display: inline-block;
    margin-top: 6px;
    margin-right: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.85em;
    font-weight: bold;
    background: #fff3bf;
    color: #7c5c00;
}

.game-color-info {
    display: inline-block;
    background: #fff3bf;
    color: #7c5c00;
    border-radius: 999px;
    padding: 8px 14px;
    font-weight: bold;
    border: 1px solid #ffe066;
}


/* עיצוב משחק מול בוט Stockfish */
.bot-setting {
    background: rgba(40, 167, 69, 0.08);
    border: 1px solid rgba(40, 167, 69, 0.18);
    border-radius: 14px;
    padding: 12px;
}

.bot-difficulty-wrap {
    margin-top: 12px;
}

.bot-difficulty-wrap label {
    margin-bottom: 8px;
    font-weight: bold;
}

.room-bot-type {
    display: inline-block;
    margin-top: 6px;
    margin-right: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.85em;
    font-weight: bold;
    background: #e6fcf5;
    color: #087f5b;
}

.game-bot-info {
    display: inline-block;
    background: #e6fcf5;
    color: #087f5b;
    border-radius: 999px;
    padding: 8px 14px;
    font-weight: bold;
    border: 1px solid #96f2d7;
}


/* ===== Promotion modal + last move highlight ===== */
.promotion-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    padding: 20px;
}

.promotion-modal.hidden {
    display: none !important;
}

.promotion-modal-content {
    width: min(92vw, 430px);
    background: #ffffff;
    color: #1f2937;
    border-radius: 18px;
    padding: 22px 18px;
    text-align: center;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
    border: 2px solid rgba(37, 99, 235, 0.15);
}

.promotion-modal-content h3 {
    margin: 0 0 8px;
    font-size: 24px;
}

.promotion-modal-content p {
    margin: 0 0 16px;
    color: #4b5563;
}

.promotion-options {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.promotion-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 94px;
    border-radius: 16px;
    border: 2px solid #dbeafe;
    background: #eff6ff;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
    font-weight: 700;
}

.promotion-option:hover {
    transform: translateY(-2px);
    border-color: #60a5fa;
    box-shadow: 0 8px 20px rgba(37, 99, 235, 0.18);
}

.promotion-piece {
    font-size: 42px;
    line-height: 1;
}

.promotion-label {
    font-size: 15px;
}

.cell.last-move {
    position: relative;
    box-shadow: inset 0 0 0 3px #3b82f6;
}

.cell.last-move::after {
    content: '';
    position: absolute;
    inset: 3px;
    border: 2px solid rgba(147, 197, 253, 0.95);
    border-radius: 6px;
    pointer-events: none;
}


/* =========================================================
   תיקון חזק לקפיצות מסך באמצע משחק שחמט
   להדביק בסוף style.css
   ========================================================= */

html,
body {
    overflow-x: hidden;
}

/* בזמן משחק בלבד: לא משתמשים במרכוז אנכי של כל העמוד */
body.game-active {
    display: block !important;
    align-items: initial !important;
    justify-content: initial !important;
    min-height: 100vh;
}

body.game-active #lobbyScreen {
    display: none !important;
}

body.game-active #gameScreen {
    display: flex !important;
    align-items: flex-start !important;
    justify-content: center !important;
    min-height: 100vh;
    width: 100%;
    padding: 12px 0 28px;
}

body.game-active #gameScreen .container {
    margin: 0 auto !important;
    align-self: flex-start !important;
}

/* שריון גובה לאזורים שמשתנים בזמן משחק */
body.game-active #gameScreen h1 {
    margin-bottom: 18px;
    line-height: 1.15;
}

body.game-active #gameScreen .game-header {
    min-height: 44px;
}

body.game-active #gameScreen .players-info {
    min-height: 88px;
    overflow: hidden;
}

body.game-active #gameScreen .player-info {
    min-width: 230px;
    min-height: 48px;
}

body.game-active #gameScreen .player-name {
    display: inline-block;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

body.game-active #gameScreen .game-meta-row {
    min-height: 44px;
    overflow: hidden;
}

body.game-active #gameScreen .game-info {
    min-height: 62px;
    margin-bottom: 10px;
    overflow: hidden;
}

body.game-active #gameScreen .player-turn {
    min-height: 28px;
    line-height: 28px;
    margin-bottom: 4px;
}

body.game-active #gameScreen .game-status {
    min-height: 28px;
    line-height: 28px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

body.game-active #gameScreen .game-actions {
    min-height: 56px;
    margin: 10px 0;
}

body.game-active #gameScreen .board-container {
    margin: 12px 0;
    min-height: 520px;
    align-items: flex-start !important;
}

body.game-active #gameScreen .captured-pieces {
    min-height: 50px;
    overflow: hidden;
}

/* במובייל הלוח קטן יותר, אז גם גובה האזור קטן יותר */
@media (max-width: 768px) {
    body.game-active #gameScreen {
        padding-top: 6px;
    }

    body.game-active #gameScreen .container {
        padding: 14px;
        width: 96%;
    }

    body.game-active #gameScreen h1 {
        margin-bottom: 12px;
    }

    body.game-active #gameScreen .players-info {
        min-height: 170px;
    }

    body.game-active #gameScreen .player-info {
        width: 100%;
        min-width: 0;
        justify-content: center;
    }

    body.game-active #gameScreen .board-container {
        min-height: 360px;
        margin: 8px 0;
    }

    body.game-active #gameScreen .game-status {
        white-space: normal;
    }
}
.lobby-subtitle {
    text-align: center;
    margin: 12px 0 24px;
    color: #666;
    font-size: 16px;
    font-weight: 500;
}
.translate-note {
    text-align: center;
    margin-bottom: 12px;
    color: #777;
    font-size: 14px;
}

/* ===== חלון ניתוח משחק / Replay ===== */
.analysis-panel {
    margin: 18px auto 10px;
    padding: 16px;
    border-radius: 18px;
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    box-shadow: 0 8px 24px rgba(0,0,0,0.08);
    max-width: 680px;
    width: 100%;
}
.analysis-header { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.analysis-header h2 { margin: 0; color: #333; font-size: 1.35em; }
.analysis-status { background: #e7f5ff; color: #1864ab; border: 1px solid #a5d8ff; border-radius: 999px; padding: 6px 12px; font-weight: bold; font-size: 0.92em; }
.replay-controls { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.btn-replay { border: none; border-radius: 999px; padding: 9px 14px; cursor: pointer; background: #e9ecef; color: #333; font-weight: bold; font-family: 'Arial', sans-serif; transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s; }
.btn-replay:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,0.14); }
.btn-replay:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-live { background: linear-gradient(135deg, #dc3545 0%, #ff6b6b 100%); color: white; }
.btn-continue { background: linear-gradient(135deg, #28a745 0%, #51cf66 100%); color: white; }
.btn-analysis-continue { background: linear-gradient(135deg, #6741d9 0%, #9775fa 100%); color: white; }
.move-history-list { direction: ltr; text-align: left; display: grid; grid-template-columns: repeat(auto-fit, minmax(145px, 1fr)); gap: 8px; max-height: 220px; overflow-y: auto; padding: 8px; background: white; border-radius: 14px; border: 1px solid #dee2e6; }
.move-item { border: 1px solid #e9ecef; background: #ffffff; border-radius: 12px; padding: 8px 10px; cursor: pointer; font-weight: bold; color: #333; transition: background 0.15s, border-color 0.15s, transform 0.15s; }
.move-item:hover { background: #eff6ff; border-color: #93c5fd; transform: translateY(-1px); }
.move-item.active { background: #dbeafe; border-color: #3b82f6; color: #1d4ed8; }
.move-item .move-number { color: #667eea; margin-right: 6px; }
.no-moves { direction: rtl; text-align: center; color: #888; padding: 14px; grid-column: 1 / -1; }
body.game-active #gameScreen .analysis-panel { min-height: 120px; }
@media (max-width: 768px) {
    .analysis-panel { padding: 12px; }
    .replay-controls { gap: 6px; }
    .btn-replay { padding: 8px 10px; font-size: 0.9em; }
    .move-history-list { grid-template-columns: repeat(2, minmax(0, 1fr)); max-height: 180px; }
}


/* ===== שמירה / פתיחה של קובץ משחק ===== */
.game-file-controls {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    margin: 10px 0 14px;
}

.btn-file-game {
    border: none;
    border-radius: 999px;
    padding: 10px 18px;
    cursor: pointer;
    font-family: 'Arial', sans-serif;
    font-weight: bold;
    background: #f1f3f5;
    color: #343a40;
    border: 1px solid #dee2e6;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.btn-pgn-game {
    background: #e7f5ff;
    color: #1864ab;
    border-color: #a5d8ff;
}

.btn-file-game:hover {
    transform: translateY(-1px);
    background: #e9ecef;
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}

@media (max-width: 768px) {
    .game-file-controls {
        flex-direction: column;
    }
    .btn-file-game {
        width: 100%;
    }
}


.btn-import-pgn-game {
    background: #e6fcf5;
    color: #087f5b;
    border-color: #96f2d7;
}
