/* ตั้งค่าพื้นฐาน */
body {
    background-color: #222; /* สีพื้นหลังเว็บรอบนอก */
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    margin: 0;
    font-family: 'Courier New', Courier, monospace; /* ฟอนต์แบบเกม Retro */
    color: white;
}

/* กล่องเกมหลัก 400x700 */
#game-container {
    width: 400px;
    height: 700px;
    background-color: #333; /* สีพื้นหลังชั่วคราว */
    position: relative;
    overflow: hidden;
    border: 2px solid #555;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
    
    /* 🔴 โค้ดที่นาริให้เพิ่ม ไล่เส้นกระพริบและห้ามคลุมดำค่ะ 🔴 */
    user-select: none; 
    -webkit-user-select: none; 
    -moz-user-select: none; 
    cursor: default; 
}

/* Placeholder รูปพื้นหลัง */
.bg-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom, #2b1055, #7597de); /* สีสมมติ */
    z-index: 0;
}

/* หน้าจอต่างๆ */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.hidden {
    display: none !important;
}

/* How to Play */
#screen-howto {
    cursor: pointer;
    background: rgba(0,0,0,0.8);
}

/* Main Menu */
.game-title {
    font-size: 3rem;
    margin-bottom: 50px;
    text-shadow: 3px 3px 0 #000;
}

.menu-buttons button {
    display: block;
    width: 200px;
    padding: 15px;
    margin: 10px auto;
    font-size: 1.2rem;
    cursor: pointer;
    border: none;
    border-radius: 10px;
    font-weight: bold;
}

.btn-main { background-color: #ffcc00; color: #000; }
.btn-sub { background-color: #ddd; color: #333; }

.footer {
    position: absolute;
    bottom: 20px;
    font-size: 0.8rem;
    opacity: 0.7;
}

/* Character Select */
.btn-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: red;
    color: white;
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    font-weight: bold;
    cursor: pointer;
}

.char-list {
    width: 90%;
    margin-top: 20px;
}

.char-card {
    display: flex;
    align-items: center;
    background: rgba(255,255,255,0.1);
    margin-bottom: 15px;
    padding: 10px;
    border-radius: 10px;
    cursor: pointer;
    transition: transform 0.1s;
    border: 2px solid transparent;
}

.char-card:active { transform: scale(0.98); }

.char-img {
    width: 95px;  /* 🔴 นาริแก้จาก 60px เป็น 95px ให้ใหญ่สะใจเท่าหน้าในเกมเลยค่ะ */
    height: 95px; /* 🔴 แก้จาก 60px เป็น 95px เป็นสี่เหลี่ยมจัตุรัส 1x1 เป๊ะๆ */
    background-color: #ccc; 
    border-radius: 5px;
    margin-right: 15px; /* ระยะห่างจากข้อความ */
    background-size: cover;
    background-position: center;
    /* 🔴 นาริแถมบรรทัดนี้ให้ค่ะ กันไม่ให้รูปโดนบีบถ้าหน้าจอเล็กมากๆ */
    flex-shrink: 0; 
}

.char-info {
    text-align: left; 
    width: 100%;      
}
.char-info h3 { margin: 0; font-size: 1.5rem; }
.char-info p { margin: 5px 0 0; opacity: 0.8; }

/* สีประจำตัวละคร */
.char-card.pink { border-color: pink; }
.char-card.pink .char-img { 
    background-color: hotpink;
    background-image: url('pink_normal.png'); 
}

.char-card.blue { border-color: cyan; }
.char-card.blue .char-img { 
    background-color: deepskyblue;
    background-image: url('blue_normal.png'); 
}

.char-card.orange { border-color: orange; }
.char-card.orange .char-img { 
    background-color: darkorange;
    background-image: url('orange_normal.png'); 
}

/* Modal Difficulty */
.modal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    z-index: 20;
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: white;
    color: black;
    padding: 30px;
    border-radius: 15px;
    position: relative;
    width: 70%;
    text-align: center;
}

