/* Kingfisher. The game is the canvas; everything here floats over it, set
 * like the labels on a print: ink on paper, in boxed cartouches, with the
 * vermilion of a seal for anything that matters. */

:root {
  --accent: #e2577a;
  --paper: #f2e8d5;
  --paper-2: #e9dcc2;
  --ink: #1e1a18;
  --dim: rgba(30, 26, 24, .62);
  --seal: #c8382b;
  --top: env(safe-area-inset-top, 0px);
  --bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #f2e8d5;
  color: var(--ink);
  font-family: "Shippori Mincho", "Hiragino Mincho ProN", "Yu Mincho", Georgia, "Times New Roman", serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  overscroll-behavior: none;
}

body { position: fixed; inset: 0; }

#print { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

p { margin: 0; }

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

/* A box set on the print: paper, a rule, a finer rule inside it. */
.cartouche, .card, .title .name, .zone b, .chip, .btn {
  background: var(--paper);
  border: 2px solid var(--ink);
  box-shadow: inset 0 0 0 3px var(--paper), inset 0 0 0 4px rgba(30, 26, 24, .55), 0 3px 0 rgba(30, 26, 24, .18);
}

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

.hud {
  position: absolute;
  top: calc(var(--top) + 2.6vh);
  left: 0; right: 0;
  display: grid;
  justify-items: center;
  gap: 8px;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity .5s ease, transform .5s ease;
}
.hud.is-on { opacity: 1; transform: none; }

.cartouche { min-width: 96px; padding: 4px 20px 6px; text-align: center; }

