/* One look everywhere: the deep sea at night, and things that glow in it. */
@font-face { font-family: Fredoka; src: url(/vendor/fredoka.woff2) format("woff2"); font-weight: 300 700; font-display: swap; }
@font-face { font-family: "JetBrains Mono"; src: url(/vendor/jetbrains-mono.woff2) format("woff2"); font-weight: 100 800; font-display: swap; }

:root {
    --ink: #041225;
    --glow: #4fd8ff;
    --text: #eaf6ff;
    --soft: #9fdcffcc;
    --glass: #071f3dcc;
    --edge: #4fd8ff40;
    color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
    background: var(--ink);
    color: var(--text);
    font: 1.0625rem/1.5 Fredoka, ui-rounded, "Segoe UI", system-ui, sans-serif;
}

a { color: var(--glow); }

button, input, select { font: inherit; color: inherit; }

/* The page to type on: the sea as the stage, and a panel beside it. */
.app { display: grid; grid-template-columns: 1fr clamp(17rem, 24vw, 21rem); overflow: hidden; }

#stage {
    position: relative; overflow: hidden;
    background: radial-gradient(120% 75% at 38% -12%, #2a86ad 0%, #0f4f7c 22%, #082c52 48%, #041428 78%, #020a15 100%);
}
#stage::after {
    content: ""; position: absolute; inset: 0; pointer-events: none;
    background: radial-gradient(ellipse at 50% 45%, transparent 55%, #010610b0 100%);
}

#sea { position: absolute; inset: 0; width: 100%; height: 100%; }

#sound {
    position: absolute; z-index: 2; top: 1rem; right: 1rem; width: 2.6rem; height: 2.6rem; padding: 0;
    border-radius: 50%; border: 1px solid var(--edge); background: var(--glass); font-size: 1.2rem; cursor: pointer;
}
#sound::before { content: "♪"; }
#sound.off { opacity: .45; text-decoration: line-through; }

main {
    position: relative; z-index: 1; height: 100%; display: grid; grid: minmax(11rem, 44%) auto auto 1fr / minmax(0, 1fr);
    justify-items: center; padding: 1.5rem 1rem 1.2rem; gap: .5rem;
}
main > * { grid-column: 1; }

/* What Kringel says: beside Kringel on a wide stage, below on a narrow one. */
#says {
    position: relative; align-self: start; margin: 3% 0 0 max(0px, 34% - 9rem); max-width: 32rem; padding: .9rem 1.25rem;
    background: var(--glass); border: 1px solid var(--edge); border-radius: 1.3rem; backdrop-filter: blur(6px);
    box-shadow: 0 0 2.5rem #4fd8ff26, inset 0 1px 0 #ffffff1f; font-size: 1.2rem; font-weight: 450;
}
#says::before {
    content: ""; position: absolute; left: -.55rem; top: 1.6rem; width: 1rem; height: 1rem; rotate: 45deg;
    background: #082242; border-left: 1px solid var(--edge); border-bottom: 1px solid var(--edge);
}
#says:empty { display: none; }
@container stage (max-aspect-ratio: 11/10) {
    #line { margin-left: 0; }
    #says { align-self: end; margin: 0; font-size: 1.05rem; }
    #says::before { left: calc(50% - .5rem); top: -.55rem; rotate: 135deg; }
}
/* A low stage, as on a small laptop: Kringel's longest lines stay clear of the text to type. */
@container stage (max-height: 44rem) {
    #says { margin-top: 0; font-size: 1.05rem; }
}
/* Kringel is at the right, pointing at the panel beside the stage. */
@container stage (min-aspect-ratio: 11/10) {
    .aside #says { margin: 3% max(0px, 34% - 9rem) 0 0; }
    .aside #says::before { left: auto; right: -.55rem; rotate: 225deg; }
}

#touch {
    display: none; position: absolute; inset: auto 0 0; z-index: 3; margin: 0; padding: .7rem 1rem;
    background: #0a2545; border-top: 1px solid #ffb34799; text-align: center;
}
@media (hover: none) and (pointer: coarse) {
    #touch { display: block; }
}
#touch a { white-space: nowrap; }

