/* Import NES.css base styles */
@import url("https://unpkg.com/nes.css@latest/css/nes-core.min.css");

body {
    font-family: 'Press Start 2P', cursive;
    background-color: #212529; /* Dark background */
    padding: 0;
    margin: 0;
    color: #fff; /* White text */
    image-rendering: pixelated; /* Helps with pixel art fonts/icons */
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center; /* Center content horizontally */
    padding-bottom: 20px; /* Add some padding at the bottom */
}

/* Header Styling */
.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    border-bottom: 4px solid #fff;
    width: 100%; /* Keep header full width */
    box-sizing: border-box;
    flex-shrink: 0;
    border-radius: 0 !important;
    margin-bottom: 20px; /* Add space below header */
}
.header-left, .header-right {
    font-size: 0.8em;
    text-shadow: 1px 1px #000;
}

/* Profile Section */
.profile-section {
    display: flex;
    align-items: center;
    gap: 8px; /* Space between elements */
    font-size: 0.8em;
    text-shadow: 1px 1px #000;
    flex-wrap: wrap; /* Allow wrapping if needed on narrow screens */
    justify-content: center; /* Center items when wrapped */
}
.profile-section > * { /* Apply margin to children to prevent collapse */
    margin: 2px 4px;
}
.profile-section #profile-icon {
    font-size: 1.2em; /* Slightly larger icon */
    cursor: pointer; /* Indicate it might be clickable (for editing) */
}
.profile-section #player-name {
     /* No special style needed */
}
/* Streak Display (replaces player-level) */
.profile-section .streak-display {
     color: #92cc41; /* Green color for streak */
     font-weight: bold;
     padding: 2px 6px;
     border: 2px solid #92cc41;
     box-shadow: 2px 2px 0 #92cc41;
}
/* Style when streak is 0 or low */
.profile-section .streak-display.is-error {
     color: #e76e55; /* Red color */
     border-color: #e76e55;
     box-shadow: 2px 2px 0 #e76e55;
}

#edit-profile-btn {
     padding: 2px 6px; /* Smaller padding for small button */
     font-size: 0.7em; /* Smaller font */
     line-height: 1;
     /* Adjusted margin due to flex gap */
}


/* Main Container - Adjusted Width */
.container.nes-container.is-dark {
    max-width: 1400px; /* Further increased max-width for wider screens */
    width: 98%; /* Use more of the screen width */
    margin: 0 auto 20px auto; /* Center horizontally, add space below */
    border-radius: 10px; /* Keep the rounded corners */
    border: 4px solid #fff; /* Keep the NES border */
    box-shadow: 8px 8px 0 #fff; /* Keep the NES shadow */

    display: flex;
    flex-direction: column;
    padding: 20px; /* Adjust internal padding */
    box-sizing: border-box;
    flex-grow: 1;
    background-color: #212529;
}

/* Game Selection */
.game-selection {
    margin-bottom: 20px;
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    border: 2px solid #fff;
    padding: 10px;
    background-color: #3a3f44;
    box-shadow: 4px 4px 0 #fff;
}
.game-selection label {
     margin-bottom: 0;
     font-size: 0.8em;
     color: #fff;
}
.nes-select select {
    font-family: 'Press Start 2P', cursive;
    font-size: 0.8em;
    background-color: #fff;
    color: #212529;
}

