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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #000;
}

#app-container {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

#canvas {
    display: block;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    touch-action: none;
}

#loading {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background-color: #000;
    color: #fff;
    font-family: 'Segoe UI', Arial, sans-serif;
    z-index: 100;
    transition: opacity 0.5s ease;
}

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

.loading-content {
    text-align: center;
    width: 80%;
    max-width: 400px;
}

.loading-title {
    font-size: 1.4rem;
    font-weight: 300;
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-bottom: 40px;
    opacity: 0.9;
}

.progress-bar-container {
    width: 100%;
    height: 4px;
    background-color: rgba(255, 255, 255, 0.15);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 16px;
}

.progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #009999, #3300FF, #CC9933);
    border-radius: 2px;
    transition: width 0.2s ease;
}

.loading-text {
    font-size: 0.85rem;
    opacity: 0.5;
    letter-spacing: 1px;
}

body.hovering-path {
    cursor: pointer;
}

body.zooming {
    cursor: ns-resize;
}

body.zooming #canvas {
    cursor: grab;
}

body.zooming #canvas:active {
    cursor: grabbing;
}

body.gold-target #canvas,
body.gold-target #canvas:active {
    cursor: pointer;
}

.path-highlight {
    position: absolute;
    top: 0;
    height: 100%;
    pointer-events: none;
    background: rgba(255, 255, 255, 0.1);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.path-highlight.active {
    opacity: 1;
}

#cycle-indicator {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-family: 'Times New Roman', serif;
    font-size: 14px;
    z-index: 200;
    opacity: 0;
    transition: opacity 0.5s ease;
    pointer-events: none;
}

#cycle-indicator.visible {
    opacity: 1;
}

#narrative-popup {
    position: fixed;
    z-index: 300;
    max-width: min(420px, calc(100vw - 40px));
    padding: 14px 18px;
    background: rgba(8, 8, 8, 0.86);
    color: #f7f1df;
    border: 1px solid rgba(204, 153, 51, 0.7);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.38);
    font-family: 'Times New Roman', serif;
    font-size: 18px;
    line-height: 1.35;
    text-align: center;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

#narrative-popup.visible {
    opacity: 1;
}

#narrative-popup.click-message {
    text-align: left;
}

#onboarding-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    opacity: 1;
    transition: opacity 0.5s ease;
}

#onboarding-overlay.startup-hidden {
    display: none;
    opacity: 0;
    pointer-events: none;
}

#onboarding-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.onboarding-content {
    color: white;
    width: min(480px, calc(100% - 32px));
    padding: 36px 40px;
    text-align: center;
    background: rgba(12, 12, 12, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
}

.onboarding-title {
    margin-bottom: 24px;
    font-family: 'Times New Roman', serif;
    font-size: 24px;
    line-height: 1.2;
}

.onboarding-list {
    display: flex;
    flex-direction: column;
    gap: 18px;
    margin-bottom: 30px;
    text-align: left;
}

.onboarding-item {
    display: flex;
    align-items: center;
    gap: 16px;
}

.onboarding-item-icon {
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 50%;
    font-size: 24px;
}

.onboarding-item-text {
    font-family: 'Times New Roman', serif;
    font-size: 17px;
    line-height: 1.45;
}

.onboarding-orientation {
    margin: -8px 0 22px;
    color: #f7d891;
    font-family: 'Times New Roman', serif;
    font-size: 16px;
    line-height: 1.35;
}

.onboarding-orientation[hidden] {
    display: none;
}

.onboarding-btn {
    background: white;
    color: black;
    border: none;
    padding: 12px 32px;
    font-size: 16px;
    cursor: pointer;
    border-radius: 4px;
    font-family: 'Times New Roman', serif;
    transition: transform 0.2s;
}

.onboarding-btn:disabled {
    cursor: default;
    opacity: 0.65;
}

.onboarding-btn:hover {
    transform: scale(1.05);
}

.onboarding-btn:disabled:hover {
    transform: none;
}

@media (max-width: 520px) {
    .onboarding-content {
        padding: 28px 24px;
    }

    .onboarding-item {
        gap: 12px;
    }

    .onboarding-item-text {
        font-size: 16px;
    }
}

@media (max-aspect-ratio: 16/9) {
    #canvas { width: 100%; height: auto; }
}

@media (min-aspect-ratio: 16/9) {
    #canvas { width: auto; height: 100%; }
}
