.puzzle-sharing {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid rgba(255, 255, 255, .12);
}
.puzzle-sharing-status {
    margin: 0 0 12px;
    color: #c5c9d0;
    font-size: .9rem;
    line-height: 1.5;
}
.puzzle-sharing-link {
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    margin-bottom: 12px;
    padding: 10px 12px;
    border: 1px solid rgba(234, 210, 148, .35);
    border-radius: 8px;
    background: #101624;
    color: #ead294;
    font: inherit;
    font-size: .85rem;
}
.puzzle-sharing-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.puzzle-sharing-actions button {
    flex: 1 1 130px;
    min-height: 44px;
}
.puzzle-sharing [hidden], .shared-puzzle-sheet [hidden] { display: none !important; }
.puzzle-sharing button:disabled { opacity: .35; cursor: wait; }
.shared-puzzle-sheet .gallery-detail-title { margin: 0 0 12px; }
.gallery-shared-credit {
    margin: 6px 4px 0;
    color: #b7bdd0;
    font-size: .75rem;
    line-height: 1.4;
    overflow-wrap: anywhere;
}
.shared-puzzle-credit { color: #ead294; font-size: .9rem; margin: 0 0 12px; }
.shared-puzzle-library { color: #b7bdd0; font-size: .85rem; line-height: 1.5; }

.instagram-story-overlay { z-index: 10010; }
.instagram-story-sheet {
    box-sizing: border-box;
    width: min(440px, calc(100vw - 24px));
    max-height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 24px);
    overflow-y: auto;
    padding: 20px;
}
.instagram-story-sheet h2 { margin: 0 0 14px; font-size: 1.2rem; }
.instagram-story-preview {
    display: block;
    width: auto;
    height: min(44dvh, 400px);
    max-width: 100%;
    object-fit: contain;
    margin: 0 auto 16px;
    border-radius: 12px;
}
.instagram-story-sheet button:disabled { opacity: .35; }

/* Report, Block and Contact support stay available but low-key: one line of
   small text links under the sheet's actions. */
.puzzle-sharing-safety { margin-top: 8px; }
.puzzle-sharing-safety-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0 12px;
}
.puzzle-sharing-safety-link {
    /* Small text, full-size touch target. */
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0 2px;
    border: 0;
    background: none;
    color: #b7bdd0;
    font: inherit;
    font-size: .8rem;
    font-weight: 500;
    text-decoration: underline;
    text-underline-offset: 3px;
    opacity: .75;
    cursor: pointer;
    transition: opacity 0.15s;
}
.puzzle-sharing-safety-link:hover { opacity: 1; }
.puzzle-sharing-safety-link:disabled { opacity: .35; cursor: wait; }
.puzzle-sharing-safety .puzzle-sharing-link { margin: 0 0 8px; }
.puzzle-sharing-safety .puzzle-sharing-status { margin: 8px 0 0; text-align: center; font-size: .8rem; }
.puzzle-sharing-safety .puzzle-sharing-status:empty { display: none; }
.puzzle-sharing-safety [hidden] { display: none !important; }
.gallery-detail-overlay {
    box-sizing: border-box;
    padding-top: max(20px, calc(env(safe-area-inset-top, 0px) + 12px), var(--native-camera-clearance, 0px));
    padding-bottom: max(20px, calc(env(safe-area-inset-bottom, 0px) + 12px));
    padding-left: max(20px, calc(env(safe-area-inset-left, 0px) + 12px));
    padding-right: max(20px, calc(env(safe-area-inset-right, 0px) + 12px));
}
.gallery-detail-overlay > .gallery-detail-sheet { max-height: 100%; min-height: 0; }

