/* Duskling: everything that is not the canvas. The picture is the game; this
 * is the score, the two thumb pads, and the screens either side of a run. */

:root {
  --accent: #ffd43b;
  --ink: #1b1440;
  --cream: #fffdf2;
  --night: #7df9ff;
  --surf: 50%;
  --font: "Fredoka", ui-rounded, "Arial Rounded MT Bold", "Hiragino Maru Gothic ProN", system-ui, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #101046;
  color: var(--cream);
  font-family: var(--font);
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  overscroll-behavior: none;
}

#lake { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

/* ---- score ------------------------------------------------------------- */

.hud {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 10px);
  left: 0; right: 0;
  display: grid;
  justify-items: center;
  gap: 2px;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-12px);
  transition: opacity .3s, transform .3s;
}
.hud.is-on { opacity: 1; transform: none; }

.score {
  font-size: clamp(40px, 12vw, 64px);
  font-weight: 700;
  line-height: 1;
  color: #fff;
  -webkit-text-stroke: 6px var(--ink);
  paint-order: stroke fill;
  text-shadow: 0 4px 0 var(--ink);
  font-variant-numeric: tabular-nums;
}
.score.bump { animation: bump .18s ease-out; }
@keyframes bump { 40% { transform: scale(1.12); } }

.harmony {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 4px 12px 4px 8px;
  border-radius: 99px;
  background: var(--ink);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: rgba(255, 253, 242, .8);
  transition: transform .2s;
}
.harmony b {
  min-width: 34px;
  padding: 1px 7px;
  border-radius: 99px;
  background: var(--accent);
  color: var(--ink);
  font-size: 15px;
  font-weight: 700;
  text-align: center;
}
.harmony i { width: 46px; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, .18); overflow: hidden; }
.harmony u { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 3px; transition: width .15s; }
.harmony.up { animation: up .45s cubic-bezier(.2, 1.6, .4, 1); }
.harmony.down { animation: down .35s; }
@keyframes up { 30% { transform: scale(1.3) rotate(-3deg); } }
@keyframes down { 25% { transform: translateX(-6px); } 50% { transform: translateX(5px); } 75% { transform: translateX(-3px); } }

/* ---- words that come and go -------------------------------------------- */

.zone {
  position: fixed;
  left: 0; right: 0;
  top: var(--surf);
  display: grid;
  justify-items: center;
  gap: 42vh;                 /* clear of the waterline, where the running is */
  transform: translateY(-50%);
  pointer-events: none;
  opacity: 0;
  text-align: center;
}
.zone b {
  font-size: clamp(22px, 7vw, 38px);
  font-weight: 700;
  line-height: 1;
  padding: 0 12px;
}
.zone b:first-child { color: #fff; -webkit-text-stroke: 6px var(--ink); paint-order: stroke fill; }
.zone b:last-child { color: var(--night); text-shadow: 0 0 14px var(--night); transform: scaleY(-1); }
.zone i { display: none; }
.zone.is-on { animation: zone 3.4s ease both; }
@keyframes zone {
  0% { opacity: 0; gap: 56vh; }
  14%, 78% { opacity: 1; gap: 42vh; }
  100% { opacity: 0; gap: 36vh; }
}

.toast {
  position: fixed;
  left: 0; right: 0;
  top: calc(env(safe-area-inset-top) + 118px);
  text-align: center;
  font-size: clamp(20px, 6vw, 30px);
  font-weight: 700;
  color: var(--accent);
  -webkit-text-stroke: 5px var(--ink);
  paint-order: stroke fill;
  pointer-events: none;
  opacity: 0;
}
.toast.is-on { animation: toast 1.3s ease-out both; }
@keyframes toast {
  0% { opacity: 0; transform: scale(.6); }
  18% { opacity: 1; transform: scale(1.12); }
  30% { transform: scale(1); }
  75% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-14px); }
}

.hint {
  position: fixed;
  left: 50%;
  top: 27%;
  width: max-content;
  max-width: calc(100vw - 32px);
  margin: 0;
  padding: 9px 16px;
  border-radius: 16px;
  background: var(--ink);
  color: var(--cream);
  font-size: 17px;
  font-weight: 500;
  text-align: center;
  transform: translate(-50%, 8px);
  opacity: 0;
  transition: opacity .25s, transform .25s;
  pointer-events: none;
}
.hint b { color: var(--accent); font-weight: 700; }
.hint.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ---- the two thumbs ---------------------------------------------------- */

