﻿@import url('https://fonts.googleapis.com/css2?family=Sora:wght@400;600;700&family=Manrope:wght@400;500;700&display=swap');

:root {
    --primary-color: #f0a11f;
    --secondary-color: #0e7a5f;
    --accent-color: #1f8a70;
    --danger-color: #f36a6a;
    --ok-color: #2bd4a8;
    --bg-dark: #0e1214;
    --bg-soft: rgba(14, 18, 20, 0.76);
    --glass-bg: rgba(255, 255, 255, 0.1);
    --glass-border: rgba(255, 255, 255, 0.22);
    --text-main: #eef4f6;
    --text-soft: rgba(238, 244, 246, 0.76);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Manrope', sans-serif;
    background:
        radial-gradient(circle at 20% 15%, rgba(240, 161, 31, 0.16), transparent 30%),
        radial-gradient(circle at 80% 10%, rgba(31, 138, 112, 0.18), transparent 35%),
        var(--bg-dark);
    color: var(--text-main);
    overflow: hidden; /* keep 3D scene fixed, allow inner scrolling via components */
}

/* ensure no accidental horizontal scroll on very small devices */
html, body {
    max-width: 100%;
    overflow-x: hidden;
    overscroll-behavior-x: none;
}

body[data-theme='claro'] {
    --bg-dark: #e9eff2;
    --bg-soft: rgba(248, 252, 253, 0.92);
    --glass-bg: rgba(255, 255, 255, 0.85);
    --glass-border: rgba(15, 20, 23, 0.18);
    --text-main: #0f1417;
    --text-soft: rgba(15, 20, 23, 0.68);
}

#loader {
    position: fixed;
    inset: 0;
    background:
        radial-gradient(circle at 50% 35%, rgba(240, 161, 31, 0.2), transparent 55%),
        var(--bg-dark);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.8s ease, visibility 0.8s;
}

#loader.hidden {
    opacity: 0;
    visibility: hidden;
}

.spinner {
    width: 58px;
    height: 58px;
    border: 3px solid rgba(255, 255, 255, 0.16);
    border-top-color: var(--primary-color);
    border-right-color: var(--accent-color);
    border-radius: 999px;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
    box-shadow: 0 0 22px rgba(240, 161, 31, 0.35);
}

.loading-text {
    color: var(--text-main);
    font-family: 'Sora', sans-serif;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    font-size: 0.75rem;
}

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

#ui-overlay {
    position: fixed;
    top: 14px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 240;
    pointer-events: none;
    text-align: center;
    width: min(94vw, 520px);
}

.title-card {
    position: relative;
    background: linear-gradient(125deg, rgba(20, 28, 34, 0.92), rgba(12, 17, 23, 0.9));
    backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 12px 22px 11px;
    border-radius: 999px;
    color: var(--text-main);
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    min-width: min(92vw, 360px);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.38);
    animation: fadeInUp 0.9s ease forwards;
    opacity: 0;
    pointer-events: auto;
    cursor: pointer;
    transition: transform 0.24s ease, box-shadow 0.28s ease, border-color 0.28s ease, border-radius 0.34s ease, padding 0.34s ease;
}

.title-card::before {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: inherit;
    background: linear-gradient(125deg, rgba(240, 161, 31, 0.26), rgba(43, 212, 168, 0.22));
    filter: blur(12px);
    opacity: 0.24;
    z-index: -1;
    transition: opacity 0.28s ease;
}

.title-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.45);
    border-color: rgba(240, 161, 31, 0.62);
}

.title-card:focus-visible {
    outline: 2px solid rgba(240, 161, 31, 0.72);
    outline-offset: 3px;
}

.title-card.open {
    border-color: rgba(43, 212, 168, 0.76);
    border-radius: 26px;
    padding: 13px 22px 12px;
    transform: translateY(0) scale(1.01);
}

.title-card.open::before {
    opacity: 0.4;
}

.title-card h1 {
    margin: 0;
    font-family: 'Sora', sans-serif;
    font-size: 1.1rem;
    font-weight: 700;
}

.title-card p {
    margin: 3px 0 0;
    font-size: 0.78rem;
    color: var(--text-soft);
}

.title-card::after {
    content: 'Toca para abrir galería';
    display: block;
    margin-top: 4px;
    font-size: 0.63rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-soft);
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.22s ease, transform 0.22s ease, margin 0.22s ease;
}

