/* Basic Reset & Body Styles */
html, body {
    width: 100vw;
    height: 100vh;
    margin: 0;
    padding: 0;
    overflow: hidden;
    font-family: sans-serif;
    background-color: #FDF6EC; /* Match React bg */
    color: #333;
    box-sizing: border-box;
}

*, *:before, *:after {
    box-sizing: inherit;
}

.game-container {
    width: 100vw;
    height: 100vh;
    max-width: 100vw;
    max-height: 100vh;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh; /* Use viewport height */
    position: relative; /* Needed for absolute/fixed positioning of children */
}

/* Screen Management */
.screen {
    display: none; /* Hide screens by default */
    width: 100%;
    flex-direction: column;
    align-items: center;
}

.screen.active {
    display: flex; /* Show active screen */
}

/* Splash Screen */
#splash-screen {
    text-align: center;
}
#splash-screen h1 {
    margin-bottom: 10px;
}
#splash-screen p {
    margin-bottom: 15px;
    color: #555;
}
#play-button {
    padding: 10px 20px;
    font-size: 1.1em;
    cursor: pointer;
}

/* Game Screen Elements */
.progress-area {
    width: 100%;
    max-width: 450px;
    margin-bottom: 30px;
}

.progress-bar-container {
    position: relative;
    height: 24px; /* Increased height for nodes */
    display: flex;
    align-items: center;
    margin-bottom: 5px;
}

.progress-bar-track {
    position: absolute;
    top: 50%;
    left: 0;
    width: 100%;
    height: 4px;
    background-color: #000000; /* Changed from #e0e0e0 */
    border-radius: 2px;
    transform: translateY(-50%);
}

.progress-bar-fill {
    position: absolute;
    top: 50%;
    left: 0;
    height: 4px;
    background-color: #9FC5F8; /* Match React */
    border-radius: 2px;
    transform: translateY(-50%);
    transition: width 0.3s ease-out;
}

#progress-nodes {
    position: absolute;
    top: 50%;
    left: 0;
    width: 100%;
    height: 100%;
    transform: translateY(-50%);
}

.progress-node {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 1px solid black;
    background-color: black;
}

.progress-node.achieved {
    background-color: #9FC5F8;
    border-color: #7ba9d9;
}

.progress-node.current {
    /* Add optional ring or bigger size? */
     box-shadow: 0 0 0 2px #6a95c5;
}

.current-score-display {
    position: absolute;
    bottom: 100%;
    left: 50%; /* Position based on current node in JS */
    transform: translateX(-50%);
    margin-bottom: 2px;
    font-size: 12px;
    font-weight: bold;
    white-space: nowrap;
}

.rank-name {
    text-align: center;
    font-size: 14px;
    font-weight: 500;
    color: #666;
    text-transform: capitalize;
}

.selected-word-area {
    width: 100%;
    max-width: 450px;
    margin-bottom: 30px;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    min-height: 50px;
}

.selected-letters {
    display: flex;
    align-items: flex-end;
    gap: 4px;
}

.letter-slot {
    position: relative;
    text-align: center;
    transition: opacity 0.2s;
    opacity: 0.4; /* Default for unused slots */
}

.letter-slot.visible {
    opacity: 1;
}

.letter-slot .points {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 0;
    font-size: 11px;
    font-weight: bold;
    color: #28a745; /* Green */
}

.letter-slot .letter {
    display: block;
    font-size: 24px;
    font-weight: bold;
    letter-spacing: 1px;
    border-bottom: 2px solid #aaa;
    padding: 0 2px;
    min-width: 18px; /* Ensure space for letter */
    color: black; /* Default */
}

.letter-slot .letter.invalid {
    color: #dc3545; /* Red */
}
.letter-slot .letter.loading {
    color: #adb5bd; /* Gray */
}

.letter-slot .letter.placeholder {
    border-bottom-style: solid;
    border-color: #aaa;
    color: transparent;
}

.word-multiplier {
    margin-left: 8px;
    font-weight: bold;
    color: #6c757d;
    font-size: 14px;
}

.current-word-score {
    font-weight: bold;
    color: #28a745; /* Green */
    font-size: 14px;
}

