@font-face {
    font-family: '4Text';
    src: url('/XT-EXTRALIGHT.TTF') format('truetype');
    font-weight: 200;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: '4Text';
    src: url('/XT-EXTRALIGHTITALIC.TTF') format('truetype');
    font-weight: 200;
    font-style: italic;
    font-display: swap;
}

@font-face {
    font-family: '4Text';
    src: url('/XT-LIGHT.TTF') format('truetype');
    font-weight: 300;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: '4Text';
    src: url('/XT-LIGHTITALIC.TTF') format('truetype');
    font-weight: 300;
    font-style: italic;
    font-display: swap;
}

@font-face {
    font-family: '4Text';
    src: url('/XT-REGULAR.TTF') format('truetype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: '4Text';
    src: url('/XT-ITALIC.TTF') format('truetype');
    font-weight: 400;
    font-style: italic;
    font-display: swap;
}

@font-face {
    font-family: '4Text';
    src: url('/XT-MEDIUM.TTF') format('truetype');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: '4Text';
    src: url('/XT-MEDIUMITALIC.TTF') format('truetype');
    font-weight: 500;
    font-style: italic;
    font-display: swap;
}

@font-face {
    font-family: '4Text';
    src: url('/XT-SEMIBOLD.TTF') format('truetype');
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: '4Text';
    src: url('/XT-SEMIBOLDITALIC.TTF') format('truetype');
    font-weight: 600;
    font-style: italic;
    font-display: swap;
}

@font-face {
    font-family: '4Text';
    src: url('/XT-BOLD.TTF') format('truetype');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: '4Text';
    src: url('/XT-BOLDITALIC.TTF') format('truetype');
    font-weight: 700;
    font-style: italic;
    font-display: swap;
}

@font-face {
    font-family: '4Text';
    src: url('/XT-BLACK.TTF') format('truetype');
    font-weight: 900;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: '4Text';
    src: url('/XT-BLACKITALIC.TTF') format('truetype');
    font-weight: 900;
    font-style: italic;
    font-display: swap;
}

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

body {
    font-family: '4Text', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #fff;
    font-weight: 400; /* Regular default */
}

.game-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.header {
    text-align: center;
    margin-bottom: 30px;
}

.header h1 {
    font-size: 3rem;
    font-weight: 900; /* Black */
    text-shadow: 3px 3px 6px rgba(0,0,0,0.5);
    margin-bottom: 20px;
    background: linear-gradient(45deg, #ff6b6b, #4ecdc4, #45b7d1, #96ceb4);
    background-size: 400% 400%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: gradientShift 3s ease-in-out infinite;
}

@keyframes gradientShift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.game-mode-selector {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
    margin-bottom: 20px;
    padding-top: 10px;
    border-top: 1px solid rgba(255,255,255,0.2);
}

.game-mode-selector label {
    font-weight: 600;
}

.game-mode-selector select {
    padding: 10px 15px;
    border: none;
    border-radius: 10px;
    background: rgba(255,255,255,0.1);
    color: #fff;
    font-size: 16px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.2);
    font-weight: 500;
}

.game-mode-selector select option {
    background-color: #4a2b71;
    color: #fff;
    font-weight: 400;
}

.game-mode-selector button {
    padding: 12px 25px;
    border: none;
    border-radius: 10px;
    background: linear-gradient(45deg, #ff6b6b, #ee5a24);
    color: #fff;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.game-mode-selector button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}

.difficulty-selector, .commentary-style-selector, .piece-display-style-selector, .timer-config {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
    margin-bottom: 15px;
}

.difficulty-selector label,
.commentary-style-selector label,
.piece-display-style-selector label,
.timer-config label {
     font-weight: 600; /* SemiBold */
}

.difficulty-selector select,
.commentary-style-selector select,
.piece-display-style-selector select,
.timer-config select,
.timer-config input[type="number"] { 
    padding: 10px 15px;
    border: none;
    border-radius: 10px;
    background: rgba(255,255,255,0.1);
    color: #fff;
    font-size: 16px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.2);
    font-weight: 500; /* Medium */
}

.difficulty-selector select option,
.timer-config select option { 
    background-color: #4a2b71;
    color: #fff;
    font-weight: 400; /* Regular */
}

.difficulty-selector button {
    padding: 12px 25px;
    border: none;
    border-radius: 10px;
    background: linear-gradient(45deg, #ff6b6b, #ee5a24);
    color: #fff;
    font-weight: 700; /* Bold */
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.difficulty-selector button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}

.multiplayer-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-top: 15px;
    padding: 15px;
    background: rgba(255,255,255,0.1);
    border-radius: 15px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.2);
}

.multiplayer-controls h3 {
    font-weight: 600;
    margin-bottom: 5px;
}

.elo-slider-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    width: 100%;
    margin-top: 5px;
}

