@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&family=VT323&display=swap');

/* Global reset for consistency */
* {
    box-sizing: border-box;
}

/* RETRO UPLOAD WINDOW */
.tms-container {
    max-width: 760px;
    margin: 2.5rem auto;
    padding: 2.5rem 2rem;
    background: #000814;
    border: 8px solid #ff006e;
    box-shadow: 0 0 0 10px #00f5d4, inset 0 0 60px rgba(255,0,110,0.35);
    font-family: 'VT323', monospace;
    color: #00f5d4;
    position: relative;
    overflow: hidden;
    z-index: 1;
}

.tms-container::before {
    content: "";
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(transparent 0px, transparent 3px, rgba(0,0,0,0.22) 3px, rgba(0,0,0,0.22) 6px);
    pointer-events: none;
    z-index: 0;
}

.tms-title {
    font-family: 'Press Start 2P', cursive;
    font-size: 2.4rem;
    color: #ff006e;
    text-shadow: 5px 5px 0 #00f5d4, -4px -4px 0 #ffff00, 0 0 30px #ff006e;
    text-align: center;
    margin-bottom: 2.2rem;
    letter-spacing: 3px;
    position: relative;
    z-index: 1;
}

.tms-upload-box {
    border: 6px dashed #00f5d4;
    padding: 4rem 1.5rem;
    text-align: center;
    background: rgba(0,245,212,0.06);
    transition: all 0.35s;
    position: relative;
    z-index: 1;
}

.tms-upload-box:hover {
    border-color: #ff006e;
    background: rgba(255,0,110,0.18);
    box-shadow: 0 0 40px #ff006e;
}

.tms-upload-label {
    font-size: 1.7rem;
    color: #ffff00;
    cursor: pointer;
    text-shadow: 2px 2px 0 #000;
}

.tms-preview {
    margin: 2rem auto;
    max-width: 100%;
    border: 10px solid #ffff00;
    box-shadow: 0 0 35px #ffff00, inset 0 0 25px rgba(255,0,110,0.5);
    border-radius: 6px;
    overflow: hidden;
    background: #000;
    position: relative;
    z-index: 1;
}

.tms-controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
    margin: 1.5rem 0;
    position: relative;
    z-index: 1;
}

.tms-select {
    padding: 0.8rem 1.2rem;
    font-size: 1.1rem;
    border: 3px solid #ffff00;
    background: #000;
    color: #00f5d4;
    font-family: 'VT323', monospace;
    min-width: 180px;
}

