/* The page keeps the look of the game's own screens: the logo in the top third, the PLAY button in the middle, a ring while
   loading, a small red dot for a pointer, and silver text over the view while playing. */

html, body {
    margin: 0;
    height: 100%;
    overflow: hidden;
    background: #000;
    color: #fff;
    font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

body {
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8'%3E%3Ccircle cx='4' cy='4' r='2' fill='red'/%3E%3C/svg%3E") 4 4, crosshair;
}

#view {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    outline: none;
    touch-action: none;
}

/* in the middle cell of the top row of a 3x3 grid, as large as fits */
#logo {
    position: fixed;
    left: 33.333vw;
    top: 0;
    width: 33.333vw;
    height: 33.333vh;
    object-fit: contain;
    pointer-events: none;
    transition: opacity 0.3s;
}

#loader {
    position: fixed;
    left: 50%;
    top: 50%;
    width: 92px;
    height: 92px;
    margin: -46px 0 0 -46px;
    display: none;
}

body.loading #loader {
    display: block;
}

/* an indeterminate ring, like the XAML ProgressRing: an arc that turns, growing and shrinking */
.ring {
    position: absolute;
    inset: -3px;
    width: 98px;
    height: 98px;
    animation: ring-turn 1.2s linear infinite;
}

.ring circle {
    fill: none;
    stroke: #fff;
    stroke-width: 6;
    stroke-linecap: round;
    stroke-dasharray: 289;
    animation: ring-sweep 2s ease-in-out infinite;
    transform-origin: 50% 50%;
}

@keyframes ring-turn {
    to { transform: rotate(360deg); }
}

@keyframes ring-sweep {
    0% { stroke-dashoffset: 265; transform: rotate(0deg); }
    50% { stroke-dashoffset: 96; transform: rotate(90deg); }
    100% { stroke-dashoffset: 265; transform: rotate(360deg); }
}

#status {
    position: absolute;
    left: -200px;
    right: -200px;
    top: 50%;
    transform: translateY(-50%);
    text-align: center;
    font-size: 18px;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

#play {
    position: fixed;
    left: 50%;
    top: 50%;
    width: 220px;
    height: 70px;
    margin: -35px 0 0 -110px;
    border: 0;
    border-radius: 4px;
    background: #111;
    color: #fff;
    font: inherit;
    font-size: 18px;
    cursor: inherit;
    display: none;
    outline: none;
}

#play:hover { background: #262626; }
#play:active { background: #0c0c0c; color: #ccc; }
#play:focus-visible { box-shadow: 0 0 0 2px #888; }

body.menu #play { display: block; }

body.playing #logo,
body.playing #play,
body.view #logo {
    opacity: 0;
}

#hud {
    position: fixed;
    left: 0;
    right: 0;
    top: 0;
    padding: 6px;
    height: 58px;
    box-sizing: border-box;
    color: #c0c0c0;
    font-size: 18px;
    line-height: 25px;
    text-shadow: 0 1px 2.5px rgba(0, 0, 0, 0.85), 0 0 2px rgba(0, 0, 0, 0.6);
    background: linear-gradient(rgba(0, 0, 0, 0.43), rgba(0, 0, 0, 0));
    pointer-events: none;
    display: none;
}

body.playing #hud { display: block; }

#help {
    position: absolute;
    left: 6px;
    top: 6px;
    right: 260px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#esc {
    position: absolute;
    right: 6px;
    top: 6px;
    white-space: nowrap;
}

#fps {
    position: absolute;
    right: 6px;
    top: 33px;
    font-size: 14px;
    line-height: 19px;
    white-space: nowrap;
}

#hint {
    position: fixed;
    left: 50%;
    top: 60%;
    transform: translateX(-50%);
    padding: 8px 16px;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.6);
    color: #ddd;
    font-size: 16px;
    pointer-events: none;
    display: none;
}

body.playing.unlocked:not(.touch) #hint { display: block; }

#esc .tap { display: none; }

/* on a touch screen the label is a button back to the menu, and the left thumb's stick shows where it came down */
body.touch #esc {
    pointer-events: auto;
    padding: 2px 12px;
    margin: -2px -6px 0 0;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.35);
}

body.touch #esc .keys { display: none; }
body.touch #esc .tap { display: inline; }

#stick {
    position: fixed;
    left: -40px;
    top: -40px;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.35);
    box-sizing: border-box;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
}

#stick.active { opacity: 1; }

#message {
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    max-width: min(560px, calc(100vw - 32px));
    box-sizing: border-box;
    padding: 20px 24px;
    border-radius: 6px;
    background: #141414;
    color: #ddd;
    font-size: 16px;
    line-height: 1.5;
    text-align: center;
    display: none;
    user-select: text;
    -webkit-user-select: text;
}

body.failed #message { display: block; }
body.failed #loader { display: none; }

.noscript {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ddd;
}

@media (max-width: 760px) {
    #hud { font-size: 14px; line-height: 20px; }
    #help { right: 200px; }
    #fps { top: 28px; font-size: 12px; }
}
