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

body {
    /*font-family: 'Segoe UI', Arial, sans-serif;*/
    font-family: Roboto, 'Open sans', sans-serif;
    background-color: #FFF9EF;
    padding: 20px;
}

.user-info {
    position: fixed;
    top: 10px;
    right: 20px;
    background-color: #fff;
    padding: 10px 20px;
    border-radius: 5px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    z-index: 1000;
}

.user-info span {
    margin-right: 15px;
    font-weight: bold;
}

.user-info a {
    color: #007bff;
    text-decoration: none;
}

.user-info a:hover {
    text-decoration: underline;
}

.container {
    max-width: 1500px;
    margin: 0 auto;
    padding-top: 60px;
}

.auth-container {
    max-width: 400px;
    margin: 100px auto;
    background-color: #fff;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.auth-container h2 {
    margin-bottom: 20px;
    text-align: center;
    color: #333;
}

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

.form-group label {
    display: block;
    margin-bottom: 5px;
    color: #555;
    font-weight: bold;
}

.form-group input {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.form-group input:focus {
    outline: none;
    border-color: #007bff;
}

button {
    width: 100%;
    padding: 10px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    cursor: pointer;
    /*margin-top: 10px;*/
}

button:hover {
    background-color: #0056b3;
}

.auth-container p {
    text-align: center;
    margin-top: 15px;
    color: #666;
}

.auth-container a {
    color: #007bff;
    text-decoration: none;
}

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

.flash-messages {
    margin-bottom: 20px;
}

.flash-message {
    padding: 10px 15px;
    background-color: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 4px;
    color: #856404;
    margin-bottom: 10px;
}

.board-controls button {
    /*width: auto;*/
    padding: 8px 16px;
    /*margin-left: 10px;*/
}

.board-selector select {
    padding: 5px 10px;
    font-size: 14px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

/* Sandwich Menu Styles */
.sandwich-menu {
    position: fixed;
    top: 10px;
    right: 20px;
    z-index: 1001;
}

.menu-toggle {
    width: 50px;
    height: 50px;
    font-size: 28px;
    cursor: pointer;
    transition: all 0.3s;
    background: none;
}

.menu-toggle:hover {
    background: #f0f0f0;
    transform: scale(1.05);
}

.menu-dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: 60px;
    background: white;
    border: 2px solid #333;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    min-width: 200px;
    overflow: hidden;
}

.menu-dropdown.show {
    display: block;
}

.menu-dropdown a {
    display: block;
    padding: 15px 20px;
    color: #333;
    text-decoration: none;
    font-size: 16px;
    border-bottom: 1px solid #eee;
    transition: background 0.2s;
}

.menu-dropdown a:last-child {
    border-bottom: none;
}

.menu-dropdown a:hover {
    background: #f0f0f0;
}

/* Language Selector Styles */
.language-selector {
    position: fixed;
    top: 0px;
    right: 85px;
    z-index: 1001;
}

.language-toggle {
    height: 55px !important;
    padding-top: 25px;
    padding-bottom: 15px;
    font-size: 18px;
    border-radius: 0 0 15px 15px !important;
    color: #396B8B;
    font-variant: small-caps;
    font-weight: 600;
}

.language-toggle:hover {
    background: #F5E3C3;
    color: #6B3F13;
    transform: scale(1.05);
}

.language-dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: 55px;
    background: #FFF9EF;
    border: 2px solid #8B5C2A;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    min-width: 180px;
    max-height: 400px;
    overflow-y: auto;
}

.language-dropdown.show {
    display: block;
}

.language-dropdown a {
    display: block;
    padding: 12px 16px;
    color: #8B5C2A;
    text-decoration: none;
    font-size: 15px;
    border-bottom: 1px solid #eee;
    transition: background 0.2s;
}

.language-dropdown a:last-child {
    border-bottom: none;
}

.language-dropdown a:hover {
    background: #F5E3C3;
    color: #6B3F13;
}

