/* Import font chữ mới đẹp hơn */
@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;700;900&display=swap');

/* --- Giao diện tổng thể --- */
body {
    font-family: 'Nunito', Arial, sans-serif;
    background-color: #f0f4f8;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    padding: 20px;
    box-sizing: border-box;
}

.container {
    background-color: white;
    padding: 30px 40px;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    text-align: center;
    width: 100%;
    max-width: 1100px; /* Tăng chiều rộng tối đa cho cả game và chat */
}

/* --- Bố cục game & chat --- */
#game-layout {
    display: flex;
    flex-wrap: wrap; /* Cho phép xuống dòng trên màn hình nhỏ */
    gap: 30px;
    align-items: flex-start;
    margin-top: 20px;
}
#left-column {
    flex: 1;
    min-width: 630px; /* Đảm bảo bàn cờ không bị vỡ */
}
#chat-panel {
    width: 300px; /* Chiều rộng cố định cho khung chat */
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    background-color: #f9fafb;
    padding: 15px;
    display: flex;
    flex-direction: column;
    height: 650px; /* Chiều cao bằng bàn cờ */
}

/* --- Chữ & Tiêu đề --- */
.home-link { display: block; margin-bottom: 20px; color: #555; text-decoration: none; font-weight: 700; transition: color 0.3s; }
.home-link:hover { color: #007bff; }
h1 { font-weight: 900; font-size: 2.5em; color: #1e3a8a; margin-bottom: 5px; text-shadow: 2px 2px 5px rgba(0,0,0,0.05); }
.subtitle { font-size: 1.1em; color: #6b7280; margin-bottom: 30px; }
#status { font-size: 1.2em; font-weight: bold; color: #1e3a8a; min-height: 25px; }
#game-info { margin-bottom: 15px; }


/* --- Nút bấm và Input --- */
#game-setup input { padding: 12px; margin-right: 10px; border: 2px solid #e5e7eb; border-radius: 8px; font-size: 1em; transition: border-color 0.3s, box-shadow 0.3s; }
#game-setup input:focus { outline: none; border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2); }
button { padding: 12px 20px; border: none; border-radius: 8px; cursor: pointer; background-color: #2563eb; color: white; font-weight: 700; font-size: 1em; transition: transform 0.2s, box-shadow 0.2s; }
button:hover { transform: translateY(-2px); box-shadow: 0 4px 15px rgba(37, 99, 235, 0.3); }

/* --- Bàn cờ và Ô cờ --- */
#game-board { display: grid; margin: 0 auto; border: 1px solid #e5e7eb; background-color: white; padding: 10px; border-radius: 12px; box-shadow: inset 0 2px 8px rgba(0,0,0,0.05); }
.cell { width: 38px; height: 38px; border: 1px solid #e5e7eb; display: flex; justify-content: center; align-items: center; font-size: 28px; font-weight: 900; cursor: pointer; transition: background-color 0.3s; }
.cell:hover { background-color: #dbeafe; }

/* --- Quân cờ và Hiệu ứng --- */
@keyframes piece-appear { from { transform: scale(0.5); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.cell.X, .cell.O { animation: piece-appear 0.2s ease-out; }
.cell.X { color: #ef4444; text-shadow: 1px 1px 3px rgba(239, 68, 68, 0.3); }
.cell.O { color: #3b82f6; text-shadow: 1px 1px 3px rgba(59, 130, 246, 0.3); }
.hidden { display: none; }
.winning-cell { background-color: #facc15; animation: blink-win 0.8s infinite alternate; box-shadow: 0 0 15px #facc15; border-radius: 4px; }
@keyframes blink-win { from { transform: scale(1); opacity: 1; } to { transform: scale(1.1); opacity: 0.8; } }

/* --- KHUNG CHAT --- */
#chat-panel h2 { font-size: 1.2em; color: #1e3a8a; margin: 0 0 10px 0; text-align: left; }
#chat-messages { flex-grow: 1; overflow-y: auto; background-color: #fff; border-radius: 8px; border: 1px solid #e5e7eb; padding: 10px; display: flex; flex-direction: column; gap: 8px; }

.chat-message { max-width: 80%; padding: 8px 12px; border-radius: 12px; word-wrap: break-word; }
.chat-message.me { background-color: #2563eb; color: white; align-self: flex-end; border-bottom-right-radius: 2px; }
.chat-message.opponent { background-color: #e5e7eb; color: #1f2937; align-self: flex-start; border-bottom-left-radius: 2px; }
.chat-message .sender { font-weight: 900; margin-right: 5px; }

#emoji-bar { text-align: left; padding: 8px 0; }
.emoji-btn { background: none; border: none; font-size: 1.5em; cursor: pointer; padding: 0 5px; transition: transform 0.2s; }
.emoji-btn:hover { transform: scale(1.2); }

#chat-input-area { display: flex; margin-top: 5px; }
#chat-input { flex-grow: 1; border: 2px solid #e5e7eb; border-radius: 8px 0 0 8px; padding: 10px; font-size: 1em; }
#chat-input:focus { outline: none; border-color: #3b82f6; }
#send-btn { border-radius: 0 8px 8px 0; padding: 10px 15px; }

/* Responsive cho màn hình nhỏ */
@media (max-width: 1024px) {
    #game-layout { flex-direction: column; align-items: center; }
    #left-column { min-width: auto; }
    #chat-panel { width: 100%; max-width: 630px; height: 400px; margin-top: 20px; }
}
/* --- Bảng điểm --- */
#scoreboard {
    display: flex;
    justify-content: center;
    gap: 30px;
    background-color: #f0f4f8;
    padding: 8px;
    border-radius: 8px;
    margin: 15px 0;
}

#scoreboard p {
    margin: 0;
    font-size: 1.1em;
    font-weight: 700;
    color: #4b5563;
}

#scoreboard span {
    display: inline-block;
    min-width: 20px;
    text-align: center;
    font-weight: 900;
    color: #1e3a8a;
}