body {
    font-family: Arial, sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    background: #2b2b2b;
    color: white;
    margin: 0;
    min-height: 100vh;
}

h1 { margin-top: 10px; }

.screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}
.screen.hidden { display: none; }
.hidden { display: none !important; }

/* --- Lobby --- */
.lobby-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
    margin-top: 20px;
}
#lobby-board {
    display: grid;
    grid-template-columns: repeat(8, 30px);
    grid-template-rows: repeat(8, 30px);
    border: 2px solid #555;
    opacity: 0.6;
}
#lobby-board .square {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}
#lobby-board .square.light { background: #f0d9b5; }
#lobby-board .square.dark  { background: #b58863; }

#lobby-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 260px;
}
#lobby-buttons button {
    font-size: 16px;
    padding: 14px 20px;
}

/* --- Waiting --- */
.waiting-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    margin-top: 100px;
}
.spinner {
    width: 60px;
    height: 60px;
    border: 5px solid #444;
    border-top-color: #4caf50;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.waiting-text { font-size: 22px; }

/* --- Game --- */
#game-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}
#my-color-indicator { font-size: 16px; color: #ccc; }

.game-container {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    margin: 20px 0;
}

.board-area {
    display: flex;
    flex-direction: column;
    align-items: center;
}

#board {
    display: grid;
    grid-template-columns: repeat(8, 60px);
    grid-template-rows: repeat(8, 60px);
    border: 3px solid #555;
}

