@font-face {
    font-family: 'Inter-Alia';
    src: url('https://joro.io/fonts/InterAlia-VF.otf') format('opentype');
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}

/* Support for Shavian font */
@font-face {
    font-family: 'Noto Sans Shavian';
    font-style: normal;
    font-weight: 400;
    src: url('https://fonts.gstatic.com/s/notosansshavian/v17/CHy5V_HZE0jxJBQlqAeCKjJvQBNF4EFQSplv2Cwg.woff2') format('woff2');
    unicode-range: U+10450-1047F;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter-Alia', 'Noto Sans Shavian', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

/* Loading Splash Screen */
.loading-splash {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    transition: opacity 0.5s ease-out;
}

.loading-splash.hidden {
    opacity: 0;
    pointer-events: none;
}

.loading-content {
    text-align: center;
    color: white;
}

.loading-content h1 {
    font-size: 2.5rem;
    margin-bottom: 2rem;
    font-weight: 600;
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1.5rem;
}

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

.loading-text {
    font-size: 1.1rem;
    opacity: 0.9;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    text-align: center;
    position: relative;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    font-weight: 700;
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.95;
}

.controls {
    padding: 30px;
    background: #f8f9fa;
    border-bottom: 2px solid #e9ecef;
}

.control-group {
    margin-bottom: 20px;
    position: relative;
}

.radio-group {
    display: flex;
    gap: 20px;
    margin-top: 8px;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 1rem;
    color: #495057;
}

.radio-label input[type="radio"] {
    width: auto;
    cursor: pointer;
}

.radio-label span {
    user-select: none;
}

.editable-input {
    min-height: 46px;
    padding: 12px;
    border: 2px solid #dee2e6;
    border-radius: 6px;
    font-size: 1rem;
    font-family: 'Inter-Alia', 'Noto Sans Shavian', sans-serif;
    background: white;
    transition: border-color 0.2s;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
    cursor: text;
}

.editable-input:focus {
    outline: none;
    border-color: #667eea;
}

.editable-input:empty:before {
    content: attr(data-placeholder);
    color: #6c757d;
    pointer-events: none;
}

.editable-span {
    display: inline;
    outline: none;
    min-width: 1px;
}

.control-group label {
    display: block;
    margin-bottom: 8px;
    color: #495057;
}

.control-group strong {
    font-weight: 600;
    color: #212529;
}

.hint {
    font-size: 0.85rem;
    color: #6c757d;
    font-weight: normal;
}

input[type="text"],
input[type="number"],
input[type="file"] {
    width: 100%;
    padding: 12px;
    border: 2px solid #dee2e6;
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.2s;
    font-family: 'Inter-Alia', 'Noto Sans Shavian', sans-serif;
}

input[type="text"]:focus,
input[type="number"]:focus {
    outline: none;
    border-color: #667eea;
}

input[type="text"]:disabled,
input[type="number"]:disabled {
    background: #e9ecef;
    cursor: not-allowed;
}

.button-group {
    display: flex;
    gap: 10px;
    margin-top: 25px;
}

button {
    flex: 1;
    padding: 14px 24px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

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

#solve-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

#solve-btn:not(:disabled):hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

#stop-btn {
    background: #dc3545;
    color: white;
}

#stop-btn:not(:disabled):hover {
    background: #c82333;
    transform: translateY(-2px);
}

#clear-btn {
    background: #6c757d;
    color: white;
}

#clear-btn:hover {
    background: #5a6268;
    transform: translateY(-2px);
}

.results-section {
    padding: 30px;
}

.results-section h2 {
    font-size: 1.8rem;
    margin-bottom: 20px;
    color: #212529;
}

.results-section h2 #solution-count {
    color: #667eea;
    font-weight: 700;
}

.results-container {
    max-height: 500px;
    overflow-y: auto;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    padding: 15px;
    background: #fff;
}

.results-container::-webkit-scrollbar {
    width: 10px;
}