/* Tableau (Card Grid) */
.tableau-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr); /* Changed from 4 to 3 columns */
    gap: 10px; /* Increased */
    width: 100%;
    max-width: 450px; /* Match other areas */
    margin-bottom: 30px; /* Increased */
    position: relative; /* Ensure this is set for absolute children */
}

.stack-container {
    position: relative;
    min-height: 120px; 
    border: 1px dashed #ccc; 
    border-radius: 8px;
    background-color: rgba(0,0,0,0.03);
    /* transition: transform 0.5s ease-in-out; */ /* Remove transition */
}

.stack-container.cleared {
     border: 2px dashed #9FC5F8;
     display: flex;
     align-items: center;
     justify-content: center;
     background: transparent;
}

.stack-container.cleared .clear-bonus {
     color: #007bff;
     font-size: 1.5em;
     font-weight: bold;
}

.card {
    position: absolute;
    /* Horizontal Centering */
    left: 50%;
    transform: translateX(-50%);
    /* End Horizontal Centering */
    width: 60px; /* Card width */
    height: 76px; /* Card height */
    border-radius: 8px;
    border: 2px solid;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: bold;
    color: black;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    user-select: none;
    background-color: #eee; /* Default bg */
}

.card.vowel {
    background-color: #FFE599;
    border-color: #e6cc8a; /* Darker yellow */
}

.card.consonant {
    background-color: #9FC5F8;
    border-color: #7ba9d9; /* Darker blue */
}

.card .card-points {
    position: absolute;
    top: 2px;
    right: 3px;
    width: 20px;
    height: 20px;
    background-color: black;
    color: white;
    border-radius: 50%;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

.card .card-remaining {
    position: absolute;
    bottom: 2px;
    left: 3px;
    width: 20px;
    height: 20px;
    background-color: white;
    color: black;
    border: 1px solid #ccc;
    border-radius: 3px;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

.card.top-card {
    cursor: pointer;
}

.card:not(.top-card) {
    pointer-events: none; /* Prevent interaction */
}

.card.selected {
    border-color: #e83e8c; /* Pinkish */
    box-shadow: 0 0 0 3px rgba(232, 62, 140, 0.4);
}

/* Controls */
.controls {
    width: 100%;
    max-width: 450px;
    display: flex;
    justify-content: space-between;
    gap: 10px;
}

.control-col {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 48%;
}

.controls button {
    padding: 10px 15px;
    font-size: 14px;
    font-weight: bold;
    border-radius: 8px;
    border: 1px solid;
    cursor: pointer;
    transition: background-color 0.2s, opacity 0.2s;
}

.controls button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#clear-button {
    background-color: #F89F9F;
    border-color: #e88f8f;
    color: black;
    flex-grow: 1;
}
#clear-button:not(:disabled):hover { background-color: #f09a9a; }

#shuffle-button {
    background-color: #9FF8A8;
    border-color: #8fe898;
    color: black;
    flex-grow: 1;
}
#shuffle-button:not(:disabled):hover { background-color: #90f09a; }

#play-word-button {
    background-color: #9FC5F8;
    border-color: #8fb5e8;
    color: black;
    font-size: 16px;
    width: 48%;
}
#play-word-button:not(:disabled):hover { background-color: #90bdf0; }

/* Results Screen */
#results-screen {
    text-align: center;
    justify-content: space-between;
    padding: 40px 20px;
    height: 100vh;
}

.final-score {
    font-size: 82px;
    font-weight: bold;
    margin: 0;
    padding: 0;
}

.result-rank {
    margin: 0;
    margin-top: 5px;
    font-size: 22px;
    font-weight: normal;
    color: #333;
}

.words-header {
    margin-top: 80px;
    margin-bottom: 20px;
    font-size: 36px;
    font-weight: bold;
    width: 100%;
    text-align: center;
}

.words-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 30px;
    width: 100%;
    text-align: left;
    margin-bottom: 40px;
}

.word-item {
    display: flex;
    justify-content: space-between;
    font-size: 20px;
    margin-bottom: 8px;
}

.word-value {
    font-weight: normal;
}

.word-points {
    font-weight: normal;
}

.play-again-button {
    background-color: #C6D9F7;
    color: #000;
    border: none;
    border-radius: 8px;
    padding: 20px;
    width: 100%;
    font-size: 24px;
    margin-top: 20px;
    cursor: pointer;
    font-weight: bold;
}

