/* --- Shared controls --- */
.utility-controls {
    position: fixed;
    top: var(--control-top);
    right: max(8px, env(safe-area-inset-right, 0px));
    left: max(8px, env(safe-area-inset-left, 0px));
    z-index: 300;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 8px;
    pointer-events: none;
}

.utility-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    min-width: 44px;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: 12px;
    background: rgba(15, 23, 42, 0.82);
    color: var(--text-primary);
    font-size: 0.8125rem;
    font-weight: 500;
    line-height: 1.2;
    letter-spacing: 0.01em;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(10px);
    cursor: pointer;
    pointer-events: auto;
    touch-action: manipulation;
    transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.utility-btn:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

.control-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.1em;
    font-size: 1.05rem;
    line-height: 1;
}

.control-label {
    display: inline;
}

@media (hover: hover) {
    .utility-btn:hover {
        border-color: rgba(94, 234, 212, 0.65);
        background: rgba(30, 41, 59, 0.96);
        color: #ffffff;
    }
}

.utility-btn-compact {
    min-width: 44px;
    padding: 10px;
}

.settings-panel {
    position: fixed;
    top: calc(var(--control-top) + 58px);
    right: max(12px, env(safe-area-inset-right, 0px));
    z-index: 450;
    width: min(350px, calc(100vw - 24px));
    max-height: min(70dvh, 620px);
    overflow-y: auto;
    padding: 16px;
    border: 1px solid rgba(148, 163, 184, 0.22);
    border-radius: 18px;
    background: rgba(9, 18, 31, 0.96);
    box-shadow: 0 26px 70px rgba(0, 0, 0, 0.48);
    backdrop-filter: blur(18px);
    overscroll-behavior: contain;
}

.settings-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 10px;
    color: #f8fafc;
    font-size: 0.92rem;
}

.settings-close {
    display: grid;
    width: 40px;
    height: 40px;
    place-items: center;
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 10px;
    background: rgba(148, 163, 184, 0.06);
    color: #cbd5e1;
    font-size: 1.2rem;
    cursor: pointer;
}

.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-height: 54px;
    padding: 10px 0;
    border-bottom: 1px solid rgba(148, 163, 184, 0.1);
}

.setting-row > span {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.setting-row strong,
.setting-range > span {
    color: #e2e8f0;
    font-size: 0.8rem;
    font-weight: 600;
}

.setting-row small {
    color: #8294aa;
    font-size: 0.7rem;
}

.setting-row input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: #2dd4bf;
}

.setting-row select {
    max-width: 130px;
    min-height: 40px;
    padding: 6px 9px;
    border: 1px solid rgba(148, 163, 184, 0.24);
    border-radius: 9px;
    background: #142235;
    color: #e2e8f0;
    font: inherit;
    font-size: 0.76rem;
}

.setting-range {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 14px 0 8px;
}

.setting-range > span {
    display: flex;
    justify-content: space-between;
}

.setting-range output {
    color: #99f6e4;
    font-variant-numeric: tabular-nums;
}

.setting-range input {
    width: 100%;
    accent-color: #2dd4bf;
}

.settings-action {
    width: 100%;
    min-height: 44px;
    margin-top: 14px;
    border: 1px solid rgba(94, 234, 212, 0.24);
    border-radius: 11px;
    background: rgba(45, 212, 191, 0.09);
    color: #ccfbf1;
    font: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
}

.settings-note {
    margin: 12px 0 0;
    color: #71849a;
    font-size: 0.66rem;
    line-height: 1.5;
    text-align: center;
}

.focus-exit {
    position: fixed;
    top: max(14px, env(safe-area-inset-top, 0px));
    right: max(14px, env(safe-area-inset-right, 0px));
    z-index: 500;
    min-height: 44px;
    padding: 10px 15px;
    border: 1px solid rgba(148, 163, 184, 0.22);
    border-radius: 999px;
    background: rgba(7, 15, 25, 0.58);
    color: #cbd5e1;
    font: inherit;
    font-size: 0.74rem;
    opacity: 0.58;
    cursor: pointer;
    backdrop-filter: blur(10px);
    transition: opacity 0.2s ease;
}

