body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    /* Default: allow scrolling */
    overflow-y: auto;
}

/* Practice Mode (IDE-like view) - Fixed height, no window scroll */
body.practice-mode {
    /* Allow body to grow beyond viewport if needed */
    height: auto;
    min-height: 100vh;
}

main {
    flex: 1;
    display: flex;
    flex-direction: column;
    /* Default: just flex grow */
}

/* Practice Mode - Fixed containers */
body.practice-mode main {
    /* Allow main to grow but try to fit in viewport */
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    /* Remove overflow: hidden to allow body scroll if needed */
    overflow: visible;
}

header {
    flex: none;
    width: 100%;
    max-width: 1600px !important;
    margin: 0 auto !important;
    padding-bottom: 1rem;
    box-sizing: border-box;
}

footer {
    flex: none;
    margin-top: 0 !important;
    padding: 1rem;
    border-top: 1px solid #eee;
}

.task-root {
    height: 100%;
    width: 100%;
    display: flex;
    flex-direction: column;
}

.content-wrapper {
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;
    padding: 1rem 2rem;
    padding-top: 0.5rem;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    box-sizing: border-box;
    min-height: 0;
    box-sizing: border-box;
}

.task-root h3 {
    margin: 0;
    font-size: 1rem;
}

.task-container {
    display: flex;
    gap: 2rem;
    flex: 1 0 auto;
    /* Allow grow, prevent shrink below content */
    width: 100%;
}

.back-link {
    display: block;
    margin-bottom: 0.5rem;
    margin-top: 0;
    text-decoration: none;
    color: #666;
    font-weight: 500;
    font-size: 0.9rem;
}

.back-link:hover {
    color: #333;
    text-decoration: underline;
}

.left-column {
    flex: 1;
    display: flex;
    flex-direction: column;
    /* min-height: 0; Removed to allow growth */
}

.panel-header {
    flex: none;
    padding: 0.75rem;
    background: #f9f9f9;
    border-bottom: 1px solid #ddd;
}

.story-panel {
    flex: 1 0 auto;
    /* Allow grow, prevent shrink */
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 4px;
    border: 1px solid #ddd;
    /* overflow: hidden; Removed */
}

.story-panel h4 {
    margin: 0;
    padding: 0.75rem;
    background: #f9f9f9;
    font-size: 1rem;
    color: #666;
    letter-spacing: 0.05em;
}

.story-panel h4:nth-of-type(2) {
    border-top: 1px solid #ddd;
}

.story-content {
    padding: 0.75rem;
    font-size: 0.85rem;
    line-height: 1.5;
}

.code-panel {
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
    flex: 1;
    min-height: 300px;
    /* Smaller minimum to ensure buttons fit */
    position: relative;
    background: #fff;
    display: flex;
    /* Ensure internal Monaco fits */
    flex-direction: column;
}

.right-column {
    flex: 2;
    display: flex;
    flex-direction: column;
    /* Remove fixed height to allow flex to work naturally */
    min-height: 0;
    gap: 1rem;
}

#raw-code {
    display: none;
}

@media (max-width: 768px) {

    body,
    main {
        height: auto;
        overflow: visible;
        display: block;
    }

    footer {
        margin-top: 2rem !important;
    }

    .task-root {
        height: auto;
        padding: 0.75rem;
    }

    .task-container {
        flex-direction: column;
        height: auto;
    }

    .story-panel {
        flex: none;
        max-height: none;
    }

    .code-panel {
        flex: none;
        height: 600px;
        display: block;
    }

    .right-column {
        flex: none;
    }
}

.practice-root {
    padding: 2rem;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
    flex: 1;
    overflow-y: auto;
    box-sizing: border-box;
}

.task-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.task-card {
    display: block;
    padding: 1.5rem;
    border: 1px solid #ddd;
    border-radius: 8px;
    text-decoration: none;
    color: inherit;
    transition: transform 0.2s, box-shadow 0.2s;
    background: #fff;
}

.task-card:not(.disabled):hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border-color: #aaa;
}

.task-card.disabled {
    opacity: 0.5;
    background: #fafafa;
    cursor: not-allowed;
    color: #999;
    border-style: dashed;
    border-color: #ddd;
    box-shadow: none;
}

.task-card.disabled h3,
.task-card.disabled p {
    color: #999;
}

.task-card h3 {
    margin-top: 0;
    margin-bottom: 0.5rem;
    color: #333;
}

.task-card p {
    color: #666;
    font-size: 0.9rem;
    margin: 0;
}

