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

body {
    font-family: Arial, sans-serif;
    background: #000;
    color: white;
    overflow-x: hidden;
    width: 100vw;
    min-height: 100vh;
}

a {
    color: white;
}

a:visited {
    color: white;
}

a:hover {
    color: #45b7d1;
    text-decoration: underline;
}

a:active {
    color: #3a9bc1;
}

.main-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 60px);
    text-align: center;
    padding: 20px;
}

.main-container h1 {
    position: relative;
    font-size: 3rem;
    margin-bottom: 1rem;
    color: white;
    transition: all 0.3s ease;
    order: 1;
}

.main-container h1::before {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, #4d69c7, #a042ec, #ff6b6b);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.main-container h1::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, #e44b58, #eba40d, #a2ff4a);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.main-container p {
    font-size: 1.2rem;
    margin-bottom: 2rem;
    opacity: 0.8;
    max-width: 600px;
    order: 2;
}

.nav-buttons {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    justify-content: center;
    order: 3;
}

.nav-button {
    position: relative;
    background: transparent;
    backdrop-filter: blur(8px);
    border: solid 1px white;
    color: white;
    padding: 16px 32px;
    font-size: 1.1rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    text-transform: uppercase;
    letter-spacing: 1px;
    overflow: hidden;
    z-index: 1;
}

.nav-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border: solid 0px transparent;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: -1;
}

.triangle-btn::before {
    background: linear-gradient(45deg, #4d69c7, #a042ec, #ff6b6b);
}

.particles-btn::before {
    background: linear-gradient(45deg, #e44b58, #eba40d, #a2ff4a);
}

.nav-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

.nav-button:hover::before {
    opacity: 1;
}

.nav-buttons:has(.triangle-btn:hover) + h1::before {
    opacity: 1;
}

.nav-buttons:has(.particles-btn:hover) + h1::after {
    opacity: 1;
}

.nav-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    transition: all 0.1s ease;
}

.nav-button:active::before {
    opacity: 1;
}

.back-button-container {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 1000;
}

.back-button {
    padding: 12px 24px;
    font-size: 1rem;
    min-width: auto;
}

.error-toast {
    position: fixed;
    top: 20px;
    right: 20px;
    max-width: 400px;
    padding: 16px 20px;
    background: rgba(220, 53, 69, 0.95);
    color: white;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-20px);
    transition: all 0.3s ease;
    word-wrap: break-word;
    line-height: 1.4;
    position: fixed;
}

.error-toast.visible {
    visibility: visible;
}

.error-toast.show {
    opacity: 1;
    transform: translateY(0);
}

.error-toast.hide {
    opacity: 0;
    transform: translateY(-20px);
}

.error-toast pre {
    background: rgba(0, 0, 0, 0.3);
    padding: 10px;
    border-radius: 4px;
    margin: 10px 0;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    white-space: pre-wrap;
    overflow-x: auto;
}

.error-toast .toast-close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 4px;
    background: rgba(255,255,255,0.2);
    color: white;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}

.error-toast .toast-close:hover {
    background: rgba(255,255,255,0.3);
}

.error-toast .toast-content {
    /* provides some right padding so text doesn't hide behind close button */
    padding-right: 24px;
}

canvas {
    display: block;
    width: 100vw;
    height: 100vh;
    background: #000;
}

/* Sidebar to show WGSL source on the right */
.shader-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    width: var(--shader-sidebar-width, 34vw);
    max-width: 90vw;
    min-width: 320px;
    background: rgba(0,0,0,0.8);
    border-left: 1px solid rgba(255,255,255,0.2);
    box-shadow: -6px 0 20px rgba(0,0,0,0.4);
    backdrop-filter: blur(8px);
    z-index: 900;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.shader-header {
    padding: 12px 16px;
    font-weight: 600;
    border-bottom: 1px solid rgba(255,255,255,0.2);
    color: #aaa;
}

.shader-pre {
    margin: 0;
    padding: 12px 16px;
    overflow: auto;
    white-space: pre;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 12px;
    line-height: 1.5;
    flex: 1 1 auto; /* take remaining space; scroll internally */
}

