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

body {
    font-family: 'Courier New', monospace;
    background: white;
    color: black;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Animated floating background elements */
.floating-elements {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.floating-char {
    position: absolute;
    font-family: 'Courier New', monospace;
    font-size: 2.5rem;
    color: rgba(0, 0, 0, 0.06);
    animation: float 20s infinite ease-in-out;
    user-select: none;
}

@keyframes float {
    0%, 100% {
        transform: translateY(0) translateX(0) rotate(0deg);
    }
    25% {
        transform: translateY(-30px) translateX(20px) rotate(5deg);
    }
    50% {
        transform: translateY(20px) translateX(-20px) rotate(-5deg);
    }
    75% {
        transform: translateY(-20px) translateX(30px) rotate(3deg);
    }
}

.container {
    width: 100%;
    min-height: 100vh;
    position: relative;
}

/* Sections */
.section {
    display: none;
    min-height: 100vh;
    padding: 40px 20px;
    position: relative;
}

.section.active {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* Typography */
h1 {
    font-size: 2.5rem;
    font-weight: normal;
    letter-spacing: 0.2em;
    margin-bottom: 10px;
    position: relative;
    z-index: 1;
}

.subtitle {
    font-size: 0.9rem;
    opacity: 0.6;
    margin-bottom: 40px;
    letter-spacing: 0.05em;
}

/* Handle Input Section */
.input-container {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    position: relative;
    width: 100%;
    max-width: 600px;
    z-index: 1;
}

.input-wrapper {
    position: relative;
    flex: 1;
    width: 100%;
}

#handle-input {
    width: 100%;
    padding: 12px 15px;
    font-size: 1rem;
    font-family: 'Courier New', monospace;
    background: white;
    border: 2px solid black;
    outline: none;
}

#handle-input:focus {
    border-width: 3px;
    padding: 11px 14px;
}

/* Autocomplete Dropdown */
.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 2px solid black;
    border-top: none;
    max-height: 200px;
    overflow-y: auto;
    display: none;
    z-index: 100;
}

.autocomplete-dropdown.show {
    display: block;
}

.autocomplete-item {
    padding: 10px 15px;
    cursor: pointer;
    border-bottom: 1px solid #ddd;
    display: flex;
    flex-direction: column;
}

.autocomplete-item:hover {
    background: #f0f0f0;
}

.autocomplete-item.selected {
    background: #f0f0f0;
}

.autocomplete-handle {
    font-weight: bold;
    font-size: 0.95rem;
}

.autocomplete-name {
    font-size: 0.85rem;
    opacity: 0.7;
    margin-top: 2px;
}

/* Buttons */
.btn {
    padding: 12px 30px;
    font-size: 0.9rem;
    font-family: 'Courier New', monospace;
    background: black;
    color: white;
    border: 2px solid black;
    cursor: pointer;
    letter-spacing: 0.1em;
    transition: all 0.2s ease;
}

.btn:hover:not(:disabled) {
    background: white;
    color: black;
}

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

/* Pulse animation for share button */
.btn.pulse {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(0, 0, 0, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(0, 0, 0, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(0, 0, 0, 0);
    }
}

.btn.secondary {
    background: white;
    color: black;
}

.btn.secondary:hover {
    background: black;
    color: white;
}

/* Game Section */
.game-header {
    text-align: center;
    position: fixed;
    top: 40px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
}

.handle-display {
    font-size: 1rem;
    margin: 10px 0;
    opacity: 0.8;
}

.handle-display span {
    font-weight: bold;
}

/* DID Assembly Area */
.did-assembly-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 100;
    background: white;
    padding: 30px;
    border: 3px solid black;
}

.did-assembly {
    display: flex;
    align-items: center;
    min-height: 60px;
    font-family: 'Courier New', monospace;
    font-size: 1.2rem;
}

.did-prefix {
    font-weight: bold;
    margin-right: 5px;
}

.drop-zone {
    display: flex;
    gap: 4px;
}

.drop-slot {
    width: 40px;
    height: 40px;
    border: 2px dashed black;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    position: relative;
}

.drop-slot.drag-over {
    background: #f0f0f0;
    border-style: solid;
}

.drop-slot.filled {
    border-style: solid;
}

/* Scattered Tiles */
.tiles-area {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 200;
}

.tile {
    width: 40px;
    height: 40px;
    background: white;
    border: 2px solid black;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Courier New', monospace;
    font-size: 1.2rem;
    font-weight: bold;
    cursor: grab;
    user-select: none;
    position: absolute;
    pointer-events: auto;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    z-index: 500;
}

.tile:hover {
    transform: scale(1.1);
    box-shadow: 3px 3px 0 rgba(0,0,0,0.3);
    z-index: 100;
}

.tile.dragging {
    cursor: grabbing;
    opacity: 0.5;
    z-index: 1000;
}

.tile.placed {
    position: static;
    pointer-events: auto;
}

/* Controls */
.controls {
    position: fixed;
    bottom: 60px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 20px;
    z-index: 10;
}

.progress {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.9rem;
    opacity: 0.6;
    z-index: 10;
}

/* Result Sections */
.result-content {
    text-align: center;
}

.failure-message {
    margin-bottom: 10px;
}

.failure-sarcasm {
    font-size: 0.9rem;
    opacity: 0.6;
    font-style: italic;
    margin-bottom: 40px;
}

.did-result {
    background: #f5f5f5;
    border: 2px solid black;
    padding: 20px;
    margin: 20px 0;
    font-family: 'Courier New', monospace;
}

.did-result code {
    font-size: 1.1rem;
    word-break: break-all;
}