body.island-open .title-card::after {
    opacity: 0;
    transform: translateY(-4px);
    margin-top: 0;
}

.mini-gallery {
    position: fixed;
    left: 50%;
    top: 76px;
    width: min(88vw, 460px);
    transform: translateX(-50%) translateY(-18px) scale(0.92);
    transform-origin: top center;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    z-index: 230;
    background: rgba(10, 13, 15, 0.94);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 22px;
    padding: 10px 10px 10px;
    backdrop-filter: blur(16px) saturate(120%);
    box-shadow: 0 22px 50px rgba(0, 0, 0, 0.45);
    clip-path: inset(0 12% 87% 12% round 22px);
    transition: opacity 0.26s ease, transform 0.34s cubic-bezier(0.22, 1, 0.36, 1), clip-path 0.38s cubic-bezier(0.22, 1, 0.36, 1), visibility 0.26s ease;
}

.mini-gallery.open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0) scale(1);
    clip-path: inset(0 0 0 0 round 22px);
}

.mini-gallery-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
}

.mini-gallery-header h3 {
    margin: 0;
    font-family: 'Sora', sans-serif;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-soft);
}

#mini-gallery-close {
    border: 1px solid rgba(255, 255, 255, 0.22);
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-main);
    border-radius: 10px;
    padding: 6px 8px;
    font-size: 0.66rem;
    font-family: 'Sora', sans-serif;
    font-weight: 600;
    cursor: pointer;
}

.mini-gallery-grid {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: rgba(240, 161, 31, 0.5) transparent;
    padding: 1px 1px 5px;
}

.mini-gallery-grid::-webkit-scrollbar {
    height: 6px;
}

.mini-gallery-grid::-webkit-scrollbar-thumb {
    background: rgba(240, 161, 31, 0.45);
    border-radius: 999px;
}

.gallery-item {
    flex: 0 0 clamp(120px, 25vw, 140px);
    scroll-snap-align: start;
    border: 1px solid rgba(255, 255, 255, 0.17);
    background: rgba(255, 255, 255, 0.07);
    color: var(--text-main);
    border-radius: 12px;
    padding: 6px;
    text-align: center;
    cursor: pointer;
    will-change: transform, border-color, box-shadow;
    transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1), border-color 0.22s ease, background 0.28s ease, box-shadow 0.28s ease;
}

.gallery-item:hover {
    transform: translateY(-1px) scale(1.02);
    border-color: rgba(240, 161, 31, 0.6);
    box-shadow: 0 7px 16px rgba(0, 0, 0, 0.24);
}

.gallery-item img {
    width: 100%;
    aspect-ratio: 16 / 9;
    border-radius: 9px;
    object-fit: cover;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.gallery-item span {
    margin-top: 5px;
    display: block;
    font-size: 0.7rem;
    font-family: 'Sora', sans-serif;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.gallery-item.active {
    border-color: rgba(43, 212, 168, 0.8);
    background: linear-gradient(120deg, rgba(31, 138, 112, 0.35), rgba(240, 161, 31, 0.28));
    box-shadow: 0 0 0 1px rgba(43, 212, 168, 0.35) inset;
    transform: translateY(-1px);
    animation: selectedThumb 0.3s ease;
}

@keyframes selectedThumb {
    from {
        transform: translateY(0) scale(0.96);
    }
    to {
        transform: translateY(-1px) scale(1);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(14px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.interaction-hint {
    position: fixed;
    top: 52%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: rgba(238, 244, 246, 0.68);
    pointer-events: none;
    z-index: 10;
    font-size: 0.85rem;
    font-weight: 500;
    padding: 8px 14px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(14, 18, 20, 0.45);
    animation: fadeOut 2.5s ease 2s forwards;
}

.gyro-permission {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 1001;
    background: rgba(255, 255, 255, 0.86);
    border: 1px solid rgba(15, 20, 23, 0.18);
    color: #0f1417;
    padding: 10px 14px;
    border-radius: 12px;
    font-family: 'Sora', sans-serif;
    font-weight: 600;
    font-size: 0.8rem;
    cursor: pointer;
    display: none;
}

.gyro-permission.show {
    display: inline-flex;
}

@keyframes fadeOut {
    to {
        opacity: 0;
        transform: translate(-50%, -45%);
    }
}

#menu-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    background: var(--bg-soft);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    width: 48px;
    height: 48px;
    border-radius: 14px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
    pointer-events: auto;
}

#menu-toggle:hover {
    transform: translateY(-2px);
    background: rgba(240, 161, 31, 0.24);
    box-shadow: 0 0 18px rgba(240, 161, 31, 0.35);
}

#menu-toggle .line-top,
#menu-toggle .line-mid,
#menu-toggle .line-bottom {
    transition: transform 0.25s ease, opacity 0.2s ease;
    transform-origin: center;
}

#menu-toggle.open .line-top {
    transform: translateY(5px) rotate(45deg);
}

#menu-toggle.open .line-mid {
    opacity: 0;
}