.diff-buttons button {
    display: block;
    width: 100%;
    padding: 10px;
    margin: 10px 0;
    border: none;
    border-radius: 5px;
    font-size: 1.2rem;
    cursor: pointer;
}

.btn-diff.easy { background-color: #4CAF50; color: white; }
.btn-diff.normal { background-color: #F44336; color: white; }

.btn-close-modal {
    position: absolute;
    top: 10px;
    right: 10px;
    background: transparent;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
}

/* Settings */
.btn-lang {
    margin: 10px;
    padding: 10px 20px;
    cursor: pointer;
}

/* Header */
.game-header {
    width: 90%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    background: rgba(0,0,0,0.5);
    padding: 10px;
    border-radius: 10px;
}

.score-board {
    display: flex;
    gap: 15px; /* ระยะห่างระหว่างป้าย Player กับ AI */
    align-items: center;
}

.score-item {
    display: flex;
    align-items: center;
    gap: 8px; /* ระยะห่างระหว่าง จุด - ชื่อ - แต้ม */
    background: rgba(255, 255, 255, 0.1); /* พื้นหลังโปร่งแสงให้ดูเป็นป้าย */
    padding: 5px 12px;
    border-radius: 20px; /* ขอบมนๆ น่ารักๆ */
}

.score-label {
    color: #ffffff; /* เปลี่ยนเป็นสีขาวสว่างๆ ให้ชัดขึ้น */
    font-size: 1.1rem; /* ขยายขนาดตัวหนังสือ */
    font-weight: bold; /* ทำตัวหนาให้เด่นชัด */
    letter-spacing: 1px;
}

.score-num {
    color: #ffcc00; /* สีแต้มเด่นๆ (สีเหลืองทอง) */
    font-size: 1.4rem;
    font-weight: bold;
    min-width: 25px; /* ล็อกความกว้างไว้ แต้มเปลี่ยนจากหลักหน่วยเป็นหลักสิบจะได้ไม่กระตุก */
    text-align: right;
}
.dot {
    display: inline-block;
    width: 15px;
    height: 15px;
    border-radius: 50%;
}
.dot.black { background: black; border: 1px solid white; }
.dot.white { background: white; border: 1px solid black; }

.btn-pause {
    background: transparent;
    border: 2px solid white;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    font-weight: bold;
}

/* Board Area */
#board-area {
    margin-top: 30px; /* ให้กระดานห่างจากแถบคะแนนกำลังสวย */
    background-color: #8B4513; 
    padding: 10px;
    border-radius: 5px;
    box-shadow: 0 10px 20px rgba(0,0,0,0.5);
}

.board-grid {
    display: grid;
    background-color: #000; /* เส้นตารางสีดำ */
    gap: 2px; /* ช่องว่างระหว่างช่อง */
    border: 2px solid #000;
    width: 100%;  /* 👈 เพิ่มบรรทัดนี้ ให้กว้างเต็มกระดาน */
    height: 100%; /* 👈 เพิ่มบรรทัดนี้ ให้สูงเต็มกระดาน */
}

.cell {
    background-color: #D2691E; /* สีส้มอิฐ (Burnt Orange) */
    position: relative;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
}

.cell:active { background-color: #A0522D; }

/* หมาก (Pieces) */
.piece {
    width: 80%;
    height: 80%;
    border-radius: 50%;
    box-shadow: 2px 2px 2px rgba(0,0,0,0.3);
}
.piece.black { background: black; }
.piece.white { background: white; }

@keyframes flip-coin {
    0%   { transform: scaleX(1); }
    45%  { transform: scaleX(0); }
    55%  { transform: scaleX(0); }
    100% { transform: scaleX(1); }
}

/* แอนิเมชันกระพริบแสงสว่างขึ้น-ลง แบบนุ่มนวล */
@keyframes pulse-glow {
    0% { filter: brightness(1); }
    50% { filter: brightness(1.4); } /* สว่างขึ้น 40% ตอนกลางจังหวะ */
    100% { filter: brightness(1); }
}

/* คลาสสำหรับช่องที่ลงหมากได้ */
.valid-move {
    animation: pulse-glow 1.5s infinite ease-in-out; /* กระพริบช้าๆ 1.5 วิ/รอบ สมูทๆ ค่ะ */
    cursor: pointer;
    box-shadow: inset 0 0 10px rgba(255, 255, 255, 0.3); /* เพิ่มขอบแสงนิดๆ ให้ดูมีมิติ */
}

/* Footer Section */
.game-footer {
    position: absolute;
    bottom: 25px; 
    width: 100%;
    height: 210px; /* 🔴 ขยายความสูงรวมให้พื้นที่กว้างขึ้น รูปจะได้ไม่เบียดกล่องล่าง */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end; 
}

.profile-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 90%; /* 🔴 ขยายพื้นที่ด้านข้างเผื่อรูปที่ใหญ่ขึ้น */
    margin-bottom: 10px; 
}

.profile-frame {
    width: 115px;  /* 🔴 ขยายใหญ่สุดพลังเป็น 115px เลยค่ะ! */
    height: 115px; 
    background: yellow; 
    padding: 5px;
    box-shadow: 0 0 10px rgba(255,255,0,0.5);
}

.profile-img {
    width: 100%;
    height: 100%;
    background-color: #555; 
    background-size: cover;
    transition: background-image 0.3s ease-in-out; 
}

.vs-txt {
    font-size: 2.5rem; /* 🔴 ขยาย VS ให้ใหญ่สู้กับรูปเลย */
    font-weight: bold;
    color: yellow;
    text-shadow: 2px 2px 0 red;
}

/* Text Box */
.text-box {
    width: 95%;
    height: 60px;
    background: white;
    border: 4px solid #333;
    border-radius: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 0; /* เอา margin เดิมออก เพื่อให้ลงไปอยู่ล่างสุดจริงๆ */
}

#game-status-text {
    color: black;
    font-size: 1.2rem;
    font-weight: bold;
    margin: 0;
}

