/* CSS Variables */
:root {
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-tertiary: #0f0f1a;
    --text-primary: #eaeaea;
    --text-secondary: #a0a0a0;
    --accent-orange: #f97316;
    --accent-green: #22c55e;
    --accent-blue: #3b82f6;
    --accent-red: #ef4444;
    --border-color: #2a2a4a;
}

/* Reset */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Base */
html,
body {
    height: 100%;
    font-family: 'Caveat', cursive;
    background-color: var(--bg-primary);
    color: var(--text-primary);
}

/* Accessibility */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* App Container */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Toolbar */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 16px 20px;
    background-color: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 4px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    transform: rotate(-0.3deg);
}

.chart-title {
    font-family: 'Caveat', cursive;
    font-size: 2.2rem;
    font-weight: 700;
    background: transparent;
    border: none;
    color: var(--text-primary);
    outline: none;
    padding: 8px 12px;
    border-radius: 6px;
    min-width: 200px;
    flex: 1;
}

.chart-title:hover,
.chart-title:focus {
    background-color: var(--bg-tertiary);
}

.toolbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

/* Buttons */
.btn {
    font-family: 'Caveat', cursive;
    padding: 10px 18px;
    border: 2px solid currentColor;
    border-radius: 4px;
    font-size: 1.3rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transform: rotate(-0.5deg);
    min-width: 44px;
    min-height: 44px;
}

#help-btn {
    text-indent: -5px;
}

.btn-primary {
    background-color: var(--accent-blue);
    color: white;
    border-color: var(--accent-blue);
}

.btn-primary:hover {
    background-color: #2563eb;
    transform: rotate(-0.5deg) translateY(-2px);
}

.btn-secondary {
    background-color: transparent;
    color: var(--text-primary);
    border-color: var(--text-secondary);
}

.btn-secondary:hover {
    background-color: var(--bg-tertiary);
    transform: rotate(-0.5deg) translateY(-2px);
}

.btn-danger {
    background-color: var(--accent-red);
    color: white;
    border-color: var(--accent-red);
}

.btn-danger:hover {
    background-color: #dc2626;
    transform: rotate(-0.5deg) translateY(-2px);
}

/* Chart Container */
.chart-container {
    flex: 1;
    background-color: transparent;
    border: none;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

#export-wrapper {
    background-color: var(--bg-secondary);
    padding: 20px;
    width: 100%;
    max-width: 980px;
    border: 2px solid var(--border-color);
    border-radius: 4px;
}

#hill-svg {
    width: 100%;
    height: auto;
    display: block;
}

/* Hill Labels */
.hill-label {
    font-family: 'Caveat', cursive;
    fill: var(--text-secondary);
    font-size: 22px;
    font-style: italic;
    text-anchor: middle;
}

/* Scope Styles */
.scope-group {
    cursor: grab;
}

.scope-group:active {
    cursor: grabbing;
}

.scope-dot {
    transition: r 0.15s ease;
}

.scope-group:hover .scope-dot {
    r: 14;
}

.scope-label {
    font-family: 'Caveat', cursive;
    fill: var(--text-primary);
    font-size: 22px;
    font-weight: 700;
    text-anchor: middle;
    pointer-events: none;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 1000;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background-color: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 4px;
    padding: 24px;
    min-width: 320px;
    max-width: 90%;
    transform: scale(0.95) rotate(-0.5deg);
    transition: transform 0.2s ease;
}

.modal-overlay.active .modal {
    transform: scale(1) rotate(-0.5deg);
}

.modal h2 {
    font-family: 'Caveat', cursive;
    margin-bottom: 16px;
    font-size: 1.8rem;
    font-weight: 700;
}

.modal input {
    font-family: 'Caveat', cursive;
    width: 100%;
    padding: 12px 14px;
    border: 2px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 1.4rem;
    outline: none;
    margin-bottom: 20px;
}

.modal input:focus {
    border-color: var(--accent-blue);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.modal-actions .btn-danger {
    margin-right: auto;
}

.help-content {
    margin-bottom: 20px;
}

.help-content p {
    margin-bottom: 12px;
    font-size: 1.2rem;
    line-height: 1.6;
}

.help-content strong {
    color: var(--accent-blue);
}

/* Notification */
.notification {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(150px) rotate(-1deg);
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    padding: 14px 24px;
    border-radius: 4px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    transition: transform 0.3s ease;
    z-index: 1001;
    border: 2px solid var(--border-color);
    font-size: 1.3rem;
}

.notification.show {
    transform: translateX(-50%) translateY(0) rotate(-1deg);
}

.notification.success {
    border-color: var(--accent-green);
}

.notification.error {
    border-color: var(--accent-red);
}

/* Responsive */
@media (max-width: 768px) {
    .app-container {
        padding: 12px;
    }

    .toolbar {
        padding: 12px;
        gap: 12px;
    }

    .chart-title {
        font-size: 1.2rem;
        min-width: 150px;
    }

    .toolbar-actions {
        width: 100%;
        justify-content: center;
    }

    .btn {
        padding: 8px 14px;
        font-size: 0.85rem;
    }

}