/* Game Area */
.game-area {
    margin-bottom: 20px;
    text-align: center;
    background-color: #3a3f44;
    border-color: #fff;
    box-shadow: 4px 4px 0 #fff;
    padding: 15px;
}
.game-area h2 {
     font-size: 1.2em;
     margin-top: 0;
     margin-bottom: 10px;
}
.game-visual-area {
    font-size: 3em; /* Base font size for emojis/icons */
    margin: 10px 0;
    min-height: 60px; /* Ensure minimum height */
    line-height: 1.2;
    transition: opacity 0.3s ease, transform 0.3s ease, filter 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    text-shadow: 2px 2px #000;
    position: relative;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* Defeated/Won Visual State */
.game-visual-area.defeated {
     transform: rotate(0deg) scale(1.05);
     opacity: 1;
     animation: pulse-victory 1s infinite alternate;
}
@keyframes pulse-victory {
    from { transform: scale(1.05); }
    to { transform: scale(1.1); }
}

/* Specific game visual element styles (if needed) */
.game-visual-area .potion-bottle {
    transition: filter 0.5s ease;
}
.game-visual-area .crystal-base {
    transition: transform 0.5s ease, filter 0.5s ease;
}


.game-progress-area {
    margin: 15px 0;
    min-height: 30px;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 0.9em;
}
/* Progress Bar - Standard NES.css */
.progress-bar-container {
    width: 90%;
    max-width: 400px; /* Cap progress bar width */
    background-color: transparent;
    border: none;
    box-shadow: none;
    padding: 0;
}
.progress-bar-container progress {
    width: 100%;
    height: 25px;
}

/* Progress Steps */
.progress-steps {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 5px;
    flex-wrap: wrap;
}
.step {
    width: 20px;
    height: 20px;
    border: 2px solid #fff;
    background-color: #555;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    position: relative;
    transition: background-color 0.3s ease, border-color 0.3s ease;
    box-shadow: 2px 2px 0 #fff;
}
.step.completed {
    background-color: #92cc41; /* NES Green */
}
/* The character marker is added by JS/rendered HTML */


/* Build/Fill/Reveal Progress Area items */
.build-progress span, .reveal-area span, .charge-indicator span, .fill-visual span {
    font-size: 1.2em;
    text-shadow: 1px 1px #000;
}
.build-piece, .reveal-item {
    display: inline-block;
    opacity: 0;
    transform: scale(0.5);
    transition: transform 0.4s cubic-bezier(0.68, -0.55, 0.27, 1.55), opacity 0.4s ease-out;
}
.build-piece.added, .reveal-item.revealed {
    opacity: 1;
    transform: scale(1);
}


/* Task Area */
.task-section {
    background-color: #fff;
    color: #212529;
    border-color: #212529;
    box-shadow: 4px 4px 0 #212529;
    padding: 20px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-height: 300px;
    overflow-y: hidden;
}
.task-section .title {
     background-color: #212529;
     color: #fff;
}

.add-task {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap; /* Allow wrapping on smaller screens */
}
.add-task label {
    flex-shrink: 0;
}
.add-task input[type="text"] {
    flex-grow: 1;
    min-width: 150px; /* Allow input to shrink but not too much */
    font-family: 'Press Start 2P', cursive;
    font-size: 0.8em;
}
.add-task button {
    flex-shrink: 0;
    font-family: 'Press Start 2P', cursive;
    font-size: 0.8em;
}
/* Style for temporary feedback */
.add-task input.input-error {
     border-color: #e76e55;
     animation: shake 0.5s;
}
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-5px); }
    40%, 80% { transform: translateX(5px); }
}


.task-lists {
    flex-grow: 1;
    display: flex;
    gap: 20px;
    margin-bottom: 15px;
    overflow-y: auto; /* Main lists scrollable container */
    padding: 0 10px;
}
.list-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    border: 2px dashed #ccc;
    padding: 10px;
    background-color: #eee;
    min-width: 250px; /* Increased minimum width for three columns */
}
.list-container h4 {
     margin-top: 0;
     margin-bottom: 10px;
     font-size: 1em;
     display: flex;
     align-items: center;
     gap: 5px;
}
.list-container ul {
    list-style: none;
    padding: 0;
    margin: 0;
    flex-grow: 1;
    overflow-y: auto; /* Make individual lists scrollable */
    /* Custom scrollbar styles if desired */
     scrollbar-width: thin; /* Firefox */
     scrollbar-color: #212529 #eee; /* Firefox */
}
/* Webkit (Chrome, Safari) scrollbar */
.list-container ul::-webkit-scrollbar {
    width: 8px;
}
.list-container ul::-webkit-scrollbar-track {
    background: #eee;
}
.list-container ul::-webkit-scrollbar-thumb {
    background-color: #212529;
    border-radius: 4px;
    border: 2px solid #eee;
}


/* Task Item Structure (Updated) */
#todo-list li, #completed-list li {
    display: flex;
    align-items: center; /* Center items vertically */
    padding: 8px 0;
    border-bottom: 1px dashed #ccc;
    transition: opacity 0.3s ease, background-color 0.3s ease, transform 0.3s ease;
    font-size: 0.9em;
    gap: 10px; /* Space between checkbox/text and actions */
    min-height: 30px; /* Ensure minimum height even if content is small */
    position: relative; /* For pseudo-elements like drag-over-visual if used directly on li */
}