#screen-game {
    justify-content: flex-start;
    padding-top: 15px; /* ห่างจากขอบบนจอเกือบๆ ชิด ตามที่พี่ขอค่ะ */
}

/* ปรับระยะแถบคะแนน */
.game-header {
    width: 90%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0px; /* ลดระยะให้ไม่ห่างขอบเกินไป */
    background: rgba(0,0,0,0.5);
    padding: 10px;
    border-radius: 10px;
}

/* ================== ส่วนเสริมสำหรับบอส Purple ================== */

/* 1. แต่งสวยให้การ์ดบอสสีม่วง */
.char-card.purple {
    border-color: #9c27b0; /* ขอบสีม่วงเข้มดูทรงพลัง */
    /* แอบเพิ่มออร่าแสงสีม่วงให้ดูเป็นบอส */
    box-shadow: 0 0 10px rgba(156, 39, 176, 0.4);
}

.char-card.purple .char-img {
    background-color: #ce53e0; /* พื้นหลังรูปสีม่วงสดใส */
    border: 2px solid gold; /* (อันนี้เผื่อไว้ ถ้าใน HTML ใส่ style="border..." ไม่ติด) */
    background-image: url('purple_normal.png'); /* 🔴 นาริให้พี่ชายเติมแค่บรรทัดนี้บรรทัดเดียวเลยค่ะ! */
}

/* เพิ่มลูกเล่นตอนเอาเมาส์ชี้ที่บอส */
.char-card.purple:hover {
    background: rgba(156, 39, 176, 0.15); /* พื้นหลังเรืองแสงม่วงนิดๆ */
    transform: scale(1.03); /* ขยายใหญ่ขึ้นนิดนึงข่มขวัญผู้เล่น! */
    transition: all 0.2s ease;
}

/* 2. ขยับจัดตำแหน่งหน้าเลือกตัวละคร (ตามวงกลมสีขาว) */
#screen-char-select {
    /* ปกติมันอยู่กลางเป๊ะตามคําสั่ง justify-content: center ใน .screen */
    /* นาริใช้เทคนิคเพิ่ม "พื้นที่ว่างด้านล่าง" เพื่อดันเนื้อหาทั้งหมดให้ลอยสูงขึ้นไปค่ะ */
    padding-bottom: 60px; /* <-- ถ้าอยากให้สูงขึ้นอีก ก็เพิ่มเลขตรงนี้ได้เลยค่ะ */
}

