/* Basic Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; /* Cleaner font */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background-color: #e0e0e0; /* Matches outer background of target image */
    padding: 20px;
}

/* Header Styles */
.game-header-nav {
    width: 100%;
    max-width: 740px;
    margin-bottom: 20px;
    font-family: 'Nanum Gothic', 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

.header-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background-color: #fff;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(40, 167, 69, 0.15);
    border-bottom: 3px solid #28a745;
}

.header-logo {
    display: flex;
    align-items: center;
}

.header-apple-logo {
    margin-right: 10px;
}

.header-apple {
    width: 35px;
    height: 35px;
    background-image: url('apple.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: bold;
    color: white;
}

.header-title {
    font-size: 22px;
    font-weight: 700;
    color: #28a745;
}

.header-nav ul {
    display: flex;
    list-style: none;
    gap: 20px;
}

.header-nav a {
    color: #555;
    text-decoration: none;
    font-size: 15px;
    font-weight: 500;
    transition: color 0.2s;
    padding: 5px 10px;
    border-radius: 5px;
}

.header-nav a:hover {
    color: #28a745;
}

.header-nav a.active {
    background-color: #28a745;
    color: white;
}

@media screen and (max-width: 480px) {
    .header-container {
        flex-direction: column;
        padding: 15px;
    }
    
    .header-logo {
        margin-bottom: 12px;
    }
    
    .header-nav ul {
        gap: 10px;
    }
    
    .header-nav a {
        font-size: 14px;
        padding: 4px 8px;
    }
}

.game-wrapper { 
    display: flex;
    flex-direction: column;
    align-items: center;
    /* background-color: #e7f0f7; Old background */
    background-color: #f0fff0; /* Honeydew - placeholder for light green checkered */
    /* If you have a checkered pattern image: */
    /* background-image: url('checkered_pattern.png'); */
    /* background-repeat: repeat; */
    border: 5px solid #28a745; 
    border-radius: 15px;
    padding: 15px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
    position: relative; 
    overflow: hidden; /* To ensure overlays with border-radius clip correctly */
    min-height: 590px; /* RESTORED: Ensures consistent height */
    min-width: 740px;  /* ADDED: Ensures consistent width for game board */
    /* transition: width 0.3s ease, height 0.3s ease; /* REMOVED: Size is now fixed */
}

.game-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    margin-bottom: 12px;
}

#score { 
    font-size: 36px; /* Larger score font */
    font-weight: bold;
    color: #333; /* Darker score color */
    margin-bottom: 10px;
}

.timer-container-horizontal { 
    width: 80%; /* Timer width relative to header */
    max-width: 350px; /* Max width for timer bar */
    height: 20px; /* Slimmer timer bar */
    background-color: #d3d3d3; /* Gray track for timer */
    border-radius: 10px; /* More rounded timer track */
    overflow: hidden;
    border: 1px solid #bbb;
}

#timer-bar-horizontal { 
    width: 100%; 
    height: 100%;
    background-color: #28a745; /* Brighter green for timer bar */
    transition: width 0.1s linear; 
    border-radius: 8px; /* Rounded corners for the bar itself */
}

.game-board {
    display: grid;
    gap: 2px; /* Keep small gap as in current JS */
    background-color: #f8f9fa; /* Very light, almost white, for the board */
    border: 1px solid #dee2e6; /* Lighter border for the board */
    padding: 5px; /* Small padding around apples */
    border-radius: 8px; /* Rounded corners for the board itself */
    margin-bottom: 15px; 
}

.apple {
    width: 39px; /* Updated from 30px */
    height: 39px; /* Updated from 30px */
    background-image: url('apple.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 19px; /* Adjusted from 15px (15 * 1.3 = 19.5) */
    font-weight: bold;
    color: white;
    user-select: none;
    cursor: default;
    position: relative;
    /* text-shadow: 1px 1px 1px rgba(0,0,0,0.4); /* Optional: for number pop */
}

/* Styling for the number inside the apple to allow fine-tuning its position */
.apple .apple-number {
    position: relative;
    top: 3.5px; /* Increased from 1.5px to 3.5px to move numbers further down */
    /* line-height: 1; /* May help if font has unusual vertical metrics */
}

.apple.empty {
    background-image: none;
}

.controls {
    display: flex;
    align-items: center;
    justify-content: center; 
    gap: 8px; 
    width: 100%;
    padding-top: 10px; /* Add some space above controls */
    z-index: 10; /* Ensure controls are above the game board content if needed */
    position: relative; /* Ensure it stacks correctly if start-screen-elements uses flex-grow */
}

.controls button, .controls label {
    padding: 8px 12px;
    border-radius: 6px; /* Slightly more rounded buttons */
    border: 1px solid #adb5bd; /* Lighter border for controls */
    cursor: pointer;
    background-color: #f8f9fa; /* Light background for buttons */
    color: #343a40; /* Dark text for buttons */
    font-size: 13px; 
    display: inline-flex; /* Align icon and text in button/label */
    align-items: center;
}

.controls button:hover, .controls label:hover {
    background-color: #e9ecef; /* Hover effect */
}

.controls input[type="checkbox"] {
    margin-right: 5px;
}

.selection-box {
    position: absolute;
    border: 2px dashed #007bff;
    background-color: rgba(0, 123, 255, 0.15); /* Lighter selection box */
    pointer-events: none;
    z-index: 10;
}

.selection-box.valid-sum {
    border: 2px solid #dc3545; /* Red for valid sum */
    background-color: rgba(220, 53, 69, 0.2); /* Lighter red */
}

/* Game Over Screen Styles */
.game-over-overlay {
    position: absolute; /* Changed from fixed to absolute */
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6); /* Semi-transparent black background */
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000; /* Ensure it's on top */
    border-radius: 15px; /* Match game-wrapper border-radius */
}

