html {
    min-height: 100%;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f4f7f9;
    color: #333;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow-x: hidden;
    overflow-y: auto;
}

header {
    background-color: #4D2467;
    color: white;
    padding: 15px 30px;
    box-shadow: 0 3px 6px rgba(0,0,0,0.15);
    position: relative;
    z-index: 10;
    border-bottom: 1px solid rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    box-sizing: border-box;
}

.header-content {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 10px;
    flex-wrap: wrap;
    justify-content: center;
    text-align: center;
}

#logo {
    height: 40px;
    width: auto;
}

header h1 {
    margin: 0;
    font-weight: 600;
    font-size: 1.8em;
}

header p {
    margin: 0 0 15px 0;
    font-size: 1em;
    opacity: 0.9;
    max-width: 600px;
    text-align: center;
    padding: 0 16px;
}

.header-buttons {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
    flex-wrap: wrap;
    justify-content: center;
    width: 100%;
}

button {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1em;
    font-weight: 500;
    transition: background-color 0.2s ease, box-shadow 0.2s ease, transform 0.1s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

button:hover {
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
    transform: translateY(-1px);
}

button:active {
     transform: translateY(0px);
     box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

#add-problem-btn {
    background-color: #e0e0e0;
    color: #333;
}
#add-problem-btn:hover { background-color: #d1d1d1; }

#share-btn {
    background-color: #6A3E87;
    color: white;
}
#share-btn:hover {
    background-color: #8A5EA7;
}

#what-is-this-btn {
    background-color: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.5);
}
#what-is-this-btn:hover {
    background-color: rgba(255, 255, 255, 0.3);
}

#modal-evaluate-btn,
#modal-use-suggestion-btn,
#explanation-ok-btn {
    background-color: #4D2467;
    color: white;
}
#modal-evaluate-btn:hover,
#modal-use-suggestion-btn:hover,
#explanation-ok-btn:hover {
    background-color: #6A3E87;
}

#modal-cancel-btn, #modal-close-btn {
    background-color: #e0e0e0;
    color: #333;
}
#modal-cancel-btn:hover, #modal-close-btn:hover { background-color: #d1d1d1; }

.subtle-btn {
    background-color: transparent;
    color: #d9534f;
    border: 1px solid #d9534f;
    padding: 8px 16px;
    font-size: 0.9em;
    box-shadow: none;
    opacity: 0.8;
}

.subtle-btn:hover {
    background-color: rgba(217, 83, 79, 0.1);
    opacity: 1;
    box-shadow: none;
}

#status-summary {
    margin-top: 0;
    font-size: 0.9em;
    background-color: rgba(255, 255, 255, 0.15);
    padding: 8px 12px;
    border-radius: 5px;
    display: inline-block;
    color: #fff;
    font-weight: 500;
}

#orb-container {
    position: relative;
    flex: 1 1 320px;
    width: 100%;
    min-height: 320px;
    overflow: hidden;
    background: radial-gradient(circle, #e0eaf5 0%, #f4f7f9 70%);
}

.problem {
    position: absolute;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background-color: #ffffff;
    box-shadow: 0 4px 8px rgba(0,0,0,0.15), inset 0 0 10px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 15px;
    box-sizing: border-box;
    cursor: grab;
    user-select: none;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.3s ease;
    will-change: transform, top, left;
    border: 4px solid;
}

.problem.focused {
    transform: scale(1.05);
    box-shadow: 0 8px 16px rgba(0,0,0,0.2), inset 0 0 12px rgba(0,0,0,0.08);
    z-index: 5;
}

.problem.editing {
    box-shadow: 0 0 15px 5px #fceb3a;
    z-index: 6;
    cursor: default;
}

.problem.dragging {
    opacity: 0.75;
    cursor: grabbing;
    transform: scale(1.08);
    box-shadow: 0 10px 20px rgba(0,0,0,0.25);
    z-index: 1000;
}

.problem-text {
    font-size: 0.9em;
    font-weight: 600;
    margin-bottom: 6px;
    max-height: 55px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    color: #222;
}

