body {
    font-family: sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 20px;
    background-color: #f0f2f5; /* Slightly different background */
}

h1 {
    color: #1a237e; /* Dark blue */
}

#difficulty-selector {
    margin-bottom: 15px;
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap; /* Allow wrapping on small screens */
    justify-content: center;
}

#difficulty-selector label {
    font-weight: bold;
    color: #333;
    margin-right: 5px;
}

.difficulty-btn,
#reset-button,
#solution-button,
#hint-button {
    padding: 8px 15px;
    font-size: 0.95em;
    cursor: pointer;
    color: white;
    border: none;
    border-radius: 5px;
    transition: background-color 0.2s ease, transform 0.1s ease;
    margin: 3px; /* Add small margin for wrap spacing */
}
.difficulty-btn:active,
#reset-button:active,
#solution-button:active,
#hint-button:active {
    transform: scale(0.98);
}


button[data-difficulty="easy"] { background-color: #4caf50; } /* Green */
button[data-difficulty="easy"]:hover { background-color: #45a049; }
button[data-difficulty="medium"] { background-color: #ff9800; } /* Orange */
button[data-difficulty="medium"]:hover { background-color: #f57c00; }
button[data-difficulty="hard"] { background-color: #f44336; } /* Red */
button[data-difficulty="hard"]:hover { background-color: #e53935; }

#reset-button {
    background-color: #607d8b; /* Blue Grey */
}
#reset-button:hover {
    background-color: #546e7a;
}

/* Style for the solution button */
#solution-button {
    background-color: #9c27b0; /* Purple */
}
#solution-button:hover {
    background-color: #8e24aa;
}

/* Style for the Hint button */
#hint-button {
    background-color: #03a9f4; /* Light Blue */
}
#hint-button:hover {
    background-color: #0288d1;
}
#hint-button:disabled { /* Style for when hints run out */
    background-color: #bdbdbd;
    cursor: not-allowed;
    opacity: 0.7;
}


#game-info {
     text-align: center;
     margin-bottom: 10px;
     width: 90%;
     max-width: 700px;
}

#instructions {
    color: #555;
    font-size: 1.0em;
    margin-bottom: 5px; /* Reduced margin */
}
#path-info {
    color: #333;
    font-weight: bold;
    min-height: 1.2em; /* Ensure space even when empty */
    font-size: 0.9em;
    display: flex; /* Use flexbox for better alignment */
    justify-content: center; /* Center items horizontally */
    align-items: center; /* Center items vertically */
    flex-wrap: wrap; /* Allow wrapping */
}

/* Style for the hint counter display */
#hint-counter {
    display: inline-block; /* Allows margin */
    margin-left: 15px; /* Space it out */
    font-weight: bold;
    color: #03a9f4; /* Match button color */
    background-color: #e1f5fe; /* Very light blue background */
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.9em;
    border: 1px solid #b3e5fc;
    line-height: 1.4; /* Adjust line height */
}
#hint-counter.no-hints { /* Style when hints are 0 */
     color: #757575;
     background-color: #f5f5f5;
     border-color: #e0e0e0;
}


#message-area {
    margin-bottom: 15px;
    padding: 10px 15px; /* Adjusted padding */
    min-height: 20px;
    font-weight: bold;
    color: #333; /* Default color */
    background-color: #ffffff; /* White background */
    border: 1px solid #ddd; /* Light border */
    border-radius: 4px;
    width: 90%; /* Responsive width */
    max-width: 700px; /* Max width */
    text-align: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1); /* Subtle shadow */
    border-left: 5px solid transparent; /* Placeholder for colored border */
    transition: border-left-color 0.3s ease;
}

#message-area.success {
    color: #28a745;
    border-left-color: #28a745;
}
#message-area.error {
    color: #dc3545;
    border-left-color: #dc3545;
}
#message-area.win {
    color: #17a2b8; /* Bootstrap info cyan */
    border-left-color: #17a2b8;
    font-size: 1.2em; /* Make win message bigger */
}
#message-area.info {
     color: #31708f; /* Bootstrap info blue text */
     border-left-color: #bce8f1; /* Bootstrap info blue border */
}


#maze-grid-container {
    padding: 14px;
    margin-bottom: 20px;
    display: inline-block;
}