.language-dropdown a.active {
    background: #8B5C2A;
    color: #FFF9EF;
    font-weight: bold;
}

/* logo */

.logo_for_homepage {
    display: none;
}

/* login */

.loginIcon {
    position: fixed;
    right: 156px;
    top: 21px;
    color: #396B8B;
    font-size: 18px;
    background-image: url(/static/login.svg);
    background-position: left center;
    background-repeat: no-repeat;
    background-size: 24px 24px;
    padding: 0 0 0 30px;
    height: 24px;
    text-decoration: none;
    font-weight: 600;
    line-height: 132%;
}

/* Login Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.6);
}

.modal-content {
    background-color: #fefefe;
    margin: 10% auto;
    padding: 30px;
    border: 2px solid #888;
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    position: relative;
}

.close {
    color: #aaa;
    float: right;
    font-size: 32px;
    font-weight: bold;
    line-height: 20px;
    cursor: pointer;
}

.close:hover,
.close:focus {
    color: #000;
}

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

.modal-content button {
    width: 100%;
    margin-top: 10px;
}

/* Background image support for body */
body {
    background-size: cover;
    background-position-x: center;
    background-position-y: 70%;
    background-repeat: no-repeat;
    background-attachment: fixed;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    body {
        background-size: contain !important;
        background-position: top !important;
    }

    .sandwich-menu {
        top: 14px;
        right: 9px;
    }
    
    .menu-toggle {
        width: 45px;
        height: 45px;
        font-size: 24px;
    }
    
    .language-toggle {
        height: 55px;
        font-size: 22px;
    }
    
    .modal-content {
        margin: 20% auto;
        padding: 20px;
        width: 95%;
    }
    
    .language-selector {
        right: 56px;
    }

    .loginIcon {
        right: 20px;
        top: 77px;
    }
}

/* ============ GAMING STYLES ============ */

/* Play board container */
.play-container {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 15px;
    box-sizing: border-box;
    height: calc(100vh - 80px);
    overflow: hidden;
}

.play-layout {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto auto auto auto 1fr;
    gap: 4px;
    height: 100%;
}

/* Mobile layout */
@media (max-width: 768px) {
    .play-layout {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto auto auto 1fr auto;
    }
    
    .time-controls-section {
        grid-column: 1;
        grid-row: 1;
    }
    
    .opponent-info {
        grid-column: 1;
        grid-row: 2;
    }
    
    .user-info {
        grid-column: 1;
        grid-row: 3;
        position: static !important;
    }
    
    .game-controls {
        grid-column: 1;
        grid-row: 4;
    }
    
    .draw-offer, .undo-offer {
        grid-column: 1;
        grid-row: 5;
    }
    
    .board-wrapper {
        grid-column: 1;
        grid-row: 6;
    }
    
    .game-chat {
        grid-column: 1;
        grid-row: 7;
    }
}

/* Desktop layout */
@media (min-width: 769px) {
    .play-layout {
        grid-template-columns: 1fr 350px;
    }
    
    .time-controls-section {
        grid-column: 1;
        grid-row: 1;
    }
    
    .opponent-info {
        grid-column: 1;
        grid-row: 2;
    }
    
    .user-info {
        grid-column: 1;
        grid-row: 3;
        position: static !important;
    }
    
    .game-controls {
        grid-column: 1;
        grid-row: 4;
    }
    
    .draw-offer, .undo-offer {
        grid-column: 1;
        grid-row: 5;
    }
    
    .board-wrapper {
        grid-column: 1;
        grid-row: 6;
        align-self: stretch;
        min-height: 0;
    }
    
    .game-chat {
        grid-column: 2;
        grid-row: 2 / 7;
        min-height: 0;
        max-height: 100%;
        overflow-y: auto;
    }
}

/* Time controls */
.time-controls-section {
    background: white;
    padding: 15px;
    border-radius: 8px;
    border: 1px solid #ddd;
}

.controls-row {
    display: flex;
    gap: 15px;
    margin-bottom: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.controls-row label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 14px;
}

