/* Quiosco táctil: dedo grande, sin zoom accidental, sin selección */

html, body {
    height: 100%;
    overscroll-behavior: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

img, svg {
    -webkit-user-drag: none;
    user-select: none;
    pointer-events: none;
}

button, a, label, .game-card, .card, .char-btn, .image-option, .level-card, .option-btn, .option-button {
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
}

button img, .char-btn img, .game-card img, .image-option img, .card img, a img {
    pointer-events: none;
}

button,
.btn-large,
.game-controls button,
.back-button,
.play-button,
.start-button,
.start-btn,
.next-button,
.action-button,
.option-btn,
.option-button,
.tool-btn {
    min-height: 56px;
}

.game-controls button,
.back-button,
.btn-small {
    min-height: 56px;
    padding: 12px 22px;
    font-size: 1.15rem;
    border-radius: 14px;
}

.btn-large,
.start-button,
.start-btn,
.play-button {
    min-height: 64px;
    font-size: 1.35rem;
}

.game-card:active,
.char-btn:active,
.card:active,
.option-btn:active,
.option-button:active,
.btn-large:active,
.image-option:active,
.level-card:active .card-content,
.color-btn:active,
.tool-btn:active,
.play-button:active,
.close-btn:active {
    transform: scale(0.97);
    filter: brightness(0.96);
}

/* Arrastre con el dedo */
.touch-draggable {
    touch-action: none;
    cursor: grab;
}

.touch-draggable.is-dragging {
    opacity: 0.35;
}

.touch-ghost {
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    margin: 0;
    pointer-events: none;
    opacity: 0.95;
    transform: translate(-50%, -58%) scale(1.06);
    filter: drop-shadow(0 14px 18px rgba(0, 0, 0, 0.35));
    touch-action: none;
}

.game-piece.is-selected,
.clothing-item.is-selected,
.card.selected {
    outline: 4px solid #e0a100;
    outline-offset: 3px;
}

.drop-zone {
    touch-action: manipulation;
}

.drop-zone.touch-drop-hover,
.base-figure.touch-drop-hover,
#drop-zone-main.touch-drop-hover {
    background: rgba(46, 139, 87, 0.28) !important;
    box-shadow: inset 0 0 0 4px #2e8b57, 0 0 0 6px rgba(46, 139, 87, 0.25);
}

.touch-hint {
    margin: 8px auto 0;
    max-width: 820px;
    text-align: center;
    color: #5a3a22;
    font-size: 1.15rem;
    font-weight: 700;
    line-height: 1.35;
    background: rgba(255, 248, 220, 0.92);
    border: 2px solid #deb887;
    border-radius: 16px;
    padding: 10px 16px;
}

/* El menú se puede recorrer con el dedo si no cabe */
.kiosk-container {
    height: 100vh;
    height: 100dvh;
    min-height: 0;
}

.games-menu {
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    align-items: flex-start;
    min-height: 0;
}

.games-grid {
    margin: auto;
}

/* Juegos: lo que no quepa se desplaza, no se corta */
.game-container {
    height: 100vh;
    height: 100dvh;
    min-height: 0;
}

#level-selection,
#selection-screen,
#start-screen,
#startScreen.screen.active,
#gameScreen.screen.active,
.game-area,
.construction-area {
    -webkit-overflow-scrolling: touch;
}

.construction-area {
    min-height: 0;
}

.inventory-panel,
.info-panel,
.wardrobe,
.pieces-container {
    -webkit-overflow-scrolling: touch;
}

.game-piece {
    width: 112px;
    height: 112px;
    touch-action: none;
}

.clothing-item {
    width: 148px;
    height: 148px;
    touch-action: none;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.88);
    border: 3px solid rgba(139, 69, 19, 0.4);
    border-radius: 18px;
    padding: 8px;
    box-sizing: border-box;
}

.top-info {
    flex-wrap: wrap;
    gap: 10px 16px;
}