/* Hide default list style markers */
.nes-list.is-disc > li::before, .nes-list.is-circle > li::before {
    content: none;
}

/* Task Checkbox (Styled Span/Div) */
.task-checkbox {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    border: 2px solid #212529;
    background-color: #fff;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: 2px 2px 0 #212529;
     position: relative; /* Needed for pseudo-element checkmark */
}
.task-checkbox:hover {
    background-color: #f0f0f0;
}

/* Checkmark for Completed Tasks */
#completed-list li .task-checkbox {
    background-color: #92cc41; /* NES Green when completed */
    border-color: #41a729;
    box-shadow: 2px 2px 0 #41a729;
}
#completed-list li .task-checkbox::after {
    content: '✔'; /* Unicode checkmark */
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #212529; /* Dark checkmark */
    font-size: 1.2em; /* Size of the checkmark */
    line-height: 1;
    text-shadow: 1px 1px #fff; /* Outline/shadow for checkmark */
}

/* Ongoing Task Styling */
#ongoing-list li {
    background-color: #fff3cd; /* Light yellow background for ongoing tasks */
    border-left: 4px solid #ffc107; /* Yellow left border */
}
#ongoing-list li.is-ongoing {
    color: #856404; /* Darker text for ongoing tasks */
}

/* Tick Button for Ongoing Tasks */
.task-tick-btn {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    padding: 0 !important;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    font-size: 1em;
    line-height: 1;
    border-radius: 50%;
    cursor: pointer;
}
.task-tick-btn:hover:not(:disabled) {
    background-color: #28a745;
    transform: scale(1.1);
}
.task-tick-btn:disabled {
    opacity: 0.6;
    cursor: default;
}

#completed-list li {
    color: #777; /* Dim completed task text */
}
#completed-list li .task-text {
     text-decoration: line-through; /* Strikethrough completed text */
}

/* Animation for tasks being completed */
.task-item.completing {
     opacity: 0.5;
     transform: translateX(10px);
     /* Optional: pointer-events: none; during animation */
}


.task-text {
    flex-grow: 1;
    word-break: break-word;
     cursor: text; /* Indicate text can be selected */
}
.task-actions {
    display: flex;
    gap: 5px;
    flex-shrink: 0;
     /* Center actions if task text is short */
     align-items: center;
}
.task-actions button {
    padding: 4px 6px;
    line-height: 1;
}

/* Inline Edit Input */
.edit-input.nes-input {
    padding: 4px 8px;
    font-size: 0.9em;
    margin-bottom: 0;
    box-sizing: border-box;
}

/* --- DRAG AND DROP STYLES --- */
.task-item.dragging {
    opacity: 0.4 !important;
    background: #777 !important; /* Lighter grey for dragging over dark items */
    border-style: dashed !important;
    color: #fff !important; /* Ensure text is visible */
    box-shadow: none !important;
}

.task-item.drag-over-visual {
    border-top: 3px dashed var(--nes-color-primary, #209cee) !important;
    /* Adjust padding to visually make space for the border */
    /* Original padding-top is part of the 8px vertical padding.
       If we add a 3px border, we might want to reduce padding-top if it looks too spaced,
       or add margin-top: -3px to compensate if it pushes content.
       Given padding is 8px 0, this means 8px top and 8px bottom.
       The border-top is outside this padding.
    */
}

/* Style for an empty todo-list to show it's a drop target */
#todo-list:empty, #ongoing-list:empty, #completed-list:empty {
    min-height: 60px;
    border: 3px dashed #aaa;
    border-radius: 4px; /* Consistent with NES.css rounding */
    background-color: rgba(255,255,255,0.05); /* Very light tint for dark bg */
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}
#todo-list:empty::after {
    content: "Drag Quests Here";
    color: #888;
    font-size: 0.85em;
}
#ongoing-list:empty::after {
    content: "Drag Active Quests Here";
    color: #888;
    font-size: 0.85em;
}
#completed-list:empty::after {
    content: "Completed Quests Here";
    color: #888;
    font-size: 0.85em;
}
/* Highlight empty list when dragging over it */
#todo-list.drag-over-empty:empty, #ongoing-list.drag-over-empty:empty, #completed-list.drag-over-empty:empty {
    background-color: rgba(32, 156, 238, 0.1); /* Light blue tint from primary color */
    border-color: var(--nes-color-primary, #209cee);
}
/* --- END DRAG AND DROP STYLES --- */