.controls-row input[type="number"] {
    width: 60px;
    padding: 5px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.controls-row input[type="checkbox"] {
    width: auto;
}

.controls-row select {
    padding: 5px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
}

.btn-primary {
    padding: 8px 20px;
    background: #4CAF50;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    transition: background 0.2s;
    width: auto;
}

.btn-primary:hover {
    background: #45a049;
}

/* Player info (play page) */
.play-layout .opponent-info,
.play-layout .user-info {
    background: white;
    padding: 8px 20px;
    border-radius: 8px;
    border: 1px solid #ddd;
    position: static;
    box-shadow: none;
    z-index: auto;
}

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

.player-login {
    font-weight: bold;
    font-size: 16px;
    flex: 1;
}

.player-timer {
    font-family: 'Courier New', monospace;
    font-size: 18px;
    font-weight: bold;
    color: #333;
    background: #f0f0f0;
    padding: 5px 12px;
    border-radius: 6px;
}

.btn-start {
    padding: 8px 16px;
    background: #4CAF50;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    transition: background 0.2s;
    width: auto;
}

.btn-start:hover:not(:disabled) {
    background: #45a049;
}

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

.btn-start.btn-ready {
    background: #28a745;
    color: white;
    cursor: default;
}

/* Game controls */
.game-controls {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
    background: white;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid #ddd;
}

.game-btn {
    padding: 10px 20px;
    border: 2px solid #4CAF50;
    background: white;
    color: #4CAF50;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.2s;
    width: auto;
}

.game-btn:hover:not(:disabled) {
    background: #4CAF50;
    color: white;
}

.game-btn:disabled {
    border-color: #ccc;
    color: #ccc;
    cursor: not-allowed;
}

.btn-danger {
    border-color: #f44336;
    color: #f44336;
    margin-left: auto;
}

.btn-danger:hover:not(:disabled) {
    background: #f44336;
    color: white;
}

/* Draw offer */
.draw-offer {
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
    color: white;
    padding: 15px 20px;
    border-radius: 8px;
    text-align: center;
    font-weight: bold;
    font-size: 16px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    animation: pulse 2s infinite;
}

/* Undo offer - orange/amber color to differentiate from draw */
.undo-offer {
    background: linear-gradient(135deg, #FF9800 0%, #F57C00 100%);
    color: white;
    padding: 15px 20px;
    border-radius: 8px;
    text-align: center;
    font-weight: bold;
    font-size: 16px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    animation: pulse 2s infinite;
    margin-top: 5px;
}

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

/* Game end overlay */
.game-end-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.2);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease-in;
    pointer-events: none;
}

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

.game-end-content {
    background: rgba(255, 255, 255, 0.92);
    padding: 40px;
    border-radius: 16px;
    text-align: center;
    max-width: 500px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.4s ease-out;
    pointer-events: none;
}

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

.game-end-content h2 {
    margin: 0 0 20px 0;
    font-size: 36px;
    font-weight: bold;
}

/* Forced game countdown overlay */
.countdown-overlay {
    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: 2000;
    animation: fadeIn 0.3s ease-in;
}

.countdown-content {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    padding: 60px 80px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 0 60px rgba(66, 153, 225, 0.3);
    border: 2px solid rgba(66, 153, 225, 0.5);
}

.countdown-title {
    font-size: 28px;
    color: #fff;
    margin-bottom: 20px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 3px;
}

.countdown-number {
    font-size: 120px;
    font-weight: bold;
    color: #4299e1;
    line-height: 1;
    text-shadow: 0 0 30px rgba(66, 153, 225, 0.8);
    animation: countdownPulse 1s ease-in-out infinite;
}

@keyframes countdownPulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.9; }
}

