/* Basic Setup */
body {
    font-family: Arial, sans-serif;
    background-color: #f0f0f0;
    color: #333;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    text-align: center;
    overflow: hidden;
}

h1 {
    color: #4a4a4a;
}

button {
    background-color: #007bff;
    color: white;
    border: none;
    padding: 12px 24px;
    font-size: 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.3s ease;
    margin: 10px;
}

button:hover {
    background-color: #0056b3;
}

button:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}

/* Screen Management */
.screen {
    display: none; /* ซ่อนทุกหน้าจอไว้ก่อน */
    width: 90%;
    max-width: 600px;
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.screen.active {
    display: block; /* แสดงเฉพาะหน้าจอที่ active */
}

/* Start Screen */
.rules {
    text-align: left;
    background: #fafafa;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 15px;
    margin: 20px 0;
}
.rules p {
    margin: 8px 0;
}

/* Score Board */
#score-board {
    display: flex;
    justify-content: space-around;
    font-size: 1.2em;
    font-weight: bold;
    margin-bottom: 20px;
    color: #0056b3;
}

/* Game Area (Image + Grid) */
#game-area {
    position: relative;
    width: 300px; /* 3 * 100px */
    height: 500px; /* 5 * 100px */
    margin: 0 auto;
    border: 2px solid #333;
}

#image-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    z-index: 1;
}

#grid-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-columns: repeat(3, 1fr); /* <--- แก้ไข */
    grid-template-rows: repeat(5, 1fr);   /* <--- แก้ไข */
    z-index: 2;
    gap: 0px;
    /* background-color: #fff; <-- ลบบรรทัดนี้ทิ้งไปเลย */
}

.panel {
    background-color: #5a5a5a;
    border: 1px solid #FFF;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5em;
    font-weight: bold;
    color: white;
    user-select: none;
    transition: opacity 0.5s ease-out, background-color 0.1s linear;
}

/* สถานะของแผ่นป้าย */
.panel.open {
    opacity: 0;
    pointer-events: none; /* เปิดแล้วคลิกไม่ได้ */
}

/* แอนิเมชันตอนสุ่ม */
.panel.highlight {
    background-color: #007bff;
    transform: scale(1.05);
}

/* Choice Screen */
#choice-buttons {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    margin-top: 20px;
}

/* --- High Score Styles --- */
#high-score-display-start {
    font-size: 1.2em;
    color: #c9302c; /* สีแดงเข้ม */
    font-weight: bold;
    margin-top: 20px;
}

#high-score-display-gameover {
    font-size: 1em;
    color: #555;
    font-weight: bold;
    margin-top: -10px; /* ขยับให้ใกล้กับคะแนนที่ได้ */
    margin-bottom: 20px;
}