/* === Webfont: load Arial first, swap to custom when ready === */
@font-face {
    font-family: 'vrtlfinale1';
    src: url('/p/font/vrtlfinale1-webfont.eot');
    src:
      url('font/vrtlfinale1-webfont.eot?#iefix') format('embedded-opentype'),
      url('font/vrtlfinale1-webfont.woff2') format('woff2'),
      url('font/vrtlfinale1-webfont.woff') format('woff'),
      url('font/vrtlfinale1-webfont.svg#vrtlfinale1') format('svg');
    font-weight: normal;
    font-style: normal;
    font-display: swap; /* shows Arial first, swaps to custom when loaded */
}

/* Global reset + font on everything */
html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #2b2b2b;
    touch-action: none;
}

/* Make all UI use the custom font (fallback to Arial/system) */
*, *::before, *::after {
    font-family: 'vrtlfinale1', Arial, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif !important;
}

/* ================= Timelapse Overlay ================= */
#timelapse-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 80;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
}

#timelapse-controls {
    background-color: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 10px 12px;
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: flex-start;
    gap: 4px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    margin-bottom: 20px;
    touch-action: auto;
    overflow-x: auto;
}

#timelapse-overlay #gif-export-progress {
    color: #fff;
    background-color: rgba(0,0,0,0.7);
    padding: 10px 20px;
    border-radius: 12px;
    margin-bottom: 90px;
    text-align: center;
    width: 250px;
}

#gif-export-progress p { margin: 0 0 10px 0; }
#gif-export-progress progress { width: 100%; }

#gif-encode-container,
#gif-download-container {
    color: #fff;
    background-color: rgba(0,0,0,0.55);
    padding: 10px 16px;
    border-radius: 12px;
    margin-top: 12px;
    text-align: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

#gif-encode-container progress,
#gif-download-container progress {
    width: 100%;
}

#gif-success-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 4000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
}

#gif-success-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.gif-success-modal {
    background: rgba(255,255,255,0.92);
    color: #111;
    border-radius: 16px;
    padding: 24px 28px;
    max-width: 320px;
    text-align: center;
    box-shadow: 0 18px 48px rgba(0,0,0,0.35);
    position: relative;
    z-index: 2;
}

.gif-success-modal h2 {
    margin: 0 0 8px;
    font-size: 1.6rem;
}

.gif-success-modal p {
    margin: 0 0 18px;
}

#gif-success-dismiss {
    appearance: none;
    border: none;
    background: linear-gradient(135deg, #ff7a18, #af002d 71%);
    color: #fff;
    border-radius: 999px;
    padding: 10px 24px;
    font-size: 1rem;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(175,0,45,0.35);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

#gif-success-dismiss:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 22px rgba(175,0,45,0.4);
}

#gif-success-sparks {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
}

#gif-success-sparks span {
    position: absolute;
    top: 100%;
    font-size: 1.8rem;
    animation: gifSparkFloat linear forwards;
    opacity: 0;
    filter: drop-shadow(0 8px 12px rgba(0,0,0,0.35));
}

@keyframes gifSparkFloat {
    0% { transform: translateY(0) scale(0.5); opacity: 0; }
    15% { opacity: 1; }
    100% { transform: translateY(-130vh) scale(1.2); opacity: 0; }
}

#timelapse-controls button {
    font-size: 22px;
    cursor: pointer;
    border: none;
    background: #e0e0e0;
    width: 36px; height: 36px;
    border-radius: 10px;
    transition: transform 0.2s;
}
#timelapse-controls button:hover { transform: scale(1.1); }

#timelapse-close-btn {
    font-size: 20px;
    font-weight: bold;
    color: #555;
    background: #f0f0f0;
}

#timelapse-controls .slider-container {
    display: flex; align-items: center; gap: 4px;
    color: #333; font-weight: 500;
    flex: 0 0 auto;
}
#timelapse-speed-slider { width: 60px; cursor: pointer; height: 16px; }
#timelapse-controls .slider-container span { font-size: 11px; }

.timelapse-option-group {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 68px;
    color: #333;
    font-size: 0.75rem;
    flex: 0 0 auto;
}

.timelapse-option-group label {
    font-weight: 600;
    font-size: 0.75rem;
    text-align: center;
}

.timelapse-option-group select,
.timelapse-option-group input[type="number"] {
    padding: 4px 6px;
    border-radius: 8px;
    border: 1px solid rgba(0,0,0,0.2);
    background: rgba(255,255,255,0.9);
    color: #222;
    font-size: 16px;
    min-height: 26px;
    line-height: 1.25;
}

.timelapse-option-group input[type="number"] {
    width: 36px;
    text-align: center;
}

.timelapse-option-group.playback-toggle-group {
    align-items: center;
    flex-direction: row;
    gap: 0;
    min-width: auto;
}