/* The text to type. */
#line {
    grid-row: 2; max-width: 58rem; min-height: 1.6em; margin-left: 22%; text-align: center;
    font: 500 clamp(1.5rem, 3.6cqw, 2.5rem)/1.7 "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
    text-shadow: 0 2px 14px var(--ink), 0 0 2px var(--ink);
}
#line > span { display: inline-block; white-space: nowrap; }
#line span span { display: inline-block; white-space: pre; padding: 0 .04em; border-radius: .18em; border-bottom: .1em solid transparent; }
#line .now { background: color-mix(in srgb, var(--finger) 24%, transparent); border-color: var(--finger); text-shadow: 0 0 .7em var(--finger); }
#line .done { color: #7dffb8b0; animation: hit .28s ease-out; }
#line .slipped { color: #ffb347; }
#line .miss { color: #ff7a7a; animation: miss .25s; }
@keyframes hit { 0% { translate: 0 -.16em; scale: 1.22; color: #fff; text-shadow: 0 0 .8em #7dffb8; } }
@keyframes miss { 25% { translate: -.12em; } 75% { translate: .12em; } }

#score {
    grid-row: 3; margin: 0; min-height: 1.9em; padding: .15rem .9rem; border-radius: 2rem; color: var(--soft); font-size: 1rem;
}
#score:not(:empty) { background: #06183099; }
#score.game { grid-row: 4; align-self: end; }  /* while a game plays: out of its way, where the keyboard was */

#summary {
    grid-row: 2; max-width: 32rem; padding: 1.2rem 1.6rem; text-align: center;
    background: var(--glass); border: 1px solid var(--edge); border-radius: 1.3rem; backdrop-filter: blur(6px);
}
#summary p { margin-top: 0; }
#more { padding: .45rem 1.1rem; border-radius: 2rem; border: 1px solid #ffffff55; background: none; color: #ffffffc0; font-size: .95rem; cursor: pointer; }

