
        /* Safe area padding */
        :root {
            --safe-area-top: env(safe-area-inset-top, 0px);
            --safe-area-right: env(safe-area-inset-right, 0px);
            --safe-area-bottom: env(safe-area-inset-bottom, 0px);
            --safe-area-left: env(safe-area-inset-left, 0px);
        }

        /* General body styling for full screen and font */
        body {
            margin: 0;
            padding: 0;
            overflow: hidden;
            display: flex;
            flex-direction: column;
            justify-content: flex-start;
            align-items: center;
            background: linear-gradient(135deg, #2c3e50, #1a1a2e);
            font-family: 'Inter', sans-serif;
            color: #ecf0f1;
            position: relative;
            height: 100vh;
            box-sizing: border-box;
        }

        /* Header styling */
        .game-header {
            position: relative;
            width: 100%;
            text-align: center;
            padding: 15px 0;
            background: rgba(0, 0, 0, 0.4);
            z-index: 20;
            flex-shrink: 0;
            box-sizing: border-box;
            display: flex;
            justify-content: center;
            align-items: center;
            gap: 10px;
        }

        .game-header h1 {
            margin: 0;
            font-size: 1.6rem;
            color: #f39c12;
            text-shadow: 0 0 10px rgba(243, 156, 18, 0.7);
            letter-spacing: 1px;
        }

        .version-badge {
            background: #3498db;
            color: white;
            padding: 3px 8px;
            border-radius: 10px;
            font-size: 0.8rem;
            font-weight: bold;
        }

        /* Main container for the game */
        .main-game-wrapper {
            display: flex;
            flex-direction: column;
            width: 98vw;
            max-width: 900px;
            flex-grow: 1;
            max-height: calc(100vh - var(--safe-area-top) - var(--safe-area-bottom) - 80px);
            border-radius: 20px;
            box-shadow: 0 15px 30px rgba(0, 0, 0, 0.6);
            overflow: hidden;
            border: 3px solid #777;
            background-color: #2c3e50;
            margin-top: 20px;
            margin-bottom: 20px;
            box-sizing: border-box;
        }

        /* Game content area */
        .game-area {
            flex: 1;
            padding: 15px;
            box-sizing: border-box;
            position: relative;
            overflow-y: auto;
            border-radius: 15px;
            margin: 5px;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            gap: 15px;
            background-color: rgba(255, 255, 255, 0.1);
            box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.3);
        }

        /* Chess board container */
        .chess-container {
            display: flex;
            flex-direction: column;
            align-items: center;
            width: 100%;
            padding: 0;
            box-sizing: border-box;
            background-color: transparent;
            border-radius: 0;
        }

        .player-names {
            display: flex;
            justify-content: space-between;
            width: 100%;
            max-width: 500px;
            margin-bottom: 10px;
        }

        .player-name {
            background: rgba(0, 0, 0, 0.4);
            padding: 8px 15px;
            border-radius: 8px;
            font-weight: bold;
        }

        .player-name.white {
            border-left: 4px solid #ecf0f1;
        }

        .player-name.black {
            border-right: 4px solid #2c3e50;
            text-align: right;
        }

        .game-info {
            display: flex;
            justify-content: space-between;
            align-items: center;
            width: 100%;
            max-width: 500px;
            margin-bottom: 10px;
            padding: 8px 12px;
            background: rgba(0, 0, 0, 0.4);
            border-radius: 8px;
            font-size: 1rem;
        }

        .player-turn {
            font-weight: bold;
            color: #f39c12;
            transition: all 0.3s ease;
            padding: 5px 10px;
            border-radius: 5px;
        }

        .game-controls {
            display: flex;
            gap: 8px;
        }

        button {
            background: #3498db;
            color: white;
            border: none;
            padding: 8px 15px;
            border-radius: 5px;
            cursor: pointer;
            font-weight: bold;
            transition: background 0.3s, transform 0.1s;
        }

        button:hover {
            background: #2980b9;
            transform: translateY(-1px);
        }

        button:active {
            transform: translateY(0);
        }

        /* Chess board styling */
        .chessboard {
            display: grid;
            grid-template-columns: repeat(8, 1fr);
            grid-template-rows: repeat(8, 1fr);
            width: 80vmin;
            height: 80vmin;
            max-width: 500px;
            max-height: 500px;
            border: 4px solid #4a69bd;
            box-shadow: 0 8px 16px rgba(0, 0, 0, 0.5);
            background: #3d5a80;
        }

        .square {
            display: flex;
            justify-content: center;
            align-items: center;
            position: relative;
        }

        .square.light {
            background-color: #90a4ae;
        }

        .square.dark {
            background-color: #546e7a;
        }

        /* Custom Dark Bordered Squares for a8, d8, h8 */
        .square.custom-dark-bordered {
            background-color: #36495b !important; /* Slightly different dark shade */
            border: 2px solid white !important; /* White border */
            box-sizing: border-box; /* Ensure border is included in dimensions */
        }
        /* Custom Light Bordered Squares (if needed, example) */
        .square.custom-light-bordered {
            background-color: #aebfd0 !important; /* Slightly different light shade */
            border: 2px solid white !important;
            box-sizing: border-box;
        }


        .square.highlighted {
            background-color: rgba(46, 204, 113, 0.5);
        }

        .square.possible-move::before {
            content: '';
            position: absolute;
            width: 30%;
            height: 30%;
            background-color: rgba(46, 204, 113, 0.8);
            border-radius: 50%;
            z-index: 1;
        }

        .square.selected {
            background-color: rgba(243, 156, 18, 0.7);
        }

        /* Chess Piece Styling */
        .piece {
            width: 100%;
            height: 100%;
            display: flex;
            justify-content: center;
            align-items: center;
            z-index: 2;
            position: relative;
            transition: transform 0.2s ease, opacity 0.2s ease;
            user-select: none;
            cursor: grab;
        }

        /* Target the SVG directly within the .piece container */
        .piece svg {
            width: 85%; /* Make the SVG take up 85% of its parent (.piece) */
            height: 85%; /* Make the SVG take up 85% of its parent (.piece) */
            object-fit: contain; /* Maintain aspect ratio within its bounds */
            /* filter: drop-shadow(1px 1px 2px rgba(0,0,0,0.5)); */ /* Re-enabled for subtle depth as it won't affect internal color */
            filter: drop-shadow(1px 1px 2px rgba(0,0,0,0.5));
        }

        .notation {
            position: absolute;
            font-size: 1.8vmin;
            pointer-events: none;
            color: rgba(255, 255, 255, 0.6);
        }

        .notation.file {
            bottom: 2px;
            right: 3px;
        }

        .notation.rank {
            top: 2px;
            left: 3px;
        }

        .status-bar {
            margin-top: 10px;
            padding: 8px 15px;
            background: rgba(0, 0, 0, 0.3);
            border-radius: 5px;
            min-height: 20px;
            text-align: center;
            width: 100%;
            max-width: 500px;
            color: #ecf0f1;
        }

        /* Player Names Modal */
        .modal {
            display: none;
            position: fixed;
            z-index: 100;
            left: 0;
            top: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0, 0, 0, 0.7);
            justify-content: center;
            align-items: center;
        }

        .modal-content {
            background-color: #34495e;
            padding: 30px;
            border-radius: 10px;
            box-shadow: 0 10px 25px rgba(0, 0, 0, 0.8);
            width: 90%;
            max-width: 400px;
            text-align: center;
            display: flex;
            flex-direction: column;
            gap: 10px;
        }

        .modal-content h2 {
            margin-top: 0;
            color: #f39c12;
            margin-bottom: 20px;
        }

        .modal-content label {
            display: block;
            margin-bottom: 5px;
            color: #ecf0f1;
            text-align: left;
            font-size: 0.9rem;
        }

        .modal-content input, .modal-content select {
            width: calc(100% - 20px);
            padding: 10px;
            margin-bottom: 5px; /* Adjusted margin */
            border: 1px solid #546e7a;
            border-radius: 5px;
            background-color: #2c3e50;
            color: #ecf0f1;
            font-size: 1rem;
            -webkit-appearance: none;
            -moz-appearance: none;
            appearance: none;
            background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23ecf0f1%22%20d%3D%22M287%2C114.7L146.2%2C255.5L5.4%2C114.7c-5.8-5.8-5.8-15.2%2C0-21s15.2-5.8%2C21%2C0l119.8%2C119.8L266%2C93.7c5.8-5.8%2C15.2-5.8%2C21%2C0S292.8%2C108.9%2C287%2C114.7z%22%2F%3E%3C%2Fsvg%3E');
            background-repeat: no-repeat;
            background-position: right 10px top 50%;
            background-size: 12px auto;
        }

        .modal-content button {
            width: 100%;
            padding: 12px;
            font-size: 1.1rem;
            margin-top: 15px; /* Added margin to button */
        }

        /* Game History Section */
        .game-history-container {
            width: 100%;
            max-width: 500px;
            background: rgba(0, 0, 0, 0.3);
            border-radius: 10px;
            padding: 15px;
            margin-top: 20px;
            box-sizing: border-box;
        }

        .game-history-container h3 {
            margin-top: 0;
            margin-bottom: 10px;
            color: #f39c12;
            text-align: center;
        }

        .game-history-list {
            list-style: none;
            padding: 0;
            max-height: 200px;
            overflow-y: auto;
        }

        .game-history-list li {
            background: rgba(255, 255, 255, 0.1);
            margin-bottom: 8px;
            padding: 10px;
            border-radius: 5px;
            display: flex;
            flex-direction: column;
            gap: 5px;
        }

        .game-history-list li strong {
            color: #ecf0f1;
        }

        .game-history-list li span {
            font-size: 0.9em;
            color: #ccc;
        }

        /* Responsive adjustments */
        @media (max-width: 600px) {
            .game-info {
                font-size: 0.9rem;
                flex-direction: column;
                align-items: center;
                gap: 8px;
            }
            
            .player-names {
                flex-direction: column;
                gap: 8px;
            }
            
            .player-name {
                text-align: center !important;
                border: none !important;
            }
            
            .game-controls {
                flex-wrap: wrap;
                justify-content: center;
            }
            
            button {
                padding: 6px 12px;
                font-size: 0.8rem;
            }

            .chessboard {
                width: 95vmin;
                height: 95vmin;
            }

            .piece svg {
                width: 80%;
                height: 80%;
            }

            .notation {
                font-size: 2vmin;
            }
        }
    
