:root {
    /* ปรับค่าตัวแปรให้เน้นโทนเขียวตามที่คุณเคยกำหนด */
    --primary-color: #006400; /* Teal/เขียวเข้ม */
    --accent-color: ; /* Dark Green/เขียวมรกต */
    --accent-light: #4cbb17; /* Lime Green/เขียวอ่อน (ใช้สำหรับเน้นข้อความ/เส้น) */
    --background-color: #f0f2f5; /* Light Gray */
    --text-color: #333;
    --success-color: #28a745; /* เขียวสำหรับความสำเร็จ */
    --error-color: #ff0019; /* แดงสำหรับข้อผิดพลาด/หยุดเล่น */
    --border-radius: 12px;
}

/* ------------------------------------------- */
/* GLOBAL STYLES & FONT */
/* ------------------------------------------- */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--background-color);
    color: var(--text-color);
    font-family: 'IBM Plex Sans Thai', sans-serif;
    line-height: 1.6;
    padding-bottom: 70px; 
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px 15px;
}

h2, h3, h4 {
    /* H2, H3, H4 ใช้สีหลักเข้ม */
    color: var(--primary-color); 
    margin-bottom: 15px;
}

hr.divider {
    border: none;
    height: 1px;
    background-color: #ddd;
    margin: 20px 0;
}

.section-title {
    font-size: 1.6em;
    font-weight: 600;
    color: var(--accent-color); /* ใช้สีเขียวมรกต */
    border-bottom: 2px solid var(--accent-light); /* ใช้สีเขียวอ่อนเป็นเส้นใต้ */
    padding-bottom: 5px;
    margin-top: 20px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
}
.section-title i {
    margin-right: 10px;
    font-size: 1.2em;
}

/* ------------------------------------------- */
/* HEADER & LOGO */
/* ------------------------------------------- */

header {
    background-color: #fff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    padding: 10px 0;
}
.logo-bar {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 15px;
    display: flex;
    justify-content: center;
}
.app-logo {
    max-height: 40px;
    width: auto;
}

/* ------------------------------------------- */
/* MODAL (Time Selection) */
/* ------------------------------------------- */

.modal {
    display: none; 
    position: fixed; 
    z-index: 10; 
    left: 0;
    top: 0;
    width: 100%; 
    height: 100%; 
    overflow: auto; 
    background-color: rgba(0,0,0,0.6); 
}

.modal-content {
    background-color: #fff;
    margin: 15% auto; 
    padding: 30px;
    border-radius: var(--border-radius);
    width: 80%; 
    max-width: 400px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    text-align: center;
    animation: fadeIn 0.3s;
}

.modal-close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
}

.modal-close:hover,
.modal-close:focus {
    color: #333;
    text-decoration: none;
    cursor: pointer;
}

.time-options {
    font-family: 'IBM Plex Sans Thai', sans-serif;
    margin-top: 20px;
    display: flex;
    justify-content: space-around;
}

.time-btn {
    font-family: 'IBM Plex Sans Thai', sans-serif;
    background-color: var(--primary-color); /* เขียวเข้ม */
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1em;
    transition: background-color 0.3s;
}

.time-btn:hover {
    background-color: var(--accent-color); /* เขียวมรกต */
}

/* ------------------------------------------- */
/* GAME AREA */
/* ------------------------------------------- */

.game-area {
    background-color: white;
    padding: 25px;
    border-radius: var(--border-radius);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    margin-top: 20px;
}