#maze-grid {
    display: grid;
    gap: 4px; /* Slightly smaller gap */
}

.cell {
    width: 48px;
    height: 48px;
    border: 2px solid #dfe6ee;
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: 'Fredoka', sans-serif;
    font-size: 1.2em;
    font-weight: 700;
    color: #2f3357;
    cursor: pointer;
    background-color: #ffffff;
    box-shadow: 0 3px 0 #dfe6ee;
    transition: background-color 0.2s ease, transform 0.15s ease, border-color 0.2s, box-shadow 0.2s ease;
    user-select: none;
    position: relative;
}

.cell:hover {
    background-color: #fff8e1;
    border-color: #ffd84d;
    transform: translateY(-2px);
}

.cell.selected {
    background-color: #b9f0cc;
    border-color: #2fbf71;
    box-shadow: 0 3px 0 #2fbf71;
    color: #1b5e35;
}

.cell.start-node {
    background-color: #cfe4ff;
    border: 3px solid #3b8bff;
    box-shadow: 0 3px 0 #3b8bff;
    color: #1f4fa0;
}
.cell.start-node::before {
    content: 'S';
    position: absolute;
    top: 1px;
    left: 3px;
    font-size: 0.6em;
    font-weight: bold;
    color: #0d47a1;
    background-color: rgba(255, 255, 255, 0.5);
    padding: 0 1px;
    border-radius: 2px;
}


.cell.end-node {
    background-color: #ffe0ee;
    border: 3px solid #ff5c9a;
    box-shadow: 0 3px 0 #ff5c9a;
    color: #a8235a;
    animation: end-glow 1.6s ease-in-out infinite;
}
.cell.end-node::before {
    content: 'E';
    position: absolute;
    top: 1px;
    right: 3px; /* Position end marker differently */
    font-size: 0.6em;
    font-weight: bold;
    color: #b71c1c;
    background-color: rgba(255, 255, 255, 0.5);
    padding: 0 1px;
    border-radius: 2px;
}


.cell.error {
    background-color: #f8d7da;
    border: 2px solid #dc3545;
    animation: shake 0.3s;
}

.cell .order-number {
    position: absolute;
    bottom: 1px; /* Position at bottom */
    right: 3px;
    font-size: 0.6em;
    font-weight: normal;
    color: #444;
    background-color: rgba(255, 255, 255, 0.6); /* Slight background */
    padding: 0 2px;
    border-radius: 2px;
    z-index: 1; /* Ensure it's above background color changes */
}

/* Style for cells that are part of the revealed solution */
.cell.solution-step {
    background-color: #fff176; /* Yellow */
    border: 1px solid #fbc02d; /* Darker Yellow/Orange */
    color: #5d4037; /* Brownish text */
}

/* Ensure start/end nodes in solution path keep their special markers */
.cell.solution-step.start-node::before,
.cell.solution-step.end-node::before {
    z-index: 2; /* Make sure S/E markers stay on top */
}

/* Style for the cell being hinted */
.cell.hint-step {
    background-color: #b3e5fc; /* Light blue hint background */
    border: 2px dashed #0277bd; /* Dashed blue border */
    box-shadow: 0 0 10px rgba(3, 169, 244, 0.7); /* Blue glow */
    /* Use transition on the base .cell class for smooth appearance/disappearance */
}


/* Shake animation for errors */
@keyframes shake {
  0% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  50% { transform: translateX(4px); }
  75% { transform: translateX(-4px); }
  100% { transform: translateX(0); }
}
/* 도착 칸이 반짝여서 어디로 가야 하는지 보이게 */
@keyframes end-glow {
    0%, 100% { box-shadow: 0 3px 0 #ff5c9a, 0 0 0 0 rgba(255, 92, 154, 0.5); }
    50% { box-shadow: 0 3px 0 #ff5c9a, 0 0 0 8px rgba(255, 92, 154, 0); }
}

/* 둥글고 통통한 버튼 */
.difficulty-btn,
#reset-button,
#solution-button,
#hint-button {
    border-radius: 999px;
    font-family: 'Fredoka', sans-serif;
    font-weight: 600;
    box-shadow: 0 4px 0 rgba(0, 0, 0, 0.18);
}

@media (prefers-reduced-motion: reduce) {
    .cell.end-node { animation: none; }
}
