/* Add these styles to your existing style.css */

.grid-and-definition {
    display: flex;
    flex-direction: column;
    align-items: center; /* Center grid/definition horizontally if needed */
    width: auto; /* Allow parent to shrink/grow based on content */
    /* REMOVED explicit width/max-width from here */
}


#timer-display {
    font-size: 1.1em;
    font-weight: bold;
    margin-top: 10px;
    color: #333;
    min-width: 150px; /* Align roughly with definition box */
    text-align: center;
}

#definition-box {
    /* REMOVE width: 100%; */
    /* Width will be set by JS */
   box-sizing: border-box; /* Keep */
   /* Keep other styles */
   margin: 10px auto; /* Center the box (top/bottom 10px, left/right auto) */
   padding: 10px 15px;
   border: 1px solid #aaa;
   background-color: #f8f9fa;
   min-height: 4em;
   font-size: 0.95em;
   line-height: 1.4;
   color: #333;
   border-radius: 4px;
   box-shadow: inset 1px 1px 3px rgba(0,0,0,0.1);
}


body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    /* Sky blue gradient */
    background: linear-gradient(to bottom, #e3faff, #e9fafd); /* Light blue to slightly darker blue */
    margin: 0;
    padding: 20px;
    min-height: 100vh;
}

.controls {
    margin-bottom: 20px;
    display: flex;
    gap: 10px;
}

/* Base style for all buttons in .controls */
.controls button {
    padding: 10px 18px; /* Slightly larger padding */
    font-size: 0.95em;
    font-weight: 600; /* Bolder text */
    cursor: pointer;
    border-radius: 6px; /* Consistent rounding */
    border: none; /* Remove default border */
    color: #ffffff; /* White text for contrast */
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15); /* Subtle shadow */
    transition: background-color 0.2s ease, transform 0.1s ease, box-shadow 0.2s ease;
    margin: 0 5px; /* Add some horizontal margin */
}

/* Style for hover effect on all buttons */
.controls button:hover {
    opacity: 0.9; /* Slight fade */
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); /* Larger shadow on hover */
    transform: translateY(-1px); /* Slight lift effect */
}

/* Style for active (pressed) effect on all buttons */
.controls button:active {
    transform: translateY(0px); /* Reset lift */
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1); /* Smaller shadow */
}

/* Specific Button Colors */
#reset-button {
    background-color: #ff6b6b; /* Red */
}

#generate-5-button {
    background-color: #48cae4; /* Light Blue */
}

#generate-10-button {
    background-color: #0096c7; /* Medium Blue */
}

#generate-20-button {
    background-color: #023e8a; /* Dark Blue */
}

#answer-button {
    background-color: #fca311; /* Orange/Yellow */
}

.puzzle-container {
    display: flex;
    flex-wrap: wrap;
    gap: 30px;
    justify-content: center;
    align-items: flex-start; /* Align top */
    width: 100%;
}
#puzzle-grid {
    position: relative;
    border: 1px solid #bbb; /* Slightly softer border */
    background-color: #ffffff;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1), inset 0 1px 2px rgba(0, 0, 0, 0.05); /* Enhanced shadow */
    overflow: hidden;
    flex-shrink: 0;
    border-radius: 8px; /* Added rounded corners */
    /* Width/Height set dynamically by JS */
}

/* Container for a word (positioned absolutely) */
.puzzle-slot {
    position: absolute;
    box-sizing: border-box;
    display: flex;
    cursor: default;
    z-index: 1; /* Base stacking order */
    /* Ensure background is transparent so underlying elements aren't hidden */
    background-color: transparent;
}

/* --- NEW: Class to bring highlighted slot to the front --- */
.puzzle-slot.highlight-active {
    z-index: 10; /* Higher value to bring to front */
}

.puzzle-slot.filled {
     cursor: pointer;
}


/* Style for the individual letter boxes */
.letter-box {
    /* ... keep existing styles ... */
    box-sizing: border-box;
    width: var(--cell-size, 35px);
    height: var(--cell-size, 35px);
    border: 1px solid #ccc;
    border-radius: 5px;
    background-color: #e9e9e9; /* Base background */
    margin-right: 1px;
    margin-bottom: 1px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: calc(var(--cell-size, 35px) * 0.6);
    font-family: monospace;
    font-weight: bold;
    text-transform: uppercase;
    color: black;
    transition: background-color 0.1s ease, border-color 0.1s ease;
    -webkit-user-select: none;
    user-select: none;
    /* Added background clip to prevent background bleeding under borders */
    background-clip: padding-box;
}