#timelapse-playback-toggle {
    width: 38px;
    height: 38px;
    font-size: 20px;
    background: #e0e0e0;
    transition: transform 0.2s, background-color 0.2s;
}

#timelapse-playback-toggle[data-mode="sequential"] {
    background: #d6f0ff;
}

.timelapse-save-group {
    min-width: auto;
    align-items: center;
    gap: 2px;
    justify-content: center;
}

.timelapse-save-label {
    font-size: 0.7rem;
    color: #555;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    text-align: center;
}

/* ================= Generic close button ================= */
.close-panel-btn {
    position: absolute;
    top: 5px; right: 10px;
    background: none; border: none;
    font-size: 24px; font-weight: bold; color: #888;
    cursor: pointer; padding: 0; line-height: 1;
    z-index: 71;
}
.close-panel-btn:hover { color: #333; }

/* ================= Trace image overlay panel ================= */
.overlay-panel {
    position: fixed;
    top: 20px; right: 20px;
    background-color: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 15px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    z-index: 70;
    display: flex; flex-direction: column; gap: 15px;
    width: 200px; box-sizing: border-box;
}
.overlay-panel h3 {
    margin: 0 0 10px 0; color: #333; font-size: 1.1em; text-align: center;
}

.overlay-panel [data-drag-handle] {
    user-select: none;
    touch-action: none;
}

.pan-zoom-controls { display: flex; justify-content: center; align-items: center; gap: 15px; }
.zoom-controls { display: flex; flex-direction: column; gap: 5px; }

.zoom-btn {
    background-color: #f0f0f0;
    border: 1px solid #ccc;
    border-radius: 8px;
    font-size: 24px; font-weight: bold;
    width: 40px; height: 40px;
    cursor: pointer;
    transition: background-color 0.2s;
}
.zoom-btn:hover { background-color: #e0e0e0; }
.zoom-btn:active { background-color: #d0d0d0; }

.overlay-panel .control-group { display: flex; flex-direction: column; gap: 5px; }
.overlay-panel label { font-size: 0.9em; color: #555; text-align: center; }

.overlay-panel input[type="range"] {
    width: 100%;
    -webkit-appearance: none;
    height: 8px; border-radius: 5px;
    background: #d3d3d3; outline: none;
    opacity: 0.7; transition: opacity .2s;
}
.overlay-panel input[type="range"]:hover { opacity: 1; }
.overlay-panel input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width: 20px; height: 20px; border-radius: 50%;
   background-color: #2b2b2b; cursor: pointer;
}

.overlay-panel .button-group {
    display: flex; justify-content: space-around; gap: 10px; margin-top: 10px;
}
.overlay-panel .action-btn {
    padding: 8px 12px; border: none; border-radius: 8px;
    cursor: pointer; font-size: 0.9em; flex-grow: 1; white-space: nowrap;
    transition: background-color 0.2s, transform 0.2s;
}
.overlay-panel .action-btn:hover { transform: translateY(-2px); }

#fix-trace-image-btn { background-color: #28a745; color: #fff; }
#fix-trace-image-btn.unfixed { background-color: #007bff; }
#fix-trace-image-btn:hover { background-color: #218838; }
#remove-trace-image-btn { background-color: #dc3545; color: #fff; }
#remove-trace-image-btn:hover { background-color: #c82333; }

/* ================= Emoji Picker (90% viewport width) ================= */
#emoji-picker-overlay {
    position: fixed; top: 10%; left: 0;
    width: 100%; height: 90%;
    background-color: #2b2b2b;
    display: flex; justify-content: center; align-items: center;
    z-index: 100;
}

#emoji-picker-modal {
   background-color: #2b2b2b;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    text-align: center;

    /* nearly full-screen width */
    width: 90vw;
    max-width: 90vw;
    max-height: 90vh;

    overflow: hidden;
    display: flex; flex-direction: column; align-items: center;
    margin-bottom: 15px;
    padding: 0 12px;
    box-sizing: border-box;
}

#emoji-picker-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 15px; padding: 10px 10px; width: 100%;
    flex-shrink: 0; box-sizing: border-box;
}

#emoji-picker-header h1.main-title {
    margin: 0; font-size: 1.5em; color: #777; font-weight: normal;
}
#emoji-picker-header .subtitle-container {
    display: flex; align-items: center; justify-content: center; gap: 10px;
}
#emoji-picker-header h2 {
    margin: 0; font-size: 1.2em; color: #555; font-weight: normal;
}

#recently-used-emojis {
    width: 100%;
    padding: 10px 0;
    border-top: 1px solid #eee; border-bottom: 1px solid #eee;
    margin-bottom: 10px;
    display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; flex-shrink: 0;
}

#prev-emoji-set-btn, #next-emoji-set-btn {
    font-size: 24px; cursor: pointer; border: none; background: #e0e0e0;
    width: 40px; height: 40px; border-radius: 50%;
    transition: transform 0.2s;
}
#prev-emoji-set-btn:hover, #next-emoji-set-btn:hover { transform: scale(1.1); }

