/* Basic styling for Trapdoor Chess board and controls.
   The board is rendered using a CSS grid.  You can replace the Unicode
   pieces with custom images by modifying the background-image rules. */

/* Increase wrapper width to accommodate move log */
.trapdoor-chess-wrapper {
    max-width: 800px;
    margin: 20px auto;
    text-align: center;
    font-family: sans-serif;
}

/* Container holding the board and move log side by side */
.trapdoor-chess-game {
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

/* Move log styling */
.trapdoor-move-log {
    width: 200px;
    max-height: 500px;
    overflow-y: auto;
    margin-left: 10px;
    padding: 5px;
    border: 1px solid #333;
    background-color: #fff;
    font-family: monospace;
    font-size: 14px;
    text-align: left;
}

/* Table styling for move log */
.trapdoor-move-log table {
    width: 100%;
    border-collapse: collapse;
}
.trapdoor-move-log thead th {
    border-bottom: 2px solid #333;
    padding: 4px;
    text-align: left;
    font-weight: bold;
}
.trapdoor-move-log tbody td {
    border-bottom: 1px solid #ddd;
    padding: 4px;
}
.trapdoor-move-log tr.trap-row td {
    font-style: italic;
    color: #c00;
}

/* Welcome section */
.trapdoor-chess-welcome {
    margin-bottom: 10px;
    text-align: left;
}
.trapdoor-chess-welcome h2 {
    margin: 0 0 5px;
}

/* Highlight for last move squares */
.trapdoor-chess-square.last-move {
    box-shadow: inset 0 0 0 4px rgba(0, 255, 0, 0.6);
}
/* Countdown timer styling */
.trapdoor-chess-countdown {
    margin-top: 10px;
    font-weight: bold;
}

/* Controls container: use flex layout for consistent spacing */
.trapdoor-chess-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

/* Style the selects and buttons uniformly */
.trapdoor-chess-controls select,
.trapdoor-chess-controls button {
    padding: 4px 8px;
    font-size: 14px;
}

.trapdoor-chess-board {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    border: 2px solid #333;
    width: 500px;
    aspect-ratio: 1 / 1;
    margin: 0;
    position: relative;
    z-index: 1; /* ensure the board sits above coordinate labels */
}

/* Wrapper around the board with padding for labels */
.trapdoor-chess-board-wrapper {
    position: relative;
    display: inline-block;
    padding-left: 20px; /* space for rank labels */
    padding-bottom: 20px; /* space for file labels */
}

/* Rank (numbers) labels down the left side */
.rank-labels {
    position: absolute;
    left: 0;
    top: 0;
    width: 20px;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    font-weight: bold;
    user-select: none;
    pointer-events: none;
    z-index: 0; /* behind the board */

    /* show rank labels */
    /* intentionally visible */
}
.rank-label {
    line-height: 1;
}

/* File (letters) labels along the bottom */
.file-labels {
    position: absolute;
    left: 20px;
    bottom: 0;
    width: 500px;
    height: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    font-weight: bold;
    user-select: none;
    pointer-events: none;
    z-index: 0; /* behind the board */

    /* show file labels */
    /* intentionally visible */
}
.rank-label, .file-label {
    pointer-events: none;
}
.file-label {
    line-height: 1;
}

.trapdoor-chess-square {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2em;
    user-select: none;
    cursor: pointer;
    position: relative;
    z-index: 2; /* bring squares above any overlay */
}

.trapdoor-chess-square.light {
    background-color: #f0d9b5;
}
.trapdoor-chess-square.dark {
    background-color: #b58863;
}

.trapdoor-chess-square.highlight {
    box-shadow: inset 0 0 0 4px rgba(255, 255, 0, 0.7);
}

/* Visual cue for a trapdoor about to open */
/* Trapdoor opening highlight */
.trapdoor-chess-square.trapdoor-opening {
    background-color: #ff6666 !important;
    color: #000;
}

.trapdoor-chess-info {
    margin-top: 10px;
    min-height: 24px;
    font-weight: bold;
}

/* Learn to Play modal overlay */
.trapdoor-chess-learn-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}
.trapdoor-chess-learn-content {
    background-color: #fff;
    padding: 20px;
    border-radius: 4px;
    max-width: 600px;
    text-align: left;
    color: #333;
}
.trapdoor-chess-learn-content h3 {
    margin-top: 0;
}
.trapdoor-chess-learn-content button {
    margin-top: 10px;
    padding: 5px 10px;
    font-size: 14px;
}