.elo-slider-container input[type="range"] {
    width: 80%;
    -webkit-appearance: none;
    height: 8px;
    background: rgba(255,255,255,0.3);
    border-radius: 5px;
    outline: none;
    transition: opacity .2s;
}

.elo-slider-container input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: linear-gradient(45deg, #4ecdc4, #45b7d1);
    cursor: pointer;
    box-shadow: 0 0 5px rgba(0,0,0,0.5);
    border: 2px solid #fff;
}

.elo-slider-container input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: linear-gradient(45deg, #4ecdc4, #45b7d1);
    cursor: pointer;
    box-shadow: 0 0 5px rgba(0,0,0,0.5);
    border: 2px solid #fff;
}

.elo-slider-container span {
    font-size: 0.9em;
    font-weight: 500;
    color: rgba(255,255,255,0.7);
}

.multiplayer-controls ul {
    list-style: none;
    padding: 0;
    max-height: 150px;
    overflow-y: auto;
    width: 100%;
    background: rgba(0,0,0,0.1);
    border-radius: 8px;
    padding: 10px;
    border: 1px solid rgba(255,255,255,0.1);
}

.multiplayer-controls li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px dashed rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.8);
    font-weight: 400;
}

.multiplayer-controls li:last-child {
    border-bottom: none;
}

.multiplayer-controls .peer-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.3);
    object-fit: cover;
}

.multiplayer-options button {
    padding: 10px 15px;
    border: none;
    border-radius: 8px;
    background: linear-gradient(45deg, #4ecdc4, #45b7d1);
    color: #fff;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    margin: 5px;
}

.multiplayer-options button:disabled {
    background: rgba(0,0,0,0.3);
    cursor: not-allowed;
}

.multiplayer-options button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

.multiplayer-controls .chat-container {
    width: 100%;
    margin-top: 15px;
    border-top: 1px solid rgba(255,255,255,0.2);
    padding-top: 15px;
}

#chat-box {
    height: 100px;
    background: rgba(0,0,0,0.1);
    border-radius: 8px;
    padding: 10px;
    overflow-y: auto;
    margin-bottom: 10px;
    color: rgba(255,255,255,0.9);
    font-size: 0.9em;
    line-height: 1.4;
    border: 1px solid rgba(255,255,255,0.1);
}

#chat-box p {
    margin-bottom: 5px;
    word-wrap: break-word;
}

#chat-input {
    width: calc(100% - 70px);
    padding: 8px 12px;
    border: none;
    border-radius: 8px;
    background: rgba(255,255,255,0.1);
    color: #fff;
    font-size: 15px;
    border: 1px solid rgba(255,255,255,0.2);
    margin-right: 5px;
}

#send-chat {
    width: 60px;
    padding: 8px;
    border: none;
    border-radius: 8px;
    background: linear-gradient(45deg, #f39c12, #e67e22);
    color: #fff;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
}

#send-chat:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

.player-avatar {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    margin: 0 auto 15px;
    display: block;
    border: 4px solid rgba(255,255,255,0.3);
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    object-fit: cover;
    display: flex;
    align-items: center;
    justify-content: center;
}

.player-avatar-img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.player-avatar.white-player-color {
    border-color: #3498db; 
}

.player-avatar.black-player-color {
    border-color: #e74c3c; 
}

.multiplayer-controls .multiplayer-options button {
    display: inline-block; 
    margin-left: 10px;
    padding: 5px 10px;
    font-size: 0.8em;
}

.opponent-info, .player-info {
    background: rgba(255,255,255,0.1);
    border-radius: 20px;
    padding: 20px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.2);
    text-align: center;
}

.opponent-avatar img, .player-icon {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    margin: 0 auto 15px;
    display: block;
    border: 4px solid rgba(255,255,255,0.3);
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    object-fit: cover;
}