.results-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.results-container::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 10px;
}

.results-container::-webkit-scrollbar-thumb:hover {
    background: #764ba2;
}

.placeholder,
.no-results {
    text-align: center;
    padding: 60px 20px;
    color: #6c757d;
    font-size: 1.1rem;
}

.result-item {
    padding: 12px 8px;
    margin-bottom: 10px;
    background: #fff;
    border-left: 4px solid #667eea;
    border-radius: 4px;
    display: flex;
    align-items: center;
    user-select: none;
}

.result-item.exact-match {
    padding: 20px;
    margin: 20px 0;
    background: linear-gradient(135deg, #667eea10 0%, #764ba220 100%);
    border: 3px solid #667eea;
    border-left: 8px solid #667eea;
    justify-content: center;
}

.result-item.exact-match .result-text {
    font-size: 1.5rem;
    font-weight: 600;
    text-align: center;
}

.result-item.exact-match .draggable-word {
    font-size: 1.3rem;
    padding: 6px 12px;
    margin: 0 4px;
}

.result-number {
    font-weight: 700;
    color: #667eea;
    margin-right: 15px;
    min-width: 40px;
}

.result-text {
    font-size: 1.1rem;
    font-family: 'Inter-Alia', 'Noto Sans Shavian', sans-serif;
    color: #212529;
}

.draggable-word {
    display: inline-block;
    padding: 4px 8px;
    margin-right: 3px;
    border-radius: 6px;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    cursor: grab;
    transition: all 0.15s;
}

.draggable-word:hover {
    background: #e9ecef;
    border-color: #adb5bd;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.draggable-word.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

.draggable-word.starter-word {
    font-weight: 600;
}

.word-chip {
    position: relative;
    display: inline-block;
    padding: 4px 8px;
    margin-right: 6px;
    margin-bottom: 4px;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    font-size: 1rem;
    font-family: 'Inter-Alia', 'Noto Sans Shavian', sans-serif;
    cursor: grab;
    transition: all 0.15s;
    user-select: none;
    font-weight: 600;
    white-space: nowrap;
}

.word-chip.dragging {
    opacity: 0.5;
}

.word-chip.error {
    background: #f8d7da;
    border-color: #dc3545;
    color: #721c24;
}

.word-chip.error:hover {
    background: #f5c6cb;
    border-color: #bd2130;
}

.chip-text {
    pointer-events: none;
}

.chip-remove {
    position: absolute;
    top: -6px;
    right: -6px;
    display: none;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #6c757d;
    color: white;
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
    transition: all 0.15s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.word-chip:hover .chip-remove {
    display: inline-flex;
}

.chip-remove:hover {
    background: #dc3545;
    transform: scale(1.1);
}

.word-chip:hover {
    background: #e9ecef;
    border-color: #adb5bd;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.word-chip.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

.word-chip:active {
    transform: scale(0.95);
}

.loading-indicator {
    display: none;
    text-align: center;
    padding: 20px;
    color: #667eea;
    font-style: italic;
    animation: pulse 1.5s ease-in-out infinite;
}

.exact-match-actions {
    display: flex;
    gap: 10px;
    margin: 15px 0;
    justify-content: center;
}

.exact-match-actions.hidden {
    display: none;
}

.exact-match-btn {
    padding: 12px 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.exact-match-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

.exact-match-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

@keyframes pulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

.share-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 30px;
    max-width: 500px;
    width: 90%;
    z-index: 10000;
    opacity: 0;
    transition: all 0.3s ease;
}

.share-popup.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

.share-popup-content {
    text-align: center;
}

.share-popup-icon {
    font-size: 3rem;
    margin-bottom: 15px;
}

.share-popup-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #667eea;
    margin-bottom: 15px;
}

.share-popup-url {
    background: #f8f9fa;
    padding: 12px;
    border-radius: 8px;
    font-family: monospace;
    font-size: 0.9rem;
    color: #495057;
    word-break: break-all;
    margin-bottom: 10px;
    border: 1px solid #dee2e6;
}

.share-popup-message {
    color: #6c757d;
    font-size: 0.95rem;
}

.share-popup-input {
    width: 100%;
    padding: 12px;
    border: 2px solid #667eea;
    border-radius: 8px;
    font-family: monospace;
    font-size: 0.9rem;
    margin-bottom: 15px;
    text-align: center;
}

.share-popup-close {
    padding: 10px 24px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.share-popup-close:hover {
    background: #5568d3;
}

/* Burger Menu */
.burger-menu {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 6px;
    padding: 8px;
    z-index: 1000;
}

.burger-menu span {
    display: block;
    width: 24px;
    height: 3px;
    background: white;
    border-radius: 2px;
    transition: all 0.3s;
}

.burger-menu:hover span {
    background: rgba(255, 255, 255, 0.8);
}

/* Menu Dropdown */
.menu-dropdown {
    position: absolute;
    top: 70px;
    right: 20px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    z-index: 999;
    min-width: 180px;
}

.menu-dropdown.hidden {
    display: none;
}

.menu-item {
    display: block;
    width: 100%;
    padding: 12px 20px;
    background: white;
    border: none;
    text-align: left;
    cursor: pointer;
    font-size: 1rem;
    color: #212529;
    transition: background 0.2s;
    border-bottom: 1px solid #e9ecef;
    text-transform: none;
}

.menu-item:last-child {
    border-bottom: none;
}

.menu-item:hover {
    background: #f8f9fa;
}

/* Dialog Overlay */
.dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.dialog-overlay.hidden {
    display: none;
}

.dialog {
    background: white;
    border-radius: 12px;
    padding: 30px;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    min-width: 400px;
}

.dialog-close {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 32px;
    height: 32px;
    border: none;
    background: #6c757d;
    color: white;
    font-size: 24px;
    line-height: 1;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dialog-close:hover {
    background: #dc3545;
    transform: scale(1.1);
}

.dialog h2 {
    margin-bottom: 20px;
    color: #212529;
}

/* About Dialog */
.about-content h2 {
    color: #667eea;
    margin-bottom: 15px;
}

.about-content h3 {
    color: #495057;
    margin-top: 20px;
    margin-bottom: 10px;
}

.about-content ul, .about-content ol {
    margin-left: 20px;
    margin-bottom: 15px;
}

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

.about-content a {
    color: #667eea;
    text-decoration: none;
}

.about-content a:hover {
    text-decoration: underline;
}

/* Solutions List */
.solutions-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
    min-height: 200px;
}

.solution-item {
    padding: 15px;
    background: #f8f9fa;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.solution-item:hover {
    background: #e9ecef;
    border-color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.solution-item.dragging {
    opacity: 0.5;
}

.solution-text {
    font-family: 'Inter-Alia', 'Noto Sans Shavian', sans-serif;
    font-size: 1.1rem;
    color: #212529;
    margin-bottom: 5px;
}

.solution-meta {
    font-size: 0.85rem;
    color: #6c757d;
}

.solution-remove {
    position: absolute;
    top: 10px;
    right: 10px;
    display: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #6c757d;
    color: white;
    border: none;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    transition: all 0.15s;
    align-items: center;
    justify-content: center;
}

.solution-item:hover .solution-remove {
    display: inline-flex;
}

.solution-remove:hover {
    background: #dc3545;
    transform: scale(1.1);
}

.save-current-btn {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.save-current-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

/* Footer */
.footer {
    text-align: center;
    padding: 20px;
    color: #000;
    font-size: 0.9rem;
}

@media (max-width: 768px) {
    header h1 {
        font-size: 1.8rem;
    }

    .subtitle {
        font-size: 0.9rem;
    }

    .button-group {
        flex-direction: column;
    }

    .stats {
        grid-template-columns: repeat(2, 1fr);
    }

    .dialog {
        min-width: 90%;
        max-width: 90%;
        padding: 20px;
    }
}