.stats-bar {
    display: flex;
    justify-content: space-around;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.stats-bar p {
    font-size: 1.1em;
    font-weight: 500;
    color: var(--text-color);
    display: flex;
    align-items: center;
    margin: 5px 10px;
}

.stats-bar i {
    color: var(--primary-color); /* เขียวเข้ม */
    margin-right: 5px;
}

.stat-value {
    font-weight: bold;
    color: var(--accent-color); /* เขียวมรกต */
    margin-left: 5px;
}

.stop-btn {
    background-color: var(--error-color); /* แดง */
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
    transition: background-color 0.3s;
    font-family: 'IBM Plex Sans Thai', sans-serif; 
    display: flex;
    align-items: center;
}

.stop-btn:hover {
    background-color: #c82333;
}
.stop-btn i {
    color: white;
    margin-right: 5px;
}
.replay-btn i {
    color: white;
    margin-right: 5px;
}


.replay-btn {
    background-color: #006400; /* แดง */
    color: rgb(255, 255, 255);
    border: none;
    padding: 8px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
    transition: background-color 0.3s;
    font-family: 'IBM Plex Sans Thai', sans-serif; 
    display: flex;
    align-items: center;
}

.replay-btn:hover {
    background-color: #023020;
}
.word-challenge {
    text-align: center;
    margin-bottom: 20px;
}

.word-meaning {
    font-size: 1.1em;
    color: #6c757d;
    margin-bottom: 20px;
}

.typing-feedback {
    display: block;
    min-height: 25px;
    font-size: 1.8em;
    font-weight: 600;
    margin-bottom: 15px;
    transition: color 0.3s;
}

.correct-text {
    color: var(--success-color); /* เขียวสำเร็จ */
}

.incorrect-text {
    color: var(--error-color); /* แดงผิดพลาด */
}

#typingInput {
    width: 90%;
    padding: 15px;
    font-size: 1.5em;
    border: 2px solid #ccc;
    border-radius: 8px;
    text-align: center;
    outline: none;
    transition: border-color 0.3s, box-shadow 0.3s;
    font-family: 'IBM Plex Sans Thai', sans-serif;
}

#typingInput:focus {
    border-color: var(--primary-color); /* เขียวเข้มเมื่อโฟกัส */
    box-shadow: 0 0 5px rgba(0, 128, 128, 0.5); /* เงาสีเขียวเข้ม */
}

#typingInput:disabled {
    background-color: #f8f8f8;
    cursor: not-allowed;
}


/* ------------------------------------------- */
/* RESULT AREA */
/* ------------------------------------------- */

.result-area {
    background-color: white;
    padding: 30px;
    border-radius: var(--border-radius);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    text-align: center;
    animation: slideIn 0.5s;
}

.result-area h3 {
    font-size: 2em;
    color: var(--accent-color); /* เขียวมรกต */
}

.result-area p {
    font-size: 1.2em;
    margin: 10px 0;
}

#finalScore, #finalWPM {
    font-weight: bold;
    color: var(--error-color); /* แดง */
}

#masteryGauge p {
    font-size: 1em;
    padding: 10px;
    border-radius: 5px;
    margin-top: 15px;
}

/* ------------------------------------------- */
/* PLAY BUTTON */
/* ------------------------------------------- */

.game-control {
    text-align: center;
    margin: 20px 0;
}

.play-btn {
    background-color: var(--primary-color); /* เขียวเข้ม */
    color: white;
    border: none;
    padding: 12px 25px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.2em;
    font-weight: 500;
    transition: background-color 0.3s, transform 0.1s;
    display: inline-flex;
    align-items: center;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.2);
    font-family: 'IBM Plex Sans Thai', sans-serif; 
}

.play-btn i {
    margin-right: 8px;
}

.play-btn:hover {
    background-color: var(--accent-color); /* เขียวมรกตเมื่อ Hover */
    box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
}

.play-btn:active {
    transform: scale(0.98);
}

/* ------------------------------------------- */
/* HISTORY LOG */
/* ------------------------------------------- */

.history-section {
    padding: 15px;
    background-color: #fff;
    border-radius: var(--border-radius);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.05);
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    border-bottom: 1px solid #f0f0f0;
    opacity: 0;
    transform: translateY(20px);
    animation: fadeInSlide 0.4s forwards;
    background-color: #fafafa;
    border-radius: 6px;
    margin-bottom: 5px;
}

.history-item:last-child {
    border-bottom: none;
}

.history-item strong {
    color: var(--primary-color); /* เขียวเข้ม */
}

/* ------------------------------------------- */
/* NEWS CAROUSEL */
/* ------------------------------------------- */

