:root {
    --radius: 12px;
}

/* Prevent horizontal scroll on body */
body {
    overflow-x: hidden;
}

.image-generator-content {
    max-width: 1100px;
    margin: 0 auto;
}

#messageArea {
    display: none !important;
}

/* Floating Upload Button */
#floatingUploadBtn,
#floatingAddBtn {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    z-index: 10000000;
}

.floating-add-btn {
    width: 50px;
    height: 50px;
    background-color: black;
    color: var(--neon-yellow);
    line-height: 50px;
    font-size: 2rem;
    cursor: pointer;
    border: none;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
}

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


.image-preview-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.image-preview {
    position: relative;
    width: 120px;
    height: 120px;
}

.image-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-preview button {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 24px;
    height: 24px;
    cursor: pointer;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.thumb-section {
    width: 100vw;
    margin-left: calc(50% - 50vw); /* stretch full width */
    padding: 0 1rem;
    box-sizing: border-box;
}
.thumb-gallery {
    overflow-x: auto;
    white-space: nowrap;
    padding: 0.5rem 0;
    width: 100vw;
    box-sizing: border-box;
}
.thumb-group {
    display: inline-flex;
    align-items: flex-start;
    gap: 0;
    padding: 4px;
    margin-right: 0.5rem;
    height: 100px;
    box-sizing: border-box;
    vertical-align: top;
}
.thumb-item {
    display: inline-block;
    margin-right: 2px;
    vertical-align: top;
}
.thumb-item img {
    height: 90px;
    width: auto;
    object-fit: contain;
    display: block;
    visibility: visible;
    opacity: 1;
}
.thumb-ascii {
    display: inline-block;
    margin-right: 2px;
    padding: 0.15rem 0.2rem;
    font-family: 'Courier New', monospace;
    line-height: 5px;
    white-space: pre;
    max-height: 90px;
    max-width: 180px;
    overflow: hidden;
    box-sizing: border-box;
    vertical-align: top;
}

/* View mode styles */
.image-gallery[data-mode="bitmap"] img,
.thumb-gallery[data-mode="bitmap"] img {
    image-rendering: pixelated;
}
.image-gallery[data-mode="low"] img,
.thumb-gallery[data-mode="low"] img {
    image-rendering: auto;
    filter: contrast(0.9) saturate(0.95);
}
.image-gallery[data-mode="full"] img,
.thumb-gallery[data-mode="full"] img {
    image-rendering: auto;
    filter: none;
}

.thumb-gallery {
    position: relative;
}

.image-gallery {
    position: relative;
    width: 100%;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    overflow-y: visible;
}

.gallery-item {
    position: absolute;
    overflow: visible;
    background: transparent;
    margin: 0;
    padding: 0;
}

.gallery-pieces-container {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: visible;
    margin: 0;
    padding: 0;
}

.gallery-piece {
    position: absolute;
    cursor: move;
    margin: 0;
    padding: 0;
    transition: z-index 0.2s;
    overflow: hidden;
    background-color: white;
}

.gallery-piece.selected {
    outline: 3px solid #0066ff;
    outline-offset: -3px;
    box-shadow: 0 0 0 3px rgba(0, 102, 255, 0.3);
}

.gallery-piece img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}


.thumb-item img {
    transition: outline 0.15s ease;
}

.ascii-gallery-item {
    position: absolute;
    padding: 0.5rem;
    margin: 0;
    white-space: pre;
    font-family: 'Courier New', monospace;
    font-size: 8px;
    letter-spacing: 0;
    overflow: hidden;
    display: block;
    text-align: left;
    background-color: white;
    box-sizing: border-box;
}
.ascii-gallery-item pre {
    margin: 0;
    display: block;
    text-align: left;
    padding: 0;
    font-size: 8px;
    width: 100%;
    overflow: hidden;
    word-wrap: break-word;
}

.gallery-piece-group {
    position: absolute;
}

.gallery-delete-btn {
    position: absolute;
    padding: 0.25rem 0.5rem;
    cursor: pointer;
    z-index: 10000;
    display: none !important;
}

.gallery-piece img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    pointer-events: none;
}

.gallery-piece:hover {
    z-index: 10;
    opacity: 0.9;
}

.gallery-piece.dragging {
    opacity: 0.8;
    z-index: 100;
}

