* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
    overflow: hidden;
}

body {
    font-family: Arial, Helvetica, "Liberation Sans", FreeSans, sans-serif;
    background:
        radial-gradient(circle at 50% 42%, rgba(255, 232, 195, 0.22), transparent 34%),
        #a97854;
    color: #f7ead7;
    cursor: pointer;
}

button,
input,
select {
    font: inherit;
}

button {
    border: 1px solid rgba(255, 232, 195, 0.46);
    border-radius: 8px;
    background: rgba(35, 20, 12, 0.78);
    color: #fff7ea;
    cursor: pointer;
    min-height: 44px;
    padding: 0 18px;
    box-shadow: 0 10px 28px rgba(38, 22, 10, 0.28);
}

button:hover:not(:disabled) {
    background: rgba(57, 34, 19, 0.9);
}

button:disabled {
    cursor: default;
    opacity: 0.45;
}

#stage,
#forPuzzle {
    position: fixed;
    inset: 0;
}

#stage {
    overflow: hidden;
}

#frameBackdrop {
    position: absolute;
    left: 50%;
    top: 46%;
    width: min(82vw, 620px, calc((100vh - 128px) * 0.6666666667));
    aspect-ratio: 1024 / 1536;
    transform: translate(-50%, -50%);
    background-image: url("images/gothic-mirror-frame-transparent-4x5.png");
    background-position: center;
    background-repeat: no-repeat;
    background-size: contain;
    pointer-events: none;
    z-index: 1;
}

#forPuzzle {
    z-index: 2;
    background: transparent;
    overflow: hidden;
    touch-action: none;
}

#forPuzzle canvas,
#forPuzzle img,
.showimage {
    z-index: 2;
}

#menu {
    position: fixed;
    left: 50%;
    bottom: 18px;
    z-index: 10;
    transform: translateX(-50%);
}

#controls,
.hidden-controls {
    display: none;
}

#menu.hidden #showhide {
    display: none;
}

.primary-controls {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: center;
    padding: 10px;
    border: 1px solid rgba(255, 232, 195, 0.3);
    border-radius: 10px;
    background: rgba(52, 31, 18, 0.62);
    backdrop-filter: blur(10px);
}

#start {
    background: #f0b35e;
    border-color: #ffda91;
    color: #241408;
    font-weight: 700;
}

#start:hover:not(:disabled) {
    background: #ffc476;
}

.showimage {
    position: absolute;
    inset: 0;
    display: none;
    background-color: rgba(79, 48, 28, 0.62);
}

.showimage img {
    display: block;
    position: absolute;
    object-fit: contain;
}

.moving {
    transition-property: top, left, width, height;
    transition-duration: 1s;
}

dialog {
    max-width: min(460px, calc(100vw - 32px));
    border: 1px solid rgba(255, 232, 195, 0.4);
    background: #2c1a10;
    color: #fff7ea;
}

@media (max-width: 760px) {
    #frameBackdrop {
        top: 43%;
        width: min(94vw, calc((100vh - 128px) * 0.6666666667));
    }

    .primary-controls {
        width: calc(100vw - 28px);
    }

    .primary-controls button {
        flex: 1 1 0;
        padding: 0 10px;
    }
}