.square {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    cursor: pointer;
    user-select: none;
    position: relative;
}
.square.light { background: #f0d9b5; }
.square.dark  { background: #b58863; }
.square.selected  { outline: 3px solid #ffeb3b; outline-offset: -3px; }
.square.drag-over { outline: 3px solid #4caf50; outline-offset: -3px; }
.square.pending-from {
    background-image: linear-gradient(45deg, rgba(255,235,59,0.3), rgba(255,235,59,0.3));
}

.checker {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2px solid;
    position: relative;
    cursor: grab;
}
.checker.white {
    background: radial-gradient(circle at 35% 30%, #fff, #d0d0d0);
    border-color: #555;
}
.checker.black {
    background: radial-gradient(circle at 35% 30%, #666, #111);
    border-color: #000;
}
.checker.pending { opacity: 0.4; }
.checker:active { cursor: grabbing; }

/* container של פיון על הלוח */
.square > .pawn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 55px;
    height: 55px;
}

.square > .pawn .piece-img {
    width: 100%;
    height: 100%;
}
.pawn.white { color: #fff; text-shadow: 1px 1px 2px #000; }
.pawn.black { color: #111; text-shadow: 1px 1px 2px #fff; }
.pawn.pending { opacity: 0.4; }
/* גודל התמונה של הפיון על הלוח */
.pawn .piece-img {
    width: 100px;
    height: 100px;
}

.marking {
    position: absolute;
    font-size: 22px;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    color: #e53935;
    text-shadow: 1px 1px 0 #fff, -1px -1px 0 #fff, 1px -1px 0 #fff, -1px 1px 0 #fff;
    font-weight: bold;
}

.side-panel {
    background: #3a3a3a;
    border: 2px solid #555;
    padding: 12px;
    border-radius: 6px;
    min-width: 200px;
}
.panel-title { text-align: center; font-size: 16px; margin-bottom: 12px; color: #ccc; }
.pool-side { margin-bottom: 15px; }
.pool-label { font-size: 13px; color: #999; margin-bottom: 5px; }
.pool-slots {
    display: grid;
    grid-template-columns: repeat(4, 42px);
    gap: 5px;
    min-height: 50px;
    padding: 6px;
    background: #2b2b2b;
    border-radius: 4px;
}
.pool-slots.drag-over { background: #1a4a1a; }

.pool-item {
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    cursor: grab;
    background: #444;
    border-radius: 4px;
    user-select: none;
}
.pool-item.white { color: #fff; text-shadow: 1px 1px 2px #000; }
.pool-item.black { color: #111; text-shadow: 1px 1px 2px #fff; }
.pool-item:active { cursor: grabbing; }

.pool-item.empty {
    background: #2b2b2b;
    border: 2px dashed #666;
    cursor: default;
}
.pool-item.empty.white::before {
    content: '';
    width: 28px; height: 28px;
    border-radius: 50%;
    background: rgba(255,255,255,0.15);
}
.pool-item.empty.black::before {
    content: '';
    width: 28px; height: 28px;
    border-radius: 50%;
    background: rgba(0,0,0,0.35);
}

#move-controls {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 15px;
    flex-wrap: wrap;
}
#global-controls {
    margin-top: 15px;
    display: flex;
    gap: 10px;
}

button {
    padding: 8px 16px;
    background: #4a4a4a;
    color: white;
    border: 1px solid #666;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-family: inherit;
}
button:hover:not(:disabled) { background: #5a5a5a; }
button:disabled { opacity: 0.35; cursor: not-allowed; }

#btn-reset, #btn-leave { background: #6b3232; }
#btn-reset:hover, #btn-leave:hover { background: #7b3232; }

#btn-submit, #btn-submit-check, #btn-submit-mate { background: #3a6b32; }
#btn-submit:hover:not(:disabled),
#btn-submit-check:hover:not(:disabled),
#btn-submit-mate:hover:not(:disabled) { background: #4a7b32; }

#btn-play-local, #btn-play-random { background: #3a6b32; }
#btn-play-local:hover, #btn-play-random:hover { background: #4a7b32; }

#turn-indicator { font-size: 20px; }
#check-banner { font-size: 22px; font-weight: bold; color: #ffb74d; min-height: 30px; }
#status { min-height: 30px; color: #ff6b6b; margin-top: 10px; }

/* Game over overlay */
#game-over-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}
.game-over-box {
    background: #2b2b2b;
    border: 3px solid #666;
    padding: 40px 60px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}
#game-over-title { font-size: 56px; font-weight: bold; margin-bottom: 15px; color: #4caf50; }
#game-over-subtitle { font-size: 22px; margin-bottom: 25px; color: #ccc; }
.game-over-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
}
.game-over-buttons button { font-size: 18px; padding: 12px 30px; }
#btn-overlay-reset { background: #3a6b32; }
#btn-overlay-menu { background: #4a4a4a; }

/* --- אינדיקציה של שח --- */
.square.king-in-check {
    animation: check-pulse 1s ease-in-out infinite;
    box-shadow: inset 0 0 0 4px rgba(229, 57, 53, 0.8);
}
@keyframes check-pulse {
    0%, 100% { box-shadow: inset 0 0 0 4px rgba(229, 57, 53, 0.5); }
    50%      { box-shadow: inset 0 0 0 4px rgba(229, 57, 53, 1); }
}

#check-banner {
    color: #e53935;
    font-size: 28px;
    text-shadow: 0 0 8px rgba(229, 57, 53, 0.6);
    animation: check-glow 1.2s ease-in-out infinite;
}
@keyframes check-glow {
    0%, 100% { opacity: 0.85; }
    50%      { opacity: 1; }
}

/* --- אינדיקציה של המהלך האחרון --- */
.square.last-move-from {
    background-image: linear-gradient(45deg,
        rgba(76, 175, 80, 0.35),
        rgba(76, 175, 80, 0.35));
}
.square.last-move-to {
    background-image: linear-gradient(45deg,
        rgba(76, 175, 80, 0.6),
        rgba(76, 175, 80, 0.6));
    box-shadow: inset 0 0 0 3px rgba(76, 175, 80, 0.9);
}

#lobby-board .checker {
    width: 22px;
    height: 22px;
    border-width: 1px;
    cursor: default;
}
#lobby-board .pawn {
    font-size: 20px;
}

/* התאמות ל-RTL */
[data-lang-dir="rtl"] .game-container {
    /* השאר את המבנה כמו שהוא - CSS grid/flex טבעי ל-RTL */
}

[data-lang-dir="rtl"] #status,
[data-lang-dir="rtl"] .waiting-text,
[data-lang-dir="rtl"] #turn-indicator,
[data-lang-dir="rtl"] #my-color-indicator,
[data-lang-dir="rtl"] #check-banner,
[data-lang-dir="rtl"] #game-over-title,
[data-lang-dir="rtl"] #game-over-subtitle {
    direction: rtl;
    unicode-bidi: plaintext;
}

/* SVG של כלים - קרדינל ומרשל */
.svg-piece {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.piece-svg {
    width: 100%;
    height: 100%;
    max-width: 40px;
    max-height: 40px;
}

/* צביעה של הכלים ה-SVG */
.piece-svg.piece-white .fill {
    fill: #ffffff;
    stroke: #333;
    stroke-width: 0.8;
    stroke-linejoin: round;
}
.piece-svg.piece-white .accent {
    fill: #666;
}
.piece-svg.piece-black .fill {
    fill: #1a1a1a;
    stroke: #000;
    stroke-width: 0.8;
    stroke-linejoin: round;
}
.piece-svg.piece-black .accent {
    fill: #999;
}

/* התאמת גדלים לפי מיקום */
.pool-item .svg-piece {
    width: 36px;
    height: 36px;
}

.marking .svg-piece {
    width: 24px;
    height: 24px;
}

/* צביעת הסימון באדום כמו הטקסט */
.marking .piece-svg .fill {
    fill: #e53935;
    stroke: #fff;
    stroke-width: 1;
}
.marking .piece-svg .accent {
    fill: #b71c1c;
}

/* היפוך צבע לכלים שחורים */
/* היפוך צבע לכלים שחורים על הלוח / במאגר / בנאכלים */
.piece-img-black {
    filter: invert(1);
}

/* בסימון: הצבע נקבע לפי צבע הדמקה שמתחת, לא לפי הכלי המסומן */
.marking .piece-img {
    filter: none;  /* סימון על דמקה לבנה - שחור, כרגיל */
}

.checker.black .marking .piece-img {
    filter: invert(1);  /* סימון על דמקה שחורה - הופך ללבן */
}/* גדלים לפי מיקום - מתאימים לכל התמונה */

/* בתוך דמקה על הלוח (dragged piece placement) */
.checker .piece-img,
.pawn .piece-img {
    width: 28px;
    height: 28px;
}

/* במאגר סימונים ובנאכלים */
.pool-item .piece-img {
    width: 32px;
    height: 32px;
}

/* בסימון (marking) על דמקה */
.marking .piece-img {
    width: 26px;
    height: 26px;
}

/* בלוח הפתיחה הקטן (אם יופיע שם) */
#lobby-board .piece-img {
    width: 20px;
    height: 20px;
}

/* התאמת ה-container של marking - לוודא שהוא לא נמתח */
.marking {
    display: flex;
    align-items: center;
    justify-content: center;
    width: auto;
    height: auto;
}


#language-menu.hidden { display: none; }

.language-option {
    padding: 10px 14px;
    cursor: pointer;
    color: white;
    border-bottom: 1px solid #4a4a4a;
    text-align: start;
    font-size: 14px;
}
.language-option:last-child { border-bottom: none; }
.language-option:hover { background: #5a5a5a; }
.language-option.current {
    background: #3a6b32;
    font-weight: bold;
}

/* בלי קשר לשפה - הלוח והתאים שלו תמיד LTR,
   כדי שהעמודות יילכו משמאל (A) לימין (H) */
#board,
#lobby-board {
    direction: ltr;
}

#analysis-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

#analysis-move-indicator {
    font-size: 18px;
    color: #ccc;
}

#analysis-board {
    display: grid;
    grid-template-columns: repeat(8, 60px);
    grid-template-rows: repeat(8, 60px);
    border: 3px solid #555;
    direction: ltr;
}

#analysis-controls {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 15px;
    flex-wrap: wrap;
}

#btn-analysis-back {
    background: #4a4a4a;
    margin-top: 15px;
}

#analysis-declaration, #last-declaration {
    font-size: 16px;
    color: #ffb74d;
    min-height: 22px;
    font-weight: 500;
}

#analysis-declaration.check-declared,
#last-declaration.check-declared {
    color: #ffb74d;
}
#analysis-declaration.mate-declared,
#last-declaration.mate-declared {
    color: #e53935;
    font-weight: bold;
}