.gallery-item .delete-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    padding: 0.25rem 0.5rem;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.3s;
}

.gallery-item:hover .delete-btn {
    opacity: 1;
}

.empty-gallery {
    text-align: center;
    padding: 2rem;
    font-style: italic;
}

.loading-indicator {
    text-align: center;
    padding: 2rem;
    font-style: italic;
    color: var(--color-dark-gray);
}

.loading-indicator span {
    font-weight: bold;
    color: var(--color-black);
}

.menu-buttons {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 1rem;
    align-items: flex-start;
    font-size: 0.75rem;
}

.menu-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 0;
    cursor: pointer;
    transition: all 0.2s;
    min-height: 100px;
    overflow: visible;
}


.menu-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.menu-btn .icon {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    stroke-width: 1;
    overflow: visible;
    padding-bottom: 0.25rem;
}

.menu-btn.active .icon {
    stroke: currentColor;
}

.menu-btn:hover:not(:disabled) .icon {
    transform: scale(1.1);
    transition: transform 0.2s;
}

/* Grid Split Animation - 네모가 갈라지는 애니메이션 */
.menu-btn:hover:not(:disabled) .icon-grid {
    overflow: visible;
}
.menu-btn:hover:not(:disabled) .icon-grid .grid-box:nth-child(1) {
    transform: translate(-2px, -2px);
    transition: transform 0.3s ease;
}
.menu-btn:hover:not(:disabled) .icon-grid .grid-box:nth-child(2) {
    transform: translate(2px, -2px);
    transition: transform 0.3s ease;
}
.menu-btn:hover:not(:disabled) .icon-grid .grid-box:nth-child(3) {
    transform: translate(-2px, 2px);
    transition: transform 0.3s ease;
}
.menu-btn:hover:not(:disabled) .icon-grid .grid-box:nth-child(4) {
    transform: translate(2px, 2px);
    transition: transform 0.3s ease;
}

/* Vertical Strips Animation - 세로 줄들이 좌우로 움직임 */
.menu-btn:hover:not(:disabled) .icon-strip {
    overflow: visible;
}
.menu-btn:hover:not(:disabled) .icon-strip .strip:nth-child(1) {
    transform: translateX(-3px);
    transition: transform 0.3s ease;
}
.menu-btn:hover:not(:disabled) .icon-strip .strip:nth-child(2) {
    transform: translateX(0);
    transition: transform 0.3s ease;
}
.menu-btn:hover:not(:disabled) .icon-strip .strip:nth-child(3) {
    transform: translateX(3px);
    transition: transform 0.3s ease;
}

/* Steganography Animation - 눈알이 굴러다니는 애니메이션 */
.menu-btn:hover:not(:disabled) .icon-steg {
    overflow: visible;
}
.menu-btn:hover:not(:disabled) .icon-steg .steg-eye {
    transform: scale(1.1);
    transition: transform 0.3s ease;
}
.menu-btn:hover:not(:disabled) .icon-steg .steg-pupil {
    animation: eyeRoll 1.5s ease-in-out infinite;
    transform-origin: center;
}
@keyframes eyeRoll {
    0%, 100% {
        transform: translate(0, 0);
    }
    20% {
        transform: translate(4px, -1px);
    }
    40% {
        transform: translate(-4px, 1px);
    }
    60% {
        transform: translate(3px, 2px);
    }
    80% {
        transform: translate(-3px, -2px);
    }
}