.problem-label {
    font-size: 0.8em;
    font-weight: bold;
    padding: 4px 10px;
    border-radius: 12px;
    color: white;
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

.problem.Vague { border-color: #adb5bd; }
.problem.Vague .problem-label { background-color: #6c757d; }

.problem.WrongDirection { border-color: #dc3545; }
.problem.WrongDirection .problem-label { background-color: #b02a37; }
.problem.WrongDirection .problem-text { color: #b02a37; font-weight: 600; }

.problem.Okay { border-color: #ffc107; }
.problem.Okay .problem-label { background-color: #e0a800; }

.problem.Acceptable { border-color: #20c997; }
.problem.Acceptable .problem-label { background-color: #1aa179; }

.problem.Actionable { border-color: #4D2467; }
.problem.Actionable .problem-label { background-color: #6A3E87; }

.problem.VeryActionable { border-color: #6f42c1; }
.problem.VeryActionable .problem-label { background-color: #5a32a3; }
.problem.VeryActionable .problem-text { color: #5a32a3; font-weight: 700;}

#modal {
    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: flex-start;
    padding: 40px 20px;
    box-sizing: border-box;
    overflow-y: auto;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

#modal:not(.hidden) {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background-color: white;
    padding: 35px 40px;
    border-radius: 10px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.2);
    width: min(90vw, 550px);
    max-height: calc(100vh - 80px);
    overflow-y: auto;
    transform: scale(0.95);
    transition: transform 0.3s ease;
}

#modal:not(.hidden) .modal-content {
    transform: scale(1);
}

#modal .modal-content h2,
#explanation-modal .modal-content h2 {
    margin-top: 0;
    margin-bottom: 15px;
    color: #4D2467;
    font-weight: 600;
}

.modal-content p {
    font-size: 1em;
    color: #555;
    margin-bottom: 20px;
    line-height: 1.5;
}

#modal-textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #ccc;
    border-radius: 6px;
    box-sizing: border-box;
    margin-bottom: 20px;
    font-size: 1em;
    min-height: 80px;
}

.modal-actions, .modal-post-eval-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-top: 20px;
    position: relative;
}

.right-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.left-space {
    flex: 1;
}

/* Position buttons in right group */
#modal-evaluate-btn, #modal-cancel-btn, #modal-close-btn, #modal-edit-again-btn {
    margin-left: 0; /* Reset previous margins */
}

/* Override for the delete button to ensure it stays on the left */
#modal-delete-btn {
    margin-right: auto;
}

/* Make error and loading indicators appear properly */
#modal-loading, #modal-error {
    position: static;
    display: block;
    width: 100%;
    margin-top: 15px;
    margin-bottom: 0;
}

/* Loading container and indicator styles */
.loading-container {
    margin-top: 15px;
    margin-bottom: 15px;
    width: 100%;
}

#modal-loading {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    background-color: #f4f4fa;
    border-radius: 6px;
    padding: 12px 15px;
    font-style: italic;
    color: #555;
    border: 1px solid #e0e0e8;
    font-weight: 500;
    box-sizing: border-box;
    width: 100%;
}

.spinner {
    width: 18px;
    height: 18px;
    border: 3px solid rgba(77, 36, 103, 0.2);
    border-radius: 50%;
    border-top-color: #4D2467;
    animation: spin 1s ease-in-out infinite;
    margin-right: 12px;
    flex-shrink: 0;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.error-message {
    color: #e63946;
    font-size: 0.95em;
    font-weight: 600;
}

#modal-error {
    padding: 8px 10px;
    background-color: #fddfe2;
    border-radius: 4px;
    border: 1px solid #f5c2c7;
    margin-top: 10px;
    width: 100%;
    box-sizing: border-box;
}

#modal-results {
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}
#modal-results h3 {
    margin-top: 0;
    margin-bottom: 15px;
    color: #333;
    font-weight: 600;
}
#modal-results p {
    margin-bottom: 10px;
    font-size: 1em;
}
#modal-result-rating {
    font-weight: bold;
    padding: 5px 10px;
    border-radius: 4px;
    color: white;
    display: inline-block;
    background-color: #6c757d; /* Default fallback background */
}

/* Rating badge colors - match the problem label colors */
#modal-result-rating.Vague { background-color: #6c757d; }
#modal-result-rating.WrongDirection { background-color: #b02a37; }
#modal-result-rating.Okay { background-color: #e0a800; }
#modal-result-rating.Acceptable { background-color: #1aa179; }
#modal-result-rating.Actionable { background-color: #6A3E87; }
#modal-result-rating.VeryActionable { background-color: #5a32a3; }

/* Rewrite Section Styles */
#modal-result-rewrite-section {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px dashed #eee;
}

#modal-result-rewrite {
    font-style: italic;
    color: #444;
    background-color: #f0eef2;
    padding: 12px 18px;
    border-radius: 6px;
    display: block;
    border-left: 4px solid #6A3E87;
    margin-bottom: 10px;
}

.rewrite-actions {
    display: flex;
    justify-content: flex-start;
    margin-top: 15px;
}

#modal-use-rewrite-btn {
    background-color: #4D2467;
    color: white;
}

#modal-use-rewrite-btn:hover {
    background-color: #6A3E87;
}

.hidden {
    display: none !important;
}

#fireworks-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 999;
    pointer-events: none;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    opacity: 0;
    transition: opacity 1.5s ease;
    overflow: visible;
}