/* The keyboard: each key has the colour of its finger, and the one to press next lights up. */
#keys {
    position: relative; grid-row: 4; align-self: end; display: grid; gap: .38rem; padding: .8rem 1rem; border-radius: 1.2rem; background: #03101fd9;
    box-shadow: 0 0 2rem 1rem #03101fd9; transition: opacity .5s; --size: clamp(1.3rem, min(4.4cqw, 5.8cqh), 3rem);
}
#keys.faded { opacity: 0; }
/* A fingertip: main.js moves it to the middle of its key. */
#keys i {
    position: absolute; left: calc(var(--size) * -.31); top: calc(var(--size) * -.31); width: calc(var(--size) * .62); height: calc(var(--size) * .62);
    border-radius: 50%; border: 2px solid #ffffffd9; background: color-mix(in srgb, var(--finger) 45%, transparent);
    box-shadow: 0 0 .6rem var(--finger); transition: translate .15s ease-out;
}
#keys div, #map div { display: flex; gap: .38rem; }
#keys div:nth-child(2), #map div:nth-child(2) { margin-left: calc(var(--size) * .3); }
#keys div:nth-child(3), #map div:nth-child(3) { margin-left: calc(var(--size) * .8); }
#keys div:nth-child(4), #map div:nth-child(4) { justify-content: center; }
kbd {
    position: relative; width: var(--size); height: var(--size); display: grid; place-items: center;
    border: 1.5px solid color-mix(in srgb, var(--finger) 75%, transparent); border-radius: .55rem;
    background: linear-gradient(#0e3158, #071c38); box-shadow: inset 0 -.2rem 0 #00000059, 0 .15rem .4rem #00000080;
    color: var(--text); font: 600 calc(var(--size) * .42) Fredoka, system-ui, sans-serif; text-transform: uppercase; opacity: .3;
}
kbd.open { opacity: 1; }
kbd.next { background: var(--finger); color: var(--ink); box-shadow: 0 0 1.5rem var(--finger), inset 0 -.2rem 0 #00000040; translate: 0 1px; }
kbd.bump::after { content: ""; position: absolute; bottom: 16%; width: 30%; height: 2px; border-radius: 2px; background: currentColor; }
kbd.space { width: calc(var(--size) * 5.5); }

/* The panel beside the stage: who you are here, how it works, what it costs. */
#panel {
    container-type: inline-size; overflow-y: auto; padding: 1.3rem 1.4rem; font-size: .95rem;
    background: linear-gradient(#0a2a4c, #051730 40%, #030d1c); border-left: 1px solid #4fd8ff2e;
}
#panel p, #panel ul { margin: .4rem 0; }
#panel ul { padding-left: 1.1rem; }
#panel li { margin: .35rem 0; }
#panel li::marker { color: var(--glow); }
#panel section { margin-top: 1.1rem; padding-top: 1rem; border-top: 1px solid #ffffff14; }
#panel h2 { margin: 0 0 .5rem; font-size: .8rem; font-weight: 600; letter-spacing: .09em; text-transform: uppercase; color: var(--soft); }
#panel footer { margin-top: 1.3rem; padding-top: 1rem; border-top: 1px solid #ffffff14; font-size: .88rem; color: var(--soft); }
#brand {
    display: flex; align-items: center; gap: .6rem; margin-bottom: .5rem; text-decoration: none;
    font-size: 2rem; font-weight: 650; letter-spacing: .01em;
    background: linear-gradient(90deg, #7df0ff, #b69bff 70%, #ff8fc2); -webkit-background-clip: text; background-clip: text; color: transparent;
}
#brand img { border-radius: .8rem; box-shadow: 0 0 1.2rem #4fd8ff40; }

#today { display: flex; align-items: center; gap: .9rem; }
#ring {
    flex: none; width: 4.2rem; height: 4.2rem; display: grid; place-items: center; border-radius: 50%;
    background: radial-gradient(closest-side, #071c38 78%, transparent 80%), conic-gradient(var(--glow) calc(var(--done, 0) * 1%), #ffffff1a 0);
    font-size: 1.25rem;
}
#map { margin-top: .8rem; display: grid; gap: .22rem; --size: min(1.35rem, 7.4cqw); }
#map div { gap: .22rem; }
#map kbd { border-radius: .35rem; border-width: 1px; box-shadow: none; opacity: .28; }
#map kbd.open { opacity: .6; }
#map kbd.known { opacity: 1; background: var(--finger); color: var(--ink); }

/* Who types here. When that is to be settled first, the section lights up, and Kringel points at it. */
#account.wanted { margin-inline: -.7rem; padding: 1rem .7rem; border: 1px solid var(--glow); border-radius: 1rem; animation: wanted 1.6s ease-in-out infinite; }
@keyframes wanted { 50% { box-shadow: 0 0 1.6rem #4fd8ff8c; } }
#account .who, #account select { font-size: 1.35rem; font-weight: 600; }
#account .nobody { color: #ffb347; }
#account label { display: block; margin-top: .5rem; font-size: .88rem; color: var(--soft); }
#account input:not([type=checkbox]), #account select, #account button {
    width: 100%; margin-top: .5rem; padding: .55rem .8rem; border-radius: .7rem; border: 1px solid var(--edge); background: #04142a;
}
#account button { background: var(--glow); border-color: var(--glow); color: var(--ink); font-weight: 600; cursor: pointer; }
#account .plain {
    display: inline-block; width: auto; margin: .5rem .3rem 0 0; padding: .3rem .8rem; border: 1px solid #ffffff30; border-radius: .7rem;
    background: none; color: var(--soft); font-weight: 400; font-size: .88rem; text-decoration: none;
}
#account small { display: block; margin-top: .5rem; color: var(--soft); }
#account .holder { display: flex; align-items: baseline; gap: .6rem; font-size: .88rem; color: var(--soft); }
#account .holder span { flex: 1; overflow: hidden; text-overflow: ellipsis; }
#account .holder .plain { margin-right: 0; }

#stage { container: stage / size; }

@media (max-width: 56rem) {
    .app { display: block; overflow: auto; }
    #stage { height: 100dvh; }
    #panel { border-left: 0; border-top: 1px solid #4fd8ff2e; }
}
/* A phone, until a key is pressed after all: the stage leaves room to see that there is more to read. */
@media (max-width: 56rem) and (hover: none) and (pointer: coarse) {
    #stage:has(#touch) { height: calc(100dvh - 9rem); }
}

/* A page of plain text. */
.page { overflow: auto; background: radial-gradient(120% 60% at 38% -12%, #145a86 0%, #082c52 40%, var(--ink) 100%) fixed; }
.page main { display: block; justify-items: normal; height: auto; max-width: 40rem; margin: 0 auto; padding: 1.5rem 1.2rem 3rem; }
.page h1, .page h2 { font-weight: 600; }
.page li { margin: .6rem 0; }
.page table { width: 100%; margin: 1rem 0; border-collapse: collapse; }
.page th, .page td { padding: .35rem .6rem .35rem 0; text-align: left; border-bottom: 1px solid #ffffff1f; }
.page th { font-size: .8rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--soft); }
.page code { font: 500 1.05rem "JetBrains Mono", ui-monospace, monospace; letter-spacing: .05em; }
.page input, .page button { padding: .4rem .7rem; border-radius: .7rem; border: 1px solid var(--edge); background: #04142a; }
.page td input { width: 100%; }
.page form { display: flex; gap: .5rem; }
.page .consent { flex-direction: column; align-items: start; }
.page .consent p { margin: 0; }
.page .kept { display: block; margin-top: 1.5rem; }
.page small { display: block; margin-top: 1.5rem; color: var(--soft); }
.page form button { background: var(--glow); border-color: var(--glow); color: var(--ink); font-weight: 600; cursor: pointer; }
.page .leave { display: flex; align-items: baseline; gap: .6rem; margin-top: 2.5rem; }
.page .leave button { cursor: pointer; }
.page .plain { color: var(--soft); border-color: #ffffff30; font-size: .88rem; }
/* On paper, to hand the codes out: the list alone, in black on white. */
@media print {
    :root { color-scheme: light; }
    .page { background: none; }
    .page, .page th { color: #000; }
    .page input { border: 0; padding: 0; background: none; }
    .page a[href="/"], .page form, .page button, .page small { display: none; }
}