/* Loading Indicator */
.loading-indicator {
    margin-top: 20px;
    font-style: italic;
    color: #666;
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background-color: white;
    padding: 20px 30px;
    border-radius: 8px;
    text-align: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.modal-content h2 {
    margin-top: 0;
    margin-bottom: 10px;
}

.modal-content p {
    margin-bottom: 20px;
}

.modal-content button {
    padding: 10px 20px;
    cursor: pointer;
}

/* Game Over Panel */
.game-over-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    z-index: 1001; /* Higher than overlay */
    transform: translateY(100%); /* Start offscreen */
    transition: transform 0.3s ease-in-out;
    pointer-events: none; /* Initially not interactive */
}

.game-over-panel.visible {
    transform: translateY(0); /* Slide up into view */
    pointer-events: auto; /* Enable interaction */
}

.panel-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.3); /* Semi-transparent background */
    z-index: 1000; /* Below panel but above everything else */
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
    pointer-events: none; /* Initially not interactive */
    visibility: hidden; /* Completely hide when not visible */
}

.panel-overlay.visible {
    opacity: 1;
    pointer-events: auto; /* Enable interaction when visible */
    visibility: visible; /* Make visible */
}

.panel-content {
    position: relative;
    width: 100%;
    max-width: 450px;
    margin: 0 auto;
    background-color: white;
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
    padding: 20px;
    text-align: center;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
}

.panel-content p {
    margin-bottom: 16px;
    font-size: 16px;
    color: #666;
}

.panel-content button {
    background-color: #9FC5F8;
    color: black;
    border: 1px solid #8fb5e8;
    border-radius: 8px;
    padding: 10px 30px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    min-width: 120px;
    transition: background-color 0.2s;
}

.panel-content button:hover {
    background-color: #90bdf0;
}

/* Game Header Styles */
.game-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 0 15px 0; /* Padding below header */
    margin-bottom: 10px; /* Space above progress bar */
}

.game-header h2 {
    margin: 0;
    font-size: 1.2em;
    text-align: center;
    flex-grow: 1; /* Allow title to take space */
}

.help-button {
    background-color: #ccc; /* Grey background */
    color: black;
    border: 1px solid #aaa;
    border-radius: 50%; /* Circular */
    width: 30px;
    height: 30px;
    font-size: 1.1em;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.help-button:hover {
    background-color: #bbb;
}

#back-button {
    /* Basic styling if used later */
    background: none;
    border: none;
    font-size: 1.5em;
    cursor: pointer;
    padding: 0 5px;
}

/* Help Panel Styles */
.help-panel {
    position: fixed; /* Fixed position relative to viewport */
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-height: 75vh; /* Limit height */
    background-color: #fff;
    border-top: 1px solid #ccc;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    padding: 20px;
    padding-top: 40px; /* Space for close button */
    transform: translateY(100%); /* Start off-screen */
    transition: transform 0.4s ease-in-out;
    z-index: 1010; /* Ensure it's above other content */
    overflow-y: auto; /* Allow scrolling if content overflows */
    display: block; /* Keep it in layout flow but off-screen */
}

.help-panel.visible {
    transform: translateY(0%); /* Slide into view */
}

.close-button {
    position: absolute;
    top: 10px;
    right: 15px;
    background: none;
    border: none;
    font-size: 2em;
    line-height: 1;
    padding: 0;
    cursor: pointer;
    color: #888;
}
.close-button:hover {
    color: #333;
}

.help-panel h2 {
    text-align: center;
    margin-top: 0;
    margin-bottom: 15px;
}

.help-content {
    font-size: 14px;
    line-height: 1.5;
}

.help-content ul {
    list-style: disc;
    padding-left: 20px;
    margin-bottom: 15px;
}

.help-content li {
    margin-bottom: 8px;
}

/* Simple utility classes copied from React for help text styling */
.font-semibold { font-weight: 600; }
.text-blue-500 { color: #3b82f6; } /* Example blue */
.text-xs { font-size: 0.75rem; }
.text-gray-500 { color: #6b7280; } /* Example gray */
.mt-3 { margin-top: 0.75rem; } 