.player-icon {
    background: linear-gradient(45deg, #4ecdc4, #45b7d1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
}

.opponent-stats h3, .player-stats h3 {
    text-align: center;
    margin-bottom: 10px;
    font-size: 1.5rem;
    font-weight: 700; 
}

.opponent-stats p, .player-stats p {
    text-align: center;
    font-size: 1rem;
    color: rgba(255,255,255,0.8);
    font-weight: 400; 
}

#opponent-elo {
    font-size: 0.9em; 
    color: rgba(255,255,255,0.7);
    margin-bottom: 5px; 
}

.health-bar {
    width: 100%;
    height: 20px;
    background: rgba(0,0,0,0.3);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 15px;
}

.health-fill {
    height: 100%;
    transition: width 0.5s ease;
    width: 100%;
}

.chess-board {
    display: grid;
    grid-template-columns: 30px repeat(8, 1fr) 30px;
    grid-template-rows: 30px repeat(8, 1fr) 30px;
    width: 540px;
    height: 540px;
    max-width: 100%;
    max-height: 100%;
    border: 4px solid rgba(255,255,255,0.3);
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 8px 30px rgba(0,0,0,0.3);
    margin: 0 auto;
    position: relative;
}

.chess-board-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    grid-column: 2 / 10;
    grid-row: 2 / 10;
    width: 100%;
    height: 100%;
    position: relative;
    z-index: 1;
}

.chess-square {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    cursor: pointer;
    transition: all 0.1s ease-in-out;
    position: relative;
    overflow: hidden;
    user-select: none;
}

.chess-board-grid .chess-square {
    width: 100%;
    height: 100%;
}

.chess-square.light {
    background: rgba(255,255,255,0.9);
    color: #333;
}

.chess-square.dark {
    background: rgba(100,100,100,0.9);
    color: #fff;
}

.chess-square.selected {
    background: rgba(255,255,0,0.7) !important;
    box-shadow: inset 0 0 20px rgba(255,255,0,0.5);
}

.chess-square.possible-move {
    background: rgba(0,255,0,0.3) !important;
}

.chess-square.enemy-piece {
    background: rgba(255,0,0,0.3) !important;
}

.chess-square:hover {
     filter: brightness(1.1);
}

.chess-piece-img {
    width: 90%;
    height: 90%;
    object-fit: cover;
    border-radius: 8px;
    pointer-events: none;
    transition: transform 0.1s ease-in-out;
}

.piece-letter {
    font-size: 2em;
    font-weight: 900; 
    text-transform: uppercase;
    pointer-events: none;
}

.chess-square.white-piece .chess-piece-img {
    border: 3px solid #fff;
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.5);
}
.chess-square.white-piece .piece-letter {
    color: #fff;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
}

.chess-square.black-piece .chess-piece-img {
    border: 3px solid #333;
    box-shadow: 0 0 8px rgba(0, 0, 0, 0.5);
}
.chess-square.black-piece .piece-letter {
    color: #333;
    text-shadow: 1px 1px 2px rgba(255,255,255,0.5);
}

.chess-square:hover .chess-piece-img {
    /* transform: scale(1.1); */
}

.coordinates-row {
    position: absolute;
    display: flex;
    font-size: 0.9em;
    font-weight: 500; 
    color: rgba(255,255,255,0.7);
    z-index: 0;
}

.rank-coords {
    flex-direction: column;
    left: 0;
    top: 30px;
    height: calc(100% - 60px);
    justify-content: space-around;
    padding: 0 5px;
}

.file-coords {
    flex-direction: row;
    bottom: 0;
    left: 30px;
    width: calc(100% - 60px);
    justify-content: space-around;
    padding: 5px 0;
}

.coordinate {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.controls {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
    margin-top: 20px;
}

.controls button {
    padding: 12px 25px;
    border: none;
    border-radius: 10px;
    background: rgba(255,255,255,0.1);
    color: #fff;
    font-weight: 700; 
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.2);
}

.controls button:hover {
    background: rgba(255,255,255,0.2);
    transform: translateY(-2px);
}

#confetti-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; 
    z-index: 999; 
}

.chess-square.hint-highlight {
    border: 3px solid yellow;
    box-shadow: 0 0 15px yellow;
    animation: pulse-hint 1s infinite alternate;
}

@keyframes pulse-hint {
    from {
        box-shadow: 0 0 10px yellow;
    }
    to {
        box-shadow: 0 2px 25px yellow;
    }
}

.reference-section {
    margin-top: 40px;
    padding: 20px;
    background: rgba(255,255,255,0.1);
    border-radius: 20px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.2);
    font-family: '4Text', sans-serif;
    font-style: italic;
}

.reference-section * {
    font-family: '4Text', sans-serif;
    font-style: italic;
}