/* ASCII Art Animation - 점들이 순차적으로 나타나는 애니메이션 */
.menu-btn:hover:not(:disabled) .icon-text {
    overflow: visible;
}
.menu-btn:hover:not(:disabled) .icon-text .ascii-dot:nth-child(1) {
    animation: asciiPop 0.6s ease 0s forwards;
    opacity: 0;
}
.menu-btn:hover:not(:disabled) .icon-text .ascii-dot:nth-child(2) {
    animation: asciiPop 0.6s ease 0.1s forwards;
    opacity: 0;
}
.menu-btn:hover:not(:disabled) .icon-text .ascii-dot:nth-child(3) {
    animation: asciiPop 0.6s ease 0.2s forwards;
    opacity: 0;
}
.menu-btn:hover:not(:disabled) .icon-text .ascii-dot:nth-child(4) {
    animation: asciiPop 0.6s ease 0.3s forwards;
    opacity: 0;
}
.menu-btn:hover:not(:disabled) .icon-text .ascii-dot:nth-child(5) {
    animation: asciiPop 0.6s ease 0.4s forwards;
    opacity: 0;
}
.menu-btn:hover:not(:disabled) .icon-text .ascii-dot:nth-child(6) {
    animation: asciiPop 0.6s ease 0.5s forwards;
    opacity: 0;
}
.menu-btn:hover:not(:disabled) .icon-text .ascii-dot:nth-child(7) {
    animation: asciiPop 0.6s ease 0.6s forwards;
    opacity: 0;
}
.menu-btn:hover:not(:disabled) .icon-text .ascii-dot:nth-child(8) {
    animation: asciiPop 0.6s ease 0.7s forwards;
    opacity: 0;
}
.menu-btn:hover:not(:disabled) .icon-text .ascii-dot:nth-child(9) {
    animation: asciiPop 0.6s ease 0.8s forwards;
    opacity: 0;
}
@keyframes asciiPop {
    0% {
        opacity: 0;
        transform: scale(0);
    }
    50% {
        transform: scale(1.3);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* Circle Cut Animation - 버블들이 튀는 애니메이션 */
.menu-btn:hover:not(:disabled) .icon-bubble {
    overflow: visible;
}
.menu-btn:hover:not(:disabled) .icon-bubble .bubble:nth-child(1) {
    transform: translate(-2px, -2px) scale(1.1);
    transition: transform 0.3s ease;
}
.menu-btn:hover:not(:disabled) .icon-bubble .bubble:nth-child(2) {
    transform: translate(2px, -1px) scale(1.15);
    transition: transform 0.3s ease 0.1s;
}
.menu-btn:hover:not(:disabled) .icon-bubble .bubble:nth-child(3) {
    transform: translate(0, -3px) scale(1.2);
    transition: transform 0.3s ease 0.2s;
}

/* Original Upload Animation - 이미지가 나타나는 애니메이션 */
.menu-btn:hover:not(:disabled) .icon-image {
    overflow: visible;
}
.menu-btn:hover:not(:disabled) .icon-image .image-dot {
    transform: scale(1.3);
    opacity: 0.8;
    transition: transform 0.3s ease, opacity 0.3s ease;
}
.menu-btn:hover:not(:disabled) .icon-image .image-line {
    stroke-dasharray: 20;
    stroke-dashoffset: 0;
    animation: lineDraw 0.6s ease forwards;
}
@keyframes lineDraw {
    from {
        stroke-dashoffset: 20;
    }
    to {
        stroke-dashoffset: 0;
    }
}

/* Upload Loading Overlay */
.upload-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
}

.upload-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: var(--neon-yellow);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Upload Modal */
.upload-modal {
    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: 10001;
}

.upload-modal-content {
    background-color: var(--color-gray);
    max-width: 90vw;
    width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.upload-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
}

.upload-modal-header h3 {
    margin: 0;
}

.upload-modal-close {
    background: none;
    border: none;
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.upload-modal-body {
    padding: 1rem;
    overflow-y: auto;
    flex: 1;
}

.upload-image-preview-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1rem;
    justify-content: center;
    align-items: center;
}

.upload-image-preview {
    position: relative;
    width: 100%;
    max-width: 100%;
    height: auto;
    display: flex;
    justify-content: center;
    align-items: center;
}

.upload-image-preview img {
    width: 100%;
    height: auto;
    max-height: 80vh;
    object-fit: contain;
    display: block;
}

.upload-image-preview button {
    display: none !important;
    border: none;
}

.upload-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 1rem;
}

.upload-modal-footer .btn {
    padding: 0.5rem 1rem;
}

/* ASCII Message Modal */
.ascii-preview-container {
    max-height: 300px;
    overflow: auto;
    padding: 1rem;
    background-color: rgba(0, 0, 0, 0.1);
    margin-bottom: 1rem;
}

.ascii-preview-text {
    font-family: 'Courier New', monospace;
    font-size: 8px;
    line-height: 8px;
    margin: 0;
    white-space: pre;
    word-wrap: normal;
    overflow-x: auto;
}


