:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --secondary-color: #ec4899;
    --background-color: #0f172a;
    --surface-color: #1e293b;
    --text-color: #f8fafc;
    --text-muted: #94a3b8;
    --node-bg: #3b82f6;
    --node-border: #60a5fa;
    --node-text: #ffffff;
    --edge-color: #64748b;
    --highlight-color: #f59e0b;
    --success-color: #10b981;
}

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

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    padding: 2rem;
}

.app-container {
    width: 100%;
    max-width: 1200px;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    text-align: left;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    background: linear-gradient(to right, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

header p {
    color: var(--text-muted);
}

.header-title p {
    margin-top: 0.35rem;
}

.external-link {
    display: inline-flex;
    align-items: center;
    padding: 0.45rem 0.9rem;
    border: 1px solid var(--edge-color);
    border-radius: 999px;
    color: var(--text-color);
    text-decoration: none;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.02);
    box-shadow: 0 6px 12px -8px rgba(0, 0, 0, 0.4);
    transition: background-color 0.2s, border-color 0.2s, transform 0.1s;
}

.external-link:hover {
    background-color: var(--surface-color);
    border-color: var(--primary-color);
    transform: translateY(-1px);
}

.external-link:active {
    transform: translateY(0);
}

@media (max-width: 720px) {
    header {
        flex-direction: column;
        align-items: flex-start;
    }

    .external-link {
        align-self: flex-start;
    }
}

.controls {
    display: flex;
    justify-content: center;
    gap: 1rem;
    background-color: var(--surface-color);
    padding: 1.5rem;
    border-radius: 1rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

input {
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    border: 1px solid var(--edge-color);
    background-color: var(--background-color);
    color: var(--text-color);
    font-family: inherit;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

input:focus {
    border-color: var(--primary-color);
}

button {
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    border: none;
    background-color: var(--primary-color);
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
}

button:hover {
    background-color: var(--primary-hover);
}

button:active {
    transform: scale(0.98);
}

button.secondary {
    background-color: var(--surface-color);
    border: 1px solid var(--edge-color);
}

button.secondary:hover {
    background-color: var(--edge-color);
}

.visualization-area {
    background-color: var(--surface-color);
    border-radius: 1rem;
    min-height: 500px;
    position: relative;
    overflow: hidden;
    /* Hide overflow if tree gets too big, maybe add scroll later */
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    /* Align to top */
    padding-top: 40px;
}

#tree-container {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.5s ease;
}

/* Node Styles */
.node {
    position: absolute;
    width: 50px;
    height: 50px;
    background-color: var(--node-bg);
    border: 2px solid var(--node-border);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: 600;
    color: var(--node-text);
    z-index: 10;
    transition: all 0.5s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.node-value {
    font-size: 1.1rem;
}

.node-info {
    position: absolute;
    top: -25px;
    font-size: 0.7rem;
    color: var(--text-muted);
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.3s;
    background: rgba(0, 0, 0, 0.8);
    padding: 2px 6px;
    border-radius: 4px;
    pointer-events: none;
}

.node:hover .node-info {
    opacity: 1;
}

.node.highlight {
    background-color: var(--highlight-color);
    border-color: #fbbf24;
    transform: scale(1.1);
    box-shadow: 0 0 15px var(--highlight-color);
}

.node.rotating {
    border-color: var(--secondary-color);
    box-shadow: 0 0 20px var(--secondary-color);
    animation: pulse 1s infinite;
}

.node.incorrect {
    background-color: #fef08a;
    /* yellow-200 */
    border-color: #eab308;
    /* yellow-500 */
    border-style: dashed;
    color: #854d0e;
    /* yellow-900 */
}

/* Edge Styles */
.edge {
    position: absolute;
    height: 2px;
    background-color: var(--edge-color);
    transform-origin: 0 50%;
    z-index: 1;
    transition: all 0.5s ease;
}

.edge.incorrect {
    background-color: #eab308;
    /* yellow-500 */
    border-top: 2px dashed #eab308;
    background-color: transparent;
}

/* Info Panel */
.info-panel {
    background-color: var(--surface-color);
    padding: 1.5rem;
    border-radius: 1rem;
    min-height: 100px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

#status-message {
    font-size: 1.2rem;
    margin-bottom: 1rem;
}

#rotation-info.hidden,
.hidden {
    display: none;
}

#rotation-type {
    color: var(--secondary-color);
    font-weight: bold;
    font-size: 1.1rem;
    margin-top: 0.5rem;
}

@keyframes popIn {
    0% {
        transform: scale(0);
        opacity: 0;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(236, 72, 153, 0.7);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(236, 72, 153, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(236, 72, 153, 0);
    }
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .controls {
        flex-direction: column;
    }

    header h1 {
        font-size: 2rem;
    }
}