/* תיבת סימוני הכתרה - עם צבע קצת שונה כדי להבחין */
#promoted-pool,
#analysis-promoted-pool {
    background: #3a3a45;
    border-color: #6a6a80;
}

#promoted-pool .panel-title,
#analysis-promoted-pool .panel-title {
    color: #d4a5ff;
}

/* פיון מוכתר על הלוח - סימון קל כדי להבחין ממנו כדסקית רגילה */
.checker.promoted {
    box-shadow: 0 0 8px rgba(212, 165, 255, 0.7);
}

/* כפתור הנחיות - קבוע בצד שמאל */
#instructions-switcher {
    position: fixed;
    top: 15px;
    left: 15px;
    z-index: 500;
}


#btn-instructions {
    padding: 8px 14px;
    background: #4a4a4a;
    color: white;
    border: 1px solid #666;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 120px;
}
#btn-instructions:hover { background: #5a5a5a; }

/* Overlay של הנחיות */
#instructions-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}
#instructions-overlay.hidden { display: none; }

.instructions-box {
    background: #2b2b2b;
    border: 3px solid #666;
    border-radius: 12px;
    max-width: 700px;
    width: 90%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}

.instructions-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 30px;
    border-bottom: 1px solid #555;
}

.instructions-header h2 {
    margin: 0;
    font-size: 24px;
    color: white;
}