.reference-section h2 {
    text-align: center;
    margin-bottom: 20px;
    font-size: 2rem;
    font-weight: 700; 
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.reference-section > p { 
    text-align: center;
    margin-bottom: 25px;
    font-size: 1.1rem;
    line-height: 1.6;
    color: rgba(255,255,255,0.9);
    font-weight: 400; 
}

.piece-reference-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 20px;
    justify-items: center; 
    align-items: start; 
}

.piece-reference-item {
    text-align: center;
    background: rgba(0,0,0,0.2);
    padding: 10px;
    border-radius: 10px;
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    border: 2px solid transparent; 
}

.piece-reference-grid h3.piece-group-heading {
    grid-column: 1 / -1; 
    text-align: center;
    margin-top: 20px;
    margin-bottom: 10px;
    font-size: 1.4rem;
    font-weight: 600; 
    color: #fff;
}

.piece-reference-item.white-piece-ref {
    border-color: #3498db; 
    background: rgba(52, 152, 219, 0.1); 
}

.piece-reference-item.black-piece-ref {
    border-color: #e74c3c; 
    background: rgba(231, 76, 60, 0.1); 
}

.piece-reference-item img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 5px;
    border: 2px solid rgba(255,255,255,0.2);
}

.piece-reference-item p {
    font-size: 0.9rem;
    font-weight: 500; 
    color: rgba(255,255,255,1);
    margin: 0; 
    text-align: center; 
}

.opponent-reference {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid rgba(255,255,255,0.2);
}

.opponent-reference h2 {
    text-align: center;
    margin-bottom: 20px;
    font-size: 2rem;
    font-weight: 700; 
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.opponent-reference p {
    text-align: center;
    margin-bottom: 25px;
    font-size: 1.1rem;
    line-height: 1.6;
    color: rgba(255,255,255,0.9);
    font-weight: 400; 
}

.opponent-strategy-details {
     display: grid;
     grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
     gap: 20px;
     justify-items: stretch; 
}

.opponent-strategy-item {
    background: rgba(0,0,0,0.2);
    padding: 15px;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.1);
    margin-bottom: 0; 
    display: flex; 
    flex-direction: column; 
}

.opponent-strategy-item h3 {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 1.3rem;
    color: rgba(255,255,255,1);
    font-weight: 600; 
    text-align: center; 
}

.opponent-strategy-item p {
    font-size: 1rem;
    line-height: 1.5;
    color: rgba(255,255,255,0.8);
    margin: 0; 
    text-align: left; 
    flex-grow: 1; 
    font-weight: 400; 
}

.rules-section {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid rgba(255,255,255,0.2);
    font-family: '4Text', sans-serif;
    font-style: italic;
}

.rules-section * {
    font-family: '4Text', sans-serif;
    font-style: italic;
}

.rules-section h2 {
     text-align: center;
    margin-bottom: 20px;
    font-size: 2rem;
    font-weight: 700; 
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.rules-section > p { 
    text-align: center;
    margin-bottom: 25px;
    font-size: 1.1rem;
    line-height: 1.6;
    color: rgba(255,255,255,0.9);
    font-weight: 400; 
}

.rules-category {
    margin-bottom: 30px; 
    padding: 15px;
    background: rgba(0,0,0,0.2);
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.1);
}

.rules-category h3 {
    font-size: 1.5rem;
    margin-bottom: 15px;
    color: rgba(255,255,255,1);
    font-weight: 600; 
    text-align: center;
}

.rules-category ul {
    list-style: none; 
    padding: 0;
}

.rules-category li {
    margin-bottom: 10px;
    font-size: 1rem;
    line-height: 1.5;
    color: rgba(255,255,255,0.8);
    padding-left: 20px; 
    position: relative;
    font-weight: 400; 
}

.rules-category li:last-child {
    margin-bottom: 0;
}

.rules-category li::before {
    content: '🎮'; 
    position: absolute;
    left: 0;
    color: #4ecdc4; 
    font-weight: 700; 
}

.rules-category li strong {
     color: rgba(255,255,255,1); 
     font-weight: 700; 
}

.commentary-section {
    margin-top: 30px;
    padding: 20px;
    background: rgba(0,0,0,0.3);
    border-radius: 15px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.2);
    text-align: center;
    display: flex; 
    flex-direction: column; 
}

.commentary-section h2 {
     font-size: 1.8rem;
     margin-bottom: 15px;
     font-weight: 700; 
     text-shadow: 1px 1px 3px rgba(0,0,0,0.3);
}