.focus-exit:hover,
.focus-exit:focus-visible {
    opacity: 1;
}

body.focus-mode #nav-bar,
body.focus-mode .toy-instruction,
body.focus-mode .scene-hint,
body.focus-mode .toy-about {
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
}

body.focus-mode.controls-hidden .utility-controls {
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
}

.save-status,
.breathe-phase {
    position: absolute;
    bottom: calc(var(--nav-pad) + 28px);
    left: 50%;
    z-index: 15;
    width: max-content;
    max-width: calc(100% - 2rem);
    margin: 0;
    padding: 9px 14px;
    border: 1px solid rgba(148, 163, 184, 0.14);
    border-radius: 999px;
    background: rgba(8, 20, 29, 0.5);
    color: rgba(226, 232, 240, 0.72);
    font-size: clamp(0.72rem, 2.5vw, 0.86rem);
    font-weight: 500;
    letter-spacing: 0.1em;
    text-align: center;
    text-transform: uppercase;
    transform: translateX(-50%);
    backdrop-filter: blur(8px);
    pointer-events: none;
}

.save-status {
    opacity: 0;
    transition: opacity 0.35s ease;
}

.save-status.visible {
    opacity: 1;
}

@media (max-width: 700px) {
    body #nav-bar {
        width: calc(100vw - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px) - 1rem);
        max-width: none;
        max-height: none;
        flex-wrap: nowrap;
        justify-content: flex-start;
        overflow-x: auto;
        overflow-y: hidden;
    }

    .nav-btn {
        flex: 0 0 auto;
    }

    .utility-btn {
        min-width: 44px;
        padding: 10px;
    }

    .utility-btn .control-label {
        position: absolute !important;
        width: 1px !important;
        height: 1px !important;
        padding: 0 !important;
        margin: -1px !important;
        overflow: hidden !important;
        clip: rect(0, 0, 0, 0) !important;
        clip-path: inset(50%) !important;
        white-space: nowrap !important;
        border: 0 !important;
    }

    .settings-panel {
        top: calc(var(--control-top) + 56px);
    }
}

.toy-about {
    position: fixed;
    bottom: calc(var(--nav-pad) + 16px);
    left: max(14px, env(safe-area-inset-left, 0px));
    z-index: 260;
    width: min(420px, calc(100vw - 28px));
    color: #e2e8f0;
}

.toy-about summary {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 10px 15px;
    border: 1px solid rgba(148, 163, 184, 0.16);
    border-radius: 999px;
    background: rgba(8, 18, 30, 0.55);
    box-shadow: 0 10px 26px rgba(0, 0, 0, 0.14);
    color: #cbd5e1;
    font-size: 0.74rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    cursor: pointer;
    list-style: none;
    backdrop-filter: blur(10px);
}

.toy-about summary::-webkit-details-marker {
    display: none;
}

.toy-about summary::after {
    margin-left: 8px;
    color: #5eead4;
    content: '+';
}

.toy-about[open] summary::after {
    content: '−';
}

.toy-about-body {
    max-height: min(48dvh, 380px);
    overflow-y: auto;
    margin-top: 8px;
    padding: 20px;
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 18px;
    background: rgba(8, 18, 30, 0.96);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.38);
    backdrop-filter: blur(16px);
    overscroll-behavior: contain;
}

.toy-about-body h2 {
    margin: 0 0 0.65rem;
    color: #f8fafc;
    font-size: 1.05rem;
    font-weight: 500;
}

.toy-about-body p,
.toy-about-body li {
    color: #a8b8ca;
    font-size: 0.8rem;
    line-height: 1.65;
}

.toy-about-body p {
    margin: 0;
}

.toy-about-body ul {
    margin: 0.8rem 0 0;
    padding-left: 1.1rem;
}

body.focus-mode .toy-about {
    opacity: 0;
    pointer-events: none;
}
