/* Global CSS Variables */
:root {
    --score-red: #cc0000;
    --chat-green: #009933;
    --board-green: #006600;
    --rack-blue: #003399;
    --move-yellow: #ffcc00;
    --text-dark: #333;
    --text-light: #fff;
    --button-green: #006600;
    --button-hover: #008800;
    --button-disabled: #cccccc;
}

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: Arial, sans-serif;
}

body {
    background-color: #e6e6fa;
    min-height: 100vh;
    padding: 20px;
}

/* Main Game Layout */
.game-container {
    display: grid;
    grid-template-columns: minmax(600px, 1fr) 300px;
    gap: 20px;
    max-width: 1200px;
    margin: 0 auto;
}

/* Score Panel */
.score-panel {
    background-color: var(--score-red);
    color: var(--text-light);
    padding: 15px;
    border-radius: 15px;
    margin-bottom: 20px;
}

.score-panel h2 {
    font-size: 1.5rem;
    margin-bottom: 10px;
}

.player-scores {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.player-score {
    display: flex;
    align-items: center;
    gap: 10px;
}

.player-icon {
    font-size: 1.2rem;
}

/* Move History */
.move-history-section {
    background-color: var(--move-yellow);
    padding: 15px;
    border-radius: 15px;
    margin-bottom: 20px;
    height: 300px;
    overflow-y: auto;
}

.move-history-section h3 {
    color: var(--text-dark);
    margin-bottom: 10px;
}

/* Game Board */
.game-board {
    display: grid;
    grid-template-columns: repeat(15, 1fr);
    gap: 1px;
    background-color: var(--board-green);
    padding: 10px;
    border-radius: 10px;
    aspect-ratio: 1;
}

/* Game Board Cell Types */
.board-cell {
    background-color: #fff;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    position: relative;
    border: 1px solid #ccc;
    transition: background-color 0.2s;
}

.board-cell::before {
    content: attr(data-bonus);
    position: absolute;
    font-size: 0.6rem;
    text-align: center;
    line-height: 1;
    opacity: 0.8;
}

/* Bonus Square Colors */
.board-cell.TW {
    background-color: #ff6666;
}

.board-cell.DW {
    background-color: #ffb366;
}

.board-cell.TL {
    background-color: #66b3ff;
}

.board-cell.DL {
    background-color: #99ff99;
}

/* Bonus Text */
.board-cell.TW::before {
    content: "TRIPLE\A WORD";
    white-space: pre;
    color: #800000;
}

.board-cell.DW::before {
    content: "DOUBLE\A WORD";
    white-space: pre;
    color: #804000;
}

.board-cell.TL::before {
    content: "TRIPLE\A LETTER";
    white-space: pre;
    color: #003366;
}

.board-cell.DL::before {
    content: "DOUBLE\A LETTER";
    white-space: pre;
    color: #004d00;
}

/* Placed Tile Styles */
.board-cell.has-tile {
    padding: 2px;
}

.board-cell .tile {
    width: 100%;
    height: 100%;
    margin: 0;
    border-radius: 3px;
}

/* Drag and Drop Styles */
.board-cell.valid-drop {
    background-color: rgba(0, 255, 0, 0.2);
}

.board-cell.invalid-drop {
    background-color: rgba(255, 0, 0, 0.2);
}

.tile.dragging {
    opacity: 0.5;
}

/* Animation for Placed Tiles */
@keyframes tilePlaced {
    0% {
        transform: scale(1.1);
        opacity: 0.8;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.tile.placed {
    animation: tilePlaced 0.3s ease-out forwards;
}

/* Empty Rack Placeholder */
.tile-rack.empty::before {
    content: "Drag tiles here";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: rgba(255, 255, 255, 0.7);
    font-size: 1.2rem;
    pointer-events: none;
}

/* Exchange Mode Styles */
.tile-rack.exchange-mode .tile {
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.2s, transform 0.2s;
}

.tile-rack.exchange-mode .tile:hover {
    opacity: 1;
    transform: scale(1.05);
}

.tile-rack.exchange-mode .tile.selected {
    border: 2px solid #fff;
    transform: scale(0.95);
}

/* Recommendation Styles */
.board-cell.recommended {
    background-color: rgba(255, 255, 0, 0.2);
}

.board-cell.recommended .tile {
    opacity: 0.8;
}

/* Tile Rack */
.tile-rack {
    background-color: var(--rack-blue);
    padding: 15px;
    border-radius: 25px;
    display: flex;
    justify-content: center;
    gap: 10px;
    margin: 20px 0;
}

.tile {
    width: 40px;
    height: 40px;
    background-color: #f4d03f;
    border-radius: 5px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: move;
    user-select: none;
}

.tile-letter {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--text-dark);
}

.tile-points {
    position: absolute;
    bottom: 2px;
    right: 2px;
    font-size: 0.8rem;
    color: var(--text-dark);
}

/* Chat Section */
.chat-section {
    background-color: var(--chat-green);
    padding: 15px;
    border-radius: 15px;
    display: flex;
    flex-direction: column;
    height: 300px;
}

.chat-messages {
    flex-grow: 1;
    background-color: white;
    border-radius: 10px;
    padding: 10px;
    margin-bottom: 10px;
    overflow-y: auto;
}

.chat-input-area {
    display: flex;
    gap: 10px;
}

#chat-input {
    flex-grow: 1;
    padding: 8px;
    border: none;
    border-radius: 20px;
    background-color: white;
}

#send-message {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background-color: white;
    color: var(--chat-green);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Game Controls */
.game-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 10px;
}