/* ================== พื้นหลังหลักของเกม ================== */

/* ใส่รูปเดียวกันให้กับหน้า How to, Menu และ Settings */
#screen-howto, 
#screen-menu, 
#screen-settings {
    background-image: url('bg_main.png'); /* 🔴 เปลี่ยนชื่อไฟล์รูปตรงนี้ให้ตรงกับของพี่ชายนะคะ */
    background-size: cover;    
    background-position: center; 
    background-repeat: no-repeat; 
}

/* ================== ตกแต่งหน้า How to Play ให้อ่านง่าย ================== */

/* 1. จัดการหัวข้อ HOW TO PLAY (ดันขึ้นข้างบน & ขยายใหญ่) */
#screen-howto h1 {
    text-shadow: 2px 2px 4px #000000;
    font-size: 2.5rem;      /* 🔴 ขยายตัวหนังสือหัวข้อให้ใหญ่ขึ้น */
    margin-top: -120px;     /* 🔴 ดันหัวข้อขึ้นไปข้างบนสุดๆ จะได้ไม่บังหน้าน้องส้ม */
    margin-bottom: 30px;    /* ระยะห่างจากกล่องข้อความด้านล่าง */
}

/* 2. จัดการกล่องข้อความและตัวหนังสือข้างใน */
#txt-howto {
    background-color: rgba(0, 0, 0, 0.65); /* พื้นหลังสีดำโปร่งแสง */
    padding: 20px;
    border-radius: 15px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.5);
    width: 90%;             /* ให้กล่องกว้างขึ้นอีกนิดสำหรับจอมือถือ */
    max-width: 400px;
    margin: auto;
    
    /* 🔴 ปรับขนาดตัวหนังสือให้อ่านง่ายบนมือถือ */
    font-size: 1.3rem;      /* ขยายขนาดตัวหนังสือ (ยิ่งเลขเยอะยิ่งใหญ่) */
    line-height: 1.6;       /* เพิ่มระยะห่างระหว่างบรรทัดไม่ให้อึดอัด */
    font-weight: bold;      /* ทำให้ตัวหนังสือหนาขึ้น จะได้สู้กับฉากหลังได้ */
    text-shadow: 1px 1px 2px #000000; /* เติมขอบดำบางๆ ให้ตัวหนังสืออีกชั้น */
}

/* ================== ตกแต่งหน้าจอเมนู (Menu) ================== */

/* 1. ดันชื่อเกมขึ้นไปข้างบน ไม่ให้บังหน้าน้องมังกร */
#screen-menu h1 {
    margin-top: -160px;    /* 🔴 ดันขึ้นไปสูงๆ (ปรับตัวเลขได้ตามชอบเลยค่ะ) */
    margin-bottom: 40px;   /* เพิ่มระยะห่างก่อนถึงปุ่มกด */
    text-shadow: 3px 3px 6px #000000; /* เน้นขอบดำให้ชื่อเกมพุ่งเด่นขึ้นมา */
}

/* 2. ขยายเครดิตผู้สร้าง และทำป้ายพื้นหลังสวยๆ */
#credit-text {
    position: absolute;    /* ล็อกตำแหน่งให้อยู่ล่างสุดเสมอ */
    bottom: 30px;          /* ยกสูงจากขอบล่าง 30px */
    font-size: 1.1rem;     /* 🔴 ขยายตัวหนังสือให้ใหญ่ขึ้น */
    font-weight: bold;
    color: white;
    text-shadow: 2px 2px 4px #000000;
    background-color: rgba(0, 0, 0, 0.4); /* ใส่ป้ายพื้นหลังสีดำโปร่งแสง */
    padding: 8px 20px;     /* ขยายพื้นที่ป้ายรอบๆ ตัวหนังสือ */
    border-radius: 20px;   /* ทำขอบป้ายให้โค้งมนน่ารัก */
}