#menu-toggle.open .line-bottom {
    transform: translateY(-5px) rotate(-45deg);
}

#side-menu {
    position: fixed;
    top: 0;
    right: -350px;
    width: 330px;
    height: 100%;
    background: rgba(12, 16, 18, 0.92);
    backdrop-filter: blur(16px);
    z-index: 999;
    padding: 86px 20px 20px;
    transition: right 0.35s ease;
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-main);
}

#side-menu.open {
    right: 0;
}

#side-menu h2 {
    margin: 0 0 18px;
    font-family: 'Sora', sans-serif;
    letter-spacing: 0.02em;
}

.menu-item {
    padding: 12px;
    margin-bottom: 10px;
    background: rgba(255, 255, 255, 0.07);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    cursor: pointer;
    transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
}

.menu-item:hover {
    transform: translateX(-4px);
    background: rgba(31, 138, 112, 0.2);
    border-color: rgba(240, 161, 31, 0.45);
}

.menu-icon {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.14);
    display: inline-flex;
    justify-content: center;
    align-items: center;
}

.menu-icon svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

body[data-theme='claro'] #menu-toggle {
    background: rgba(255, 255, 255, 0.88);
    border-color: rgba(15, 20, 23, 0.18);
    color: #0f1417;
}

body[data-theme='claro'] #side-menu {
    background: rgba(245, 250, 252, 0.94);
    border-left-color: rgba(15, 20, 23, 0.12);
    color: #0f1417;
}

body[data-theme='claro'] .menu-item {
    background: rgba(15, 20, 23, 0.06);
    border-color: rgba(15, 20, 23, 0.12);
}

body[data-theme='claro'] .menu-item:hover {
    background: rgba(14, 122, 95, 0.2);
    border-color: rgba(240, 161, 31, 0.5);
}

body[data-theme='claro'] .menu-icon {
    background: rgba(15, 20, 23, 0.08);
}

body[data-theme='claro'] .title-card {
    background: linear-gradient(125deg, rgba(248, 252, 253, 0.95), rgba(236, 245, 248, 0.94));
    border-color: rgba(15, 20, 23, 0.2);
    box-shadow: 0 16px 34px rgba(6, 20, 30, 0.18);
}

body[data-theme='claro'] .title-card::before {
    background: linear-gradient(125deg, rgba(240, 161, 31, 0.2), rgba(14, 122, 95, 0.2));
}

body[data-theme='claro'] .title-card.open {
    border-color: rgba(14, 122, 95, 0.55);
}

body[data-theme='claro'] .interaction-hint {
    color: rgba(15, 20, 23, 0.72);
    border-color: rgba(15, 20, 23, 0.16);
    background: rgba(255, 255, 255, 0.72);
}

body[data-theme='claro'] .mini-gallery {
    background: rgba(248, 252, 253, 0.97);
    border-color: rgba(15, 20, 23, 0.16);
    box-shadow: 0 18px 45px rgba(6, 20, 30, 0.22);
}

body[data-theme='claro'] #mini-gallery-close {
    border-color: rgba(15, 20, 23, 0.2);
    background: rgba(15, 20, 23, 0.06);
    color: #0f1417;
}

body[data-theme='claro'] .gallery-item {
    border-color: rgba(15, 20, 23, 0.16);
    background: rgba(15, 20, 23, 0.05);
    color: #0f1417;
}

body[data-theme='claro'] .gallery-item img {
    border-color: rgba(15, 20, 23, 0.12);
}

.settings-modal {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.settings-modal.open {
    display: flex;
}

.settings-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(4, 6, 8, 0.68);
    backdrop-filter: blur(3px);
}