.task-explanation {
    padding: 0 0.75rem;
    margin: 0.5rem 0;
    font-size: 0.85rem;
    line-height: 1.5;
    color: #333;
}

.task-actions {
    padding: 1rem 0;
    display: flex;
    gap: 1rem;
    background: transparent;
    border-top: none;
    justify-content: center;
}

.task-actions button {
    flex: 1;
    max-width: 300px;
    background-color: #2563eb;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-icon {
    width: 20px;
    height: 20px;
}

.btn-good {
    background-color: #ffffff !important;
    color: #2563eb !important;
    border: 1px solid #2563eb !important;
}

.btn-good:hover {
    background-color: #eff6ff !important;
}

.btn-smells {
    background-color: #ffffff !important;
    color: #dc2626 !important;
    border: 1px solid #dc2626 !important;
}

.btn-smells:hover {
    background-color: #fef2f2 !important;
}

.btn-secondary {
    background-color: #ffffff !important;
    color: #4b5563 !important;
    border: 1px solid #d1d5db !important;
}

.btn-secondary:hover {
    background-color: #f3f4f6 !important;
    border-color: #9ca3af !important;
}

.task-actions button:disabled {
    background-color: #f3f4f6 !important;
    color: #9ca3af !important;
    border: 1px solid #d1d5db !important;
    cursor: not-allowed;
    opacity: 0.7;
    box-shadow: none;
}

.task-actions button:disabled img {
    opacity: 0.5;
    filter: grayscale(100%);
}

.feedback-message {
    margin: 1.5rem 0;
    padding: 1.5rem;
    border-radius: 8px;
    text-align: left;
    display: none;
    background-color: #f9fafb;
    border: 1px solid #e5e7eb;
    color: #1f2937;
}

.feedback-title {
    font-weight: 700;
    font-size: 1.125rem;
    margin-bottom: 0.5rem;
    color: #111827;
}

.feedback-desc {
    font-size: 1rem;
    line-height: 1.5;
    color: #4b5563;
    margin: 0;
}

.btn-next {
    display: none;
    margin: 1rem auto;
    background-color: #007bff;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    width: 100%;
    font-weight: bold;
    max-width: 200px;
}

.btn-next:hover {
    background-color: #0056b3;
}

/* Hints Section */
.hints-section {
    padding: 0.75rem;
    border-top: 1px solid #ddd;
}

.hint-text {
    font-size: 0.85rem;
    line-height: 1.5;
    color: #333;
    margin: 0;
    margin-bottom: 0.5rem;
}

.hint-text:last-child {
    margin-bottom: 0;
}

.hint-trigger-text {
    font-size: 0.85rem;
    line-height: 1.5;
    color: #333;
    margin: 0;
}

.dotted-link {
    color: #2563eb;
    cursor: pointer;
    border-bottom: 1px dotted #2563eb;
    padding-bottom: 1px;
}

.dotted-link:hover {
    color: #1d4ed8;
    border-bottom-color: #1d4ed8;
}

/* Latest Tasks Section */
.latest-tasks-title {
    margin-top: 3rem;
    margin-bottom: 1.5rem;
    font-size: 1.25rem;
    color: #333;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
    padding-left: 0;
    /* Align with grid */
}

.latest-tasks-list {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 1.5rem;
    max-width: 1200px;
    margin: 0 auto;
}

.latest-task-card {
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    background: #fff;
    border: 1px solid #eee;
    border-radius: 8px;
    text-decoration: none;
    color: inherit;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    height: 100%;
    box-sizing: border-box;
    flex: 1 1 300px;
    max-width: 350px;
    min-width: 280px;
    justify-content: space-between;
}

.latest-task-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
    border-color: #ddd;
}

.latest-task-card h3 {
    margin-top: 0;
    margin-bottom: 0.75rem;
    color: #111;
    font-size: 1.1rem;
    line-height: 1.4;
    padding-left: 0;
}

.latest-task-card p {
    color: #555;
    font-size: 0.95rem;
    line-height: 1.6;
    margin: 0;
    flex: 1;
}

.view-task-link {
    display: inline-block;
    margin-top: 1rem;
    color: #2563eb;
    font-weight: 500;
    text-decoration: none;
    font-size: 0.95rem;
}

.view-task-link:hover {
    text-decoration: underline;
}


/* Adjustments for Home Page */
.latest-tasks-section {
    padding-top: 2rem;
    padding-bottom: 2rem;
    box-sizing: border-box;
    width: 100%;
}

@media (min-width: 1600px) {
    .content-wrapper {
        max-width: 1600px;
        margin: 0 auto;
    }
}