/* General/Shared Styles | สไตล์หลักที่ใช้ร่วมกันทั้งเว็บ */
@import url('https://fonts.googleapis.com/css2?family=Sarabun:wght@400;700&display=fallback');

:root {
    --primary-color: #333;
    --secondary-color: #f4f4f4;
    --accent-color: #4CAF50;
    --light-text: #fff;
    --dark-text: #333;
}

body {
    font-family: 'Sarabun', sans-serif;
    line-height: 1.6;
    margin: 0;
    padding: 0;
    background: var(--secondary-color);
    color: var(--dark-text);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.container {
    width: 90%;
    max-width: 1200px;
    margin: auto;
    overflow: hidden;
    padding: 0 20px;
}

header {
    background: #1a1a2e; /* Dark cohesive background | พื้นหลังเข้มให้ภาพรวมดูสอดคล้อง */
    padding: 1rem 5%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 1000; /* Keeps header on top | ทำให้แถบหัวเว็บอยู่เหนือองค์ประกอบอื่น */
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

header h1 {
    margin: 0;
    font-size: 1.8rem;
    color: var(--light-text);
    transition: transform 0.3s ease;
}

header h1:hover {
    transform: scale(1.02);
}

nav ul {
    padding: 0;
    margin: 0;
    list-style: none;
    display: flex;
    justify-content: center;
    gap: 30px;
}

nav a {
    color: #e0e0e0;
    text-decoration: none;
    font-size: 1.1rem;
    font-weight: bold;
    position: relative;
    padding-bottom: 5px;
    transition: color 0.3s ease;
}

nav a::after {
    content: '';
    position: absolute;
    width: 0;
    height: 3px;
    bottom: 0;
    left: 0;
    background-color: var(--accent-color);
    transition: width 0.3s ease;
    border-radius: 5px;
}

nav a:hover {
    color: #fff;
}

nav a:hover::after {
    width: 100%;
}

main {
    flex: 1; /* Make main content take up available space | ให้เนื้อหาหลักยืดเต็มพื้นที่ที่เหลือ */
    padding: 0;
    text-align: center;
}

footer {
    text-align: center;
    padding: 2rem 20px;
    background: #1a1a2e;
    color: #ccc;
    margin-top: auto; 
    border-top: 4px solid var(--accent-color);
    font-size: 0.95rem;
    letter-spacing: 0.5px;
}

footer p {
    margin: 0;
}

.is-hidden {
    display: none !important;
}

.noscript-note {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeeba;
    border-radius: 10px;
    padding: 12px 16px;
    margin: 0 0 1.5rem;
    text-align: center;
}

/* Game Page Specific Styles | สไตล์เฉพาะหน้าเกม */
#gameCanvas {
    background: #fff;
    border: 1px solid #ccc;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    max-width: 100%; /* Make canvas responsive | ให้แคนวาสยืดหยุ่นตามหน้าจอ */
    height: auto;
}

#game-controls, #restartBtn {
    margin: 20px 0;
}

button {
    background-color: var(--accent-color);
    color: white;
    border: none;
    padding: 12px 24px;
    text-align: center;
    text-decoration: none;
    display: inline-block;
    font-size: 16px;
    margin: 4px 2px;
    cursor: pointer;
    border-radius: 8px;
    transition: background-color 0.3s ease, transform 0.2s ease;
    font-family: 'Sarabun', sans-serif;
}

button:hover {
    background-color: #45a049;
    transform: translateY(-2px);
}

#restartBtn {
    background-color: #f44336; /* Red for restart | ใช้สีแดงเน้นปุ่มเริ่มเกมใหม่ */
}

#restartBtn:hover {
    background-color: #da190b;
}

/* Responsive Design | การจัดวางสำหรับหน้าจอขนาดต่าง ๆ */
@media (max-width: 768px) {
    header {
        flex-direction: column;
        gap: 15px;
        padding: 1.5rem 20px;
    }

    header h1 {
        font-size: 1.6rem;
    }

    nav ul {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 15px;
    }
}

/* Game Page Specific Styles | สไตล์เพิ่มเติมสำหรับหน้าเกม */
#gameCanvas {
    display: block;
    margin: 20px auto;
    background: #bebebe;
}

