:root {
    --primary-bg: #f0f2f5;
    --game-start-bg: #b8e3e9;
    --score-bg: #ff99cc;
    --history-bg: #ffc266;
    --bot-bg: #4d9900;
    --control-bg: #b3d9ff;
    --board-green: #006600;
    --board-cell: #ffffff;
    --text-dark: #333333;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: Arial, sans-serif;
}

body {
    background-color: var(--primary-bg);
    padding: 20px;
}

.game-container {
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    grid-template-areas:
        "start start start"
        "score board chat"
        "score rack chat"
        "score controls chat"
        "score history chat";
    grid-template-columns: 200px 1fr 300px;
    grid-template-rows: auto auto auto auto 1fr;
    gap: 20px;
    padding: 20px;
    min-height: 100vh;
    position: relative;
}

/* Game Start Section */
.game-start {
    grid-area: start;
    background-color: var(--game-start-bg);
    padding: 20px;
    border-radius: 15px;
    width: 100%;
    margin-bottom: 20px;
    z-index: 10;
}

.game-start.inactive {
    opacity: 0.5;
    pointer-events: none;
}

.game-start input {
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 5px;
}

.game-start button {
    background-color: #4CAF50;
    color: white;
    border: none;
    padding: 10px;
    border-radius: 5px;
    cursor: pointer;
}

.retro-connection {
    display: flex;
    align-items: center;
    gap: 10px;
}

.connection-icon {
    width: 20px;
    height: 20px;
    background-color: #4CAF50;
    border-radius: 50%;
}

/* Score and Stats Section */
.score-stats {
    grid-area: score;
    background-color: var(--score-bg);
    padding: 20px;
    border-radius: 15px;
    height: fit-content;
    position: sticky;
    top: 20px;
    align-self: start;
}

.score-section, .stats-section {
    margin-bottom: 15px;
}

.player-score {
    margin: 2px 0;
}

/* Game Board Container */
.board-container {
    grid-area: board;
    display: flex;
    flex-direction: column;
    align-items: center;
    background-color: var(--primary-bg);
    padding: 20px;
    border-radius: 15px;
    margin-bottom: 0;
    width: 100%;
    position: relative;
}

/* Game Board */
.game-board {
    width: 450px;
    height: 450px;
    display: grid;
    grid-template-columns: repeat(15, 1fr);
    grid-template-rows: repeat(15, 1fr);
    gap: 1px;
    padding: 1px;
    background-color: var(--board-green);
    margin: 0 auto;
}

.board-cell {
    background-color: var(--board-cell);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 8px;
    width: 29px;
    height: 29px;
    position: relative;
    padding: 0;
    box-sizing: border-box;
    font-weight: bold;
}

.board-cell::before {
    content: attr(data-bonus);
    position: absolute;
    font-size: 8px;
    font-weight: bold;
    z-index: 1;
}

.board-cell.star::before {
    content: "★";
    position: absolute;
    color: #333;
    font-size: 20px;
    z-index: 1;
}

/* Tile Rack Container */
.rack-container {
    grid-area: rack;
    display: flex;
    flex-direction: column;
    align-items: center;
    background-color: var(--primary-bg);
    padding: 20px;
    border-radius: 15px;
    width: 100%;
    margin: 0;
    position: relative;
}

/* Tile Rack */
.tile-rack {
    background-color: #996633;
    min-height: 50px;
    border-radius: 10px;
    padding: 10px;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 5px;
    margin: 0;
}

.tile {
    width: 27px;
    height: 27px;
    min-width: 27px;
    min-height: 27px;
    background-color: #f4d03f;
    border-radius: 3px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    cursor: move;
    font-weight: bold;
    position: relative;
    font-size: 12px;
    line-height: 1;
    text-align: center;
    user-select: none;
    z-index: 2;
    margin: 1px;
}

.tile .points {
    position: absolute;
    bottom: 1px;
    right: 1px;
    font-size: 7px;
    line-height: 1;
}

.tile[data-new="true"] {
    cursor: move;
}

/* Controls Container */
.controls-container {
    grid-area: controls;
    display: flex;
    flex-direction: column;
    align-items: center;
    background-color: var(--primary-bg);
    padding: 20px;
    border-radius: 15px;
    width: 100%;
    margin: 0;
    position: relative;
}

/* Game Controls */
.game-controls {
    display: flex;
    gap: 10px;
    margin: 10px 0;
    flex-wrap: wrap;
    justify-content: center;
    width: 100%;
    position: relative;
}

.game-controls button {
    padding: 5px 10px;
    border: none;
    border-radius: 20px;
    background-color: var(--control-bg);
    cursor: pointer;
    font-size: 12px;
    transition: opacity 0.3s ease;
}

.game-controls button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background-color: #cccccc;
    pointer-events: none;
}

.game-controls button:not(:disabled) {
    opacity: 1;
    cursor: pointer;
    pointer-events: auto;
}

.recommendation-controls {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

/* Game History Section */
.game-history {
    grid-area: history;
    background-color: var(--history-bg);
    padding: 20px;
    border-radius: 15px;
    height: 200px;
    width: 100%;
    margin: 0;
    position: relative;
}

#historyContent {
    height: calc(100% - 30px);
    overflow-y: auto;
    padding: 10px;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 5px;
    word-wrap: break-word;
    position: relative;
}

/* Fix retro connection text */
.retro-connection span:last-child {
    content: "Retry Connection";
}

/* Ensure consistent element visibility */
.inactive {
    opacity: 0.5;
    pointer-events: none;
    user-select: none;
}

.active {
    opacity: 1;
    pointer-events: auto;
    user-select: auto;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .game-container {
        grid-template-columns: 1fr;
    }
    
    .bottom-sections {
        grid-template-columns: 1fr;
    }
}

/* ScrabbleBot Section */
.scrabble-bot {
    grid-area: chat;
    background-color: var(--bot-bg);
    padding: 20px;
    border-radius: 15px;
    color: white;
    display: flex;
    flex-direction: column;
    height: 100%;
    position: sticky;
    top: 20px;
    align-self: start;
}

/* Chat History */
#chatHistory {
    flex: 1;
    overflow-y: auto;
    margin: 10px 0;
    padding: 10px;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 5px;
    height: calc(100% - 100px);
    min-height: 400px;
}

.chat-input {
    width: 100%;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    margin-top: 10px;
    color: #0066cc;
    font-size: 14px;
    position: relative;
}

.chat-history .player-message {
    color: #0066cc;
    text-align: right;
    margin: 5px 0;
}

.chat-history .bot-message {
    color: #333;
    text-align: left;
    margin: 5px 0;
}

/* Special Tiles */
.double-letter::before { content: "DL" !important; color: #0066cc; }
.triple-letter::before { content: "TL" !important; color: #003366; }
.double-word::before { content: "DW" !important; color: #cc3300; }
.triple-word::before { content: "TW" !important; color: #990000; } 