/* Editable code styling */
.shader-pre code[contenteditable="true"] {
    display: block;
    outline: none;
    caret-color: #ffffff;
    white-space: pre; /* keep exact formatting */
}

/* Sticky footer inside shader sidebar */

.shader-footer {
    margin-top: auto;
    padding: 12px 16px;
    border-top: 1px solid rgba(255,255,255,0.2);
    background: rgba(0,0,0,0.6);
}

/* Draggable resizer at the left edge of the sidebar */
.shader-resizer {
    position: absolute;
    top: 0;
    left: 0;
    width: 8px;
    height: 100%;
    cursor: col-resize;
    touch-action: none;
}

.shader-resizing, .shader-resizing * {
    user-select: none !important;
    cursor: col-resize !important;
}

/* Sidebar is always visible; canvas width compensates via --shader-sidebar-width */

.fps-counter {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    padding: 12px 16px;
    border-radius: 8px;
    border: solid 1px white;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    color: #aaaaaa;
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    line-height: 1;
    user-select: none;
    pointer-events: none;
}

footer {
    text-align: center;
    padding: 20px;
    margin-top: auto;
    background: rgba(0, 0, 0, 0.8);
}

footer p {
    font-size: 0.9rem;
    opacity: 0.7;
    margin: 0;
}

.gravity-info {
    text-align: left;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    border: solid 1px white;
    border-radius: 8px;
    padding: 16px;
    font-family: Arial, sans-serif;
}

#gravity-status {
    font-size: 1.1rem;
    font-weight: 600;
    color: #aaaaaa;
    margin-bottom: 8px;
    transition: color 0.3s ease;
}

#gravity-status.none {
    color: #aaaaaa;
}

#gravity-status.upward {
    color: #a2ff4a;
}

#gravity-status.downward {
    color: #ff6b6b;
}

.gravity-instruction {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.8);
    font-style: italic;
}

.mouse-info {
    text-align: left;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    border: solid 1px white;
    border-radius: 8px;
    padding: 16px;
    font-family: Arial, sans-serif;
}

#mouse-status {
    font-size: 1.1rem;
    font-weight: 600;
    color: #aaaaaa;
    margin-bottom: 8px;
    transition: color 0.3s ease;
}

#mouse-status.active {
    color: #a2ff4a;
}

.mouse-instruction {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.8);
    font-style: italic;
}

.controls-container {
    position: fixed;
    left: 20px;
    bottom: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.circle-controls {
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    border: solid 1px white;
    border-radius: 8px;
    padding: 16px;
    font-family: Arial, sans-serif;
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
}

.circle-controls label {
    font-size: 1.1rem;
    font-weight: 600;
    color: #aaaaaa;
    margin: 0 0 8px 0;
    transition: color 0.3s ease;
}

.circle-controls input[type="number"] {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    color: white;
    font-size: 1rem;
    padding: 8px 12px;
    width: 100px;
    transition: all 0.3s ease;
    -moz-appearance: textfield; /* Firefox */
    appearance: textfield; /* Standard property */
}

/* Chrome, Safari, Edge, Opera */
.circle-controls input[type="number"]::-webkit-outer-spin-button,
.circle-controls input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.apply-button {
    background: linear-gradient(45deg, #45b7d1, #4d69c7);
    border: none;
    border-radius: 6px;
    color: white;
    font-size: 0.9rem;
    font-weight: 600;
    padding: 8px 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.apply-button:hover {
    background: linear-gradient(45deg, #3a9bc1, #4159b7);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(69, 183, 209, 0.3);
}

.apply-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(69, 183, 209, 0.2);
}

.apply-button:disabled {
    background: rgba(255, 255, 255, 0.2);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Mode control styling */
#mode-status {
    font-size: 1.1rem;
    font-weight: 600;
    color: #aaaaaa;
}

/* Loading container and spinner styles */
.loading-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.loading-container.hidden {
    display: none;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top: 4px solid #45b7d1;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

.loading-text {
    color: white;
    font-size: 1.2rem;
    font-weight: 300;
    letter-spacing: 1px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