.countdown-subtitle {
    font-size: 20px;
    color: #a0aec0;
    margin-top: 15px;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.game-end-content.win h2 {
    background: linear-gradient(135deg, #FFD700, #FFA500, #FF6347, #FF1493, #8A2BE2, #4169E1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: rainbow 3s linear infinite;
}

@keyframes rainbow {
    0% { background-position: 0% 50%; }
    100% { background-position: 200% 50%; }
}

.game-end-content.loss h2 {
    color: #555;
}

.game-end-content.draw h2 {
    color: #2196F3;
}

#game-end-reason {
    font-size: 18px;
    color: #666;
    margin: 15px 0 30px 0;
}

.game-end-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 25px;
}

.btn_white { 
    border-radius: 10px;
    font-size: 14px;
    background-color:#fff; 
    box-shadow: 0 0 10px #00000026;
    width: 33%;
    line-height: 122%;
    color: #396B8B; 
    font-weight: 500;
    display: flex; 
    flex-direction: row !important;
    justify-content: space-between !important;
    gap: 6px;
    align-items: center;
    justify-content: center;
    padding: 10px; 
    text-decoration: none; 
    text-align: center;
    flex-direction: column;
    min-height: 55px;
}

.btn_white img { 
    width: 24px;
}

.btn_white:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 15px #00000026;
    transition: 100ms;
}

.btn_white_king {
    border-radius: 15px;
    width: 50%;
    font-size: 16px;
    padding: 15px 12px 12px 12px; 
    flex-direction: column !important;
    justify-content: center !important;
}


.btn_white_king img {
    height: 56px;
    margin-bottom: 5px;
    width: auto;
}


.btn_transparent {

    width: 50px;
    height: 50px;    
    border-radius: 15px;
    box-shadow: 0 0 10px #00000026;
    background: none !important;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}


.btn-replay {
    padding: 12px 30px;
    font-size: 16px;
    font-weight: bold;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-replay-yes {
    background: linear-gradient(135deg, #4CAF50, #45a049);
    color: white;
}

.btn-replay-yes:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.4);
}

.btn-replay-no {
    background: #f44336;
    color: white;
}

.btn-replay-no:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(244, 67, 54, 0.4);
}

#replay-status {
    margin-top: 20px;
    font-size: 16px;
    color: #666;
    font-style: italic;
}

/* Board wrapper */
.board-wrapper {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 0;
    min-height: 0;
    /* overflow: hidden;*/
}

.game-board {
    display: block;
    cursor: crosshair;
    border-radius: 4px;
}

/* Game chat */
.game-chat {
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    min-height: 300px;
}

.game-chat h3 {
    margin: 0 0 10px 0;
    font-size: 1.2em;
    color: #333;
    border-bottom: 2px solid #4CAF50;
    padding-bottom: 8px;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    max-height: 250px;
    padding: 5px;
    background: #fafafa;
    border-radius: 4px;
    margin-bottom: 10px;
}

.chat-message {
    padding: 4px 0;
    font-size: 14px;
    word-wrap: break-word;
}

.chat-user {
    font-weight: bold;
    color: #333;
}

.chat-system {
    font-weight: bold;
    color: #2e7d32;
    font-style: italic;
}

.chat-input-container {
    display: flex;
    gap: 5px;
}

