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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.container {
    max-width: 1200px;
    width: 100%;
}

/* מסך לובי */
.lobby-screen, .game-screen {
    background: white;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.lobby-card {
    text-align: center;
}

.lobby-card h1 {
    color: #333;
    margin-bottom: 10px;
    font-size: 2.5em;
}

.lobby-card p {
    color: #666;
    margin-bottom: 30px;
    font-size: 1.1em;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 15px 40px;
    font-size: 1.2em;
    border-radius: 50px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.2);
}

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

.waiting-status {
    margin-top: 30px;
    padding: 20px;
    background: #f0f0f0;
    border-radius: 10px;
}

.spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.hidden {
    display: none;
}

/* מסך משחק */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.game-header h2 {
    color: #333;
    margin: 0;
}

.turn-indicator {
    background: #667eea;
    color: white;
    padding: 8px 20px;
    border-radius: 25px;
    font-weight: bold;
}

.player-info {
    display: flex;
    gap: 15px;
}

.player {
    padding: 5px 15px;
    border-radius: 20px;
    background: #f0f0f0;
}

.black-player {
    border-right: 3px solid #333;
}

.red-player {
    border-right: 3px solid #e74c3c;
}

.btn-leave {
    background: #e74c3c;
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: 20px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-leave:hover {
    background: #c0392b;
}

#boardCanvas {
    display: block;
    margin: 20px auto;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    cursor: pointer;
}

.game-messages {
    margin-top: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 10px;
    max-height: 200px;
    overflow-y: auto;
}

.game-messages h3 {
    margin-bottom: 10px;
    color: #333;
    font-size: 1em;
}

#messagesList {
    font-size: 0.9em;
    color: #666;
}

.message {
    padding: 5px 0;
    border-bottom: 1px solid #e0e0e0;
}

.message.error {
    color: #e74c3c;
}

.message.success {
    color: #27ae60;
}

.message.warning {
    color: #f39c12;
    font-weight: bold;
    background: #fff3e0;
    padding: 5px 10px;
    border-radius: 5px;
    margin: 5px 0;
}

@media (max-width: 768px) {
    .game-header {
        flex-direction: column;
        text-align: center;
    }
    
    #boardCanvas {
        width: 100%;
        height: auto;
    }
}

/* לובי חדש */
.lobby-actions {
    margin: 30px 0;
}

.create-table-section, .join-table-section {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin: 15px 0;
}

.create-table-section input, .join-table-section input {
    padding: 12px 20px;
    font-size: 1em;
    border: 2px solid #e0e0e0;
    border-radius: 25px;
    outline: none;
    transition: border-color 0.2s;
}

.create-table-section input:focus, .join-table-section input:focus {
    border-color: #667eea;
}

/* כפתור משחק נגד מחשב */
.bot-game-section {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin: 15px 0;
}

.btn-bot {
    background: linear-gradient(135deg, #f39c12 0%, #e67e22 100%);
    color: white;
    border: none;
    padding: 12px 30px;
    font-size: 1em;
    border-radius: 50px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-bot:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.2);
}

.difficulty-select {
    padding: 12px 20px;
    font-size: 1em;
    border: 2px solid #e0e0e0;
    border-radius: 25px;
    background: white;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s;
}

.difficulty-select:focus {
    border-color: #f39c12;
}

.divider {
    text-align: center;
    color: #999;
    margin: 20px 0;
    position: relative;
}

.divider::before, .divider::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 40%;
    height: 1px;
    background: #e0e0e0;
}

.divider::before {
    left: 0;
}

.divider::after {
    right: 0;
}

.btn-secondary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 30px;
    font-size: 1em;
    border-radius: 50px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.2);
}

.tables-list {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #e0e0e0;
}

.tables-list h3 {
    margin-bottom: 15px;
    color: #333;
}

.table-item {
    background: #f8f9fa;
    padding: 15px;
    margin: 10px 0;
    border-radius: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.2s;
}

.table-item:hover {
    background: #e9ecef;
}

.table-info {
    display: flex;
    gap: 20px;
}

.table-code {
    font-family: monospace;
    font-size: 1.2em;
    font-weight: bold;
    color: #667eea;
}

.table-host {
    color: #666;
}

.join-table-btn {
    background: #27ae60;
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: 20px;
    cursor: pointer;
    transition: background 0.2s;
}

.join-table-btn:hover {
    background: #219a52;
}

.empty-tables {
    text-align: center;
    color: #999;
    padding: 30px;
}

/* מסך המתנה בשולחן */
.table-waiting-screen {
    background: white;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    max-width: 500px;
    margin: 0 auto;
}

.waiting-card {
    text-align: center;
}

