/* style.css */

:root {
    --primary-color: #2c3e50;
    --text-color: #ecf0f1;
}

html, body {
    width: 100%;
    height: 100%;
    margin: 0;
    overflow: hidden;
    background: transparent;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

#game-viewport {
    position: fixed;
    inset: 0;
    overflow: hidden;
}

#game-world {
    position: absolute;
    width: 1920px;
    height: 1080px;
    transform-origin: top left;
}

#dry-background,
#restored-background {
    position: absolute;
    inset: 0;
    width: 1920px;
    height: 1080px;
    object-fit: fill;
    pointer-events: none;
    user-select: none;
}

#dry-background {
    z-index: 0;
    opacity: 1;
}

#restored-background {
    z-index: 1;
    opacity: 0;
    transition: opacity 1.5s ease;
}

#restored-background.is-visible {
    opacity: 1;
}

.final-hidden {
    opacity: 0 !important;
    pointer-events: none;
    transition: opacity 1.5s ease;
}

.layer {
    position: absolute;
    inset: 0;
    width: 1920px;
    height: 1080px;
}

#river-canvas {
    position: absolute;
    inset: 0;
    width: 1920px;
    height: 1080px;
    z-index: 2;
}

#level-layer {
    position: absolute;
    inset: 0;
    width: 1920px;
    height: 1080px;
    z-index: 4;
}

#effects-layer {
    position: absolute;
    inset: 0;
    width: 1920px;
    height: 1080px;
    z-index: 6;
}

#world-ui-layer {
    position: absolute;
    inset: 0;
    width: 1920px;
    height: 1080px;
    z-index: 10;
}

#screen-ui-layer {
    position: fixed;
    inset: 0;
    z-index: 10;
    pointer-events: none;
}

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

/* Ensure canvas respects z-index and doesn't get squished */
canvas.layer {
    display: block;
    width: 100%;
    height: 100%;
    position: absolute;
    pointer-events: none;
    z-index: 3;
}

#river-canvas.is-active {
    pointer-events: auto;
    touch-action: none;
    cursor: crosshair;
}

.environment-item {
    position: absolute;
    transition: opacity 1s ease-in-out;
}

.full-size {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* UI Screens */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.75);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: var(--text-color);
    text-align: center;
    transition: opacity 0.5s ease;
    pointer-events: auto;
}

.screen h1 {
    font-size: 48px;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.screen p {
    font-size: 24px;
    margin-bottom: 30px;
}

button {
    padding: 15px 30px;
    font-size: 24px;
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    transition: background-color 0.3s, transform 0.1s;
}

button:hover {
    background-color: #2980b9;
}

button:active {
    transform: translateY(2px);
}

/* HUD */
#hud {
    position: absolute;
    top: 20px;
    right: 20px;
    font-size: 24px;
    color: white;
    background-color: rgba(0, 0, 0, 0.6);
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: bold;
}

/* Toast Message */
#message-toast {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 20px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 100;
}

#message-toast.visible {
    opacity: 1;
}

/* Level Objects */
.level-object {
    position: absolute;
    height: auto;
    object-fit: contain;
    user-select: none;
    -webkit-user-drag: none;
    transform-origin: center center;
    transition: opacity 1.5s ease-in-out;
}

#level-layer {
    z-index: 2;
}

/* Editor Styles */
#editor-ui {
    position: fixed;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 15px;
    border-radius: 8px;
    border: 1px solid #444;
    pointer-events: auto;
    z-index: 9999;
}

#editor-ui.hidden {
    display: none;
}

.editor-panel h3 {
    margin: 0 0 10px 0;
    font-size: 16px;
}

#editor-info {
    margin-bottom: 10px;
    font-family: monospace;
    white-space: pre-wrap;
}

#editor-copy-btn, #editor-reset-btn {
    display: block;
    width: 100%;
    margin-top: 5px;
    padding: 5px;
    background: #3498db;
    border: none;
    color: white;
    cursor: pointer;
}

#editor-reset-btn {
    background: #e74c3c;
}

.editor-selected {
    outline: 2px dashed #f39c12;
    outline-offset: 2px;
}

/* Resize Handle */
.resize-handle {
    position: absolute;
    width: 10px;
    height: 10px;
    background: #f39c12;
    border: 1px solid white;
    right: -6px;
    bottom: -6px;
    cursor: nwse-resize;
    z-index: 9999;
    pointer-events: auto;
}

/* Utility */
.hidden {
    opacity: 0;
    pointer-events: none;
}

.visible {
    opacity: 1;
    pointer-events: auto;
}

/* Loading Bar */
.progress-bar-container {
    width: 300px;
    height: 20px;
    background-color: #333;
    border-radius: 10px;
    overflow: hidden;
    margin-top: 20px;
}

#progress-bar {
    width: 0%;
    height: 100%;
    background-color: #3498db;
    transition: width 0.2s ease;
}

/* Debug Canvas */
#debug-canvas {
    z-index: 999;
}