/* Action Buttons */
.day-actions {
    margin-top: 20px;
    display: flex;
    justify-content: center; /* Center buttons */
    flex-wrap: wrap;
    gap: 10px;
    border-top: 2px solid #eee;
    padding-top: 15px;
}
.day-actions button {
    font-size: 0.8em; /* Match header buttons */
}


/* --- Modal Styling (General) --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease-out;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-overlay.hidden { display: none !important; }

.modal-overlay .nes-dialog {
    max-width: 550px;
    width: 90%;
    background-color: #fff;
    color: #212529;
    border-color: #212529;
    box-shadow: 8px 8px 0 #212529;
    max-height: 80vh;
    overflow-y: auto;
    padding: 20px;
    box-sizing: border-box;
    animation: popIn 0.4s cubic-bezier(0.68, -0.55, 0.27, 1.55);
    font-size: 0.9em; /* Smaller font size in modals */
}
@keyframes popIn { from { transform: scale(0.8); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.modal-overlay .nes-dialog .title {
    background-color: #212529;
    color: #fff;
    padding: 10px 20px;
    margin: -20px -20px 20px -20px;
    border-radius: 8px 8px 0 0;
    font-size: 1.2em;
}
.modal-overlay .nes-dialog p { margin-bottom: 10px; }
.modal-overlay .nes-dialog .dialog-menu { display: flex; justify-content: center; margin-top: 20px; gap: 10px; }
.modal-overlay .nes-dialog .dialog-menu button {
    font-size: 0.8em;
}


/* --- Mission Report Modal Specifics --- */
#mission-report-modal #report-tasks {
    margin: 15px 0;
    padding: 10px;
    border: 2px dashed #ccc;
    background-color: #eee;
}
#mission-report-modal #report-tasks p { margin-top: 0; margin-bottom: 5px; font-weight: bold; }
#mission-report-modal #report-tasks ul {
     max-height: 150px;
     overflow-y: auto;
     padding-left: 20px;
     list-style-type: disc;
}
#mission-report-modal #report-tasks ul li { margin-bottom: 5px; }

#mission-report-modal #report-game-status {
     font-weight: bold;
     margin-top: 15px;
     text-align: center;
     font-size: 1em;
}
#mission-report-modal #report-game-status.is-success { color: #41a729; }
#mission-report-modal #report-game-status:not(.is-success) { color: #e76e55; }

/* New Streak Status in Report */
#mission-report-modal #report-streak-status {
    font-weight: bold;
    text-align: center;
    margin-top: 10px;
}
#mission-report-modal #report-streak-status.is-success { color: #41a729; } /* Streak maintained/increased */
#mission-report-modal #report-streak-status.is-error { color: #e76e55; } /* Streak reset */


/* --- Incomplete Tasks Modal Specifics --- */
#incomplete-dialog-overlay #incomplete-dialog-tasks {
    margin: 15px 0;
    padding: 10px;
    border: 2px dashed #e76e55; /* Reddish dashed border */
    background-color: #ffe0e0; /* Light red background */
}
#incomplete-dialog-overlay #incomplete-dialog-tasks p { margin-top: 0; margin-bottom: 5px; font-weight: bold; }
#incomplete-dialog-overlay #incomplete-dialog-tasks ul {
     max-height: 100px; /* Slightly shorter list */
     overflow-y: auto;
     padding-left: 20px;
     list-style-type: disc;
}
#incomplete-dialog-overlay #incomplete-dialog-tasks ul li { margin-bottom: 5px; }
#incomplete-dialog-overlay #incomplete-dialog .title {
     background-color: #e76e55; /* Red title bar */
}


/* --- Profile Edit Modal Specifics --- */
#profile-edit-modal .nes-field { margin-bottom: 15px; }
#profile-edit-modal .nes-field label { margin-bottom: 5px; display: block; }
#profile-edit-modal input[type="text"].nes-input { font-family: 'Press Start 2P', cursive; font-size: 0.9em;}

#profile-icon-selection.icon-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    max-height: 120px;
    overflow-y: auto;
    padding: 10px;
    border: 2px dashed #ccc;
    background-color: #eee;
    justify-content: center;
}
.icon-option {
    font-size: 1.5em;
    cursor: pointer;
    padding: 5px;
    border: 2px solid transparent;
    transition: border-color 0.2s ease, background-color 0.2s ease;
}
.icon-option:hover {
    background-color: #ccc;
}
.icon-option.selected {
    border-color: #007bff;
    background-color: #b0dfff;
}

