* {
    box-sizing: border-box;
}

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

body {
    background: #050D1C radial-gradient(ellipse 90% 85% at 50% 40%, #0C2547 0%, #050D1C 100%);
    color: #FFFFFF;
    font-family: "Segoe UI Light", "Segoe UI", "Selawik", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, sans-serif;
    font-weight: 300;
    cursor: default;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

body.dg-crashed {
    cursor: none;
}


/* --- The update screen ------------------------------------------------- */

#dg-update {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 0 6vw 6vh;
    font-size: clamp(16px, 1.55vw, 34px);
    line-height: 1.45;
}

.dg-line {
    margin: 0;
}

.dg-sub {
    margin: 0.5em 0 0;
    font-size: 0.78em;
    color: #C9D3E6;
}

.dg-foot {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 6vh;
    margin: 0;
    padding: 0 6vw;
    font-size: 0.78em;
    color: #C9D3E6;
}

/* The ring, copied from win-update: each <i> is a full-size box spun about
   the centre; its ::after is the dot at twelve o'clock. */
.dg-ring {
    position: relative;
    width: 3.4em;
    height: 3.4em;
    margin-bottom: 1.6em;
    flex: 0 0 auto;
}

.dg-ring i {
    position: absolute;
    inset: 0;
    opacity: 0;
    animation: dg-orbit 5.5s infinite;
}

.dg-ring i::after {
    content: "";
    position: absolute;
    left: 45%;
    top: 0;
    width: 10%;
    height: 10%;
    border-radius: 50%;
    background: #FFFFFF;
}

.dg-ring i:nth-child(2) { animation-delay: 0.24s; }
.dg-ring i:nth-child(3) { animation-delay: 0.48s; }
.dg-ring i:nth-child(4) { animation-delay: 0.72s; }
.dg-ring i:nth-child(5) { animation-delay: 0.96s; }

@keyframes dg-orbit {
    0%   { transform: rotate(225deg); opacity: 1; animation-timing-function: ease-out; }
    7%   { transform: rotate(345deg); animation-timing-function: linear; }
    30%  { transform: rotate(455deg); animation-timing-function: ease-in-out; }
    39%  { transform: rotate(690deg); animation-timing-function: linear; }
    70%  { transform: rotate(815deg); opacity: 1; animation-timing-function: ease-out; }
    75%  { transform: rotate(945deg); animation-timing-function: ease-out; }
    76%  { transform: rotate(945deg); opacity: 0; }
    100% { transform: rotate(945deg); opacity: 0; }
}

/* Every step of the downgrade under the dialog, read down the columns:
   done ones ticked in green, the current one lit with a pulsing dot, the ones
   still to come dimmed behind a hollow ring. Each marker sits in a fixed 1em
   slot, so the names line up whichever state they are in. */
#dg-steps {
    list-style: none;
    margin: 1.3em 0 0;
    padding: 0;
    font-size: 0.68em;
    line-height: 1.55;
    display: grid;
    grid-template-rows: repeat(4, auto);
    grid-auto-flow: column;
    gap: 0.1em 2.6em;
    text-align: left;
    color: #7083A5;
}

#dg-steps li {
    display: flex;
    align-items: center;
    gap: 0.55em;
    white-space: nowrap;
    transition: color 0.6s ease;
}

#dg-steps li::before {
    content: "";
    flex: 0 0 auto;
    box-sizing: border-box;
    width: 0.62em;
    height: 0.62em;
    margin: 0 0.19em;
    border-radius: 50%;
    border: 1px solid #5B6E91;
}

#dg-steps li.dg-done {
    color: #C9D3E6;
}

#dg-steps li.dg-done::before {
    content: "\2713";
    width: 1em;
    height: auto;
    margin: 0;
    border: 0;
    border-radius: 0;
    text-align: center;
    color: #7FD38B;
}

#dg-steps li.dg-now {
    color: #FFFFFF;
}

#dg-steps li.dg-now::before {
    border-color: #FFFFFF;
    background: #FFFFFF;
    animation: dg-pulse 1.4s ease-in-out infinite;
}

@keyframes dg-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.55); }
    50%      { box-shadow: 0 0 0 0.3em rgba(255, 255, 255, 0); }
}


/* --- The Windows 95 dialog ------------------------------------------------ */

#dg-dialog {
    margin-top: 1.5em;
    width: 30em;
    max-width: 92vw;
    flex: 0 0 auto;
    text-align: left;

    font-family: "MS Sans Serif", "Microsoft Sans Serif", Tahoma, Geneva, Verdana, sans-serif;
    font-weight: normal;
    font-size: clamp(13px, 1.05vw, 26px);
    line-height: 1.35;
    color: #000000;

    background: #C0C0C0;
    padding: 0.2em;
    border-top: 2px solid #DFDFDF;
    border-left: 2px solid #DFDFDF;
    border-right: 2px solid #404040;
    border-bottom: 2px solid #404040;
    box-shadow: inset -1px -1px 0 #808080, inset 1px 1px 0 #FFFFFF, 0 0.6em 2em rgba(0, 0, 0, 0.45);
}

.dg-titlebar {
    display: flex;
    align-items: center;
    background: #000080;
    color: #FFFFFF;
    font-weight: bold;
    padding: 0.15em 0.15em 0.15em 0.4em;
}