.settings-dialog {
    position: relative;
    width: min(92vw, 520px);
    max-height: 90vh;
    overflow-y: auto;
    background: rgba(10, 13, 15, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 18px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5);
    padding: 16px 16px 14px;
    color: var(--text-main);
}

body[data-theme='claro'] .settings-dialog {
    background: rgba(248, 252, 253, 0.97);
    border-color: rgba(15, 20, 23, 0.16);
    box-shadow: 0 25px 50px rgba(6, 20, 30, 0.2);
}

.settings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.settings-header h3 {
    margin: 0;
    font-family: 'Sora', sans-serif;
    font-size: 1rem;
}

.settings-close {
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-main);
    border-radius: 10px;
    padding: 8px 10px;
    cursor: pointer;
    font-family: 'Sora', sans-serif;
    font-size: 0.78rem;
    font-weight: 600;
}

body[data-theme='claro'] .settings-close {
    border-color: rgba(15, 20, 23, 0.18);
    background: rgba(15, 20, 23, 0.06);
}

.settings-body {
    display: grid;
    gap: 10px;
}

.settings-section {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 14px;
    padding: 12px;
}

body[data-theme='claro'] .settings-section {
    background: rgba(15, 20, 23, 0.03);
    border-color: rgba(15, 20, 23, 0.12);
}

.settings-section h4 {
    margin: 0 0 10px;
    font-family: 'Sora', sans-serif;
    font-size: 0.86rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-soft);
}

.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-size: 0.9rem;
    line-height: 1.3;
}

.setting-row + .setting-row {
    margin-top: 10px;
}

.setting-row-range {
    align-items: flex-start;
    flex-direction: column;
}

.setting-row.disabled {
    opacity: 0.55;
    pointer-events: none;
}

.setting-switch {
    appearance: none;
    width: 44px;
    height: 24px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.26);
    background: rgba(255, 255, 255, 0.14);
    position: relative;
    cursor: pointer;
    transition: background 0.2s ease;
}

.setting-switch::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    top: 2px;
    left: 2px;
    transition: transform 0.2s ease;
}

.setting-switch:checked {
    background: rgba(31, 138, 112, 0.75);
    border-color: rgba(43, 212, 168, 0.8);
}

.setting-switch:checked::before {
    transform: translateX(20px);
}

.setting-select {
    min-width: 132px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
    padding: 7px 9px;
    font-family: inherit;
    font-size: 0.88rem;
}

body[data-theme='claro'] .setting-select {
    border-color: rgba(15, 20, 23, 0.22);
    background: rgba(15, 20, 23, 0.05);
}

.setting-range-wrap {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
}

.setting-range {
    width: 100%;
    accent-color: var(--primary-color);
}

.setting-value {
    min-width: 52px;
    text-align: right;
    font-size: 0.82rem;
    color: var(--text-soft);
    font-weight: 600;
}

.settings-actions {
    margin-top: 14px;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
}

.settings-btn {
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-main);
    border-radius: 10px;
    padding: 9px 8px;
    font-family: 'Sora', sans-serif;
    font-size: 0.74rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    cursor: pointer;
}

body[data-theme='claro'] .settings-btn {
    border-color: rgba(15, 20, 23, 0.18);
    background: rgba(15, 20, 23, 0.06);
}

.settings-btn-primary {
    border-color: rgba(43, 212, 168, 0.5);
    background: linear-gradient(120deg, rgba(31, 138, 112, 0.5), rgba(240, 161, 31, 0.45));
}

.settings-status {
    min-height: 18px;
    margin: 10px 2px 0;
    font-size: 0.78rem;
    color: var(--text-soft);
}

.settings-status.error {
    color: var(--danger-color);
}

body.ui-hidden #ui-overlay,
body.ui-hidden .mini-gallery,
body.ui-hidden .interaction-hint,
body.ui-hidden .hotspot-card,
body.ui-hidden .gyro-permission {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

.hotspot-card {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    background: rgba(255, 255, 255, 0.86);
    backdrop-filter: blur(18px) saturate(150%);
    border: 1px solid rgba(255, 255, 255, 0.7);
    box-shadow: 0 18px 36px rgba(0, 0, 0, 0.25), 0 0 20px rgba(0, 0, 0, 0.08);
    padding: 24px;
    border-radius: 20px;
    color: #0f1417;
    max-width: 360px;
    width: 90%;
    max-height: min(76vh, 560px);
    overflow-y: auto;
    overscroll-behavior: contain;
    display: none;
    z-index: 1000;
    animation: hotspotDialogOpen 0.35s cubic-bezier(0.22, 1, 0.36, 1) forwards;
    cursor: default;
    user-select: none;
}

.hotspot-card.active {
    display: block;
    animation: hotspotDialogOpen 0.35s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes hotspotDialogOpen {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.95) translateY(10px);
    }
    100% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1) translateY(0);
    }
}

