:root {
    --bg-color: #f4f0ec; /* Old paper */
    --text-color: #111;
    --accent: #ff3300;
}

* {
    box-sizing: border-box;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none; /* Prevent scrolling, handle touches in JS */
}

body, html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    background-color: var(--bg-color);
    overflow: hidden;
    font-family: 'Courier New', Courier, monospace;
}

/* Background texture simulation */
body::before {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-image: 
        radial-gradient(#ccc 1px, transparent 1px),
        radial-gradient(#ccc 1px, transparent 1px);
    background-position: 0 0, 20px 20px;
    background-size: 40px 40px;
    opacity: 0.3;
    z-index: -1;
}

#collage-board {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* Draggable Collage Items */
.collage-item {
    position: absolute;
    cursor: grab;
    box-shadow: 4px 4px 0px rgba(0,0,0,0.2);
    border: 2px solid var(--text-color);
    background: white;
    padding: 10px;
    will-change: transform, left, top;
}

.collage-item:active {
    cursor: grabbing;
    box-shadow: 8px 8px 0px rgba(0,0,0,0.3);
    z-index: 1000 !important;
}

.text-item {
    max-width: 80vw;
    word-wrap: break-word;
    font-size: 1.2rem;
    line-height: 1.1;
    text-transform: uppercase;
}

.image-item {
    padding: 0;
    background: transparent;
    border: none;
    box-shadow: none;
}

.image-item img {
    max-width: 60vw;
    max-height: 40vh;
    display: block;
    filter: grayscale(100%) contrast(150%) brightness(90%); /* Dada photocopy look */
    mix-blend-mode: multiply;
}

/* Specific styling for words added dynamically */
.word-fragment {
    display: inline-block;
    background: black;
    color: white;
    padding: 2px 5px;
    margin: 2px;
}

/* Controls */
#controls {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    width: 90%;
    z-index: 2000;
}

button {
    background: white;
    color: black;
    border: 3px solid black;
    padding: 12px 15px;
    font-family: 'Impact', fantasy, sans-serif;
    font-size: 1.1rem;
    text-transform: uppercase;
    cursor: pointer;
    box-shadow: 4px 4px 0px black;
    transition: all 0.1s;
}

button:active {
    transform: translate(4px, 4px);
    box-shadow: 0px 0px 0px black;
}

button.danger {
    background: var(--accent);
    color: white;
}

/* Loading Overlay */
#loading {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.8);
    color: white;
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
}

#loading.hidden {
    display: none;
}

.loading-text {
    font-size: 2rem;
    font-weight: bold;
    font-family: 'Courier New', Courier, monospace;
    animation: jitter 0.2s infinite;
}

@keyframes jitter {
    0% { transform: translate(2px, 2px) rotate(0deg); color: white; }
    25% { transform: translate(-2px, -2px) rotate(-2deg); color: var(--accent); }
    50% { transform: translate(2px, -2px) rotate(2deg); color: white; }
    75% { transform: translate(-2px, 2px) rotate(-1deg); color: yellow; }
    100% { transform: translate(0px, 0px) rotate(0deg); color: white; }
}

/* Random fonts used by JS */
.font-1 { font-family: 'Courier New', monospace; }
.font-2 { font-family: 'Impact', sans-serif; }
.font-3 { font-family: 'Times New Roman', serif; }
.font-4 { font-family: 'Arial', sans-serif; font-weight: bold; }
.font-5 { font-family: 'Georgia', serif; font-style: italic; }