html, body {
    margin: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #000;
    overscroll-behavior: none;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

#stage {
    position: fixed;
    inset: 0;
    overflow: hidden;
    background: #000;
}

/* The app is laid out at a "logical" size and scaled/rotated to fit. */
#app {
    position: absolute;
    left: 0;
    top: 0;
    border: 0;
    display: block;
    background: #000;
    transform-origin: 0 0;
    visibility: hidden;
    /* Own compositing layer: when the app shrinks after a resize, Safari
       otherwise could leave the old page's pixels around it. */
    will-change: transform;
}

#app.ready {
    visibility: visible;
}

/* Used to read env(safe-area-inset-*) from script. */
#safe-area-probe {
    position: fixed;
    visibility: hidden;
    pointer-events: none;
    padding-top: env(safe-area-inset-top, 0px);
    padding-right: env(safe-area-inset-right, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    padding-left: env(safe-area-inset-left, 0px);
}

/* Mute toggle: always on top; main.js places it on an empty spot of the
   current ScratchJr screen. */
#mute {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 10;
    width: 44px;
    height: 44px;
    padding: 9px;
    box-sizing: border-box;
    border: 0;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.45);
    color: #fff;
    cursor: pointer;
    display: none;
    touch-action: manipulation;
}

#mute.ready {
    display: block;
}

#mute:hover {
    background: rgba(0, 0, 0, 0.6);
}

#mute:focus-visible {
    outline: 3px solid #ffe75a;
    outline-offset: 2px;
}

#mute svg {
    width: 100%;
    height: 100%;
    fill: currentColor;
    stroke: currentColor;
}

#mute .icon-off,
#mute[aria-pressed="true"] .icon-on {
    display: none;
}

#mute[aria-pressed="true"] .icon-off {
    display: block;
}

#mute[aria-pressed="true"] {
    background: rgba(214, 34, 34, 0.85);
}

/* Projects (backup/restore) button: same look as the mute button; shown on
   the home screen only, placed by main.js. */
#projects {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 10;
    border: 0;
    border-radius: 50%;
    box-sizing: border-box;
    background: rgba(0, 0, 0, 0.45);
    color: #fff;
    cursor: pointer;
    display: none;
    touch-action: manipulation;
}

#projects.ready {
    display: block;
}

#projects:hover {
    background: rgba(0, 0, 0, 0.6);
}

#projects:focus-visible {
    outline: 3px solid #ffe75a;
    outline-offset: 2px;
}

#projects svg {
    width: 100%;
    height: 100%;
    stroke: currentColor;
}

#projects .dot {
    position: absolute;
    top: 6%;
    right: 6%;
    width: 26%;
    height: 26%;
    border-radius: 50%;
    background: #FF6B3D;
    box-shadow: 0 0 0 2px #fff;
    display: none;
}

#projects.remind .dot {
    display: block;
}

.dialog {
    position: fixed;
    inset: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(20, 30, 50, 0.55);
    font-family: system-ui, -apple-system, sans-serif;
}

.dialog[hidden] {
    display: none;
}

.dialog-card {
    width: min(420px, 100%);
    max-height: 100%;
    overflow: auto;
    box-sizing: border-box;
    padding: 24px;
    border-radius: 20px;
    background: #fff;
    color: #2b3445;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
    text-align: center;
}

.dialog-card h2 {
    margin: 0 0 8px;
    font-size: 22px;
    color: #1F5F66;
}

.dialog-card p {
    margin: 0 0 12px;
    font-size: 15px;
    line-height: 1.45;
}

.dialog-status {
    min-height: 1.45em;
    font-weight: 600;
    color: #1F5F66;
}

.dialog-card button {
    display: block;
    width: 100%;
    margin-top: 10px;
    padding: 13px 16px;
    border: 0;
    border-radius: 14px;
    font: 700 16px/1.2 system-ui, -apple-system, sans-serif;
    cursor: pointer;
    touch-action: manipulation;
}

.dialog-card button:disabled {
    opacity: 0.6;
    cursor: wait;
}

.dialog-primary {
    background: #3DC1B5;
    color: #fff;
    box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.15);
}

.dialog-secondary {
    background: #FFF1D6;
    color: #8A5300;
}

.dialog-close {
    background: none;
    color: #5b6578;
    font-weight: 600 !important;
}

.dialog-card button:focus-visible {
    outline: 3px solid #FFB627;
    outline-offset: 2px;
}

#toast {
    position: fixed;
    left: 50%;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 24px);
    z-index: 20;
    max-width: calc(100% - 48px);
    padding: 10px 18px;
    border-radius: 22px;
    background: rgba(31, 42, 68, 0.92);
    color: #fff;
    font: 600 15px/1.3 system-ui, -apple-system, sans-serif;
    text-align: center;
    pointer-events: none;
    opacity: 0;
    transform: translate(-50%, 12px);
    transition: opacity 0.25s, transform 0.25s;
}

#toast.show {
    opacity: 1;
    transform: translate(-50%, 0);
}

#boot {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font: 600 18px/1.4 system-ui, -apple-system, sans-serif;
    text-align: center;
    padding: 24px;
    box-sizing: border-box;
}

#boot.hidden {
    display: none;
}