.chat-input {
    flex: 1;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.chat-send-btn {
    padding: 8px 15px;
    background: #4CAF50;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.chat-send-btn:hover {
    background: #45a049;
}

/* ============ MOBILE PLAY BOARD STYLES ============ */
@media (max-width: 768px) {
    /* Prevent body scrolling during game */
    body.game-active {
        overflow: hidden;
        position: fixed;
        width: 100%;
        height: 100%;
        padding: 0;
    }
    
    body.game-active .container {
        padding-top: 0;
    }
    
    /* Container takes full width */
    .play-container {
        padding: 2px;
        margin: 0 auto;
        height: calc(100vh - 80px);
        overflow: hidden;
    }
    
    body.game-active .play-container {
        height: 100vh;
        padding: 2px;
    }
    
    /* Single column layout that fits screen */
    .play-layout {
        display: flex;
        flex-direction: column;
        gap: 2px;
        height: 100%;
        overflow: hidden;
    }
    
    /* Time controls - compact */
    .time-controls-section {
        padding: 8px;
        order: 1;
        flex-shrink: 0;
    }
    
    body.game-active .time-controls-section {
        display: none;
    }
    
    .time-controls-section .controls-row {
        gap: 8px;
        margin-bottom: 5px;
    }
    
    .time-controls-section .controls-row label {
        font-size: 11px;
    }
    
    .time-controls-section .controls-row input[type="number"] {
        width: 40px;
        padding: 3px;
        font-size: 12px;
    }
    
    .time-controls-section .controls-row select {
        padding: 3px 5px;
        font-size: 11px;
    }
    
    .time-controls-section .btn-primary {
        padding: 5px 12px;
        font-size: 12px;
    }
    
    /* Player info - compact */
    .opponent-info {
        padding: 4px 10px;
        order: 2;
        flex-shrink: 0;
    }
    
    .user-info, .user-info.play-user, .user-info:not(.play-user) {
        position: static !important;
        padding: 4px 10px;
        order: 3;
        flex-shrink: 0;
    }
    
    .opponent-info .player-display,
    .user-info .player-display {
        gap: 8px;
    }
    
    .opponent-info .player-login,
    .user-info .player-login {
        font-size: 14px;
    }
    
    .opponent-info .player-timer,
    .user-info .player-timer {
        font-size: 16px;
    }
    
    /* Game controls - compact */
    .game-controls {
        padding: 3px;
        order: 4;
        display: flex;
        flex-wrap: wrap;
        gap: 4px;
        justify-content: center;
        flex-shrink: 0;
    }
    
    .game-controls .game-btn {
        padding: 4px 8px;
        font-size: 11px;
        min-width: auto;
    }
    
    /* Board - fills ALL available space */
    .board-wrapper {
        order: 5;
        padding: 0;
        background: transparent;
        border: none;
        width: 100%;
        flex: 1;
        display: flex;
        align-items: flex-start;
        justify-content: center;
        min-height: 0;
    /*    overflow: hidden;*/
    }
    
    .game-board {
        display: block;
        max-width: 100%;
        max-height: 100%;
    }
    
    .btn-start {
        padding: 6px 15px;
        font-size: 13px;
    }
    
    /* Hide chat during game on mobile */
    .game-chat {
        order: 6;
        display: none;
    }
    
    /* Draw/undo offer compact */
    .draw-offer, .undo-offer {
        padding: 6px 12px;
        font-size: 13px;
        order: 3;
        flex-shrink: 0;
    }
    
    /* Game end overlay - mobile friendly */
    .game-end-content {
        padding: 25px 20px;
        margin: 10px;
        max-width: 95%;
    }
    
    .game-end-content h2 {
        font-size: 28px;
    }
    
    #game-end-reason {
        font-size: 14px;
    }
    
    .game-end-buttons {
        gap: 10px;
        flex-direction: column;
    }
    
    .btn-replay {
        padding: 12px 25px;
        width: 100%;
    }
}

.leaderboard-section h2 {
    color: white; 
    padding: 10px; 
    border-radius: 12px 12px 0 0; 
    font-weight: normal; 
    text-align: center; 
    margin: -16px -16px 16px -16px;
    font-size: 24px;
}

.leaderboard-section td:first-child, td:nth-child(3), td:nth-child(4) {
    text-align: center;
}
.leaderboard-section th:first-child {
    text-align: left;
}

.leaderboard-section td {
    padding: 8px;
}

.leaderboard-section th {
    padding: 10px;
    border-bottom: 2px solid #ddd;
}
    
.go_back_btn {
    background-image: url(/static/arrow-left.svg);
    background-position: left center;
    background-repeat: no-repeat;
    background-size: 24px 24px;
    padding-left: 30px;
    color: #396B8B;
    font-size: 16px;
    display: block;
    text-decoration: none;
}

    
.page-header {
    padding-bottom: 20px;
    max-width: 418px;
}



h1 {
    font-size: 24px;
    font-weight: bold;
    color: #000000;
    padding: 5px 0 5px 0;
}