.waiting-card h2 {
    color: #333;
    margin-bottom: 20px;
}

.table-info {
    background: #f0f0f0;
    padding: 15px;
    border-radius: 10px;
    margin: 20px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.table-info strong {
    font-size: 1.5em;
    font-family: monospace;
    color: #667eea;
}

.btn-small {
    background: #667eea;
    color: white;
    border: none;
    padding: 6px 15px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9em;
    transition: background 0.2s;
}

.btn-small:hover {
    background: #5a67d8;
}

.players-list {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 10px;
    margin: 20px 0;
}

.player-waiting {
    padding: 10px;
    margin: 5px 0;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
}

.player-waiting.host {
    background: #e8f0fe;
    border-right: 3px solid #667eea;
}

.player-waiting.guest {
    background: #fef5e8;
    border-right: 3px solid #f39c12;
}

.share-link {
    margin: 20px 0;
}

.share-link input {
    width: 100%;
    padding: 10px;
    margin: 10px 0;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 0.9em;
    text-align: center;
    background: #f8f9fa;
}

.waiting-message {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: 20px 0;
    padding: 15px;
    background: #fff3e0;
    border-radius: 10px;
    color: #f39c12;
}

.spinner-small {
    border: 2px solid #f3f3f3;
    border-top: 2px solid #f39c12;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    animation: spin 1s linear infinite;
}

#inviteLink {
    transition: background 0.3s, border-color 0.3s;
}

#inviteLink.copied {
    background: #e3f2fd;
    border-color: #2196f3;
}

.copy-code-btn, .copy-link-btn {
    transition: background 0.3s;
}

.copy-code-btn.copied, .copy-link-btn.copied {
    background: #27ae60 !important;
}

@keyframes flash {
    0% { background: #27ae60; }
    100% { background: #667eea; }
}

/* כפתור לובי במסך משחק */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.header-buttons {
    display: flex;
    align-items: center;
    gap: 15px;
}

.btn-lobby {
    background: #3498db;
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: 20px;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 0.9em;
}

.btn-lobby:hover {
    background: #2980b9;
}

.btn-back {
    background: #27ae60;
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: 20px;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 0.9em;
    position: absolute;
    top: 20px;
    right: 20px;
}

.btn-back:hover {
    background: #219a52;
}

.lobby-header {
    position: relative;
    text-align: center;
}

.lobby-card {
    position: relative;
}

/* סגנונות לשדה שם */
.player-name-input {
    border: 2px solid #e0e0e0;
    transition: border-color 0.2s, background 0.2s;
    padding: 12px 20px;
    font-size: 1em;
    border-radius: 25px;
    outline: none;
    flex: 1;
}

.player-name-input:focus {
    border-color: #667eea;
}

.player-name-input.guest-name {
    border-color: #f39c12;
    background: #fff9e6;
}

.name-error {
    color: #e74c3c;
    font-size: 0.8em;
    margin-top: 5px;
    text-align: center;
    position: absolute;
    bottom: -25px;
    left: 0;
    right: 0;
}

.name-error.hidden {
    display: none;
}

.create-table-section {
    position: relative;
    display: flex;
    gap: 10px;
    justify-content: center;
    margin: 15px 0;
    flex-wrap: wrap;
}

@media (max-width: 768px) {
    .create-table-section {
        flex-direction: column;
    }
    
    .name-error {
        position: static;
        margin-top: 5px;
    }
}

/* כפתורי משחק חדשים */
.game-controls {
    display: flex;
    gap: 10px;
    margin: 10px 0;
}

.btn-surrender {
    background: #e74c3c;
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: 20px;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 0.9em;
}

.btn-surrender:hover {
    background: #c0392b;
}

.btn-draw {
    background: #f39c12;
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: 20px;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 0.9em;
}

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

/* מודל סוף משחק */
.game-over-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: fadeIn 0.3s ease;
}

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

.modal-content h2 {
    margin-bottom: 20px;
    color: #333;
}

.modal-content p {
    margin-bottom: 20px;
    color: #666;
    font-size: 1.1em;
}

.rematch-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 20px;
}

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

.btn-rematch:hover {
    transform: translateY(-2px);
}

.btn-close {
    background: #95a5a6;
    color: white;
    border: none;
    padding: 12px 25px;
    border-radius: 25px;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 1em;
}

.btn-close:hover {
    background: #7f8c8d;
}

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

@media (max-width: 768px) {
    .game-controls {
        width: 100%;
        justify-content: center;
    }
    
    .modal-content {
        width: 95%;
        padding: 20px;
    }
    
    .rematch-buttons {
        flex-direction: column;
    }
}