.game-over-modal {
    background-color: #fff;
    padding: 30px 40px;
    border-radius: 10px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.25);
    text-align: center;
    color: #333;
}

.game-over-modal h2 {
    font-size: 28px;
    margin-bottom: 15px;
    color: #dc3545; /* Red color for "Game Over!" */
}

.game-over-title {
    font-size: 32px;
    font-weight: bold;
    margin-bottom: 20px;
    color: #dc3545; /* Red color for "Game Over!" */
    text-shadow: 1px 1px 3px rgba(0,0,0,0.2);
    font-family: 'Nanum Gothic', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    position: relative;
    display: inline-block;
}

.game-over-title::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: -8px;
    width: 100%;
    height: 3px;
    background: linear-gradient(to right, transparent, #dc3545, transparent);
}

.game-over-modal p {
    font-size: 20px;
    margin-bottom: 25px;
}

.game-over-modal #final-score {
    font-weight: bold;
    font-size: 22px;
}

.game-over-modal button {
    padding: 12px 25px;
    font-size: 18px;
    color: white;
    background-color: #28a745; /* Green button */
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.game-over-modal button:hover {
    background-color: #218838; /* Darker green on hover */
}

/* Styles for the new start screen elements */
.start-screen-elements {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    /* max-width: 380px; /* REMOVED: Allow start content to use full width of wrapper */
    padding: 20px 0; 
    text-align: center;
    flex-grow: 1; 
}

.game-title-container {
    margin-bottom: 30px;
}

.title-line1 {
    font-size: 20px; /* Adjust as needed */
    color: #556b2f; /* Dark Olive Green - placeholder */
    display: block;
}

.title-line2 {
    font-size: 40px; /* Adjust as needed */
    font-weight: bold;
    color: #ff8c00; /* DarkOrange - placeholder for orange part */
    /* For multi-color text like the image, you might need spans or SVG */
}

.start-play-area {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 40px;
}

.play-apple {
    width: 120px; 
    height: 120px;
    background-color: transparent; 
    border-radius: 50%; /* Simplified from complex apple shape to a circle */
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0px 5px 10px rgba(0,0,0,0.2);
    position: relative; 
    background-image: url('apple.png'); 
    background-size: contain; /* Show entire image, maintain aspect ratio */
    background-position: center;
    background-repeat: no-repeat;
}

.example-apples-cluster {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    width: calc(4 * 39px + 3 * 8px); /* Based on APPLE_SIZE=39px */
}

.small-apple {
    width: 39px; /* Match game APPLE_SIZE */
    height: 39px;
    background-image: url('apple.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 19px;
    font-weight: bold;
    color: white;
    border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%; /* Approximate apple shape */
}

/* Positioning example apples as in the image */
.example-apple-1 { grid-column: 1; grid-row: 1; }
.example-apple-2 { grid-column: 2; grid-row: 1; }
.example-apple-3 { grid-column: 3; grid-row: 1; }
.example-apple-4 { grid-column: 4; grid-row: 1; }
.example-apple-5 { grid-column: 1; grid-row: 2; transform: translateX(19.5px); } /* Offset for pyramid */
.example-apple-6 { grid-column: 2; grid-row: 2; transform: translateX(19.5px); }
.example-apple-7 { grid-column: 3; grid-row: 2; transform: translateX(19.5px); }
.example-apple-8 { grid-column: 2; grid-row: 3; transform: translateX(0px); } /* Moved left, was translateX(19.5px) */
.example-apple-9 { grid-column: 3; grid-row: 3; transform: translateX(9px); } /* Moved right */

/* Animation for cleared apples */
@keyframes appleClearEffect {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    100% {
        transform: scale(0.5);
        opacity: 0;
    }
}

.apple-cleared-animation {
    animation-name: appleClearEffect;
    animation-duration: 0.3s; /* Adjust duration as needed */
    animation-fill-mode: forwards; /* Keeps the state of the last keyframe */
    /* Important: The element will still occupy space until fully removed/hidden by JS */
}

/* Hide the old start screen overlay if it wasn't removed from HTML */
#start-screen-overlay {
    display: none !important; 
}

/* Game Description Styles */
.game-description {
    width: 100%;
    max-width: 740px; /* Match game-wrapper width */
    margin: 30px 0;
    font-family: 'Nanum Gothic', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    animation: fadeIn 0.8s ease-out;
}

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

.description-container {
    background-color: #fff;
    border: 3px solid #28a745;
    border-radius: 15px;
    padding: 25px 30px;
    box-shadow: 0 6px 15px rgba(40, 167, 69, 0.15);
    position: relative;
    overflow: hidden;
}

.description-container::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 5px;
    background: linear-gradient(to right, #28a745, #7fda90, #28a745);
}

.instruction-section {
    margin-bottom: 20px;
    transition: transform 0.3s ease;
}

.instruction-section:hover {
    transform: translateX(3px);
}

.instruction-section h2 {
    color: #e44d26;
    font-size: 22px;
    margin-bottom: 15px;
    font-weight: 700;
    display: flex;
    align-items: center;
}

.instruction-section h2::after {
    content: "";
    flex-grow: 1;
    height: 1px;
    background: linear-gradient(to right, rgba(228, 77, 38, 0.5), transparent);
    margin-left: 15px;
}

.instruction-section p {
    color: #333;
    line-height: 1.7;
    font-size: 16px;
    text-align: justify;
    word-break: keep-all;
    letter-spacing: -0.3px;
    padding-left: 10px;
    border-left: 2px solid rgba(40, 167, 69, 0.2);
}

.instruction-section strong {
    color: #e44d26;
    font-weight: 700;
    position: relative;
    display: inline-block;
}

.instruction-section strong::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 3px;
    background-color: rgba(228, 77, 38, 0.2);
}