/* Remove margin for last box in a row/column */
.puzzle-slot[data-orientation="across"] > .letter-box:last-child {
    margin-right: 0;
}
.puzzle-slot[data-orientation="down"] > .letter-box:last-child {
    margin-bottom: 0;
}


/* Style for letter boxes when filled */
.letter-box.filled {
    background-color: #fff;
    border-color: #555;
}

/* Highlight for length MATCH */
.puzzle-slot.drag-over-match .letter-box {
    background-color: #c0f0c0; /* Bright Green */
    border-color: #6a6; /* Darker Green Border */
    border-style: solid;
}

/* Highlight for length MISMATCH */
.puzzle-slot.drag-over-mismatch .letter-box {
    background-color: #f0c0c0; /* Bright Red */
    border-color: #a66; /* Darker Red Border */
    border-style: solid;
}

/* Highlight for length MATCH */
/* Apply to boxes inside a slot with BOTH match and active highlight classes */
.puzzle-slot.drag-over-match.highlight-active .letter-box {
    background-color: #c0f0c0; /* Bright Green */
    border-color: #6a6;
    border-style: solid;
}

/* Highlight for length MISMATCH */
/* Apply to boxes inside a slot with BOTH mismatch and active highlight classes */
.puzzle-slot.drag-over-mismatch.highlight-active .letter-box {
    background-color: #f0c0c0; /* Bright Red */
    border-color: #a66;
    border-style: solid;
}


/* REMOVE OR COMMENT OUT THIS RULE */
/* Highlight/Feedback for dragging over an already FILLED slot */
/*
.puzzle-slot.drag-over-filled .letter-box {
    background-color: #ddd;
    border-color: #aaa;
}
.puzzle-slot.drag-over-filled {
     cursor: not-allowed;
}
*/

.word-bank-container {
    border: 1px solid #ccc;
    padding: 15px;
    background-color: #fff;
    box-shadow: 2px 2px 5px rgba(0,0,0,0.1);
    align-self: flex-start; /* Keep word bank aligned to top */
    min-width: 150px;
}
.word-bank-container h2 {
    margin-top: 0;
    margin-bottom: 10px;
    text-align: center;
    font-size: 1.2em;
}

#word-bank {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.word-block {
    border: 1px solid #adb5bd; /* Softer border color */
    /* Subtle gradient for background */
    background: linear-gradient(to bottom, #ffffff, #f1f3f5);
    padding: 10px 15px; /* Slightly more padding */
    cursor: grab;
    text-align: center;
    font-weight: 600; /* Slightly bolder */
    font-size: 0.95em; /* Adjust font size if needed */
    color: #495057; /* Darker text color */
    border-radius: 6px; /* Rounded corners */
    text-transform: uppercase;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08); /* Softer shadow */
    transition: all 0.2s ease; /* Smooth transitions for all properties */
}

.word-block:active {
    cursor: grabbing;
    background: linear-gradient(to bottom, #e9ecef, #dee2e6); /* Darker gradient when grabbed */
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1); /* Slightly reduced shadow */
    transform: scale(0.98); /* Subtle shrink effect */
}

/* Keep placed and dragging styles */
.word-block.placed {
    opacity: 0;
    pointer-events: none;
    height: 0;
    padding-top: 0;
    padding-bottom: 0;
    border: none;
    margin-top: 0;
    margin-bottom: 0;
    overflow: hidden;
}

.word-block.dragging {
    opacity: 0.6;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); /* More pronounced shadow when dragging */
}
/* Define cell size (used in JS for positioning) */
:root {
    --cell-size: 35px;
}
/* 탭해서 고른 단어 (휴대폰·태블릿) */
.word-block.tap-selected {
    background-color: #ffd84d;
    color: #2f3357;
    box-shadow: 0 0 0 4px rgba(255, 216, 77, 0.5);
    transform: scale(1.05);
}