#btn-instructions-close {
    background: #6b3232;
    padding: 8px 20px;
}
#btn-instructions-close:hover { background: #7b3232; }

#instructions-content {
    padding: 20px 30px;
    overflow-y: auto;
    color: white;
}

/* פרק - collapsible */
.instructions-chapter {
    margin-bottom: 12px;
    border: 1px solid #555;
    border-radius: 6px;
    background: #333;
}

.instructions-chapter summary {
    padding: 14px 20px;
    cursor: pointer;
    font-size: 18px;
    font-weight: bold;
    user-select: none;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 10px;
}

.instructions-chapter summary::before {
    content: '▶';
    display: inline-block;
    transition: transform 0.2s;
    font-size: 14px;
    color: #aaa;
}

.instructions-chapter[open] summary::before {
    transform: rotate(90deg);
}

/* בעברית וערבית - החץ מסתובב לכיוון הנכון */
[data-lang-dir="rtl"] .instructions-chapter summary::before {
    content: '◀';
}
[data-lang-dir="rtl"] .instructions-chapter[open] summary::before {
    transform: rotate(-90deg);
}

.instructions-chapter-content {
    padding: 0 20px 20px 20px;
    color: #ddd;
    line-height: 1.6;
    white-space: pre-line;
}

/* עיצוב לתוכן ההנחיות */
.instructions-chapter-content h3 {
    color: #d4a5ff;
    margin-top: 20px;
    margin-bottom: 8px;
    font-size: 18px;
    border-bottom: 1px solid #555;
    padding-bottom: 4px;
}

.instructions-chapter-content h3:first-child {
    margin-top: 0;
}

.instructions-chapter-content p {
    margin: 8px 0;
}

.instructions-chapter-content ul {
    margin: 8px 0;
    padding-inline-start: 22px;
}

.instructions-chapter-content li {
    margin: 4px 0;
}

.instructions-chapter-content .piece-showcase {
    display: flex;
    align-items: center;
    gap: 15px;
    margin: 12px 0;
    padding: 10px;
    background: #2b2b2b;
    border-radius: 6px;
}

.instructions-chapter-content .piece-showcase img {
    width: 60px;
    height: 60px;
    flex-shrink: 0;
}

.instructions-chapter-content .piece-showcase .description {
    flex: 1;
}

.instructions-chapter-content .mini-board {
    display: grid;
    grid-template-columns: repeat(8, 32px);
    grid-template-rows: repeat(8, 32px);
    border: 2px solid #555;
    margin: 12px auto;
    width: fit-content;
    direction: ltr;
}

.instructions-chapter-content .mini-board .square {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.instructions-chapter-content .mini-board .square.light { background: #f0d9b5; }
.instructions-chapter-content .mini-board .square.dark  { background: #b58863; }

/* הכלי במרכז - הצריך שיתאים לגודל של mini-board */
.instructions-chapter-content .mini-board .piece-here {
    width: 26px;
    height: 26px;
}

/* משבצות שהכלי יכול לזוז אליהן */
.instructions-chapter-content .mini-board .move-target::after {
    content: '';
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: rgba(76, 175, 80, 0.7);
    position: absolute;
}

/* משבצות שהכלי יכול לאכול בהן */
.instructions-chapter-content .mini-board .capture-target::after {
    content: '';
    width: 22px;
    height: 22px;
    border: 3px solid rgba(229, 57, 53, 0.9);
    border-radius: 50%;
    box-sizing: border-box;
}

/* תמונת כלי inline בטקסט */
.instructions-chapter-content .inline-piece {
    display: inline-block;
    width: 24px;
    height: 24px;
    vertical-align: middle;
}

/* ============================================================
   כפתור פרופיל (מחליף את כפתור השפה) - צד ימין למעלה
   ============================================================ */

#profile-switcher {
    position: fixed;
    top: 15px;
    right: 15px;
    z-index: 500;
}

#btn-profile {
    padding: 8px 14px;
    background: #4a4a4a;
    color: white;
    border: 1px solid #666;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 140px;
}
#btn-profile:hover { background: #5a5a5a; }

#btn-profile-name {
    font-weight: bold;
}

#btn-profile-elo {
    color: #d4a5ff;
    font-size: 12px;
}
#btn-profile-elo:empty { display: none; }

/* תפריט נגלל */
#profile-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 6px;
    background: #3a3a3a;
    border: 1px solid #666;
    border-radius: 6px;
    min-width: 240px;
    max-width: 280px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    color: white;
}
#profile-menu.hidden { display: none; }