@keyframes hotspotDialogClose {
    0% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1) translateY(0);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.9) translateY(20px);
    }
}

.hotspot-card.closing {
    animation: hotspotDialogClose 0.25s ease forwards;
}

@keyframes hotspotDialogOpenMobile {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes hotspotDialogCloseMobile {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateY(18px) scale(0.97);
    }
}

.hotspot-card::before {
    content: '';
    position: absolute;
    top: -1px;
    left: 20%;
    right: 20%;
    height: 3px;
    background: linear-gradient(90deg, transparent, rgba(15, 20, 23, 0.4), transparent);
    border-radius: 0 0 50% 50%;
}

.hotspot-card-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(15, 20, 23, 0.12);
}

.hotspot-card h3 {
    margin: 0;
    font-family: 'Sora', sans-serif;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-shadow: none;
}

.hotspot-card p {
    margin: 0;
    font-size: 0.95rem;
    line-height: 1.7;
    color: rgba(15, 20, 23, 0.75);
}

.hotspot-card .icon-chip {
    width: 44px;
    height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(15, 20, 23, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.hotspot-card .icon-chip:hover {
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.12);
}

.hotspot-card .icon-chip svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.hotspot-card button {
    margin-top: 20px;
    width: 100%;
    padding: 12px 20px;
    background: rgba(15, 20, 23, 0.08);
    border: 1px solid rgba(15, 20, 23, 0.18);
    color: #0f1417;
    border-radius: 12px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    font-family: 'Sora', sans-serif;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    transition: all 0.25s ease;
}

.hotspot-card button:hover {
    background: rgba(15, 20, 23, 0.14);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.hotspot-card button:active {
    transform: translateY(0);
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-14px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@media (max-width: 768px) {
    /* position tweaks to respect device safe areas */
    body {
        overscroll-behavior: none;
    }

    #ui-overlay {
        top: calc(8px + env(safe-area-inset-top, 0px));
        width: calc(100vw - 16px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px));
        max-width: 520px;
    }

    .title-card {
        width: 100%;
        min-width: 0;
        border-radius: 20px;
        padding: 10px 14px 9px;
    }

    .title-card.open {
        border-radius: 20px;
        padding: 10px 14px;
    }

    .title-card p {
        font-size: 0.72rem;
        line-height: 1.35;
    }

    .title-card::after {
        font-size: 0.58rem;
        letter-spacing: 0.06em;
    }

    #side-menu {
        width: min(86vw, 320px);
        top: 0;
        height: 100dvh;
        padding: calc(76px + env(safe-area-inset-top, 0px)) 16px calc(16px + env(safe-area-inset-bottom, 0px));
    }

    #menu-toggle {
        top: calc(12px + env(safe-area-inset-top, 0px));
        right: calc(12px + env(safe-area-inset-right, 0px));
        width: 44px;
        height: 44px;
        border-radius: 12px;
    }

    .menu-item {
        padding: 11px;
        margin-bottom: 8px;
    }

    .interaction-hint {
        top: auto;
        bottom: calc(18px + env(safe-area-inset-bottom, 0px));
        left: 50%;
        width: min(88vw, 320px);
        text-align: center;
        font-size: 0.76rem;
        line-height: 1.4;
        padding: 8px 12px;
        transform: translateX(-50%);
    }

    .gyro-permission {
        top: auto;
        left: calc(12px + env(safe-area-inset-left, 0px));
        right: calc(12px + env(safe-area-inset-right, 0px));
        bottom: calc(18px + env(safe-area-inset-bottom, 0px));
        width: auto;
        justify-content: center;
        text-align: center;
        min-height: 44px; /* Ensure touch target size */
    }

    /* Improve touch targets for mobile */
    .clickable {
        min-width: 44px;
        min-height: 44px;
    }

    .gallery-item {
        min-height: 44px;
    }

    .menu-item {
        min-height: 44px;
    }

    .settings-btn {
        min-height: 44px;
        padding: 12px 16px;
    }

    .hotspot-card {
        top: auto;
        left: calc(12px + env(safe-area-inset-left, 0px));
        right: calc(12px + env(safe-area-inset-right, 0px));
        bottom: calc(12px + env(safe-area-inset-bottom, 0px));
        width: auto;
        max-width: none;
        max-height: min(56dvh, 430px);
        padding: 16px 16px calc(16px + env(safe-area-inset-bottom, 0px));
        border-radius: 18px;
        transform: translateY(14px) scale(0.98);
    }

    .hotspot-card.active {
        animation: hotspotDialogOpenMobile 0.3s cubic-bezier(0.22, 1, 0.36, 1) forwards;
    }

    .hotspot-card.closing {
        animation: hotspotDialogCloseMobile 0.22s ease forwards;
    }

    .hotspot-card h3 {
        font-size: 1.05rem;
    }

    .hotspot-card p {
        font-size: 0.9rem;
        line-height: 1.55;
    }

    .hotspot-card::before {
        left: 28%;
        right: 28%;
    }

    .hotspot-card-header {
        gap: 10px;
        margin-bottom: 12px;
        padding-bottom: 10px;
    }

    .hotspot-card .icon-chip {
        width: 40px;
        height: 40px;
        min-width: 40px;
    }

    .hotspot-card button {
        margin-top: 14px;
        padding: 10px 14px;
        font-size: 0.82rem;
        min-height: 44px;
    }

    .mini-gallery {
        width: calc(100vw - 16px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px));
        max-width: 420px;
        top: calc(72px + env(safe-area-inset-top, 0px));
        padding: 8px;
        border-radius: 18px;
    }

    .mini-gallery-header {
        margin-bottom: 6px;
    }

    .mini-gallery-grid {
        gap: 6px;
        padding-bottom: 4px;
    }

    .gallery-item {
        flex-basis: clamp(108px, 34vw, 128px);
        border-radius: 10px;
        padding: 5px;
    }

    .gallery-item img {
        border-radius: 8px;
    }

    .gallery-item span {
        font-size: 0.68rem;
    }

    .settings-actions {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 6px;
    }

    .settings-modal {
        padding: 0;
        align-items: flex-end;
    }

    .settings-dialog {
        width: 100%;
        max-width: none;
        max-height: min(88dvh, 760px);
        border-radius: 20px 20px 0 0;
        padding: 14px 14px calc(12px + env(safe-area-inset-bottom, 0px));
    }

    .settings-section {
        padding: 11px;
        border-radius: 12px;
    }

    .setting-row {
        align-items: flex-start;
        flex-wrap: wrap;
    }

    .setting-switch {
        margin-left: auto;
    }

    .setting-select {
        width: 100%;
        min-width: 0;
    }

    .settings-btn {
        min-height: 42px;
    }
}