#commentary-box {
    flex-grow: 1; 
    min-height: 50px; 
    max-height: 250px; 
    overflow-y: auto; 
    background: rgba(255,255,255,0.1);
    border-radius: 10px;
    padding: 15px;
    text-align: left;
    font-size: 1.1rem;
    line-height: 1.6;
    color: rgba(255,255,255,0.9);
    display: flex; 
    flex-direction: column; 
    gap: 5px; 
}

#commentary-box p {
    margin: 0; 
    padding-bottom: 5px; 
    border-bottom: 1px dotted rgba(255,255,255,0.1); 
    margin-bottom: 0; 
    font-weight: 400; 
}

#commentary-box p:last-child {
    border-bottom: none; 
}

.rating-Outrageous { color: #8B0000; font-weight: 700; } 
.rating-Blunder { color: #FF0000; font-weight: 700; } 
.rating-Miss { color: #FF4500; font-weight: 500; } 
.rating-Mistake { color: #FFA500; font-weight: 500; } 
.rating-Inaccuracy { color: #FFFF00; font-weight: 500; } 
.rating-Good { color: #90EE90; font-weight: 500; } 
.rating-Excellent { color: #008000; font-weight: 700; } 
.rating-BestMove { color: #0000FF; font-weight: 700; } 
.rating-GreatMove { color: #800080; font-weight: 700; } 
.rating-Brilliant { color: #FF69B4; font-weight: 700; } 
.rating-Trophy { color: #FFD700; font-weight: 700; text-shadow: 1px 1px 2px rgba(0,0,0,0.5); } 

@keyframes flash-red-white {
    0% { color: #e74c3c; } 
    50% { color: #ffffff; } 
    100% { color: #e74c3c; } 
}

.flashing-title {
    animation: flash-red-white 1.5s infinite alternate; 
}

#damage-values-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 15px;
    justify-items: center;
    align-items: center;
    margin-top: 20px;
    margin-bottom: 30px; 
}

.damage-item {
    background: rgba(0,0,0,0.2);
    padding: 10px;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.1);
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 80px; 
}

.damage-item p {
    margin: 0;
    font-weight: 500; 
    color: rgba(255,255,255,0.9);
}

.damage-item .piece-name {
    font-size: 1.1rem;
    font-weight: 700; 
    margin-bottom: 5px;
}

.damage-item .damage-value {
    font-size: 1.5rem;
    font-weight: 900; 
    color: #e74c3c; 
    text-shadow: 1px 1px 3px rgba(0,0,0,0.5);
}

.damage-value-inline {
    font-weight: 900;
    color: #e74c3c; 
    text-shadow: 0 0 5px rgba(255, 0, 0, 0.5);
}

.timer-display {
    font-family: 'Digital-7', monospace; 
    font-size: 1.8em;
    font-weight: bold;
    color: #4ecdc4; 
    background: rgba(0,0,0,0.2);
    padding: 5px 10px;
    border-radius: 8px;
    margin-top: 10px;
    min-width: 100px; 
    text-align: center;
    box-shadow: inset 0 0 5px rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.1);
}

.timer-display.low-time {
    animation: flash-red 1s infinite alternate;
}

@keyframes flash-red {
    from { color: #e74c3c; transform: scale(1.0); }
    to { color: #ffffff; transform: scale(1.05); }
}

@media (max-width: 1024px) {
    .game-board-container {
        grid-template-columns: 200px 1fr 200px; 
        gap: 20px;
    }

    .chess-board {
        width: 460px; 
        height: 460px;
    }

     .opponent-info, .player-info {
         padding: 15px; 
     }

     .opponent-avatar img, .player-icon {
        width: 80px; 
        height: 80px;
     }

     .opponent-stats h3, .player-stats h3 {
        font-size: 1.3rem;
     }

     .opponent-stats p, .player-stats p {
        font-size: 0.9rem;
     }

    .reference-section p {
        font-size: 1rem;
    }

    .piece-reference-grid {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
        gap: 10px;
    }

     .piece-reference-item img {
        width: 60px;
        height: 60px;
     }

    .opponent-reference h2 {
        font-size: 1.5rem;
    }

    .opponent-reference p {
        font-size: 1rem;
    }

    .opponent-strategy-details {
         grid-template-columns: 1fr; 
    }

    .opponent-strategy-item h3 {
         font-size: 1.2rem; 
    }

    .opponent-strategy-item p {
         font-size: 0.95rem; 
    }

    #damage-values-grid {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); 
        gap: 10px;
    }

    .damage-item {
        padding: 8px; 
        min-height: 70px;
    }

    .damage-item .piece-name {
        font-size: 1rem; 
    }

    .damage-item .damage-value {
        font-size: 1.3rem; 
    }
}

@media (max-width: 768px) {
    .game-board-container {
        grid-template-columns: 1fr; 
        grid-template-rows: auto auto auto;
        gap: 20px;
    }

    .opponent-info, .player-info {
         order: initial; 
         flex-direction: row; 
         justify-content: center;
         align-items: center;
         gap: 20px;
    }

     .opponent-avatar, .player-avatar {
        margin: 0; 
     }

     .opponent-stats, .player-stats {
        text-align: left; 
     }
     .opponent-stats h3, .player-stats h3,
     .opponent-stats p, .player-stats p {
        text-align: left; 
     }

    .chess-board {
        width: 380px; 
        height: 380px;
    }

    .chess-square {
        font-size: 25px;
    }
    .piece-letter {
        font-size: 1.8em; 
    }

    .header h1 {
        font-size: 2rem;
    }

    .difficulty-selector, .commentary-style-selector, .piece-display-style-selector {
        flex-direction: column;
        gap: 10px;
    }

    .reference-section {
        padding: 15px;
    }

    .reference-section h2 {
        font-size: 1.5rem;
    }

     .reference-section p {
        font-size: 1rem;
    }

    .piece-reference-grid {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
        gap: 10px;
    }

     .piece-reference-item img {
        width: 60px;
        height: 60px;
     }

    .opponent-reference h2 {
        font-size: 1.5rem;
    }

    .opponent-reference p {
        font-size: 1rem;
    }

    .opponent-strategy-details {
         grid-template-columns: 1fr; 
    }

    .opponent-strategy-item h3 {
         font-size: 1.2rem; 
    }

    .opponent-strategy-item p {
         font-size: 0.95rem; 
    }

    .rules-section h2 {
         font-size: 1.3rem;
    }
    .rules-section > p {
         font-size: 0.9rem;
    }
     .rules-category h3 {
         font-size: 1.1rem;
    }
    .rules-category li {
         font-size: 0.95rem;
         padding-left: 15px; 
    }
    .rules-category li::before {
         font-size: 0.9em; 
    }

    .commentary-section {
        padding: 15px;
    }

     .commentary-section h2 {
        font-size: 1.4rem;
    }

     #commentary-box {
        font-size: 1rem;
        max-height: 200px; 
     }

    #damage-values-grid {
        grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); 
        gap: 8px;
    }

    .damage-item {
        padding: 6px;
        min-height: 60px;
    }

    .damage-item .piece-name {
        font-size: 0.9rem;
    }

    .damage-item .damage-value {
        font-size: 1.1rem;
    }

    .multiplayer-controls .multiplayer-options button {
        display: block; 
        margin: 5px auto;
    }
}

@media (max-width: 480px) {
    .chess-board {
        width: 340px; 
        height: 340px;
    }

     .chess-square {
        font-size: 20px; 
     }
     .piece-letter {
        font-size: 1.6em; 
     }

     .opponent-info, .player-info {
         flex-direction: column; 
         gap: 10px;
     }
      .opponent-stats, .player-stats {
        text-align: center; 
     }
      .opponent-stats h3, .opponent-stats h3,
      .opponent-stats p, .opponent-stats p {
        text-align: center; 
     }

     .opponent-avatar img, .player-icon {
         width: 70px; 
         height: 70px;
     }

     .controls {
        flex-direction: column;
        gap: 10px;
     }

     .rules-section h2 {
         font-size: 1.3rem;
     }
     .rules-section > p {
         font-size: 0.9rem;
     }
      .rules-category h3 {
         font-size: 1.1rem;
     }
     .rules-category li {
         font-size: 0.9rem;
         padding-left: 15px; 
     }
     .rules-category li::before {
         font-size: 0.9em; 
     }

    #damage-values-grid {
        grid-template-columns: repeat(auto-fill, minmax(60px, 1fr)); 
        gap: 6px;
    }

    .damage-item {
        padding: 5px;
        min-height: 50px;
    }

    .damage-item .piece-name {
        font-size: 0.8rem;
    }

    .damage-item .damage-value {
        font-size: 1rem;
    }
}