#emoji-picker-modal h1 { margin-top: 0; color: #333; }

#emoji-grid-container {
    overflow-y: auto; flex-grow: 1; padding-right: 10px; width: 100%;
    box-sizing: border-box;
}

#emoji-category-title {
    position: sticky; top: 0; background-color: #3b3b3b; z-index: 1;
    margin: 0 0 10px 0; padding: 10px 0 5px 0;
    font-size: 1em; font-weight: 600; color: #555; text-align: left;
}

/* Responsive grid fills the wide modal nicely */
#emoji-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
    gap: 10px;
}

.emoji-btn {
    font-size: 32px; cursor: pointer; border: none; background: none;
    padding: 5px; border-radius: 8px;
    transition: transform 0.2s, background-color 0.2s;
}
.emoji-btn:hover { transform: scale(1.2); background-color: #e0e0e0; }

@keyframes emojiAutoPickPulse {
    0% { transform: scale(1); box-shadow: 0 0 0 rgba(255,255,255,0); }
    50% { transform: scale(1.2); box-shadow: 0 0 18px rgba(255,255,255,0.85); }
    100% { transform: scale(1); box-shadow: 0 0 0 rgba(255,255,255,0); }
}

.emoji-btn.auto-picked {
    animation: emojiAutoPickPulse 0.7s ease-in-out;
    background-color: rgba(255,255,255,0.3);
}

.emoji-picker-title-container { display: flex; flex-direction: column; align-items: center; flex-grow: 1; }
.main-title-wrapper { display: flex; align-items: center; justify-content: center; gap: 10px; }
.emoji-anim-tools { display: flex; align-items: center; gap: 8px; }
#emoji-picker-animation-container {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    font-size: 34px;
    border-radius: 14px;
    background: rgba(0,0,0,0.12);
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.25);
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}
#emoji-picker-animation-container:hover,
#emoji-picker-animation-container:focus-visible {
    transform: scale(1.08);
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.45);
    background: rgba(0,0,0,0.2);
    outline: none;
}
#emoji-picker-animation-container:active {
    transform: scale(0.96);
}
#emoji-random-btn {
    width: 36px;
    height: 36px;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.25);
    background: rgba(0,0,0,0.28);
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease, transform 0.2s ease;
}
#emoji-random-btn:hover,
#emoji-random-btn:focus-visible {
    background: rgba(0,0,0,0.4);
    outline: none;
}
#emoji-random-btn:active { transform: scale(0.95); }

/* ================= Share Overlay ================= */
#share-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex; justify-content: center; align-items: center; z-index: 100;
}
#share-modal {
    background-color: #fff;
    padding: 20px 30px;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    text-align: center;
    max-width: 90%; width: 400px; box-sizing: border-box;
}
#share-modal h2 { margin-top: 0; color: #333; }
#share-modal p { color: #666; margin-bottom: 20px; }

.share-controls { display: flex; gap: 10px; align-items: center; margin-bottom: 20px; }
.share-input-container { display: flex; flex-grow: 1; }

#emoji-animation-container {
    font-size: 32px; width: 44px; height: 44px;
    display: flex; justify-content: center; align-items: center;
    background-color: #f0f0f0; border-radius: 8px; flex-shrink: 0;
}

#share-link-input {
    flex-grow: 1; padding: 10px;
    border: 1px solid #ccc; border-right: none;
    border-radius: 8px 0 0 8px;
    font-size: 1em; background-color: #f0f0f0;
}

#copy-link-btn {
    padding: 10px 15px;
    border: 1px solid #007bff; background-color: #007bff; color: #fff;
    border-radius: 0; cursor: pointer; font-size: 1em;
    transition: background-color 0.2s; border-left: none; border-right: none;
}
#copy-link-btn:hover { background-color: #0056b3; }

#share-btn {
    padding: 10px 15px; border: 1px solid #17a2b8; background-color: #17a2b8;
    color: #fff; border-radius: 0 8px 8px 0; cursor: pointer; font-size: 1em;
    transition: background-color 0.2s;
}
#share-btn:hover { background-color: #138496; }

#close-share-btn {
    padding: 10px 20px; border: none; background-color: #6c757d; color: #fff;
    border-radius: 8px; cursor: pointer; font-size: 1em; transition: background-color 0.2s;
}
#close-share-btn:hover { background-color: #5a6268; }

/* ================= Upload Loader ================= */
#upload-loader-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex; justify-content: center; align-items: center;
    z-index: 200; color: #fff;
}
.loader-content {
    text-align: center; padding: 20px; background: rgba(0,0,0,0.5); border-radius: 10px;
}
.loader-content p { margin: 0; font-size: 1.2em; }

/* ================= Layers Panel ================= */
#layers-panel {
    top: 50%; right: 20px; transform: translateY(-50%);
}