.profile-menu-header {
    padding: 14px 16px;
    border-bottom: 1px solid #555;
    text-align: center;
}

.profile-menu-name {
    font-size: 16px;
    font-weight: bold;
    margin-bottom: 4px;
}

.profile-menu-elo {
    font-size: 14px;
    color: #d4a5ff;
    margin-bottom: 6px;
}
.profile-menu-elo:empty { display: none; }

.profile-menu-stats {
    font-size: 12px;
    color: #aaa;
}
.profile-menu-stats:empty { display: none; }

.profile-menu-section {
    padding: 10px 12px;
    border-bottom: 1px solid #4a4a4a;
}
.profile-menu-section:last-child { border-bottom: none; }
.profile-menu-section.hidden { display: none; }

.profile-menu-label {
    font-size: 11px;
    color: #888;
    text-transform: uppercase;
    margin-bottom: 6px;
    letter-spacing: 0.5px;
}

.menu-action {
    display: block;
    width: 100%;
    padding: 8px 12px;
    background: #4a4a4a;
    color: white;
    border: 1px solid #5a5a5a;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    text-align: start;
    margin-bottom: 6px;
    font-family: inherit;
}
.menu-action:last-child { margin-bottom: 0; }
.menu-action:hover { background: #5a5a5a; }

#btn-logout { background: #6b3232; }
#btn-logout:hover { background: #7b3232; }

/* בחירת שפה בתוך התפריט */
#language-menu-inline .language-option {
    padding: 6px 10px;
    cursor: pointer;
    border-radius: 4px;
    margin-bottom: 2px;
    font-size: 13px;
}
#language-menu-inline .language-option:hover { background: #4a4a4a; }
#language-menu-inline .language-option.current {
    background: #3a6b32;
    font-weight: bold;
}

/* ============================================================
   Overlay של התחברות והרשמה
   ============================================================ */

.auth-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}
.auth-overlay.hidden { display: none; }

.auth-box {
    background: #2b2b2b;
    border: 3px solid #666;
    border-radius: 12px;
    width: 90%;
    max-width: 420px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}

.auth-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    border-bottom: 1px solid #555;
}

.auth-header h2 {
    margin: 0;
    color: white;
    font-size: 22px;
}

.auth-close, .profile-close {
    background: #6b3232;
    padding: 6px 14px;
    font-size: 13px;
}
.auth-close:hover, .profile-close:hover { background: #7b3232; }

.auth-body {
    padding: 20px 24px;
}

.auth-field {
    margin-bottom: 16px;
}

.auth-field label {
    display: block;
    color: #ccc;
    margin-bottom: 6px;
    font-size: 14px;
}

.auth-field input[type="text"],
.auth-field input[type="password"],
.auth-field input[type="email"] {
    width: 100%;
    padding: 8px 10px;
    background: #1a1a1a;
    border: 1px solid #555;
    border-radius: 4px;
    color: white;
    font-size: 14px;
    box-sizing: border-box;
    font-family: inherit;
}

.auth-field input:focus {
    outline: none;
    border-color: #d4a5ff;
}

.auth-hint {
    font-size: 12px;
    color: #888;
    margin-top: 4px;
}

.rating-choice {
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: #1a1a1a;
    padding: 10px 12px;
    border-radius: 4px;
    border: 1px solid #555;
}

.rating-choice label {
    color: #ddd;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
}

.auth-submit {
    width: 100%;
    padding: 10px;
    background: #3a6b32;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 15px;
    font-weight: bold;
    margin-top: 8px;
    font-family: inherit;
}
.auth-submit:hover { background: #4a7b32; }

.auth-error {
    color: #ff6b6b;
    font-size: 14px;
    margin-top: 10px;
    min-height: 20px;
    text-align: center;
}

/* ============================================================
   Overlay של פרופיל מלא
   ============================================================ */

.profile-page {
    max-width: 800px;
    margin: 60px auto 40px auto;
    padding: 0 20px;
    color: white;
}

.profile-page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 16px;
    border-bottom: 2px solid #555;
    margin-bottom: 24px;
}

.profile-page-header h1 {
    margin: 0;
    color: white;
    font-size: 28px;
}

#btn-profile-back {
    background: #4a4a4a;
    padding: 8px 18px;
}
#btn-profile-back:hover { background: #5a5a5a; }

.profile-page-body {
    background: #2b2b2b;
    border: 1px solid #555;
    border-radius: 8px;
    padding: 24px;
}

