* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, sans-serif;
    background: #1a1a2e;
    color: #e8e8e8;
    overflow: hidden;
    height: 100vh;
    -webkit-font-smoothing: antialiased;
}

#app {
    width: 100%;
    height: 100vh;
    position: relative;
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.screen.active {
    display: flex;
    opacity: 1;
}

/* Intro Screen */
#intro-screen {
    justify-content: center;
    align-items: center;
    background: radial-gradient(ellipse at center, #1f1f3a 0%, #0d0d1a 100%);
    cursor: pointer;
}

.intro-content {
    max-width: 650px;
    text-align: center;
    padding: 40px;
    pointer-events: none;
}

.intro-content .cta-btn {
    pointer-events: auto;
}

.intro-text {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 1.5rem;
    line-height: 1.9;
    margin-bottom: 2rem;
    opacity: 0;
    color: #b8b8c8;
    font-weight: 400;
}

.intro-text.visible {
    animation: fadeIn 2s ease forwards;
}

@keyframes fadeIn {
    to { opacity: 1; }
}

.cta-btn {
    background: transparent;
    border: 1px solid #c9a227;
    color: #c9a227;
    padding: 14px 45px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
    letter-spacing: 2px;
    text-transform: uppercase;
    opacity: 0;
}

.cta-btn.visible {
    animation: fadeIn 1s ease forwards;
}

.cta-btn:hover {
    background: #c9a227;
    color: #1a1a2e;
}

/* Selection Screen */
#selection-screen {
    flex-direction: column;
    align-items: center;
    padding: 50px 30px;
    overflow-y: auto;
    background: linear-gradient(180deg, #1a1a2e 0%, #12121f 100%);
}

.screen-title {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 1.8rem;
    margin-bottom: 40px;
    color: #c9a227;
    font-weight: 400;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.puzzle-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 25px;
    max-width: 1100px;
    width: 100%;
}

.puzzle-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(201, 162, 39, 0.2);
    border-radius: 4px;
    padding: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.puzzle-card:hover {
    transform: translateY(-3px);
    border-color: #c9a227;
    background: rgba(255, 255, 255, 0.06);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.puzzle-preview {
    width: 100%;
    height: 160px;
    background-size: cover;
    background-position: center;
    filter: blur(8px) saturate(0.5);
    margin-bottom: 15px;
    border-radius: 2px;
}

.puzzle-card h3 {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 1rem;
    color: #c9a227;
    font-weight: 400;
    line-height: 1.5;
    text-align: center;
}

/* Difficulty Screen */
#difficulty-screen {
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: radial-gradient(ellipse at center, #1f1f3a 0%, #0d0d1a 100%);
}

.difficulty-options {
    display: flex;
    gap: 25px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 20px;
}

.difficulty-btn {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(201, 162, 39, 0.3);
    color: #c9a227;
    padding: 25px 45px;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    border-radius: 4px;
}

.difficulty-btn:hover {
    background: #c9a227;
    color: #1a1a2e;
    transform: scale(1.02);
}

.piece-count {
    font-size: 0.85rem;
    opacity: 0.7;
}

/* Puzzle Screen */
#puzzle-screen {
    flex-direction: column;
    background: #0f0f1a;
}

.puzzle-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 25px;
    background: rgba(0, 0, 0, 0.4);
    border-bottom: 1px solid rgba(201, 162, 39, 0.15);
}

.puzzle-hint {
    font-size: 1.1rem;
    color: #c9a227;
    font-weight: 300;
}

.puzzle-controls {
    display: flex;
    gap: 10px;
}

.control-btn {
    background: transparent;
    border: 1px solid rgba(201, 162, 39, 0.4);
    color: #c9a227;
    padding: 8px 16px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    border-radius: 3px;
}

.control-btn:hover {
    background: rgba(201, 162, 39, 0.15);
}

.puzzle-container {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.puzzle-area {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    background: #0a0a12;
}

.puzzle-board {
    position: relative;
    background: #1a1a28;
    border: 2px solid rgba(201, 162, 39, 0.3);
    border-radius: 4px;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.5), inset 0 0 30px rgba(0, 0, 0, 0.3);
}

.puzzle-board-inner {
    position: relative;
    width: 100%;
    height: 100%;
}

.board-grid {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0.2;
    pointer-events: none;
    z-index: 2;
}

.background-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    filter: blur(8px) brightness(0.4);
    opacity: 0.6;
    pointer-events: none;
    z-index: 1;
    transition: filter 0.5s ease, opacity 0.5s ease;
}

.pieces-tray {
    width: 280px;
    background: #12121f;
    border-left: 1px solid rgba(201, 162, 39, 0.15);
    display: flex;
    flex-direction: column;
}

.tray-header {
    padding: 15px 20px;
    border-bottom: 1px solid rgba(201, 162, 39, 0.1);
}

.tray-header h3 {
    color: #c9a227;
    font-weight: 400;
    font-size: 0.9rem;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.tray-header span {
    color: #666;
    font-size: 0.8rem;
    margin-left: 10px;
}

#tray-content {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
    gap: 8px;
}

.puzzle-piece {
    position: absolute;
    cursor: grab;
    transition: filter 0.2s ease;
    image-rendering: crisp-edges;
    image-rendering: -webkit-optimize-contrast;
}

.puzzle-piece:hover {
    filter: brightness(1.1);
    z-index: 100;
}

.puzzle-piece.dragging {
    cursor: grabbing;
    z-index: 1000;
    filter: brightness(1.2) drop-shadow(0 5px 15px rgba(0, 0, 0, 0.5));
}