.tms-btn {
    font-family: 'Press Start 2P', cursive !important;
    font-size: 1.1rem !important;
    padding: 1.1rem 2.2rem !important;
    margin: 0.5rem !important;
    border: 5px solid #000 !important;
    background: linear-gradient(135deg, #ff006e, #00f5d4, #ffff00) !important;
    background-size: 300% 300% !important;
    color: white !important;
    text-shadow: 3px 3px 0 #000 !important;
    box-shadow: 8px 8px 0 #000, inset 4px 4px rgba(255,255,255,0.25) !important;
    cursor: pointer !important;
    transition: all 0.18s !important;
    animation: gradientShift 12s ease infinite !important;
    position: relative !important;
    z-index: 1 !important;
}

@keyframes gradientShift {
    0%   { background-position: 0% 50%; }
    50%  { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.tms-btn:hover {
    transform: translate(5px, 5px) !important;
    box-shadow: 3px 3px 0 #000, 0 0 35px #ff006e !important;
}

.tms-message {
    text-align: center;
    font-size: 1.4rem;
    color: #ffff00;
    text-shadow: 2px 2px 0 #ff006e;
    min-height: 1.6rem;
    margin-top: 1rem;
    position: relative;
    z-index: 1;
}

.tms-message.error {
    color: #ff3366;
    text-shadow: 2px 2px 0 #000;
}

/* POLAROID GALLERY */
.tms-gallery-wrapper {
    max-width: 1280px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

.tms-gallery-header {
    font-family: 'Press Start 2P', cursive;
    font-size: 2rem;
    color: #ff006e;
    text-align: center;
    margin: 2rem 0 1.5rem;
    text-shadow: 3px 3px 0 #00f5d4;
    letter-spacing: 2px;
}

.tms-polaroid-masonry {
    column-count: 4;
    column-gap: 2.5rem;
}

.tms-polaroid-item {
    break-inside: avoid;
    margin-bottom: 3rem;
    position: relative;
}

.tms-polaroid-frame {
    background: #f9f5f0;
    padding: 1.2rem 1.2rem 3.2rem;
    box-shadow: 0 8px 20px rgba(0,0,0,0.25), inset 0 0 0 1px #e0d8c8;
    transform: rotate(1.2deg);
    transition: transform 0.35s ease, box-shadow 0.35s ease;
}

.tms-polaroid-item:nth-child(3n) .tms-polaroid-frame { transform: rotate(-1.4deg); }
.tms-polaroid-item:nth-child(5n) .tms-polaroid-frame { transform: rotate(1.8deg); }

.tms-polaroid-item:hover .tms-polaroid-frame {
    transform: translateY(-8px) rotate(0deg);
    box-shadow: 0 16px 40px rgba(0,0,0,0.35);
}

.tms-polaroid-photo {
    width: 100%;
    height: auto;
    display: block;
    background: #000;
    filter: contrast(1.08) brightness(0.96) saturate(0.92) sepia(0.08);
    box-shadow: inset 0 0 40px rgba(0,0,0,0.45), 0 0 0 1px rgba(0,0,0,0.15);
    position: relative;
    cursor: pointer;
}

.tms-polaroid-photo::before,
.tms-polaroid-photo::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.tms-polaroid-photo::before {
    background: radial-gradient(circle at 20% 30%, transparent 20%, rgba(0,0,0,0.15) 60%),
                radial-gradient(circle at 80% 70%, transparent 15%, rgba(0,0,0,0.12) 55%);
    opacity: 0.6;
    mix-blend-mode: multiply;
}

.tms-polaroid-photo::after {
    background: linear-gradient(45deg, transparent 48%, rgba(255,255,255,0.05) 50%, transparent 52%),
                linear-gradient(-35deg, transparent 45%, rgba(0,0,0,0.03) 50%, transparent 55%);
    opacity: 0.7;
}

.tms-polaroid-caption {
    margin-top: 1.4rem;
    text-align: center;
    font-family: 'Courier New', monospace;
    font-size: 1.05rem;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-shadow: 0 1px 0 #fff;
}

/* Lightbox – improved mobile support */
.tms-lightbox {
    position: fixed !important;
    inset: 0 !important;
    z-index: 99999 !important;
    background: rgba(0,0,0,0.92) !important;
    display: none !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 20px !important;
}

.tms-lightbox.active {
    display: flex !important;
}

.tms-lightbox-content {
    max-width: 96% !important;
    max-height: 90vh !important;
    object-fit: contain !important;
    border-radius: 8px !important;
    background: #000 !important;
}

.tms-lightbox-close {
    position: absolute !important;
    top: 25px !important;
    right: 35px !important;
    color: white !important;
    font-size: 50px !important;
    cursor: pointer !important;
    line-height: 1 !important;
    padding: 20px !important; /* larger touch area on mobile */
}

.tms-lightbox-close:hover {
    color: #ff3366 !important;
}

.tms-load-more-wrapper {
    text-align: center;
    margin: 3rem 0 1rem;
}

#tms-load-more {
    font-family: 'Press Start 2P', cursive;
    font-size: 1rem;
    padding: 1rem 2.5rem;
    background: linear-gradient(135deg, #00f5d4, #ff006e);
    color: white;
    border: 4px solid #000;
    box-shadow: 6px 6px 0 #000;
    cursor: pointer;
    transition: all 0.2s;
}

#tms-load-more:hover {
    transform: translate(3px, 3px);
    box-shadow: 3px 3px 0 #000;
    background: linear-gradient(135deg, #ff006e, #00f5d4);
}

#tms-load-more:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Responsive */
@media (max-width: 1100px) { .tms-polaroid-masonry { column-count: 3; } }
@media (max-width: 768px)  { .tms-polaroid-masonry { column-count: 2; } }
@media (max-width: 500px)  { .tms-polaroid-masonry { column-count: 1; } }