.profile-page-body .stat-row {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid #3a3a3a;
    font-size: 15px;
}

.profile-page-body .stat-row:last-child {
    border-bottom: none;
}

.profile-page-body .stat-label {
    color: #aaa;
}

.profile-page-body .stat-value {
    color: white;
    font-weight: bold;
}

.player-info {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 8px 12px;
    background: #3a3a3a;
    border-radius: 6px;
    margin: 8px 0;
    max-width: 480px;
    color: white;
    font-size: 15px;
}
.player-info.hidden { display: none; }

.player-info .player-name {
    font-weight: bold;
}

.player-info .player-elo {
    color: #d4a5ff;
}
.player-info .player-elo:empty { display: none; }

/* כפתור הצע תיקו */
#btn-offer-draw {
    background: #6a5a4a;
}
#btn-offer-draw:hover { background: #7a6a5a; }

/* כפתור פעיל - אני לחצתי */
#btn-offer-draw.offered {
    background: #8a7020;
    border-color: #d4a5ff;
}

/* היריב לחץ - סימון עדין */
#btn-offer-draw.opponent-offered {
    background: #6a5a4a;
    border-color: #d4a5ff;
    box-shadow: 0 0 8px rgba(212, 165, 255, 0.5);
}

/* כפתור Rematch */
#btn-overlay-rematch {
    background: #3a6b32;
}
#btn-overlay-rematch:hover { background: #4a7b32; }

#btn-overlay-rematch.offered {
    background: #6a8b32;
    border-color: #d4a5ff;
}

#btn-overlay-rematch.opponent-offered {
    box-shadow: 0 0 12px rgba(212, 165, 255, 0.7);
}

#draw-response {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: #4a3a5a;
    border: 1px solid #d4a5ff;
    border-radius: 4px;
    color: white;
}
#draw-response.hidden { display: none; }

.draw-response-btn {
    padding: 4px 10px;
    font-size: 16px;
    font-weight: bold;
    min-width: 30px;
}
.draw-response-btn.accept {
    background: #3a6b32;
}
.draw-response-btn.accept:hover { background: #4a7b32; }
.draw-response-btn.decline {
    background: #6b3232;
}
.draw-response-btn.decline:hover { background: #7b3232; }

#fifty-move-warning {
    font-size: 14px;
    color: #ffa726;
    min-height: 18px;
    font-weight: 500;
}
#fifty-move-warning:empty { display: none; }

#fifty-move-warning.critical {
    color: #e53935;
    font-weight: bold;
}

/* Badge של התראות בכפתור הפרופיל */
#btn-profile-badge {
    background: #e53935;
    color: white;
    border-radius: 10px;
    padding: 2px 6px;
    font-size: 11px;
    font-weight: bold;
    min-width: 16px;
    text-align: center;
}
#btn-profile-badge.hidden { display: none; }

/* Profile Tabs */
.profile-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    border-bottom: 2px solid #555;
}

.profile-tab {
    background: transparent;
    color: #aaa;
    border: none;
    padding: 10px 20px;
    cursor: pointer;
    font-size: 15px;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    font-family: inherit;
}

.profile-tab:hover { color: white; }

.profile-tab.active {
    color: white;
    border-bottom-color: #d4a5ff;
    font-weight: bold;
}

.profile-tab-content.hidden { display: none; }

/* Friends */
.friends-section {
    background: #2b2b2b;
    border: 1px solid #555;
    border-radius: 8px;
    padding: 16px 20px;
    margin-bottom: 16px;
    color: white;
}

.friends-section h3 {
    margin: 0 0 12px 0;
    color: #d4a5ff;
    font-size: 16px;
}

.friends-add-form {
    display: flex;
    gap: 8px;
}

.friends-add-form input {
    flex: 1;
    padding: 8px 10px;
    background: #1a1a1a;
    border: 1px solid #555;
    border-radius: 4px;
    color: white;
    font-family: inherit;
}

.friends-add-form input:focus {
    outline: none;
    border-color: #d4a5ff;
}

.friend-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: #3a3a3a;
    border-radius: 6px;
    margin-bottom: 6px;
}
.friend-item:last-child { margin-bottom: 0; }

.friend-item .friend-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.friend-item .friend-name {
    font-weight: bold;
}

.friend-item .friend-elo {
    color: #d4a5ff;
    font-size: 13px;
}

.friend-item .friend-status {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #666;
}

.friend-item .friend-status.online {
    background: #4caf50;
}

.friend-item .friend-actions {
    display: flex;
    gap: 6px;
}