/* Availability describes the puzzle copy; it does not change network settings. */
.puzzle-offline-availability {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    color: #c5c9d0;
    font-size: .88rem;
    min-height: 44px;
}
.puzzle-offline-toggle {
    position: relative;
    min-width: 48px;
    min-height: 32px;
    padding: 4px 10px;
    border: 1px solid rgba(255,255,255,.22);
    border-radius: 22px;
    background: rgba(255,255,255,.06);
    color: #c5c9d0;
    font: inherit;
    font-size: .78rem;
    font-weight: 600;
    cursor: pointer;
}
.puzzle-offline-toggle::before { content: ''; position: absolute; inset: -6px -2px; }
.puzzle-offline-toggle[aria-checked="true"] {
    background: rgba(var(--accent-rgb, 100, 100, 200), .2);
    border-color: var(--accent, #9d9dea);
    color: #fff;
}
.puzzle-offline-toggle:disabled { cursor: default; }
.puzzle-offline-toggle[aria-busy="true"] { opacity: .65; }
.puzzle-offline-toggle:focus-visible { outline: 2px solid var(--accent, #9d9dea); outline-offset: 3px; }

.gallery-detail-difficulty {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    color: var(--text-primary, #f3f6f4);
    font-size: .9rem;
}
.gallery-detail-difficulty select {
    box-sizing: border-box;
    min-height: 44px;
    max-width: 70%;
    padding: 8px 12px;
    border: 1px solid var(--panel-border, rgba(255,255,255,.22));
    border-radius: 10px;
    background: var(--select-bg, #202a36);
    color: inherit;
    font: inherit;
    cursor: pointer;
}
.gallery-detail-difficulty option { background: var(--bg-primary, #142632); color: var(--text-primary, #f3f6f4); }
.gallery-detail-difficulty select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.gallery-detail-difficulty select:disabled { opacity: .5; }

/* Sharing is a compact secondary action pair, followed by its explanation. */
.gallery-detail-sheet .compact-sharing-actions {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    width: 100%;
}
.gallery-detail-sheet .compact-sharing-actions > .btn-modal-secondary {
    flex: 1 1 0;
    width: auto;
    min-width: 0;
    max-width: 160px;
    min-height: 44px;
    padding: 6px 10px;
    border-radius: 10px;
    font-size: .8rem;
    line-height: 1.25;
}
.puzzle-sharing .compact-sharing-actions { margin-bottom: 10px; }
.puzzle-sharing > .puzzle-sharing-status {
    font-size: .78rem;
    line-height: 1.4;
    margin-bottom: 8px;
}
.shared-puzzle-primary-actions { flex-direction: column; }
.shared-puzzle-primary-actions > .compact-sharing-actions { margin-bottom: 2px; }
.shared-puzzle-primary-actions > .win-sharing-hint { font-size: .78rem; margin: 0 0 8px; }

.library-puzzle-detail .gallery-detail-hero {
    flex: 0 0 auto;
    height: 190px;
    height: clamp(120px, 22dvh, 210px);
    aspect-ratio: auto;
    object-fit: contain;
}
.library-puzzle-detail .gallery-detail-info { padding: 14px 20px; gap: 8px; }
.library-puzzle-detail .puzzle-sharing { margin-top: 4px; padding-top: 12px; }
.library-puzzle-detail .gallery-detail-title,
.library-puzzle-detail .shared-puzzle-credit { margin: 0; }
.library-puzzle-detail .shared-puzzle-library:empty,
.library-puzzle-detail .puzzle-sharing-status:empty { display: none; }
.library-detail-results { font-size: .82rem; color: #c5c9d0; }
.library-detail-results > summary { min-height: 36px; display: list-item; align-content: center; cursor: pointer; }
.library-detail-results > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (orientation: landscape) and (max-height: 600px) {
    .gallery-detail-sheet.library-puzzle-detail { max-width: 760px; display: grid; grid-template-columns: 42% minmax(0, 1fr); }
    .library-puzzle-detail .gallery-detail-hero { height: 100%; min-height: 200px; max-height: calc(100dvh - 48px); border-radius: 16px 0 0 16px; }
}

.gallery-detail-sheet.library-puzzle-detail {
    background: linear-gradient(145deg, var(--modal-bg-start, #181a2e), var(--modal-bg-end, #181a2e));
    border: 1px solid var(--panel-border, rgba(255,255,255,.12));
}
.shared-puzzle-primary-actions > button {
    flex: 0 0 auto;
    min-height: 48px;
    padding: 12px 18px;
}

.library-puzzle-detail .gallery-detail-delete {
    align-self: center;
    width: 100%;
    min-height: 44px;
    padding: 8px 16px;
    border: 1px solid rgba(255, 155, 155, .45);
    background: rgba(255, 90, 90, .08);
    color: #ff9b9b;
    font-size: .82rem;
    box-shadow: none;
}
.library-puzzle-detail .gallery-detail-delete:hover { color: #ffc0c0; background: rgba(255, 90, 90, .1); }

.sharing-information { position: relative; min-height: 44px; color: #c5c9d0; }
.sharing-information > .puzzle-sharing-status { display: flex; align-items: center; min-height: 36px; margin: 0; padding-right: 42px; font-size: .78rem; line-height: 1.4; }
.sharing-information-details > summary {
    position: absolute;
    top: -4px;
    right: -4px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    list-style: none;
    cursor: pointer;
    color: var(--color-gold, #e8be55);
    font-size: .8rem;
    font-weight: 700;
}
.sharing-information-details > summary::-webkit-details-marker { display: none; }
.sharing-information-details > summary::before { content: ''; position: absolute; width: 20px; height: 20px; border: 1px solid currentColor; border-radius: 50%; }
.sharing-information-details > summary:focus-visible { outline: 2px solid var(--accent); border-radius: 8px; }
.sharing-information-details > .puzzle-sharing-status { margin: 8px 0 0; padding-top: 8px; border-top: 1px solid var(--panel-border); font-size: .78rem; line-height: 1.4; }

.puzzle-play-icon {
    display: inline-block;
    width: 0;
    height: 0;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
    border-left: 10px solid currentColor;
    margin-right: 2px;
}

.sharing-information[data-information="false"] > .puzzle-sharing-status { padding-right: 0; }
/* A plan action needs a full touch target, unlike the compact Yes/No switch. */
.puzzle-offline-toggle[role="button"] { min-height: 44px; flex-shrink: 0; }