/* Collected Items Display */
#collected-items-display {
    background-color: #3a3f44 !important; /* Dark background */
    border-color: #fff !important; /* White border */
    color: #fff !important; /* White text */
    box-shadow: 4px 4px 0 #fff !important; /* White shadow */
    padding: 10px;
    min-height: 50px; /* Give it some space */
    max-height: 150px; /* Limit height */
    overflow-y: auto;
}
#collected-items-display label { /* Style for the label above the items box */
    color: #fff;
    margin-bottom: 5px;
    display: block;
    font-size: 0.9em;
}

#collected-items-list {
    padding: 0 15px; /* Add some padding for list markers */
    list-style-type: disc;
    margin: 0;
}
#collected-items-list li {
    margin-bottom: 5px;
    font-size: 0.8em; /* Smaller font for items */
    word-break: break-word;
}
#collected-items-list li::before { /* Ensure NES.css list style is used */
    content: '● '; /* Disc character */
    color: #92cc41; /* Green marker */
}

#no-items-message {
    text-align: center;
    font-style: italic;
    color: #ccc;
    font-size: 0.8em;
    margin: 10px 0;
}
#collected-items-display #no-items-message.hidden {
    display: none;
}


/* Disable interaction styles */
.day-completed .task-section input:not(#new-task-input),
.day-completed .task-section button:not(#new-day-btn):not(.nes-btn.is-error),
.day-completed .game-selection select,
.day-completed .task-checkbox { /* Also disable task-checkbox interaction */
    pointer-events: none;
    opacity: 0.6;
    cursor: default !important;
}

/* More specific disabling of drag for completed day */
.day-completed #todo-list li,
.day-completed #todo-list li * { /* Ensure children are also not draggable/interactive */
    cursor: default !important;
    /* draggable attribute is handled by JS, but this reinforces no interaction */
}
.day-completed #todo-list li {
    opacity: 0.4; /* Dim incomplete tasks */
    /* pointer-events: none; /* This would prevent even tooltips if any */
}


/* Dim completed tasks slightly more when day is done */
.day-completed #completed-list li { opacity: 0.8; }


.hidden { display: none !important; }

/* Minor adjustments for NES icons */
.nes-icon.is-small {
    width: 1em;
    height: 1em;
    vertical-align: -0.25em;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .main-header {
        flex-direction: column;
        gap: 10px;
    }
    .header-left, .header-right, .profile-section {
        width: 100%;
        justify-content: center;
        text-align: center;
    }
     .profile-section {
         flex-wrap: wrap;
         gap: 5px;
     }
     .profile-section > * { margin: 2px 4px; } /* Keep small margins */

    .game-selection {
        flex-direction: column;
        gap: 5px;
    }
    .game-selection label { width: 100%; text-align: center; }
    .game-selection .nes-select { width: 100%; }
    .game-selection select { width: 100%; box-sizing: border-box; }


    .task-lists {
        flex-direction: column;
        gap: 15px;
    }
     .list-container {
         min-width: auto;
     }
     
     /* Adjust container width for mobile */
     .container.nes-container.is-dark {
         width: 95%;
         max-width: none;
     }
}
/* --- Pomodoro Timer Styles --- */
#pomodoro-container {
    position: fixed; /* Keeps it in place when scrolling */
    top: 120px; /* Position from the top */
    right: 20px; /* Position from the right */
    width: 200px; /* Fixed width */
    z-index: 500; /* Ensures it's above the background but below modals */
    text-align: center;
    border: 4px solid #fff;
    box-shadow: 4px 4px 0 #fff;
}

#pomodoro-container .title {
    background-color: #fff;
    color: #212529;
    display: table;
    margin-left: auto;
    margin-right: auto;
}

.timer-display {
    font-size: 2.5em; /* Large font for the timer */
    font-weight: bold;
    margin: 15px 0;
    color: #fff;
    text-shadow: 2px 2px #000;
    letter-spacing: 2px;
}

.pomodoro-controls {
    display: flex;
    justify-content: center;
    gap: 10px;
}

.pomodoro-controls .nes-btn {
    font-size: 0.8em; /* Smaller font for buttons */
}