.news-section {
    padding: 15px;
    background-color: #fff;
    border-radius: var(--border-radius);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.news-carousel-container {
    overflow-x: hidden;
}

.news-carousel {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.news-item {
    padding: 15px;
    border: 1px solid #eee;
    border-radius: 8px;
    background-color: #fafafa;
    transition: transform 0.3s;
}

.news-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.news-content {
    display: flex;
    align-items: center;
}

.news-image {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 8px;
    margin-right: 15px;
}

.news-text {
    flex-grow: 1;
}

.news-title {
    margin: 0 0 5px 0;
    font-size: 1.1em;
    color: var(--accent-color); /* เขียวมรกต */
}

/* Pagination */
.pagination {
    text-align: center;
    margin-top: 15px;
}

.pagination button {
    background-color: #eee;
    color: var(--text-color);
    border: none;
    padding: 5px 10px;
    margin: 0 3px;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s;
    font-family: 'IBM Plex Sans Thai', sans-serif; 
}

.pagination button:hover:not(:disabled) {
    background-color: #ccc;
}

.pagination button.active {
    background-color: var(--primary-color); /* เขียวเข้มเมื่อ Active */
    color: white;
}

.pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ------------------------------------------- */
/* BANNER SLIDER */
/* ------------------------------------------- */

.banner-slider {
    overflow: hidden;
    border-radius: var(--border-radius);
    margin: 20px 0;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

/* ------------------------------------------- */
/* NEW YEAR COUNTDOWN STYLES (สำหรับ Banner Slider) */
/* ------------------------------------------- */

/* Container หลักของเคาท์ดาวน์ */
#newYearCountdownText {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%; /* ให้เต็มพื้นที่สไลด์ */
    padding: 10px;
    text-align: center;
    color: white; /* ข้อความหลักเป็นสีขาว */
}

/* องค์ประกอบรวมทั้งหมด */
.countdown-display {
    width: 100%;
    max-width: 800px; /* จำกัดความกว้างไม่ให้ใหญ่เกินไป */
}

/* หัวข้อด้านบน */
.countdown-title {
    font-size: 1.2em;
    display: block;
    margin-bottom: 10px;
    font-weight: 500;
}

/* แถบรวมตัวเลข วัน ชั่วโมง นาที วินาที */
.countdown-units {
    display: flex;
    justify-content: center;
    gap: 15px;
    padding: 15px 10px;
    background: rgba(0, 0, 0, 0.3); /* ฉากหลังทึบเล็กน้อย */
    border-radius: var(--border-radius);

}

/* กล่องย่อยของแต่ละหน่วย (วัน, ชั่วโมง, นาที, วินาที) */
.countdown-unit {
    flex: 1;
    min-width: 60px;
    max-width: 100px;
    text-align: center;
}

/* ตัวเลข */
.countdown-value {
    display: block;
    font-size: 2.5em; /* ทำให้ตัวเลขใหญ่ */
    font-weight: 700;
    color: var(--accent-light); /* ใช้สีเน้น (Gold) เพื่อให้โดดเด่น */
    line-height: 1.1;
}

/* ป้ายชื่อหน่วย (วัน, ชั่วโมง, นาที, วินาที) */
.countdown-label {
    display: block;
    font-size: 0.8em;
    margin-top: 5px;
    font-weight: 400;
    text-transform: uppercase;
}

.banner-track {
    display: flex;
    width: 300%; 
    transition: transform 0.6s ease-in-out;
}

.banner-item {
    width: calc(100% / 3); 
    padding: 20px;
    text-align: center;
    color: white;
    font-size: 1.5em;
    font-weight: 700;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.3);
}

/* ------------------------------------------- */
/* NAVIGATION BAR (Fixed Footer) */
/* ------------------------------------------- */

.nav-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: space-around;
    background-color: white;
    box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.1);
    z-index: 5;
    padding: 5px 0;
}

.nav-btn {
    text-decoration: none;
    color: #6c757d;
    padding: 10px 5px;
    flex-grow: 1;
    text-align: center;
    font-size: 0.9em;
    transition: color 0.3s, background-color 0.3s;
    border-radius: 5px;
}

.nav-btn:hover {
    color: var(--primary-color); /* เขียวเข้ม */
    background-color: #f7f7f7;
}

.nav-btn.active {
    color: var(--primary-color); /* เขียวเข้ม */
    background-color: #e0f7fa; /* พื้นหลังสีเขียวอ่อนมาก */
    font-weight: bold;
}

.nav-btn .icon {
    display: block;
    font-size: 1.2em;
    margin-bottom: 3px;
}

/* ------------------------------------------- */
/* SETTINGS PAGE (Specific Styles) */
/* ------------------------------------------- */

.settings-group {
    background-color: white;
    padding: 20px;
    border-radius: var(--border-radius);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    margin-bottom: 20px;
}

