/* General Styles */
body {
    min-height: 100vh;
    margin: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: 'Poppins', sans-serif;
    background-image: url(bg.jpg);
    background-repeat: no-repeat;
    background-size: cover;
    background-position: center;
}

.container {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    text-align: center;
    background-color: rgba(0, 0, 0, 0.5);
    border: 2px solid black;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0px 4px 6px rgba(0, 0, 0, 0.5);
}

h1 {
    font-variant: small-caps;
    color: white;
    margin: 0 0 5px 0;
    padding-bottom: 10px;
    border-bottom: 2px solid white;
    font-size: clamp(1.5rem, 4vw, 2.5rem);
}

/* Chessboard Container */
#board-container {
    margin: 0 auto; /* Center the container */
    border-radius: 8px; /* Rounded corners */
    box-sizing: border-box; /* Include padding and border in the width */
    overflow: hidden;
}

/* Chessboard Table */
#chessboard {
    border-collapse: collapse; /* Remove spacing between cells */
    table-layout: fixed; /* Ensure equal column widths */
}

#chessboard tr {
    overflow: hidden;
}

/* Chessboard Cells */
#chessboard td {
    background-image: url(light.png); /* Background for light squares */
    background-size: cover;
    position: relative; /* Required for absolute positioning of child elements */
    box-sizing: border-box; /* Include padding and border in the width */
}

/* Ensure images inside cells don't overflow */
#chessboard td img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    display: block;
    margin: auto;
}

/* Knight and Avatar */
.knight img {
    max-width: 80% !important;
    max-height: 80% !important;
    width: auto;
    height: auto;
    display: block;
    margin: auto;
}

/* Valid Moves */
.valid-move {
    position: relative;
    border-radius: 8px;
    transition: transform 0.2s ease-in-out;
}

.valid-move::before {
    content: ""; /* Required for pseudo-elements */
    position: absolute;
    top: 0;
    left: 0;
    width: 75%;
    height: 75%;
    background-color: rgba(255, 186, 0, 0.3);
    border-radius: 50%;
    z-index: 1;
    display: flex; /* Enable Flexbox */
    justify-content: center; /* Center horizontally */
    align-items: center; /* Center vertically */
    transform: translate(16.666%, 16.666%); /* Adjust for 75% size */
}

/* Wall Styling */
.wall {
    cursor: not-allowed;
    background-size: cover;
}

.wall img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Coin Styling */
.coin {
    background-size: cover;
}

/* Finish Styling */
.finish {
    background-size: cover;
}

/* Game Container */
#game-container {
    position: relative;
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

/* Scores Container */
#scores-container {
    display: flex;
    justify-content: center;
    gap: 30px;
    font-size: clamp(16px, 3.5vw, 24px);
    color: white;
}

/* Controls Container */
#controls-container {
    display: flex;
    justify-content: center;
    gap: 20px;
}

/* Buttons */
.control-button {
    margin: 10px;
    padding: clamp(8px, 2vw, 16px) clamp(12px, 3vw, 24px);
    font-size: clamp(14px, 3vw, 18px);
    cursor: pointer;
    background-color: #fdd181;
    color: black;
    border: none;
    border-radius: 4px;
    touch-action: manipulation;
}

.control-button:hover {
    background-color: #ffc538;
}

/* Avatar Button */
.avatar-button {
    margin: 10px;
    padding: clamp(8px, 2vw, 16px) clamp(16px, 4vw, 32px);
    font-size: clamp(14px, 3vw, 18px);
    cursor: pointer;
    background-color: #fdd181;
    color: black;
    border: none;
    border-radius: 4px;
    touch-action: manipulation;
}

/* Modal */
.avatar-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 350px;
    background: white;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.3);
    z-index: 1000;
}

/* Hide Modal by Default */
.hidden {
    display: none;
}

/* Modal Close Button */
.close-button {
    font-size: 24px;
    cursor: pointer;
    float: right;
}

/* Avatar Grid */
.avatar-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-top: 10px;
}

/* Avatar Images */
.avatar-option {
    width: 70px;
    height: 70px;
    cursor: pointer;
    transition: transform 0.2s;
}

.avatar-option:hover {
    transform: scale(1.1);
}

/* Timer and Score Display */
#timer-display, #score-display {
    color: white;
    font-size: clamp(16px, 3.5vw, 24px);
}

/* Win Modal */
#win-modal {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80%;
    max-width: 500px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    text-align: center;
    padding: 20px;
    z-index: 1000;
}

#win-modal-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

#win-message, #win-points, #win-level-message {
    font-size: 24px;
    font-weight: bold;
    color: #333;
}

#win-score {
    font-size: 18px;
    margin: 10px 0;
    color: #555;
}

#win-close {
    background: #fdd181;
    color: black;
    border: none;
    padding: 10px 20px;
    font-size: 18px;
    cursor: pointer;
    border-radius: 5px;
    margin-top: 15px;
}

#win-close:hover {
    background: #ffc538;
}

/* Help Modal */
.help-modal {
    position: absolute;
    top: 0;
    left: 0;
    height: auto;
    max-height: 90vh;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 8px;
    box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    padding: 20px;
    color: black;
    text-align: left;
    max-width: 760px;
    overflow-y: auto;
    display: none;
}

.help-modal.show {
    display: block;
}

.help-modal h2 {
    font-size: clamp(1.2rem, 3vw, 1.5rem);
    color: black;
    margin-bottom: 15px;
    border-bottom: 2px solid #fdd181;
    padding-bottom: 10px;
}

.help-modal p {
    font-size: clamp(1rem, 2.5vw, 1.2rem);
    color: black;
    margin-bottom: 10px;
    line-height: 1.6;
}

.help-close {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    transition: color 0.2s;
}

.help-close:hover {
    color: #000;
}

/* Help Button */
.help-button {
    margin: 10px;
    width: clamp(40px, 8vw, 50px);
    font-size: clamp(20px, 4vw, 24px);
    cursor: pointer;
    background-color: #fdd181;
    color: black;
    border: none;
    border-radius: 4px;
    touch-action: manipulation;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

.help-button:hover {
    background-color: #ffc538;
}