#fireworks-container.active {
    opacity: 1;
}

.fireworks-canvas-container {
    position: fixed;    
    top: 0;
    left: 0;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 998;
    overflow: visible;  
    pointer-events: none;
    margin: 0;
    padding: 0;
}

.celebration-text {
    font-size: 2.5em;
    font-weight: bold;
    color: #ffdd57;
    text-shadow: 0 0 8px black, 0 0 15px #ffdd57, 0 0 20px #ff8c00;
    background-color: rgba(0, 0, 0, 0.6);
    padding: 15px 25px;
    border-radius: 8px;
    margin-top: 0;
    z-index: 999;
    position: relative;
    opacity: 0;
    transition: opacity 1.5s ease;
    animation: text-fade-in 0.5s ease forwards;
    animation-delay: 0.2s;
}

#fireworks-container.active .celebration-text {
    opacity: 1;
}

@keyframes text-fade-in {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

#explanation-modal {
    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: flex-start;
    padding: 40px 20px;
    box-sizing: border-box;
    overflow-y: auto;
    z-index: 101;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

#explanation-modal:not(.hidden) {
    opacity: 1;
    visibility: visible;
}

#explanation-modal .modal-content {
     position: relative;
}

#explanation-modal ul {
    list-style: disc;
    margin-left: 20px;
    margin-bottom: 20px;
}

#explanation-modal li {
    margin-bottom: 8px;
}

.close-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 2em;
    color: #aaa;
    cursor: pointer;
    line-height: 1;
}

.close-btn:hover {
    color: #666;
}

#modal-result-feedback {
    font-style: italic;
    color: #444;
    background-color: #f8f9fa;
    padding: 10px 15px;
    border-radius: 6px;
    display: block;
    border-left: 3px solid #6A3E87;
}

.modal-post-eval-actions {
    display: none;
}

#modal-close-btn {
    /* Styles removed in favor of primary/secondary classes */
}

#modal-close-btn:hover {
    /* Styles removed in favor of primary/secondary classes */
}

#modal-edit-again-btn {
    /* Styles removed in favor of primary/secondary classes */
    margin-right: auto;
}

#modal-edit-again-btn:hover {
    /* Styles removed in favor of primary/secondary classes */
}

#delete-confirm-modal {
    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: flex-start;
    padding: 40px 20px;
    box-sizing: border-box;
    overflow-y: auto;
    z-index: 101;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

#delete-confirm-modal:not(.hidden) {
    opacity: 1;
    visibility: visible;
}

.delete-confirm-content {
    max-width: 400px;
    padding: 25px;
}

.delete-confirm-content h3 {
    color: #d9534f;
    margin-top: 0;
}

#confirm-delete-btn {
    background-color: #d9534f;
    color: white;
}

#confirm-delete-btn:hover {
    background-color: #c9302c;
}

#cancel-delete-btn {
    background-color: #e0e0e0;
    color: #333;
}

#cancel-delete-btn:hover {
    background-color: #d1d1d1;
}

.primary-btn {
  background-color: #4D2467;
  color: white;
}

.primary-btn:hover {
  background-color: #6A3E87;
}

.secondary-btn {
  background-color: #e0e0e0;
  color: #333;
}

.secondary-btn:hover {
  background-color: #d1d1d1;
}

#modal-close-btn, #modal-edit-again-btn {
  /* Remove specific background colors since they'll use the primary/secondary classes */
}

/* New Tertiary Button Style */
.tertiary-btn {
    background-color: #f8f9fa; /* Light grey */
    color: #555;
    border: 1px solid #ddd;
}

.tertiary-btn:hover {
    background-color: #e9ecef;
    border-color: #ccc;
}

.modal-buttons-container {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 25px;
    width: 100%;
}

/* Add compact button style for 3+ button layouts */
.compact-btn {
    padding: 8px 12px;
    font-size: 0.9em;
}

/* Buttons with rewrite container needs more space */
#buttons-with-rewrite {
    flex-wrap: nowrap;
    width: 100%;
}

#buttons-with-rewrite button {
    white-space: nowrap;
    flex: 0 0 auto;
}

/* Responsive adjustments for modal buttons */
@media (max-width: 550px) {
    .modal-content {
        padding: 25px 20px;
        max-width: 90%;
    }
    
    #buttons-with-rewrite {
        flex-direction: column;
        align-items: stretch;
    }
    
    #buttons-with-rewrite button {
        margin-bottom: 8px;
    }
    
    button {
        width: 100%;
    }
}

@media (min-height: 700px) {
    #modal,
    #explanation-modal,
    #delete-confirm-modal {
        align-items: center;
    }
}
