* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    background: #0a0a0a;
    color: #e0e0e0;
    font-family: 'Georgia', serif;
    min-height: 100vh;
    overflow: hidden;
}

#container {
    max-width: 800px;
    margin: 0 auto;
    padding: 40px 20px;
    min-height: 100vh;
    position: relative;
}

#header {
    text-align: center;
    margin-bottom: 40px;
}

#header h1 {
    font-size: 2rem;
    font-weight: normal;
    letter-spacing: 0.1em;
    color: #888;
}

/* Intro */
#intro {
    text-align: center;
    padding: 60px 20px;
}

#intro-text {
    font-size: 1.1rem;
    line-height: 1.8;
    color: #aaa;
    max-width: 500px;
    margin: 0 auto 40px;
}

#intro-text p {
    margin-bottom: 1em;
}

#begin-btn {
    background: transparent;
    border: 1px solid #444;
    color: #888;
    padding: 12px 40px;
    font-family: inherit;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

#begin-btn:hover {
    border-color: #666;
    color: #ccc;
}

/* Workspace */
#workspace {
    display: none;
    padding: 20px;
}

#instruction {
    text-align: center;
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 30px;
    font-style: italic;
}

#canvas {
    position: relative;
    width: 100%;
    height: 400px;
    border: 1px solid #222;
    background: #0d0d0d;
    border-radius: 4px;
    overflow: hidden;
}

.fragment {
    position: absolute;
    padding: 12px 20px;
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 3px;
    cursor: grab;
    font-size: 0.95rem;
    color: #ccc;
    user-select: none;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.fragment:hover {
    border-color: #555;
}

.fragment.dragging {
    cursor: grabbing;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
    z-index: 100;
}

.fragment.changed {
    animation: pulse-changed 0.5s ease;
}

@keyframes pulse-changed {
    0%, 100% { border-color: #333; }
    50% { border-color: #664422; }
}

.fragment.new {
    animation: fade-in 0.5s ease;
}

@keyframes fade-in {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

#action-count {
    text-align: center;
    margin-top: 20px;
    color: #444;
    font-size: 0.8rem;
}

/* Gap overlay */
#gap-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 1s ease;
    z-index: 200;
}

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

#gap-text {
    color: #444;
    font-size: 1rem;
    text-align: center;
}

#gap-text p {
    margin-bottom: 0.5em;
    animation: fade-pulse 2s ease infinite;
}

@keyframes fade-pulse {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.7; }
}

/* Return message */
#return-message {
    display: none;
    text-align: center;
    padding: 60px 20px;
}

#return-text {
    font-size: 1rem;
    line-height: 1.8;
    color: #888;
    max-width: 500px;
    margin: 0 auto 40px;
}

#return-text p {
    margin-bottom: 1em;
}

#return-text .time-passed {
    color: #664422;
    font-style: italic;
}

#return-choices {
    display: flex;
    gap: 20px;
    justify-content: center;
    flex-wrap: wrap;
}

.return-choice {
    background: transparent;
    border: 1px solid #333;
    color: #777;
    padding: 10px 30px;
    font-family: inherit;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.return-choice:hover {
    border-color: #555;
    color: #aaa;
}

/* Examination */
#examination {
    display: none;
    text-align: center;
    padding: 40px 20px;
}

#exam-text {
    font-size: 0.95rem;
    line-height: 1.9;
    color: #777;
    max-width: 550px;
    margin: 0 auto 40px;
}

#exam-text p {
    margin-bottom: 1.2em;
}

#exam-text .diff {
    color: #886644;
    font-style: italic;
}

#exam-continue {
    background: transparent;
    border: 1px solid #333;
    color: #666;
    padding: 10px 30px;
    font-family: inherit;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

#exam-continue:hover {
    border-color: #555;
    color: #999;
}

/* Ending */
#ending {
    display: none;
    text-align: center;
    padding: 60px 20px;
}

#ending-text {
    font-size: 1rem;
    line-height: 1.9;
    color: #888;
    max-width: 550px;
    margin: 0 auto 40px;
}

#ending-text p {
    margin-bottom: 1.2em;
    opacity: 0;
    animation: fadeInUp 0.6s ease forwards;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#contributors {
    margin: 40px auto;
    max-width: 400px;
}

.contributor {
    padding: 15px;
    margin-bottom: 10px;
    background: #111;
    border-left: 2px solid #333;
    text-align: left;
    opacity: 0;
    animation: fadeInUp 0.5s ease forwards;
}

.contributor .label {
    font-size: 0.8rem;
    color: #555;
    margin-bottom: 5px;
}

.contributor .actions {
    font-size: 0.9rem;
    color: #888;
}

.contributor.you {
    border-left-color: #666;
}

.contributor.other {
    border-left-color: #664422;
}

#ending-choices {
    margin-top: 40px;
    opacity: 0;
    transition: opacity 0.5s ease;
}

#ending-choices.visible {
    opacity: 1;
}

.ending-choice {
    background: transparent;
    border: 1px solid #333;
    color: #666;
    padding: 10px 30px;
    font-family: inherit;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.ending-choice:hover {
    border-color: #555;
    color: #999;
}

/* Mobile */
@media (max-width: 600px) {
    #container {
        padding: 20px 15px;
    }

    #header h1 {
        font-size: 1.5rem;
    }

    #canvas {
        height: 350px;
    }

    .fragment {
        padding: 10px 15px;
        font-size: 0.85rem;
    }
}
