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

body {
    font-family: Arial, 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: 1200px;
    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: 10px;
    right: 80px;
    z-index: 1001;
}

.language-toggle {
    width: 45px;
    height: 45px;
    font-size: 24px;
    cursor: pointer;
    border: 2px solid #8B5C2A;
    border-radius: 8px;
    background: #FFF9EF;
    color: #8B5C2A;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-variant: small-caps;
}

.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;
}

/* 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: 60%;
    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: 10px;
        right: 10px;
    }
    
    .menu-toggle {
        width: 45px;
        height: 45px;
        font-size: 24px;
    }
    
    .language-selector {
        top: 10px;
        right: 65px;
    }
    
    .language-toggle {
        width: 40px;
        height: 40px;
        font-size: 22px;
    }
    
    .modal-content {
        margin: 20% auto;
        padding: 20px;
        width: 95%;
    }
}

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

/* Play board container */
.play-container {
    width: 100%;
    max-width: 1400px;
    margin: 60px auto 0;
    padding: 15px;
}

.play-layout {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto auto 1fr auto auto;
    gap: 15px;
    align-items: start;
}

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

/* 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 */
.opponent-info, .user-info.play-user {
    background: white;
    padding: 12px 20px;
    border-radius: 8px;
    border: 1px solid #ddd;
}

.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;
}

@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.5);
    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: white;
    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;
}

.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-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;
    background: white;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #ddd;
}

.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;
}

/* ============ MOBILE PLAY BOARD STYLES ============ */
@media (max-width: 768px) {
    /* Container takes full width */
    .play-container {
        padding: 5px;
        margin-top: 50px;
    }
    
    /* Single column layout */
    .play-layout {
        display: flex;
        flex-direction: column;
        gap: 8px;
    }
    
    /* Time controls - compact 2-line layout before game */
    .time-controls-section {
        padding: 8px;
        order: 1;
    }
    
    .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;
    }
    
    /* Opponent info - compact */
    .opponent-info {
        padding: 6px 10px;
        order: 2;
    }
    
    .opponent-info .player-display {
        gap: 8px;
    }
    
    .opponent-info .player-login {
        font-size: 14px;
    }
    
    .opponent-info .player-timer {
        font-size: 16px;
    }
    
    /* Game controls - single line, compact */
    .game-controls {
        padding: 5px;
        order: 3;
        display: flex;
        flex-wrap: wrap;
        gap: 4px;
        justify-content: center;
    }
    
    .game-controls .game-btn {
        padding: 4px 8px;
        font-size: 11px;
        min-width: auto;
    }
    
    /* Board - full width, maximum size */
    .board-wrapper {
        order: 4;
        padding: 0;
        background: transparent;
        border: none;
        width: 100%;
        overflow: visible;
    }
    
    .game-board {
        width: 100vw !important;
        height: auto !important;
        max-width: none;
        margin-left: -5px;  /* Offset container padding */
    }
    
    /* User info - compact */
    .user-info.play-user, .user-info:not(.play-user) {
        position: static !important;
        padding: 6px 10px;
        order: 5;
    }
    
    .user-info .player-display {
        gap: 8px;
    }
    
    .user-info .player-login {
        font-size: 14px;
    }
    
    .user-info .player-timer {
        font-size: 16px;
    }
    
    .btn-start {
        padding: 6px 15px;
        font-size: 13px;
    }
    
    /* Hide chat during game on mobile */
    .game-chat {
        order: 6;
        display: none;
    }
    
    /* Draw offer compact */
    .draw-offer {
        padding: 8px 12px;
        font-size: 13px;
        order: 3;
    }
    
    /* 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 {
        flex-direction: column;
        gap: 10px;
    }
    
    .btn-replay {
        padding: 12px 25px;
        width: 100%;
    }
}

/* During game - even more compact */
@media (max-width: 768px) {
    body.game-active .time-controls-section {
        display: none;
    }
    
    body.game-active .play-container {
        margin-top: 5px;
        padding: 2px;
    }
    
    body.game-active .play-layout {
        gap: 4px;
    }
    
    body.game-active .opponent-info,
    body.game-active .user-info.play-user,
    body.game-active .user-info:not(.play-user) {
        padding: 4px 8px;
    }
    
    body.game-active .game-controls {
        padding: 3px;
    }
    
    body.game-active .game-board {
        margin-left: -2px;
    }
}