@media (max-height: 1200px) {
    .quiz-container .start-content {
        padding: 18px 22px;
    }

    .quiz-container .level-options {
        flex-direction: row;
        align-items: stretch;
    }

    .quiz-container .level-card {
        flex: 1;
    }

    .quiz-container .level-card .card-content {
        min-height: 0;
        padding: 16px 12px;
    }

    .quiz-container .game-instructions {
        margin-bottom: 8px;
        padding: 12px 16px;
    }

    .quiz-container .start-button {
        margin-top: 14px;
    }
}

.card {
    min-height: 92px;
    padding: 18px 20px;
}

.card-text {
    font-size: 1.2rem;
}

.option-btn {
    min-height: 72px;
    font-size: 1.3rem;
}

.color-btn {
    width: 68px;
    height: 68px;
}

.image-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
    margin-top: 24px;
}

.image-option {
    min-width: 220px;
    min-height: 180px;
}

.close-btn {
    width: 64px;
    height: 64px;
    font-size: 1.7rem;
}

/* Constructor: la silueta se adapta y las piezas quedan a mano */
.church-silhouette {
    width: min(800px, 100%) !important;
    height: auto !important;
    aspect-ratio: 4 / 3;
    max-height: calc(100dvh - 120px);
}

.workspace {
    min-width: 0;
    min-height: 0;
}

@media (max-width: 1200px) {
    .construction-area {
        flex-direction: column;
        overflow-y: auto;
    }

    .inventory-panel,
    .info-panel {
        width: 100%;
        height: auto;
        max-height: none;
        flex-direction: column;
        border: none;
        border-bottom: 3px solid #8b4513;
        flex-shrink: 0;
    }

    .inventory-panel {
        order: 2;
    }

    .workspace {
        order: 1;
        min-height: 280px;
    }

    .info-panel {
        order: 3;
    }

    .pieces-container {
        flex-wrap: nowrap;
        justify-content: flex-start;
        overflow-x: auto;
        overflow-y: hidden;
        min-height: 130px;
        padding-bottom: 8px;
    }

    .game-piece {
        flex: 0 0 auto;
    }

    .church-silhouette {
        max-height: 52dvh;
    }
}

@media (max-width: 1100px) {
    .dressing-room {
        flex: 0 0 auto;
        flex-direction: column;
        justify-content: flex-start;
        gap: 12px;
        overflow: visible;
        max-width: none;
    }

    .character-stage {
        width: 100%;
        order: 1;
        min-height: 0;
        flex: 0 0 auto;
    }

    .wardrobe {
        width: 100%;
        flex-direction: row;
        justify-content: flex-start;
        overflow-x: auto;
        overflow-y: hidden;
        gap: 16px;
        min-height: 170px;
        height: auto;
    }

    #wardrobe-left { order: 2; }
    #wardrobe-right { order: 3; }

    .base-figure {
        width: min(280px, 56vw);
        height: min(420px, 34dvh);
    }
}

@media (max-height: 1100px) and (min-width: 1101px) {
    .base-figure {
        width: min(280px, 26vw);
        height: min(420px, calc(100dvh - 250px));
    }

    .char-btn img {
        height: 120px;
    }

    .char-btn {
        width: 160px;
    }
}

/* Pintar: el lienzo cabe en la pantalla y el dedo no desplaza la página */
#canvas {
    width: min(800px, calc(100vw - 32px), calc((100dvh - 300px) * 1.6));
    height: auto;
    touch-action: none;
}

.game-area,
.association-area {
    flex: 1;
    height: auto !important;
    min-height: 0;
    overflow-y: auto;
}

html:has(.quiz-container),
html:has(.quiz-container) body {
    height: auto;
    min-height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
}

.game-container > .screen.active {
    display: block;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.palette {
    gap: 16px;
}

.tool-btn {
    min-width: 120px;
    min-height: 88px;
}