.score {
  font-size: clamp(38px, 11vmin, 60px);
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.score.bump { animation: bump .32s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes bump { 0% { transform: scale(1.2); } 100% { transform: scale(1); } }

.hunger {
  position: relative;
  width: min(46vw, 190px);
  height: 9px;
  border: 1.5px solid var(--ink);
  background: var(--paper);
  overflow: hidden;
}
.hunger i {
  position: absolute;
  inset: 1.5px;
  background: repeating-linear-gradient(90deg, #2c5d8f 0 6px, #24507c 6px 7px);
  transform-origin: left center;
  transition: transform .25s ease, background .4s ease;
}
.hunger.is-low { animation: low 0.9s ease-in-out infinite; }
.hunger.is-low i { background: repeating-linear-gradient(90deg, var(--seal) 0 6px, #a72c22 6px 7px); }
@keyframes low { 50% { transform: scale(1.05); } }

.streak {
  display: flex;
  align-items: baseline;
  gap: .55em;
  padding: 3px 12px 4px;
  background: var(--seal);
  color: var(--paper);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
  box-shadow: 0 2px 0 rgba(30, 26, 24, .25);
  opacity: 0;
  transform: scale(.8) rotate(-2deg);
  transition: opacity .25s ease, transform .25s ease;
}
.streak b { font-size: 18px; font-weight: 800; letter-spacing: 0; }
.streak.is-on { opacity: 1; transform: rotate(-2deg); }
.streak.bump { animation: stamp .36s cubic-bezier(.2, 1.8, .4, 1); }
@keyframes stamp { 0% { transform: scale(1.35) rotate(-6deg); } 100% { transform: rotate(-2deg); } }

/* ---- floating words ---------------------------------------------------- */

.pops { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }

.pop {
  position: absolute;
  left: 0; top: 0;
  display: grid;
  justify-items: center;
  white-space: nowrap;
  color: var(--ink);
  font-size: 22px;
  font-weight: 800;
  text-shadow: 0 0 3px var(--paper), 0 0 8px var(--paper), 0 0 14px var(--paper);
  animation: pop 1.05s cubic-bezier(.15, .8, .3, 1) forwards;
  will-change: transform, opacity;
}
.pop small {
  margin: 1px 0;
  padding: 1px 7px 2px;
  background: var(--seal);
  color: var(--paper);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .26em;
  text-indent: .26em;
  text-shadow: none;
  text-transform: uppercase;
}
.pop.is-perfect { font-size: 28px; }
.pop.is-miss small { background: var(--ink); }
@keyframes pop {
  0% { opacity: 0; transform: translate(-50%, -30%) scale(.6); }
  14% { opacity: 1; transform: translate(-50%, -100%) scale(1.12); }
  30% { transform: translate(-50%, -115%) scale(1); }
  72% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -200%) scale(.96); }
}

/* ---- zone banner ------------------------------------------------------- */

.zone {
  position: absolute;
  top: 26%;
  left: 0; right: 0;
  display: grid;
  justify-items: center;
  gap: 8px;
  pointer-events: none;
  opacity: 0;
}
.zone small {
  padding: 2px 8px;
  background: var(--seal);
  color: var(--paper);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .36em;
  text-indent: .36em;
  text-transform: uppercase;
}
.zone b {
  padding: 8px 22px 10px;
  font-size: clamp(22px, 7vmin, 36px);
  font-weight: 800;
  letter-spacing: .12em;
}
.zone.is-on { animation: zone 2.9s ease forwards; }
@keyframes zone {
  0% { opacity: 0; transform: translateY(-8px); }
  14% { opacity: 1; transform: none; }
  76% { opacity: 1; }
  100% { opacity: 0; }
}

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

.title {
  position: absolute;
  top: calc(var(--top) + 6vh);
  left: 0; right: 0;
  display: grid;
  justify-items: center;
  gap: 1.6vh;
  pointer-events: none;
  transition: opacity .6s ease, transform .9s cubic-bezier(.3, 0, .2, 1);
}
.title.is-off { opacity: 0; transform: translateY(-6vh); }
.seal { width: min(22vw, 13vh, 112px); transform: rotate(-3deg); }
.seal-svg { display: block; width: 100%; height: auto; filter: drop-shadow(0 2px 0 rgba(30, 26, 24, .2)); }
.title .name {
  margin: 0;
  padding: .12em .7em .2em;
  font-size: clamp(34px, 10.5vmin, 58px);
  font-weight: 800;
  letter-spacing: .08em;
  line-height: 1.1;
}
.tagline {
  padding: 2px 10px 3px;
  background: rgba(242, 232, 213, .82);
  color: var(--ink);
  font-size: clamp(13px, 3.8vmin, 17px);
  font-weight: 500;
  letter-spacing: .1em;
}
.title-best {
  padding: 3px 12px;
  background: var(--ink);
  color: var(--paper);
  font-size: 11px;
  letter-spacing: .26em;
  text-indent: .26em;
  text-transform: uppercase;
}
.title-best b { font-weight: 800; letter-spacing: .04em; }

/* ---- tap prompt and hints ---------------------------------------------- */

.prompt {
  position: absolute;
  left: 0; right: 0;
  bottom: calc(var(--bottom) + 5vh);
  display: grid;
  justify-items: center;
  pointer-events: none;
  transition: opacity .35s ease;
}
.prompt span {
  padding: 5px 14px 6px;
  background: var(--ink);
  color: var(--paper);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .34em;
  text-indent: .34em;
  text-transform: uppercase;
  animation: breathe 1.6s ease-in-out infinite;
}
.prompt.is-off { opacity: 0; }
@keyframes breathe { 0%, 100% { opacity: .6; } 50% { opacity: 1; } }

.hint {
  position: absolute;
  left: 8vw; right: 8vw;
  bottom: calc(var(--bottom) + 11vh);
  display: grid;
  justify-items: center;
  pointer-events: none;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .45s ease, transform .45s ease;
}
.hint.is-on { opacity: 1; transform: none; }
.hint:not(:empty) {
  width: fit-content;
  max-width: 84vw;
  margin: 0 auto;
  padding: 7px 14px 8px;
  background: rgba(242, 232, 213, .92);
  border: 1.5px solid var(--ink);
  font-size: 15px;
  font-weight: 500;
  line-height: 1.4;
  text-align: center;
}
.hint b { color: var(--seal); font-weight: 800; }

/* ---- game over --------------------------------------------------------- */

.over {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: calc(var(--top) + 20px) 22px calc(var(--bottom) + 20px);
  background: rgba(30, 26, 24, .18);
  animation: fade-in .45s ease both;
}
.over[hidden] { display: none; }
@keyframes fade-in { from { opacity: 0; } }

.card {
  position: relative;
  width: min(100%, 360px);
  padding: 26px 24px 22px;
  text-align: center;
  animation: card-in .55s cubic-bezier(.2, 1.2, .3, 1) both;
}
@keyframes card-in { from { opacity: 0; transform: translateY(26px) scale(.95); } }
.card-seal {
  position: absolute;
  top: -18px; right: -14px;
  width: 64px;
  transform: rotate(8deg);
  animation: stamp-in .5s cubic-bezier(.2, 1.6, .4, 1) .3s both;
}
@keyframes stamp-in { from { opacity: 0; transform: scale(1.6) rotate(-10deg); } }

.over-cause { color: var(--dim); font-size: 12px; font-weight: 700; letter-spacing: .28em; text-indent: .28em; text-transform: uppercase; }
.over-new {
  display: inline-block;
  margin-top: 14px;
  padding: 3px 12px 4px;
  background: var(--seal);
  color: var(--paper);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .24em;
  text-indent: .24em;
  text-transform: uppercase;
  animation: bump .5s cubic-bezier(.2, 1.8, .4, 1) .35s both;
}
.over-new[hidden] { display: none; }
.over-score {
  margin-top: 4px;
  font-size: clamp(72px, 23vmin, 108px);
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.over-best { color: var(--dim); font-size: 12px; letter-spacing: .24em; text-indent: .24em; text-transform: uppercase; }
.over-best b { color: var(--ink); font-weight: 800; }

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: 18px 0 0;
  padding: 12px 0;
  border-top: 1.5px solid var(--ink);
  border-bottom: 1.5px solid var(--ink);
}
.stats div + div { border-left: 1px solid rgba(30, 26, 24, .35); }
.stats dt { color: var(--dim); font-size: 10px; font-weight: 700; letter-spacing: .16em; text-indent: .16em; text-transform: uppercase; }
.stats dd { margin: 4px 0 0; font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; }

.over-zone { margin-top: 12px; color: var(--dim); font-size: 14px; }
.over-zone b { color: var(--seal); font-weight: 800; }

.btn {
  display: grid;
  place-items: center;
  min-height: 48px;
  padding: 0 18px;
  color: var(--ink);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: .22em;
  text-indent: .22em;
  text-decoration: none;
  text-transform: uppercase;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform .12s ease;
}
.btn:active { transform: scale(.96); }
.btn:focus-visible, .chip:focus-visible { outline: 3px solid var(--seal); outline-offset: 3px; }
.btn-main {
  width: 100%;
  min-height: 56px;
  margin-top: 18px;
  background: var(--seal);
  border-color: var(--ink);
  box-shadow: inset 0 0 0 3px var(--seal), inset 0 0 0 4px rgba(242, 232, 213, .7), 0 3px 0 rgba(30, 26, 24, .25);
  color: var(--paper);
  font-size: 15px;
  font-weight: 800;
}
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }

/* ---- corner controls --------------------------------------------------- */

.corner {
  position: absolute;
  top: calc(var(--top) + 12px);
  left: 14px; right: 14px;
  display: flex;
  justify-content: space-between;
  pointer-events: none;
  transition: opacity .4s ease;
}
.corner.is-off { opacity: 0; }
.corner.is-off .chip { pointer-events: none; }

.chip {
  display: grid;
  place-items: center;
  width: 44px; height: 44px;
  padding: 0;
  border-radius: 50%;
  box-shadow: 0 2px 0 rgba(30, 26, 24, .2);
  color: var(--ink);
  cursor: pointer;
  pointer-events: auto;
  touch-action: manipulation;
}
.chip svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.chip .mute { display: none; }
.chip[aria-pressed="false"] { color: var(--dim); }
.chip[aria-pressed="false"] .wave { display: none; }
.chip[aria-pressed="false"] .mute { display: inline; }

/* ---- paused / failure -------------------------------------------------- */

.paused {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 12px;
  background: rgba(242, 232, 213, .7);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.paused[hidden] { display: none; }
.paused b { font-size: 34px; font-weight: 800; letter-spacing: .24em; text-indent: .24em; text-transform: uppercase; }
.paused span { color: var(--dim); font-size: 12px; letter-spacing: .3em; text-indent: .3em; text-transform: uppercase; }

.fail {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 12vw;
  color: var(--dim);
  font-size: 17px;
  line-height: 1.5;
  text-align: center;
}
.fail[hidden] { display: none; }

@media (max-height: 560px) {
  .title { top: calc(var(--top) + 3vh); gap: 1vh; }
  .prompt { bottom: calc(var(--bottom) + 3vh); }
  .card { padding: 16px 20px 14px; }
  .over-score { font-size: 60px; }
  .stats { margin-top: 10px; padding: 8px 0; }
  .btn-main { margin-top: 10px; min-height: 46px; }
}

@media (prefers-reduced-motion: reduce) {
  .prompt span, .score.bump, .streak.bump, .hunger.is-low { animation: none; }
  .title, .hud { transition: opacity .3s ease; }
  .title.is-off { transform: none; }
}