.pads {
  position: fixed;
  left: 0; right: 0;
  bottom: calc(env(safe-area-inset-bottom) + 18px);
  display: flex;
  justify-content: space-between;
  padding: 0 18px;
  pointer-events: none;
  opacity: 0;
  transition: opacity .4s;
}
.pads.is-on { opacity: 1; }
.pads.is-faint { opacity: .34; }
.pad {
  display: grid;
  justify-items: center;
  gap: 2px;
  width: 92px;
  padding: 10px 0 8px;
  border-radius: 24px;
  border: 2px solid rgba(255, 255, 255, .5);
  background: rgba(16, 12, 52, .42);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: #fff;
  transition: transform .08s, background .12s;
}
.pad svg { width: 34px; height: 34px; fill: none; stroke: currentColor; stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
.pad b { font-size: 15px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.pad kbd { display: none; font: inherit; font-size: 12px; opacity: .7; }
.pad.is-down { transform: scale(.9); background: rgba(255, 255, 255, .3); }
.pad.is-cue { border-color: var(--accent); color: var(--accent); animation: cue .5s ease-in-out infinite alternate; }
@keyframes cue { to { transform: scale(1.14); box-shadow: 0 0 0 8px rgba(255, 255, 255, .14); } }
@media (hover: hover) and (pointer: fine) { .pad kbd { display: block; } }

/* ---- title ------------------------------------------------------------- */

.title, .under {
  position: fixed;
  left: 0; right: 0;
  display: grid;
  justify-items: center;
  text-align: center;
  pointer-events: none;
  transition: opacity .35s, transform .45s cubic-bezier(.3, 0, .2, 1);
}
.title { bottom: calc(100% - var(--surf) + 13vh); gap: 6px; }
.under { top: calc(var(--surf) + 13vh); }
.title.is-off { opacity: 0; transform: translateY(-30px); }
.under.is-off { opacity: 0; transform: translateY(30px); }

.logo {
  margin: 0;
  font-size: clamp(54px, 19vw, 120px);
  font-weight: 700;
  line-height: .95;
  letter-spacing: -.01em;
  color: #fffdf2;
  -webkit-text-stroke: clamp(8px, 2.6vw, 14px) var(--ink);
  paint-order: stroke fill;
  text-shadow: 0 clamp(4px, 1.4vw, 8px) 0 var(--ink);
}
.under .logo {
  display: block;
  transform: scaleY(-1);
  color: #101046;
  -webkit-text-stroke: clamp(3px, .9vw, 5px) var(--night);
  text-shadow: 0 0 22px rgba(125, 249, 255, .9);
  opacity: .9;
  animation: swim 3.2s ease-in-out infinite alternate;
}
@keyframes swim { from { transform: scaleY(-1) skewX(-2.5deg); } to { transform: scaleY(-1) skewX(2.5deg); } }

.tagline {
  margin: 4px 0 0;
  padding: 5px 14px;
  border-radius: 99px;
  background: var(--ink);
  font-size: clamp(14px, 4.2vw, 19px);
  font-weight: 500;
}
.title-best { margin: 2px 0 0; font-size: 16px; font-weight: 600; color: var(--ink); }
.title-best b { font-weight: 700; }

.prompt {
  position: fixed;
  left: 0; right: 0;
  bottom: calc(env(safe-area-inset-bottom) + 7vh);
  margin: 0;
  text-align: center;
  font-size: clamp(18px, 5.4vw, 24px);
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: #fff;
  text-shadow: 0 0 18px rgba(125, 249, 255, .8);
  pointer-events: none;
  transition: opacity .3s;
}
.prompt span { display: inline-block; animation: breathe 1.15s ease-in-out infinite alternate; }
.prompt.is-off { opacity: 0; }
@keyframes breathe { from { opacity: .55; transform: scale(.97); } to { opacity: 1; transform: scale(1.03); } }

/* ---- run over ---------------------------------------------------------- */

.over {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(10, 8, 40, .46);
  animation: fade .35s both;
}
.over[hidden], .paused[hidden] { display: none; }
@keyframes fade { from { opacity: 0; } }
.card {
  width: min(340px, 100%);
  padding: 22px 22px 20px;
  border-radius: 30px;
  background: var(--cream);
  color: var(--ink);
  text-align: center;
  box-shadow: 0 8px 0 var(--ink), 0 0 0 5px var(--ink);
  animation: card .5s cubic-bezier(.2, 1.4, .4, 1) both;
}
@keyframes card { from { transform: translateY(40px) scale(.9); opacity: 0; } }
.card p { margin: 0; }
.over-cause { font-size: 17px; font-weight: 600; opacity: .75; }
.over-new {
  display: inline-block;
  margin-top: 8px !important;
  padding: 2px 12px;
  border-radius: 99px;
  background: #ff5fa2;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  animation: up .6s cubic-bezier(.2, 1.6, .4, 1) .3s both;
}
.over-score { font-size: 76px; font-weight: 700; line-height: 1.05; font-variant-numeric: tabular-nums; }
.over-best { font-size: 16px; font-weight: 500; opacity: .7; min-height: 1.3em; }
.over-best b { font-weight: 700; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 16px 0 10px; }
.stats div { padding: 8px 4px; border-radius: 16px; background: rgba(27, 20, 64, .08); }
.stats dt { font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; opacity: .65; }
.stats dd { margin: 0; font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.over-zone { font-size: 15px; font-weight: 500; opacity: .8; margin-bottom: 16px !important; }
.over-zone b { font-weight: 700; }

.btn {
  display: block;
  width: 100%;
  padding: 12px 10px;
  border: 0;
  border-radius: 18px;
  background: rgba(27, 20, 64, .1);
  color: var(--ink);
  font: inherit;
  font-size: 17px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
}
.btn-main {
  padding: 15px 10px;
  background: var(--accent);
  font-size: 21px;
  font-weight: 700;
  box-shadow: 0 5px 0 var(--ink), 0 0 0 3px var(--ink);
  margin-bottom: 16px;
}
.btn:active { transform: translateY(2px); }
.btn-main:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink), 0 0 0 3px var(--ink); }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn:focus-visible, .chip:focus-visible { outline: 3px solid #ff5fa2; outline-offset: 3px; }

/* ---- corners ----------------------------------------------------------- */

.paused {
  position: fixed;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 6px;
  background: rgba(10, 8, 40, .6);
}
.paused b { font-size: 44px; font-weight: 700; }
.paused span { font-size: 18px; font-weight: 500; opacity: .85; }

.corner {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 12px);
  left: calc(env(safe-area-inset-left) + 12px);
  right: calc(env(safe-area-inset-right) + 12px);
  display: flex;
  gap: 8px;
  pointer-events: none;
}
.chip {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  cursor: pointer;
  pointer-events: auto;
  touch-action: manipulation;
  transition: opacity .25s, transform .25s;
}
.chip[hidden] { display: none; }
.chip svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
#sound { margin-left: auto; }
#sound .mute { display: none; }
#sound[aria-pressed="false"] .wave { display: none; }
#sound[aria-pressed="false"] .mute { display: block; }
.corner.is-play #back, .corner.is-play #sound { opacity: 0; transform: scale(.6); pointer-events: none; }
.corner.is-play #pause { opacity: .55; }

.fail {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  padding: 32px;
  background: #101046;
  text-align: center;
  font-size: 18px;
}
.fail[hidden] { display: none; }

@media (max-height: 520px) {
  .hud { top: calc(env(safe-area-inset-top) + 6px); }
  .score { font-size: 34px; -webkit-text-stroke-width: 5px; }
  .harmony { font-size: 11px; padding: 2px 9px 2px 5px; }
  .harmony b { font-size: 12px; min-width: 28px; }
  .toast { top: calc(env(safe-area-inset-top) + 76px); font-size: 20px; }
  .pad { width: 78px; padding: 6px 0 5px; }
  .pad svg { width: 26px; height: 26px; }
  .title { bottom: calc(100% - var(--surf) + 8vh); }
  .under { top: calc(var(--surf) + 8vh); }
  .logo { font-size: clamp(40px, 15vh, 80px); }
  .tagline { display: none; }
  .card { padding: 14px 18px; }
  .over-score { font-size: 48px; }
  .stats { margin: 8px 0 6px; }
  .btn-main { margin-bottom: 10px; padding: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .prompt span, .under .logo, .pad.is-cue { animation: none; }
}
