body {
    font-family: 'Segoe UI', sans-serif;
    background-color: #2c3e50;
    color: white;
    margin: 0;
    display: flex;
    justify-content: center;
    min-height: 100vh;
}

.container {
    width: 100%;
    max-width: 900px;
    background: #34495e;
    padding: 20px;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 15px;
    border-bottom: 1px solid #555;
    margin-bottom: 15px;
}

/* Battle Field */
.battle-field {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.player-zone {
    background: rgba(0,0,0,0.2);
    padding: 15px;
    border-radius: 10px;
}

.hand {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    min-height: 140px;
    padding-top: 10px;
}

/* Card Style (ปรับให้ตรงกับ JS ของคุณ) */
.card {
    width: 90px;
    height: 130px;
    background: #ecf0f1;
    border-radius: 8px;
    border: 2px solid #bdc3c7;
    color: #333;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: 5px;
    cursor: pointer;
    transition: transform 0.2s;
    user-select: none;
    position: relative;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    border-color: #f1c40f;
}

.card.active {
    border-color: #2ecc71;
    box-shadow: 0 0 10px #2ecc71;
    transform: scale(1.05);
}

.card-back {
    width: 100%; height: 100%;
    background: repeating-linear-gradient(45deg, #2980b9, #2980b9 10px, #3498db 10px, #3498db 20px);
    border-radius: 6px;
}

/* Elements inside Card (ตาม JS ของคุณ) */
.card-header {
    font-size: 1.5em; /* Symbol */
    margin-top: 5px;
}
.card-number {
    font-size: 1.8em;
    font-weight: bold;
    color: #c0392b;
}
.card-ability {
    font-size: 0.6em;
    text-align: center;
    color: #555;
    height: 30px;
    overflow: hidden;
    line-height: 1.1;
    display: flex;
    align-items: center;
}

/* Arena & Buttons */
.arena {
    text-align: center;
    padding: 10px;
    background: rgba(255,255,255,0.05);
    border-radius: 8px;
    min-height: 80px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

.vs-message {
    font-size: 1.2em;
    color: #f1c40f;
    font-weight: bold;
}

button {
    padding: 10px 20px;
    cursor: pointer;
    border: none;
    border-radius: 5px;
    font-size: 1em;
    color: white;
}
.btn-success { background: #27ae60; }
.btn-success:hover { background: #2ecc71; }
.btn-danger { background: #c0392b; }
.btn-small { padding: 5px 10px; font-size: 0.8em; background: #7f8c8d; }

/* HP Bars */
.hp-bar-bg {
    width: 200px; height: 15px; background: #555; border-radius: 10px; overflow: hidden; display: inline-block; vertical-align: middle;
}
.hp-bar { height: 100%; background: #2ecc71; transition: width 0.3s; }

/* Log Table */
#turn-history-container table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    font-size: 0.9em;
}
#turn-history-container th, #turn-history-container td {
    border-bottom: 1px solid #555;
    padding: 8px;
    text-align: center;
}
#turn-history-container th { color: #f1c40f; }

/* Start Screen */
#start-screen {
    position: fixed; top:0; left:0; width:100%; height:100%;
    background: rgba(0,0,0,0.9);
    display: flex; justify-content: center; align-items: center;
    z-index: 1000;
}
.modal-box {
    background: #34495e; padding: 40px; border-radius: 10px; text-align: center;
}
input { padding: 10px; font-size: 1.2em; text-align: center; display: block; margin: 15px auto; width: 80%; }
#start-button { background: #3498db; width: 100%; }

/* เพิ่มต่อท้ายไฟล์ style.css เดิม */

/* จัดเมนูหน้าแรก */
.start-options {
    margin-top: 20px;
    display: flex;
    justify-content: center;
    gap: 15px;
    border-top: 1px solid rgba(255,255,255,0.1);
    padding-top: 20px;
}

/* ปุ่มใหญ่สำหรับเริ่มเกม */
.btn-large {
    font-size: 1.5em;
    padding: 15px 40px;
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s;
    width: 100%;
}
.btn-large:hover { transform: scale(1.05); background: #c0392b; }

/* ปุ่มรอง (Handbook & Scoreboard) */
.btn-secondary {
    background: #7f8c8d;
    color: white;
    padding: 10px 20px;
    text-decoration: none; /* สำหรับ tag <a> */
    border-radius: 5px;
    border: none;
    cursor: pointer;
    font-size: 1em;
    display: inline-block;
}
.btn-secondary:hover { background: #95a5a6; }

/* จัด Header ให้สวยงาม */
.header-controls {
    display: flex;
    gap: 10px;
}

/* --- Modal / Popup Styles --- */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.85); /* พื้นหลังสีดำจางๆ */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    backdrop-filter: blur(5px); /* เบลอฉากหลังให้ดูหรู */
}

.modal-box {
    background: #2c3e50;
    width: 90%;
    max-width: 500px; /* ไม่กว้างเกินไป */
    border-radius: 12px;
    border: 1px solid #34495e;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    padding: 20px;
    position: relative; /* เพื่อให้ปุ่ม X อิงตำแหน่งกับกล่องนี้ */
    animation: popIn 0.3s ease-out;
}

/* ปุ่ม X (Close Button) */
.close-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 28px;
    color: #95a5a6;
    cursor: pointer;
    font-weight: bold;
    line-height: 1;
    transition: color 0.2s;
}
.close-btn:hover {
    color: #e74c3c; /* เมาส์ชี้เป็นสีแดง */
}

/* พื้นที่ตารางแบบมี Scroll Bar */
.table-scroll-area {
    max-height: 300px; /* สูงสุด 300px ถ้าเกินจะขึ้น Scroll */
    overflow-y: auto;  /* ให้เลื่อนแนวตั้งได้ */
    margin: 15px 0;
    border: 1px solid #34495e;
    border-radius: 5px;
    background: rgba(0,0,0,0.2);
}

/* ปรับแต่ง Scrollbar ให้สวยงาม (Webkit browsers) */
.table-scroll-area::-webkit-scrollbar {
    width: 8px;
}
.table-scroll-area::-webkit-scrollbar-track {
    background: #2c3e50; 
}
.table-scroll-area::-webkit-scrollbar-thumb {
    background: #7f8c8d; 
    border-radius: 4px;
}
.table-scroll-area::-webkit-scrollbar-thumb:hover {
    background: #95a5a6; 
}

/* Animation ตอนเด้งขึ้นมา */
@keyframes popIn {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* สีสำหรับสถานะต่างๆ */
.text-win { color: #2ecc71; }   /* สีเขียว */
.text-lose { color: #e74c3c; }  /* สีแดง */
.text-draw { color: #f1c40f; }  /* สีเหลือง */

/* Animation ให้หน้าต่างเด้งดึ๋ง */
.modal-box {
    animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
    from { transform: scale(0.5); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