.friend-item button {
    padding: 6px 12px;
    font-size: 13px;
}

.friend-btn-invite {
    background: #3a6b32;
}
.friend-btn-invite:hover { background: #4a7b32; }

.friend-btn-accept {
    background: #3a6b32;
}
.friend-btn-accept:hover { background: #4a7b32; }

.friend-btn-decline, .friend-btn-remove, .friend-btn-cancel {
    background: #6b3232;
}
.friend-btn-decline:hover, .friend-btn-remove:hover, .friend-btn-cancel:hover {
    background: #7b3232;
}

.friends-empty {
    color: #888;
    font-style: italic;
    padding: 8px 0;
}

/* התראה צפה - לא חוסמת */
#floating-notification {
    position: fixed;
    top: 60px;
    right: 15px;
    background: #2b2b2b;
    border: 2px solid #d4a5ff;
    border-radius: 8px;
    padding: 14px 18px;
    z-index: 900;
    max-width: 320px;
    box-shadow: 0 4px 20px rgba(212, 165, 255, 0.4);
    color: white;
    animation: slide-in 0.3s ease-out;
}
#floating-notification.hidden { display: none; }

@keyframes slide-in {
    from { transform: translateX(120%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.notification-content {
    margin-bottom: 10px;
    font-size: 14px;
    line-height: 1.4;
}

.notification-actions {
    display: flex;
    gap: 8px;
}

.notification-actions button {
    padding: 6px 14px;
    font-size: 13px;
    flex: 1;
}

.share-link-box {
    display: flex;
    gap: 8px;
    margin: 12px 0;
}

.share-link-box input {
    flex: 1;
    padding: 8px 10px;
    background: #1a1a1a;
    border: 1px solid #555;
    border-radius: 4px;
    color: white;
    font-family: monospace;
    font-size: 13px;
}

#share-link-status {
    text-align: center;
    color: #d4a5ff;
    margin-top: 10px;
    min-height: 20px;
}

.share-link-close {
    background: #6b3232;
    padding: 6px 14px;
    font-size: 13px;
}

.code-join-section {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 8px;
}

.code-join-section input {
    flex: 1;
    padding: 10px 12px;
    background: #1a1a1a;
    border: 1px solid #555;
    border-radius: 4px;
    color: white;
    font-family: monospace;
    font-size: 16px;
    text-align: center;
    letter-spacing: 3px;
    text-transform: uppercase;
}

.code-join-section input:focus {
    outline: none;
    border-color: #d4a5ff;
}

.share-code-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin: 20px 0;
}

#share-code-display {
    background: #1a1a1a;
    border: 2px solid #d4a5ff;
    border-radius: 8px;
    padding: 16px 32px;
    font-family: monospace;
    font-size: 32px;
    letter-spacing: 8px;
    color: white;
    font-weight: bold;
}

#btn-copy-code {
    padding: 8px 20px;
}

/* Leaderboard */
.leaderboard-page {
    max-width: 900px;
    margin: 60px auto 40px auto;
    padding: 0 20px;
    color: white;
}

.leaderboard-note {
    color: #888;
    font-size: 13px;
    margin-bottom: 16px;
    text-align: center;
}

.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    background: #2b2b2b;
    border: 1px solid #555;
    border-radius: 8px;
    overflow: hidden;
}

.leaderboard-table th,
.leaderboard-table td {
    padding: 10px 12px;
    text-align: center;
    border-bottom: 1px solid #3a3a3a;
}

.leaderboard-table th {
    background: #1f1f1f;
    color: #d4a5ff;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.leaderboard-table tbody tr:last-child td {
    border-bottom: none;
}

.leaderboard-table .col-player {
    text-align: start;
    font-weight: bold;
}

.leaderboard-row.me {
    background: #3a2b4a;
}

.leaderboard-row.me td {
    color: #e8d0ff;
}

.leaderboard-empty,
.leaderboard-loading {
    background: #2b2b2b;
    border: 1px solid #555;
    border-radius: 8px;
    padding: 40px;
    text-align: center;
    color: #888;
}

.leaderboard-my-rank {
    margin-top: 24px;
}

.leaderboard-my-rank-label {
    color: #d4a5ff;
    font-size: 14px;
    margin-bottom: 8px;
    text-align: center;
}

/* Clickable username */
.clickable-username {
    cursor: pointer;
    color: #d4a5ff;
    text-decoration: none;
    transition: color 0.15s;
}
.clickable-username:hover {
    color: #e8c5ff;
    text-decoration: underline;
}

/* User profile actions */
.user-profile-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 20px;
}