/* CV / Resume Page Specific Styles | สไตล์เฉพาะหน้าเรซูเม่ */
.cv-container {
    max-width: 1000px;
    margin: 2rem auto;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    overflow: hidden;
    display: flex;
    flex-wrap: wrap;
    animation: fadeIn 1s ease-in-out;
}

.cv-container * {
    box-sizing: border-box;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.cv-sidebar {
    background: var(--primary-color);
    color: var(--light-text);
    width: 100%;
    padding: 3rem 2rem;
    text-align: center;
}

@media(min-width: 768px) {
    .cv-sidebar {
        width: 30%;
        text-align: left;
    }
}

.profile-img {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    border: 4px solid var(--accent-color);
    margin: 0 auto 1.5rem auto;
    display: block;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.profile-img:hover {
    transform: scale(1.05);
}

.cv-sidebar h2 {
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
    color: var(--accent-color);
}

.contact-info {
    list-style: none;
    padding: 0;
    margin-top: 2rem;
}

.contact-info li {
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.contact-icon {
    width: 28px;
    height: 28px;
    object-fit: contain;
    flex-shrink: 0;
}

.cv-main {
    width: 100%;
    padding: 3rem 2rem;
}

@media(min-width: 768px) {
    .cv-main {
        width: 70%;
    }
}

.section-title {
    color: var(--primary-color);
    border-bottom: 2px solid var(--accent-color);
    padding-bottom: 0.5rem;
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
    text-transform: uppercase;
}

.card {
    background: var(--secondary-color);
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    text-align: left;
    border-left: 4px solid transparent;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    border-left: 4px solid var(--accent-color);
}

.card h3 {
    margin-top: 0;
    color: var(--primary-color);
}

.card .date {
    color: var(--accent-color);
    font-size: 0.9rem;
    font-weight: bold;
    margin-bottom: 0.5rem;
}

.skills-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

@media(min-width: 768px) {
    .skills-container {
        grid-template-columns: 1fr 1fr;
    }
}

.skill {
    margin-bottom: 1rem;
    text-align: left;
}

.skill-name {
    font-weight: bold;
    display: block;
    margin-bottom: 0.5rem;
}

.skill-bar {
    background: #e0e0e0;
    height: 10px;
    border-radius: 5px;
    overflow: hidden;
    position: relative;
}

.skill-progress {
    background: var(--accent-color);
    height: 100%;
    width: var(--width); /* เริ่มต้นแสดงผลเต็มสำหรับหน้าจอมือถือ */
    border-radius: 5px;
    transition: width 1.5s cubic-bezier(0.1, 0.5, 0.1, 1);
}

/* ตั้งค่าให้แสดง Hover Effect เฉพาะบนหน้าจอ Desktop (มากกว่า 768px ขึ้นไป) */
@media(min-width: 768px) {
    .skill-progress {
        width: 0;
    }

    /* Trigger animation on hover over skills container | ให้แอนิเมชันทำงานเมื่อโฮเวอร์บนกรอบทักษะ */
    .skills-container:hover .skill-progress[data-width] {
        width: var(--width);
    }
}


/* Home Page Specific Styles | สไตล์เฉพาะหน้าแรก */
.hero-section {
    background: linear-gradient(135deg, var(--primary-color) 0%, #1a1a2e 100%);
    color: var(--light-text);
    padding: 6rem 20px;
    position: relative;
    overflow: hidden;
}

.hero-content {
    max-width: 800px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
    animation: slideUp 1s ease-out forwards;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(40px); }
    to { opacity: 1; transform: translateY(0); }
}

.hero-title {
    font-size: 3rem;
    margin-bottom: 1rem;
    color: var(--light-text);
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.hero-subtitle {
    font-size: 1.2rem;
    margin-bottom: 2.5rem;
    color: #e0e0e0;
    line-height: 1.8;
}

.hero-buttons {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
}

.btn {
    text-decoration: none;
    padding: 12px 28px;
    font-size: 1.1rem;
    font-weight: bold;
    border-radius: 30px;
    transition: all 0.3s ease;
    display: inline-block;
    box-shadow: 0 4px 6px rgba(0,0,0,0.2);
}

.btn-primary {
    background-color: var(--accent-color);
    color: #fff;
    border: 2px solid var(--accent-color);
}

.btn-primary:hover {
    background-color: transparent;
    color: var(--accent-color);
    transform: translateY(-3px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.3);
}

.btn-secondary {
    background-color: transparent;
    color: #fff;
    border: 2px solid #fff;
}

.btn-secondary:hover {
    background-color: #fff;
    color: var(--primary-color);
    transform: translateY(-3px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.3);
}

/* Highlights Section | ส่วนแสดงจุดเด่น */
.highlights-section {
    padding: 5rem 20px;
    background: var(--secondary-color);
}

.highlights-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 30px;
    max-width: 1100px;
    margin: 0 auto;
}

.highlight-card {
    background: #fff;
    padding: 2.5rem 2rem;
    border-radius: 15px;
    box-shadow: 0 10px 20px rgba(0,0,0,0.05);
    transition: transform 0.4s ease, box-shadow 0.4s ease;
    text-align: center;
    border-bottom: 4px solid transparent;
}

.highlight-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 15px 30px rgba(0,0,0,0.1);
    border-bottom: 4px solid var(--accent-color);
}

.card-icon {
    font-size: 3.5rem;
    margin-bottom: 1.5rem;
    display: inline-block;
    transition: transform 0.4s ease;
}

.highlight-card:hover .card-icon {
    transform: scale(1.2) rotate(5deg);
}

.highlight-card h3 {
    color: var(--primary-color);
    font-size: 1.4rem;
    margin-bottom: 1rem;
}

.highlight-card p {
    color: #666;
    line-height: 1.6;
}

@media (max-width: 768px) {
    .hero-title { font-size: 2.2rem; }
    .hero-subtitle { font-size: 1rem; }
    .hero-section { padding: 4rem 20px; }
}


/* Game Page Specific Styles (Modern UI) | สไตล์หน้าเกมแบบโมเดิร์น */
.game-page-main {
    background: var(--secondary-color);
    padding: 3rem 20px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.game-container {
    background: #ffffff;
    border-radius: 20px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
    max-width: 800px;
    width: 100%;
    padding: 2.5rem;
    text-align: center;
    animation: fadeIn 0.8s ease-out;
}

.game-header {
    margin-bottom: 2rem;
}

.game-header h2 {
    color: var(--primary-color);
    font-size: 2.2rem;
    margin-bottom: 0.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.game-title-icon {
    width: 36px;
    height: 36px;
    object-fit: contain;
}

.game-header p {
    color: #666;
    font-size: 1.1rem;
}

.game-dashboard {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    border: 1px solid #e9ecef;
}

.control-label {
    font-weight: bold;
    color: var(--primary-color);
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.button-group {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

.game-btn {
    padding: 10px 24px;
    font-size: 1.05rem;
    font-weight: bold;
    border-radius: 30px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #fff;
    color: var(--primary-color);
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}

.game-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.1);
}

/* Difficulty specific styles | สไตล์แยกตามระดับความยาก */
.game-btn.easy { border-color: #28a745; color: #28a745; }
.game-btn.easy:hover, .game-btn.easy.active { background: #28a745; color: white; }

.game-btn.medium { border-color: #ffc107; color: #ffc107; }
.game-btn.medium:hover, .game-btn.medium.active { background: #ffc107; color: white; }

.game-btn.hard { border-color: #dc3545; color: #dc3545; }
.game-btn.hard:hover, .game-btn.hard.active { background: #dc3545; color: white; }

.canvas-wrapper {
    background: #1a1a2e; /* Dark background to make game pop | พื้นหลังเข้มช่วยให้ตัวเกมเด่นขึ้น */
    padding: 15px;
    border-radius: 12px;
    box-shadow: inset 0 4px 10px rgba(0,0,0,0.2);
    display: inline-block;
    margin-bottom: 2rem;
    border: 4px solid var(--accent-color);
}

#gameCanvas {
    display: block;
    background: #000; /* Assuming standard arcade game black bg | พื้นหลังดำสไตล์เกมอาร์เคด */
    border-radius: 8px;
    margin: 0 auto;
    box-shadow: 0 0 15px rgba(76, 175, 80, 0.3);
}

.action-controls {
    margin-top: 1rem;
}

.game-btn.restart {
    background: linear-gradient(135deg, #f44336 0%, #d32f2f 100%);
    color: white;
    border: none;
    padding: 12px 30px;
    font-size: 1.2rem;
    letter-spacing: 1px;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.game-btn.restart:hover {
    background: linear-gradient(135deg, #d32f2f 0%, #b71c1c 100%);
    box-shadow: 0 8px 15px rgba(244, 67, 54, 0.4);
}

.game-btn.restart .icon {
    font-size: 1.2rem;
    transition: transform 0.5s ease;
}

.game-btn.restart:hover .icon {
    transform: rotate(180deg);
}

@media (max-width: 600px) {
    .game-container {
        padding: 1.5rem;
    }
    
    #gameCanvas {
        width: 100%;
        height: auto;
    }
}


/* Fullscreen Game UI | ส่วนติดต่อผู้ใช้โหมดเต็มหน้าจอ */
.canvas-wrapper {
    position: relative;
    transition: all 0.3s ease;
}

.fullscreen-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 1.5rem;
    padding: 2px 8px;
    border-radius: 5px;
    cursor: pointer;
    z-index: 10;
    transition: background 0.3s;
}

.fullscreen-btn:hover {
    background: rgba(255, 255, 255, 0.5);
}

body.game-fullscreen-active {
    overflow: hidden; /* Prevent background scrolling | ป้องกันการเลื่อนพื้นหลังเมื่อเข้าโหมดเต็มจอ */
}

/* The overlay background | พื้นหลังทับซ้อนเมื่อเปิดเต็มหน้าจอ */
.canvas-wrapper.fullscreen-mode {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.85); /* Dark opaque background | พื้นหลังทึบสีเข้มลดสิ่งรบกวน */
    z-index: 10000;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 0;
    border: none;
    padding: 0;
    margin: 0;
}

.canvas-wrapper.fullscreen-mode #gameCanvas {
    width: min(92vw, 900px);
    height: auto;
    max-height: 84vh;
    box-shadow: 0 0 30px rgba(76, 175, 80, 0.8); /* Glowing effect | เงาเรืองแสงเพิ่มความเด่นของเกม */
}

.canvas-wrapper.fullscreen-mode .fullscreen-btn {
    top: 20px;
    right: 30px;
    font-size: 2rem;
    background: rgba(255, 255, 255, 0.1);
}

@media (max-width: 768px) {
    .canvas-wrapper.fullscreen-mode #gameCanvas {
        width: min(88vw, 420px);
        max-height: 78vh;
    }
}


/* Game Over Overlay | ชั้นแสดงผลเมื่อเกมจบ */
.game-over-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border-radius: 8px;
    z-index: 20;
    color: white;
    text-align: center;
    animation: fadeIn 0.5s ease-out;
}

.game-over-overlay h3 {
    font-size: 3rem;
    color: #ff4757;
    margin-bottom: 10px;
    text-shadow: 0 0 15px rgba(255, 71, 87, 0.6);
    text-transform: uppercase;
}

.game-over-overlay p {
    font-size: 1.5rem;
    margin-bottom: 25px;
}

.game-over-overlay span {
    color: #4CAF50;
    font-weight: bold;
    font-size: 2rem;
}

/* Pause Overlay | ชั้นแสดงผลเมื่อพักเกม */
.pause-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border-radius: 8px;
    z-index: 20;
    color: white;
    text-align: center;
    animation: fadeIn 0.4s ease-out;
}

.pause-overlay h3 {
    font-size: 2.2rem;
    color: #ffd166;
    margin-bottom: 10px;
    text-transform: uppercase;
}

.pause-overlay p {
    font-size: 1.1rem;
    margin-bottom: 20px;
}

.pause-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
}

.game-btn.continue {
    background: #28a745;
    color: white;
    border: none;
}

.game-btn.continue:hover {
    background: #218838;
}

.game-btn.end {
    background: #6c757d;
    color: white;
    border: none;
}

.game-btn.end:hover {
    background: #5a6268;
}


.contact-details {
    display: flex;
    flex-direction: column;
    text-align: left;
    line-height: 1.3;
}
.contact-label {
    font-size: 0.8rem;
    color: var(--accent-color);
    font-weight: bold;
}
.contact-details a {
    color: var(--light-text);
    text-decoration: none;
    transition: color 0.3s;
}
.contact-details a:hover {
    color: var(--accent-color);
}