.dg-title {
    flex: 1 1 auto;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dg-close {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.3em;
    height: 1.15em;
    background: #C0C0C0;
    border-top: 1px solid #FFFFFF;
    border-left: 1px solid #FFFFFF;
    border-right: 1px solid #000000;
    border-bottom: 1px solid #000000;
    box-shadow: inset -1px -1px 0 #808080;
    cursor: default;
}

.dg-close svg {
    width: 0.62em;
    height: 0.54em;
    fill: #000000;
}

.dg-body {
    padding: 0.9em 0.9em 0.7em;
}

#dg-status,
#dg-file {
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#dg-file {
    margin-top: 0.3em;
    color: #404040;
}

.dg-progress {
    position: relative;
    height: 1.5em;
    margin-top: 0.8em;
    background: #C0C0C0;
    border-top: 1px solid #808080;
    border-left: 1px solid #808080;
    border-right: 1px solid #FFFFFF;
    border-bottom: 1px solid #FFFFFF;
    overflow: hidden;
}

.dg-progress-fill {
    position: absolute;
    left: 2px;
    top: 2px;
    width: calc(100% - 4px);
    height: calc(100% - 4px);
    background-image: repeating-linear-gradient(
        to right,
        #000080 0,
        #000080 0.62em,
        #C0C0C0 0.62em,
        #C0C0C0 0.75em
    );
    background-size: 0.75em 100%;
    -webkit-clip-path: inset(0 100% 0 0);
    clip-path: inset(0 100% 0 0);
}

.dg-buttons {
    display: flex;
    justify-content: flex-end;
    margin-top: 0.9em;
}

.dg-btn {
    font-family: inherit;
    font-size: 1em;
    min-width: 6.2em;
    padding: 0.3em 0.8em;
    background: #C0C0C0;
    color: #000000;
    cursor: default;

    border-top: 2px solid #FFFFFF;
    border-left: 2px solid #FFFFFF;
    border-right: 2px solid #404040;
    border-bottom: 2px solid #404040;
    box-shadow: inset -1px -1px 0 #808080, inset 1px 1px 0 #DFDFDF;
}

.dg-btn:active {
    border-top-color: #404040;
    border-left-color: #404040;
    border-right-color: #FFFFFF;
    border-bottom-color: #FFFFFF;
    box-shadow: inset 1px 1px 0 #808080;
}

.dg-btn.dg-btn-default {
    outline: 1px solid #000000;
    outline-offset: 1px;
}


/* --- The blue screen, copied from w95 ------------------------------------ */

#dg-bsod {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 3;

    background: #0000AA;
    color: #AAAAAA;
    font-family: "Courier New", Courier, "Lucida Console", "Lucida Sans Typewriter", "DejaVu Sans Mono", monospace;
    font-weight: bold;
    font-size: clamp(13px, 1.2vw, 26px);
    line-height: 1.45;

    padding: 6vh 4vw;
    overflow: hidden;
    justify-content: center;
    align-items: center;
}

body.dg-crashed #dg-bsod {
    display: flex;
}

body.dg-crashed #dg-update,
body.dg-crashed #dg-hint {
    display: none;
}

#dg-bsod pre {
    margin: 0;
    font: inherit;
    white-space: pre-wrap;
    max-width: 72ch;
}

.dg-bsod-title {
    display: block;
    text-align: center;
    margin-bottom: 1.5em;
}

.dg-bsod-title span {
    background: #AAAAAA;
    color: #0000AA;
    padding: 0 0.5em;
}

.dg-bsod-prank {
    color: #FFFFFF;
}

.dg-bsod-continue {
    display: block;
    text-align: center;
    margin-top: 1.5em;
}

#dg-cursor {
    animation: dg-blink 1s steps(1, end) infinite;
}

@keyframes dg-blink {
    50% {
        opacity: 0;
    }
}


/* --- Held upright ---------------------------------------------------------- */

@media (orientation: portrait) {
    #dg-update {
        font-size: clamp(15px, 4.4vw, 30px);
        padding: 0 5vw 8vh;
    }

    #dg-dialog {
        font-size: clamp(12px, 3.3vw, 20px);
        width: 100%;
        max-width: 30em;
    }

    /* One column, read straight down. */
    #dg-steps {
        grid-template-rows: none;
        grid-auto-flow: row;
        margin-top: 1.1em;
    }

    #dg-bsod {
        font-size: clamp(11px, 3.2vw, 18px);
        padding: 4vh 4vw;
    }
}


/* --- Hint ---------------------------------------------------------------- */

#dg-hint {
    position: fixed;
    left: 50%;
    top: 34px;
    transform: translateX(-50%);
    z-index: 4;

    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-weight: 400;
    font-size: clamp(15px, 4vw, 20px);
    line-height: 1.5;
    text-align: center;
    color: #FFFFFF;
    background: rgba(0, 0, 0, 0.72);
    border-radius: 14px;
    padding: 18px 28px 22px;
    width: max-content;
    max-width: min(92vw, 30em);
    overflow: hidden;

    transition: opacity 0.6s ease;
}

#dg-hint kbd {
    font-family: inherit;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.18);
    border-radius: 4px;
    padding: 1px 6px;
    white-space: nowrap;
}

/* Countdown to the hint going away: drains over HINT_TIMEOUT_MS, which the
   JS hands over as --hint-ms. */
#dg-hint::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    box-sizing: content-box;
    height: 5px;
    background: #FFFFFF;
    border-top: 1px solid #000000;
    border-bottom: 1px solid #000000;
    transform-origin: left center;
    animation: dg-hint-countdown var(--hint-ms, 8s) linear forwards;
}

@keyframes dg-hint-countdown {
    from { transform: scaleX(1); }
    to   { transform: scaleX(0); }
}

#dg-hint.dg-hint-gone {
    opacity: 0;
    pointer-events: none;
}