.settings-group h3 {
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    color: var(--accent-color); /* เขียวมรกต */
}
.settings-group h3 i {
    margin-right: 8px;
}

#masterVolume {
    width: 100%;
    margin-top: 10px;
}


/* ------------------------------------------- */
/* ABOUT PAGE (Specific Styles) */
/* ------------------------------------------- */

.info-section {
    background-color: white;
    padding: 20px;
    border-radius: var(--border-radius);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    margin-bottom: 20px;
}
.info-section h3 {
    color: var(--primary-color); /* เขียวเข้ม */
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}

.donation-section h3 i {
    color: var(--error-color); /* แดง */
    margin-right: 8px;
}

.donation-links p {
    margin: 8px 0;
    font-size: 1em;
}

.donation-links i {
    color: var(--accent-color); /* เขียวมรกต */
    margin-right: 5px;
}

/* ------------------------------------------- */
/* LEADERBOARD & FAQ STYLES */
/* ------------------------------------------- */

.leaderboard-section {
    padding: 20px;
    background-color: #fff;
    border-radius: 15px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    margin-bottom: 30px;
}
.leaderboard-items {
    display: flex;
    justify-content: space-around;
    text-align: center;
    margin-bottom: 20px;
}
.rank-item {
    flex-grow: 1;
    padding: 10px;
}
.rank-item h4 {
    margin-top: 5px;
    margin-bottom: 5px;
    font-size: 1.2em;
}
.rank-item .wpm-score {
    font-size: 1.5em;
    font-weight: bold;
    color: var(--accent-color); /* เขียวมรกต */
}
.rank-item i.fas.fa-medal { 
    font-size: 2em;
}
.gold { color: gold; }
.silver { color: silver; }
.bronze { color: #cd7f32; }
.verify-text {
    text-align: center;
    font-size: 0.9em;
    color: #666;
    margin-bottom: 20px;
}

.faq-section {
    margin-top: 30px;
    padding: 20px;
    background-color: #fff;
    border-radius: 15px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}
.faq-item h4 {
    cursor: pointer;
    color: var(--accent-color); /* เขียวมรกต */
    margin: 10px 0;
    display: flex;
    align-items: center;
}
.faq-item h4 i {
    margin-right: 10px;
    font-size: 0.8em;
    color: var(--primary-color); /* เขียวเข้ม */
}
.faq-answer {
    font-size: 0.95em;
    color: #555;
    padding: 5px 0 15px 15px;
    border-left: 3px solid var(--accent-light); /* เขียวอ่อน */
    display: none;
}

/* Leaderboard Table (leaderboard.html) */
.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    background-color: white;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    font-family: 'IBM Plex Sans Thai', sans-serif; 
}
.leaderboard-table th, .leaderboard-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #eee;
}
.leaderboard-table th {
    background-color: var(--accent-color); /* เขียวมรกต */
    color: white;
    font-weight: bold;
}
.leaderboard-table tr:nth-child(even) {
    background-color: #f9f9f9;
}
.leaderboard-table tr:hover {
    background-color: #f1f1f1;
}
.rank-number {
    font-weight: bold;
    text-align: center;
    width: 50px;
}
.gold-rank { background-color: #ffd70030; }
.silver-rank { background-color: #c0c0c030; }
.bronze-rank { background-color: #cd7f3230; }

/* ------------------------------------------- */
/* KEYFRAMES */
/* ------------------------------------------- */

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInSlide {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ------------------------------------------- */
/* RESPONSIVE DESIGN (Optional but recommended) */
/* ------------------------------------------- */

@media (max-width: 600px) {
    .container {
        padding: 10px;
    }

    .stats-bar {
        flex-direction: column;
        align-items: center;
    }
    
    .stats-bar p {
        margin: 5px 0;
    }

    .stop-btn {
        margin-top: 10px;
        width: 100%;
        justify-content: center;
    }
        .replay-btn {
        margin-top: 10px;
        width: 100%;
        justify-content: center;
    }

    .time-options button {
        padding: 8px 15px;
        font-size: 0.9em;
    }
    
    .leaderboard-items {
        flex-wrap: wrap;
    }
    .rank-item {
        width: 33%;
        margin-bottom: 10px;
    }
    
    .play-btn {
        padding: 10px 20px;
        font-size: 1.1em;
    }
}