.instruction-divider {
    border: 0;
    height: 1px;
    background: linear-gradient(to right, transparent, rgba(40, 167, 69, 0.5), transparent);
    margin: 25px 0;
}

/* Add Apple decoration to the description */
.instruction-section h2::before {
    content: "";
    display: inline-block;
    width: 30px;
    height: 30px;
    background-image: url('apple.png');
    background-size: contain;
    background-repeat: no-repeat;
    margin-right: 12px;
    transform: scale(0.9);
}

/* Apply special styling for Korean text */
@media screen and (min-width: 640px) {
    .instruction-section p {
        letter-spacing: -0.3px;
    }
}

@media screen and (max-width: 768px) {
    .game-description {
        max-width: 95%;
    }
    
    .description-container {
        padding: 20px;
    }
    
    .instruction-section h2 {
        font-size: 20px;
    }
    
    .instruction-section p {
        font-size: 15px;
        padding-left: 8px;
    }
}

@media screen and (max-width: 480px) {
    .description-container {
        padding: 15px;
    }
    
    .instruction-section h2 {
        font-size: 18px;
    }
    
    .instruction-section h2::before {
        width: 24px;
        height: 24px;
        margin-right: 8px;
    }
    
    .instruction-section p {
        line-height: 1.6;
    }
    
    .instruction-divider {
        margin: 20px 0;
    }
}

/* Footer Styles */
.game-footer {
    width: 100%;
    max-width: 740px;
    margin-top: 20px;
    margin-bottom: 30px;
    font-family: 'Nanum Gothic', 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

.footer-content {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 15px;
    background-color: #f8f9fa;
    border-radius: 10px;
    border-top: 3px solid #28a745;
    box-shadow: 0 -2px 10px rgba(40, 167, 69, 0.1);
}

.footer-logo {
    margin-right: 20px;
}

.footer-apple {
    width: 35px;
    height: 35px;
    background-image: url('apple.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: bold;
    color: white;
}

.footer-text {
    text-align: center;
    color: #555;
}

.footer-text p {
    margin: 5px 0;
    font-size: 14px;
}

.footer-links {
    font-size: 12px;
}

.footer-links a {
    color: #28a745;
    text-decoration: none;
    transition: color 0.2s;
}

.footer-links a:hover {
    color: #218838;
    text-decoration: underline;
}

@media screen and (max-width: 480px) {
    .footer-content {
        flex-direction: column;
        padding: 10px;
    }
    
    .footer-logo {
        margin-right: 0;
        margin-bottom: 10px;
    }
    
    .footer-text p {
        font-size: 12px;
    }
    
    .footer-links {
        font-size: 11px;
    }
} 