.control-button {
    padding: 10px 20px;
    border: none;
    border-radius: 25px;
    background-color: var(--button-green);
    color: white;
    cursor: pointer;
    font-weight: bold;
    transition: background-color 0.2s;
}

.control-button:hover:not(:disabled) {
    background-color: var(--button-hover);
}

.control-button:disabled {
    background-color: var(--button-disabled);
    cursor: not-allowed;
}

/* Start Menu */
.start-menu {
    background-color: #003399;
    padding: 30px;
    border-radius: 20px;
    max-width: 800px;
    margin: 50px auto;
    display: grid;
    grid-template-columns: 2fr 3fr;
    gap: 30px;
}

.start-menu h1 {
    color: white;
    font-size: 2.5rem;
    margin-bottom: 20px;
    grid-column: 1 / -1;
}

/* Connection Log */
.connection-log {
    background-color: white;
    padding: 20px;
    border-radius: 15px;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.connection-log h3 {
    color: #333;
    margin-bottom: 15px;
    font-size: 1.2rem;
}

#log-entries {
    flex-grow: 1;
    overflow-y: auto;
    margin-bottom: 15px;
    padding: 10px;
    background-color: #f8f9fa;
    border-radius: 8px;
}

.log-entry {
    margin-bottom: 8px;
    padding: 5px;
    border-radius: 4px;
    font-family: monospace;
}

.log-entry.info {
    background-color: #e8eaf6;
}

.log-entry.success {
    background-color: #e8f5e9;
    color: #2e7d32;
}

.log-entry.error {
    background-color: #ffebee;
    color: #c62828;
}

.timestamp {
    color: #666;
    margin-right: 8px;
}

/* Connection Status */
.connection-status {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background-color: #f8f9fa;
    border-radius: 8px;
    margin-top: auto;
}

.status-text {
    flex-grow: 1;
    color: #333;
}

.status-text.connected {
    color: #2e7d32;
}

.status-text.connecting {
    color: #ed6c02;
}

#api-status-icon {
    font-size: 1.2rem;
}

/* User Details Panel */
.user-details {
    background-color: white;
    padding: 20px;
    border-radius: 15px;
    color: #333;
}

.user-details h3 {
    color: #333;
    margin-bottom: 20px;
    font-size: 1.2rem;
}

.input-group {
    margin-bottom: 20px;
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    color: #333;
    font-weight: 500;
}

.input-group input,
.input-group select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 8px;
    font-size: 1rem;
    background-color: #f8f9fa;
}

.input-group input:focus,
.input-group select:focus {
    outline: none;
    border-color: #003399;
    box-shadow: 0 0 0 2px rgba(0, 51, 153, 0.1);
}

#start-game {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 8px;
    background-color: #003399;
    color: white;
    font-weight: bold;
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.2s;
    margin-top: 20px;
}

#start-game:hover:not(:disabled) {
    background-color: #002266;
}

#start-game:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

/* Recommendation Buttons */
.recommendation-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 10px;
}

.recommendation-button {
    padding: 8px 15px;
    border: none;
    border-radius: 20px;
    background-color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    font-size: 0.9rem;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .game-container {
        grid-template-columns: 1fr;
    }
    
    .game-board {
        max-width: 600px;
        margin: 0 auto;
    }
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .board-cell::before {
        font-size: 0.5rem;
    }
    
    .tile-letter {
        font-size: 1rem;
    }
    
    .tile-points {
        font-size: 0.7rem;
    }
}