.puzzle-piece.placed {
    cursor: default;
    filter: none;
}

.puzzle-piece.correct {
    animation: correctPlace 0.4s ease;
}

@keyframes correctPlace {
    0% { filter: brightness(1); }
    50% { filter: brightness(1.5) drop-shadow(0 0 10px rgba(201, 162, 39, 0.8)); }
    100% { filter: brightness(1); }
}

.tray-piece {
    width: 70px;
    height: 70px;
    cursor: grab;
    transition: transform 0.2s ease, filter 0.2s ease;
    image-rendering: crisp-edges;
    image-rendering: -webkit-optimize-contrast;
}

.tray-piece:hover {
    transform: scale(1.08);
    filter: brightness(1.1);
    z-index: 10;
}

.tray-piece.dragging {
    opacity: 0.5;
}

/* Completion Screen */
#completion-screen {
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    padding: 40px 20px;
    background: radial-gradient(ellipse at center, #1f1f3a 0%, #0d0d1a 100%);
    position: relative;
    overflow-y: auto;
}

.completion-content {
    max-width: 700px;
    width: 100%;
    text-align: center;
    position: relative;
    z-index: 10;
    animation: fadeInUp 0.8s ease;
    padding-bottom: 40px;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.completed-image {
    width: 100%;
    max-width: 500px;
    aspect-ratio: 4/3;
    background-size: cover;
    background-position: center;
    margin: 0 auto 25px;
    border: 2px solid #c9a227;
    border-radius: 4px;
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.4);
}

.revelation-title {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 1.4rem;
    color: #c9a227;
    margin-bottom: 18px;
    font-weight: 500;
    letter-spacing: 1px;
    padding: 0 15px;
}

.revelation-text {
    font-family: 'Roboto', sans-serif;
    font-size: 0.95rem;
    line-height: 1.8;
    color: #a8a8b8;
    margin-bottom: 30px;
    text-align: left;
    padding: 0 15px;
    font-weight: 300;
}

#celebration-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
}

/* Responsive */
@media (max-width: 900px) {
    .puzzle-container {
        flex-direction: column;
    }
    
    .pieces-tray {
        width: 100%;
        height: 180px;
        border-left: none;
        border-top: 1px solid rgba(201, 162, 39, 0.15);
    }
    
    #tray-content {
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
        flex-wrap: nowrap;
    }
    
    .tray-piece {
        flex-shrink: 0;
    }
}

@media (max-width: 600px) {
    .screen-title {
        font-size: 1.4rem;
    }
    
    .intro-text {
        font-size: 1.1rem;
    }
    
    .puzzle-header {
        flex-direction: column;
        gap: 10px;
    }
}


/* Mobile Touch Support */
@media (max-width: 768px) {
    .intro-content {
        padding: 25px;
    }
    
    .intro-text {
        font-size: 1.1rem;
        margin-bottom: 1.5rem;
    }
    
    .cta-btn {
        padding: 12px 35px;
        font-size: 0.9rem;
    }
    
    .puzzle-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 15px;
    }
    
    .puzzle-preview {
        height: 120px;
    }
    
    .puzzle-card h3 {
        font-size: 0.9rem;
    }
    
    .difficulty-options {
        gap: 15px;
    }
    
    .difficulty-btn {
        padding: 20px 35px;
        font-size: 1rem;
    }
    
    .puzzle-header {
        padding: 10px 15px;
    }
    
    .puzzle-hint {
        font-size: 0.95rem;
        text-align: center;
    }
    
    .control-btn {
        padding: 6px 12px;
        font-size: 0.75rem;
    }
    
    .puzzle-area {
        padding: 10px;
    }
    
    .pieces-tray {
        height: 150px;
    }
    
    .tray-header {
        padding: 10px 15px;
    }
    
    .tray-header h3 {
        font-size: 0.8rem;
    }
    
    #tray-content {
        padding: 10px;
        gap: 6px;
    }
    
    .tray-piece {
        width: 55px;
        height: 55px;
    }
    
    .completed-image {
        max-width: 100%;
        aspect-ratio: 4/3;
    }
    
    .revelation-title {
        font-size: 1.2rem;
    }
    
    .revelation-text {
        font-size: 0.9rem;
        line-height: 1.7;
    }
}

@media (max-width: 480px) {
    .screen-title {
        font-size: 1.2rem;
        letter-spacing: 1px;
    }
    
    .intro-text {
        font-size: 1rem;
    }
    
    .puzzle-grid {
        grid-template-columns: 1fr;
        padding: 0 10px;
    }
    
    .difficulty-options {
        flex-direction: column;
        width: 100%;
        padding: 0 30px;
    }
    
    .difficulty-btn {
        width: 100%;
    }
    
    .puzzle-controls {
        width: 100%;
        justify-content: center;
    }
    
    .tray-piece {
        width: 50px;
        height: 50px;
    }
}

/* Touch-friendly interactions */
@media (hover: none) and (pointer: coarse) {
    .puzzle-card:active {
        transform: scale(0.98);
        background: rgba(255, 255, 255, 0.08);
    }
    
    .difficulty-btn:active {
        transform: scale(0.98);
    }
    
    .cta-btn:active {
        background: #c9a227;
        color: #1a1a2e;
    }
    
    .control-btn:active {
        background: rgba(201, 162, 39, 0.2);
    }
    
    .tray-piece {
        touch-action: none;
    }
    
    .tray-piece:active {
        transform: scale(1.1);
        filter: brightness(1.2);
    }
}