/* Result grid and stats */
.result-grid {
    background: #f9f9f9;
    border: 2px solid #ddd;
    padding: 20px;
    margin: 20px auto;
    font-family: 'Courier New', monospace;
    font-size: 1.1rem;
    letter-spacing: 0.1em;
    line-height: 1.8;
    max-width: 600px;
}

.result-stats {
    font-family: 'Courier New', monospace;
    font-size: 0.95rem;
    margin: 15px 0 25px;
    line-height: 1.6;
    opacity: 0.8;
}

/* Error Message */
.error-message {
    color: black;
    font-size: 0.9rem;
    margin-top: 10px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.error-message.show {
    opacity: 1;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-overlay.show {
    display: flex;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #ddd;
    border-top-color: black;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Small button for back navigation */
.btn-small {
    padding: 8px 16px;
    font-size: 0.8rem;
    font-family: 'Courier New', monospace;
    background: white;
    color: black;
    border: 2px solid black;
    cursor: pointer;
    letter-spacing: 0.05em;
    transition: all 0.2s ease;
}

.btn-small:hover {
    background: black;
    color: white;
}

/* Inverted style for hint button */
.btn-small.inverted {
    background: black;
    color: white;
}

.btn-small.inverted:hover {
    background: white;
    color: black;
}

/* Game navigation buttons container */
.game-nav-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 15px;
}

/* Footer */
.footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 20px;
    text-align: center;
    font-size: 0.85rem;
    opacity: 0.7;
    background: white;
    border-top: 1px solid rgba(0,0,0,0.1);
}

.footer-content {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 5px;
}

.footer a {
    color: black;
    text-decoration: underline;
    transition: opacity 0.2s ease;
}

.footer a:hover {
    opacity: 0.6;
}

.footer .separator {
    margin: 0 10px;
    opacity: 0.4;
}

/* Button group for multiple buttons */
.button-group {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 20px;
}

/* Share copied notification */
.share-copied {
    margin-top: 15px;
    font-size: 0.9rem;
    color: black;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.share-copied.show {
    opacity: 0.7;
}

/* Touch indicator for mobile */
.touch-indicator {
    position: fixed;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.95);
    border: 3px solid black;
    display: none;
    pointer-events: none;
    z-index: 1001;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    font-weight: bold;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
    transform: translate(-50%, -120%);
}

.touch-indicator.show {
    display: flex;
}

/* Mobile Adjustments */
@media (max-width: 768px) {
    /* Lighter floating characters on mobile */
    .floating-char {
        color: rgba(0, 0, 0, 0.05);
    }

    h1 {
        font-size: 1.8rem;
        letter-spacing: 0.1em;
    }

    .game-header {
        top: 20px;
        padding: 0 20px;
        width: 100%;
        text-align: center;
        z-index: 150;
        background: white;
    }

    .game-header h1 {
        font-size: 1.5rem;
        white-space: nowrap;
    }

    .game-header .subtitle {
        font-size: 0.75rem;
        white-space: nowrap;
    }

    .handle-display {
        font-size: 0.85rem;
        white-space: nowrap;
    }

    .btn-small {
        padding: 6px 12px;
        font-size: 0.7rem;
    }

    .game-nav-buttons {
        margin-top: 10px;
    }

    /* Handle input on mobile */
    .input-container {
        max-width: 90%;
        flex-direction: column;
        gap: 15px;
    }

    .input-wrapper {
        width: 100%;
    }

    #handle-input {
        font-size: 1rem;
        padding: 15px;
    }

    .btn {
        width: 100%;
        padding: 15px;
    }

    /* DID Assembly on mobile - allow wrapping */
    .did-assembly-container {
        width: 90%;
        max-width: 90%;
        padding: 15px;
        top: 50%;
        z-index: 50;
    }

    .did-assembly {
        flex-wrap: wrap;
        justify-content: center;
        gap: 5px;
        font-size: 0.9rem;
    }

    .did-prefix {
        width: 100%;
        text-align: center;
        margin-bottom: 10px;
        font-size: 0.8rem;
    }

    .drop-zone {
        display: grid;
        grid-template-columns: repeat(auto-fill, 32px);
        justify-content: center;
        gap: 4px;
        max-width: 100%;
        padding: 5px;
    }

    .tile, .drop-slot {
        width: 32px;
        height: 32px;
        font-size: 0.9rem;
        border-width: 2px;
    }

    .drop-slot {
        margin: 0;
    }

    /* Ensure drop slots maintain square shape */
    .drop-slot.drag-over {
        border-width: 2px;
        background: rgba(0, 0, 0, 0.1);
    }

    /* Controls at bottom */
    .controls {
        bottom: 80px;
        gap: 10px;
        width: 90%;
    }

    .controls .btn {
        padding: 12px 20px;
        font-size: 0.85rem;
    }

    .progress {
        bottom: 50px;
        font-size: 0.8rem;
    }

    /* Footer on mobile */
    .footer {
        padding: 15px 10px;
        font-size: 0.75rem;
    }

    .footer .separator {
        display: inline;
        margin: 0 5px;
    }

    .footer-content {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        gap: 3px;
    }

    /* Button groups on mobile */
    .button-group {
        width: 90%;
        flex-direction: column;
        gap: 10px;
    }

    .button-group .btn {
        width: 100%;
    }

    /* Results on mobile */
    .result-content {
        padding: 0 20px;
    }

    .did-result {
        padding: 15px;
        font-size: 0.9rem;
    }

    .did-result code {
        font-size: 0.85rem;
        word-break: break-all;
    }
}