.user-profile-actions .menu-action {
    min-width: 140px;
}

.profile-btn-primary {
    background: #3a6b32;
}
.profile-btn-primary:hover { background: #4a7b32; }
.profile-btn-primary:disabled { background: #333; color: #666; cursor: not-allowed; }

.profile-btn-secondary {
    background: #4a4a4a;
}
.profile-btn-secondary:hover { background: #5a5a5a; }

.profile-btn-danger {
    background: #6b322b;
}
.profile-btn-danger:hover { background: #7b3a2b; }

.user-profile-status {
    font-size: 13px;
    margin-inline-start: 8px;
    font-weight: normal;
}
.user-profile-status.online { color: #4caf50; }
.user-profile-status.offline { color: #888; }

.user-profile-error {
    margin-top: 12px;
    text-align: center;
}

/* ============================================================
   Games history
   ============================================================ */

.games-container,

.games-table {
    width: 100%;
    border-collapse: collapse;
    background: #2b2b2b;
    border: 1px solid #555;
    border-radius: 8px;
    overflow: hidden;
}

.games-table th,
.games-table td {
    padding: 8px 10px;
    text-align: center;
    border-bottom: 1px solid #3a3a3a;
    font-size: 14px;
}

.games-table th {
    background: #1f1f1f;
    color: #d4a5ff;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.games-table tbody tr:last-child td {
    border-bottom: none;
}

.games-table .col-opponent {
    text-align: start;
    font-weight: bold;
}

.games-table .col-reason,
.games-table .col-date {
    color: #aaa;
    font-size: 13px;
}

/* Result badges */
.result-badge {
    display: inline-block;
    width: 26px;
    height: 26px;
    line-height: 26px;
    border-radius: 50%;
    font-weight: bold;
    font-size: 13px;
    color: white;
}
.result-badge.win  { background: #3a7b32; }
.result-badge.loss { background: #7b3a2b; }
.result-badge.draw { background: #666; }

/* Elo tag next to opponent */
.elo-tag {
    color: #888;
    font-weight: normal;
    font-size: 12px;
    margin-inline-start: 4px;
}

/* Elo delta */
.elo-delta {
    font-weight: bold;
    font-size: 13px;
}
.elo-delta.positive { color: #7bcf6f; }
.elo-delta.negative { color: #e07b6a; }
.elo-delta.neutral  { color: #888; }

/* Watch button */
.btn-watch-game {
    background: #4a3a6b;
    color: white;
    border: none;
    padding: 4px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: background 0.15s;
}
.btn-watch-game:hover { background: #5a4a7b; }

.games-empty,
.games-loading {
    background: #2b2b2b;
    border: 1px solid #555;
    border-radius: 8px;
    padding: 24px;
    text-align: center;
    color: #888;
}

/* Settings screen */
.settings-section {
    background: #2b2b2b;
    border: 1px solid #555;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
}

.settings-section h3 {
    color: #d4a5ff;
    font-size: 15px;
    margin: 0 0 12px 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.settings-value {
    color: #ddd;
    font-size: 15px;
    word-break: break-all;
}

.settings-form {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.settings-form input {
    padding: 10px;
    background: #1f1f1f;
    color: white;
    border: 1px solid #555;
    border-radius: 4px;
    font-size: 14px;
}

.settings-form input:focus {
    outline: none;
    border-color: #d4a5ff;
}

.settings-form-actions {
    display: flex;
    gap: 8px;
}

.settings-form-actions .menu-action {
    flex: 1;
}

.settings-tab { /* אותה מחלקה כמו profile-tab */ }

button.menu-action:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.reset-panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px;
    background: #2b2b2b;
    border: 1px solid #555;
    border-radius: 8px;
}

.reset-info {
    color: #ccc;
    font-size: 14px;
    line-height: 1.5;
    margin: 0;
}

#reset-email-display {
    color: #d4a5ff;
    font-weight: bold;
    word-break: break-all;
}

.reset-panel input {
    padding: 10px;
    background: #1f1f1f;
    color: white;
    border: 1px solid #555;
    border-radius: 4px;
    font-size: 14px;
}

.reset-panel input:focus {
    outline: none;
    border-color: #d4a5ff;
}

#reset-code {
    font-size: 20px;
    letter-spacing: 4px;
    text-align: center;
    font-family: monospace;
}

.link-button {
    background: none;
    border: none;
    color: #d4a5ff;
    text-decoration: underline;
    cursor: pointer;
    padding: 4px 0;
    font-size: 13px;
}
.link-button:hover {
    color: #e8c5ff;
}