/* handle very narrow phones separately */
@media (max-width: 480px) {
    .title-card h1 {
        font-size: 0.95rem;
    }

    .title-card {
        padding: 8px 10px;
        border-radius: 18px;
    }

    .title-card p {
        font-size: 0.68rem;
    }

    .title-card::after {
        font-size: 0.54rem;
    }

    #menu-toggle {
        width: 42px;
        height: 42px;
    }

    #side-menu {
        width: min(92vw, 300px);
    }

    .hotspot-card {
        left: calc(8px + env(safe-area-inset-left, 0px));
        right: calc(8px + env(safe-area-inset-right, 0px));
        bottom: calc(8px + env(safe-area-inset-bottom, 0px));
        max-height: min(60dvh, 400px);
        padding: 14px 14px calc(14px + env(safe-area-inset-bottom, 0px));
    }

    .mini-gallery {
        width: calc(100vw - 12px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px));
        top: calc(68px + env(safe-area-inset-top, 0px));
    }

    .gallery-item {
        flex-basis: clamp(104px, 42vw, 124px);
    }

    .settings-dialog {
        padding: 12px 12px calc(10px + env(safe-area-inset-bottom, 0px));
        max-height: 92dvh;
    }

    .interaction-hint {
        width: calc(100vw - 24px);
        font-size: 0.72rem;
        padding: 6px 12px;
    }
}