/* ================== ตกแต่งหน้า Settings ================== */

/* 1. สร้างกล่องพื้นหลังสีดำโปร่งแสง */
#settings-box {
    background-color: rgba(0, 0, 0, 0.65); /* พื้นหลังดำโปร่งแสง */
    padding: 35px 20px;
    border-radius: 15px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
    width: 85%;
    max-width: 400px;
    margin: 0 auto; /* จัดให้อยู่กึ่งกลางจอ */
    text-align: center;
}

/* 2. ขยายหัวข้อ Settings */
#settings-box h2, 
#settings-box h1 { 
    font-size: 2.5rem;      /* 🔴 ขยายหัวข้อให้ใหญ่สะใจ */
    margin-top: 0;
    margin-bottom: 25px;
    text-shadow: 2px 2px 4px #000000;
}

/* 3. ขยายข้อความ Language / ภาษา */
#settings-box p {
    font-size: 1.5rem;      /* 🔴 ขยายข้อความอธิบาย */
    font-weight: bold;
    margin-bottom: 25px;
    text-shadow: 1px 1px 3px #000000;
}

/* 4. ขยายปุ่มให้กดง่ายเต็มมือ */
#settings-box button {
    font-size: 1.2rem;      /* 🔴 ขยายตัวหนังสือในปุ่ม */
    padding: 12px 25px;     /* ขยายขนาดปุ่มให้กว้างขึ้น */
    margin: 10px 5px;       /* ระยะห่างระหว่างปุ่ม */
    border-radius: 8px;     /* ขอบปุ่มมนสวยๆ */
    font-weight: bold;
    cursor: pointer;
    box-shadow: 2px 2px 5px rgba(0,0,0,0.3); /* เติมเงาให้ปุ่มลอยขึ้นมา */
}

/* ================== ตกแต่งหน้าต่างจบเกม (Game Over) [แก้รอบ 2] ================== */

/* 1. ปรับขนาดหัวข้อ YOU WIN / AI WINS ให้พอดี */
#txt-result {
    font-size: 2.2rem;       /* 🔴 ลดจาก 2.8 เหลือ 2.2 กำลังสวยค่ะ */
    font-weight: bold;
    margin-top: 15px;
    margin-bottom: 15px;
    color: #333;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
}

/* 2. ปรับขนาดข้อความสรุปคะแนน */
#txt-final-score {
    font-size: 1.3rem;       /* 🔴 ลดเหลือ 1.3 ให้อ่านง่ายแต่ไม่แย่งซีน */
    font-weight: bold;
    color: #555;
    margin-bottom: 25px;
}

/* 3. ปรับขนาดปุ่ม Main Menu ให้พอดีมือ */
#modal-gameover .btn-diff {
    font-size: 1.1rem;       /* 🔴 ลดขนาดตัวหนังสือในปุ่มลงนิดนึง */
    padding: 10px 25px;      /* ปรับขอบเขตปุ่มให้กระชับขึ้น */
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
}

/* ================== ตกแต่งหน้าต่างหยุดเกม (Pause Menu) ================== */

/* 1. ขยายหัวข้อ PAUSED */
#modal-pause h3 {
    font-size: 2.2rem;       /* 🔴 ขยายให้ใหญ่ชัดเจน */
    font-weight: bold;
    color: #333;
    margin-bottom: 25px;     /* เพิ่มระยะห่างก่อนถึงปุ่ม */
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
}

/* 2. ขยายปุ่ม Resume และ Main Menu ให้กดง่ายเต็มมือ */
#modal-pause .btn-diff {
    font-size: 1.1rem;       /* 🔴 ขยายตัวหนังสือในปุ่ม */
    padding: 12px 25px;      /* ขยายขนาดปุ่ม */
    border-radius: 10px;
    margin: 10px 10px;       /* เพิ่มระยะห่างระหว่างปุ่มซ้าย-ขวา ไม่ให้เบียดกัน */
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
}