/* Deep Cut, Storybook Critters: Digby the mole digs through five layers of a
   storybook hillside. Sky blue, chunky rounded type, white cards with a soft
   drop, sunflower buttons. */

:root {
  color-scheme: light;
  --sky: #cfeaff;
  --ink: #2e2a3b;
  --ink-2: #3e3a52;
  --muted: #5b5670;
  --card: #ffffff;
  --card-edge: #9cc8ea;
  --track: #eaf4ff;
  --sun: #ffb938;
  --sun-edge: #d68a00;
  --coral: #ff6f61;
  --error: #b23a2e;
  --good: #2f7d3e;
  --link: #1f5f99;
  --layer-1: #c98b5b;
  --layer-2: #b26a3e;
  --layer-3: #8c7b6b;
  --layer-4: #4e4378;
  --layer-5: #e2643a;
  --display: Fredoka, Nunito, system-ui, sans-serif;
  font: 16px/1.5 Nunito, system-ui, -apple-system, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
}

body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--sky);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

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

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

[hidden] {
  display: none !important;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 14px;
}

:focus-visible {
  outline: 3px solid var(--link);
  outline-offset: 2px;
}

/* Header */

.top {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  gap: 8px;
  width: min(560px, 100%);
  margin: 0 auto;
  padding: 14px 16px 6px;
}

.wordmark {
  text-align: center;
}

.wordmark h1 {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--display);
  font-weight: 700;
  font-size: 27px;
  line-height: 1.1;
}

.wordmark h1 svg {
  width: 24px;
  height: 24px;
}

.day-label {
  margin: 2px 0 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-2);
}

.icon-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 14px;
  background: var(--card);
  box-shadow: 0 3px 0 var(--card-edge);
  font-family: var(--display);
  font-weight: 700;
  font-size: 19px;
  cursor: pointer;
}

.icon-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.6;
  stroke-linecap: round;
}

/* Layout and shared pieces */

main {
  flex: 1;
  width: min(560px, 100%);
  margin: 0 auto;
  padding: 6px 16px 24px;
}

.screen {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.card {
  padding: 14px 16px;
  border-radius: 20px;
  background: var(--card);
  box-shadow: 0 4px 0 var(--card-edge);
}

.primary {
  min-height: 54px;
  padding: 12px 20px;
  border: 0;
  border-radius: 18px;
  background: var(--sun);
  box-shadow: 0 4px 0 var(--sun-edge);
  font-family: var(--display);
  font-weight: 600;
  font-size: 19px;
  color: var(--ink);
  cursor: pointer;
  transition: transform 0.08s, box-shadow 0.08s;
}

.primary:hover {
  filter: brightness(1.04);
}

.primary:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--sun-edge);
}

.secondary {
  min-height: 48px;
  padding: 10px 18px;
  border: 2px solid var(--ink);
  border-radius: 16px;
  background: var(--card);
  font-family: var(--display);
  font-weight: 600;
  font-size: 17px;
  cursor: pointer;
}

.link {
  align-self: center;
  padding: 8px;
  border: 0;
  background: none;
  color: var(--ink-2);
  font-size: 15px;
  text-decoration: underline;
  cursor: pointer;
}

.kicker {
  margin: 0;
  text-align: center;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-2);
}

/* The five layers, used as the tiers: on the start screen and the results */

.strata {
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 4px 0 var(--card-edge);
}

.stratum {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 34px;
  padding: 4px 10px;
  background: var(--c);
  font-family: var(--display);
  font-weight: 600;
  font-size: 14px;
}

.stratum > span {
  padding: 1px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
}

.stratum.now {
  min-height: 44px;
  box-shadow: inset 0 0 0 3px var(--sun);
}

.stratum.now > span:first-child {
  background: var(--sun);
}

.stratum svg {
  width: 34px;
  height: 34px;
}

/* Start screen */

.hello {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 6px;
}

.hello-digby {
  width: 108px;
  height: 108px;
  flex: none;
}

.bubble {
  position: relative;
  margin: 0 0 56px;
  padding: 10px 14px;
  border-radius: 18px;
  background: var(--card);
  box-shadow: 0 3px 0 var(--card-edge);
  font-family: var(--display);
  font-weight: 600;
  font-size: 17px;
}

.bubble::after {
  content: "";
  position: absolute;
  right: -14px;
  bottom: 12px;
  border: 8px solid transparent;
  border-left-color: var(--card);
}

.headline {
  margin: -6px 0 0;
  text-align: center;
  font-family: var(--display);
  font-weight: 700;
  font-size: 27px;
  line-height: 1.2;
}

#intro > p {
  margin: 0;
  text-align: center;
  color: var(--ink-2);
}

#intro > .fine {
  font-size: 13px;
}

.example {
  display: grid;
  gap: 8px;
}

.example p {
  margin: 0;
}

.example-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 2px 10px;
  font-weight: 700;
}

.example-row strong {
  font-family: var(--display);
  font-weight: 600;
}

.example-bar,
.s-bar {
  grid-column: 1 / -1;
  height: 10px;
  border-radius: 6px;
  background: var(--track);
  overflow: hidden;
}

.example-bar span,
.s-bar span {
  display: block;
  height: 100%;
  width: calc(var(--d) * 1%);
  min-width: 4px;
  border-radius: 6px;
  background: var(--c, var(--layer-1));
}

/* A prompt */

.progress {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.progress li {
  width: 30px;
  height: 10px;
  border-radius: 10px;
  background: var(--card);
}

.progress li.done {
  background: var(--sun);
}

.progress li.now {
  box-shadow: inset 0 0 0 3px var(--sun);
}

.prompt-card {
  text-align: center;
}

.prompt-label {
  margin: 0;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.prompt-text {
  margin: 2px 0 12px;
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(26px, 7vw, 34px);
  line-height: 1.15;
}

.timer {
  height: 12px;
  border-radius: 8px;
  background: var(--track);
  overflow: hidden;
}

.timer-fill {
  width: 100%;
  height: 100%;
  border-radius: 8px;
  background: var(--sun);
  transform-origin: left;
}

.timer-fill.low {
  background: var(--coral);
}

.timer-text {
  margin: 6px 0 0;
  font-family: var(--display);
  font-weight: 600;
  font-size: 15px;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}

.guess {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.guess input {
  min-width: 0;
  min-height: 54px;
  padding: 10px 16px;
  border: 2px solid var(--ink);
  border-radius: 16px;
  background: var(--card);
  font-size: 19px;
}

.guess input:focus {
  outline: none;
  box-shadow: 0 0 0 3px var(--sun);
}

.guess.shake {
  animation: shake 0.32s;
}

@keyframes shake {
  20%,
  60% {
    transform: translateX(-6px);
  }
  40%,
  80% {
    transform: translateX(6px);
  }
}

.feedback {
  min-height: 22px;
  margin: -4px 0 0;
  text-align: center;
  font-weight: 700;
  color: var(--error);
}

.feedback.ok {
  color: var(--good);
}

.digby-status {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.6);
  font-size: 14px;
  color: var(--ink-2);
}

.digby-status p {
  margin: 0;
}

.digby-status svg {
  width: 48px;
  height: 48px;
  flex: none;
}

/* The reveal: the answer, and Digby digging */

.answer-card p {
  margin: 0;
}

.answer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 2px 0;
}

.reveal-answer {
  margin: 0;
  font-family: var(--display);
  font-weight: 600;
  font-size: 24px;
  line-height: 1.15;
}

.reveal-answer.missed {
  color: var(--muted);
}

/* Rarities, colored like loot: gray, green, blue, purple, gold */

.rarity {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.5;
  white-space: nowrap;
  vertical-align: 1px;
}

.rarity.r0 {
  background: #ece8e1;
  color: #5d554b;
}

.rarity.r1 {
  background: #d9f2d2;
  color: #2b6e27;
}

.rarity.r2 {
  background: #d8e8ff;
  color: #1d5aa8;
}

.rarity.r3 {
  background: #ebdcff;
  color: #6236ad;
}

.rarity.r4 {
  background: linear-gradient(135deg, #ffe48a, #ffc93c);
  color: #7a4b00;
  box-shadow: 0 0 0 1.5px #e0a400 inset;
}

.rarity.none {
  color: var(--muted);
}

.reveal-rarity {
  flex: none;
  margin-left: auto;
}

.reveal-rarity .rarity {
  font-size: 14px;
  padding: 3px 10px;
}

.rarity-key {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.rarity-key b {
  font-weight: 800;
  opacity: 0.8;
}

.depth-pill {
  flex: none;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--sun);
  font-family: var(--display);
  font-weight: 600;
  font-size: 17px;
  font-variant-numeric: tabular-nums;
}

.scene {
  margin: 0 -16px;
}

.scene svg {
  display: block;
  width: 100%;
  height: auto;
}

.scene-label {
  font-family: var(--display);
  font-weight: 600;
  font-size: 11.5px;
  fill: var(--ink);
}

.scene-sign {
  font-family: Nunito, sans-serif;
  font-weight: 800;
  font-size: 11px;
  fill: #3a2418;
}

.dig-total {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.dig-number {
  margin: 0;
  font-family: var(--display);
  font-weight: 700;
  font-size: 46px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.dig-unit {
  font-size: 24px;
}

.dig-tier {
  margin: 0;
  text-align: right;
  font-size: 14px;
  line-height: 1.35;
  color: var(--ink-2);
}

.lists {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.lists .card {
  padding: 12px 14px;
}

.lists h3 {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.lists ul {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 14px;
}

.lists li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.lists li span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lists li span:last-child {
  flex: none;
  font-weight: 800;
}

/* Digby's moves */

.digby-move {
  transition: transform 1.6s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.digby-bob {
  animation: bob 0.45s ease-in-out infinite alternate;
}

@keyframes bob {
  from {
    transform: translateY(-2px);
  }
  to {
    transform: translateY(2px);
  }
}

.claw {
  transform-box: fill-box;
  transform-origin: 50% 0%;
  animation: claw 0.22s ease-in-out infinite alternate;
}

.claw-2 {
  animation-delay: 0.11s;
}

@keyframes claw {
  from {
    transform: rotate(-20deg);
  }
  to {
    transform: rotate(20deg);
  }
}

.wave {
  transform-box: fill-box;
  transform-origin: 30% 100%;
  animation: wave 0.5s ease-in-out infinite alternate;
}

@keyframes wave {
  from {
    transform: rotate(-25deg);
  }
  to {
    transform: rotate(15deg);
  }
}

.dirt {
  animation: dirt 0.9s ease-out infinite;
}

@keyframes dirt {
  from {
    transform: translate(0, 0);
    opacity: 1;
  }
  to {
    transform: translate(var(--dx), var(--dy));
    opacity: 0;
  }
}

.tunnel-new {
  transition: stroke-dashoffset 1.6s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.sign-new {
  transform-box: fill-box;
  transform-origin: 0% 50%;
  animation: pop 0.5s 1.4s both cubic-bezier(0.3, 1.6, 0.5, 1);
}

@keyframes pop {
  from {
    transform: scale(0);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.worm {
  transform-box: fill-box;
  transform-origin: 50% 50%;
  animation: wiggle 1.1s ease-in-out infinite alternate;
}

@keyframes wiggle {
  from {
    transform: rotate(-7deg);
  }
  to {
    transform: rotate(7deg);
  }
}

.twinkle {
  animation: twinkle 1.4s ease-in-out infinite alternate;
}

@keyframes twinkle {
  from {
    opacity: 0.45;
  }
  to {
    opacity: 1;
  }
}

.rise {
  animation: rise 2.6s ease-in infinite;
}

@keyframes rise {
  from {
    transform: translateY(0);
    opacity: 0.95;
  }
  to {
    transform: translateY(-30px);
    opacity: 0;
  }
}

/* Results */

.medal {
  display: grid;
  place-items: center;
}

.medal svg {
  width: 200px;
  height: 122px;
}

.medal-swing {
  transform-box: fill-box;
  transform-origin: 50% 0%;
  animation: swing 2.4s ease-in-out infinite alternate;
}

@keyframes swing {
  from {
    transform: rotate(-5deg);
  }
  to {
    transform: rotate(5deg);
  }
}

.confetti {
  animation: fall 3.2s linear infinite;
}

@keyframes fall {
  from {
    transform: translateY(-20px) rotate(0deg);
    opacity: 0;
  }
  10% {
    opacity: 1;
  }
  to {
    transform: translateY(130px) rotate(220deg);
    opacity: 0;
  }
}

#results .kicker + .kicker {
  margin-top: -12px;
}

.tier-name {
  margin: -10px 0 0;
  text-align: center;
  font-family: var(--display);
  font-weight: 700;
  font-size: 38px;
  line-height: 1.1;
}

.total {
  margin: -8px 0 0;
  text-align: center;
  font-family: var(--display);
  font-weight: 700;
  font-size: 32px;
  font-variant-numeric: tabular-nums;
}

.total .muted {
  font-family: Nunito, sans-serif;
  font-weight: 400;
}

#total-note {
  margin: -12px 0 0;
  text-align: center;
}

.summary {
  display: grid;
  gap: 9px;
  margin: 0;
  list-style: none;
  font-size: 14px;
}

.summary li {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) 46px;
  align-items: center;
  gap: 8px;
}

.summary .s-bar {
  grid-column: auto;
}

.s-prompt {
  display: block;
  font-size: 12.5px;
  color: var(--muted);
}

.s-answer {
  display: block;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.s-answer.missed {
  font-weight: 700;
  color: var(--muted);
}

.s-depth {
  text-align: right;
  font-family: var(--display);
  font-weight: 600;
}

.next-in {
  margin: 0;
  text-align: center;
  color: var(--ink-2);
}

.next-in strong {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

/* Dialogs */

.sheet {
  width: min(460px, calc(100% - 32px));
  padding: 20px;
  border: 0;
  border-radius: 24px;
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 6px 0 var(--card-edge);
}

.sheet::backdrop {
  background: rgba(46, 42, 59, 0.45);
}

.sheet h2 {
  margin: 0 0 12px;
  font-family: var(--display);
  font-weight: 700;
}

.sheet-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sheet-head h2 {
  margin: 0;
}

.sheet-digby {
  width: 64px;
  height: 64px;
  flex: none;
}

.sheet ul {
  display: grid;
  gap: 8px;
  margin: 12px 0 16px;
  padding-left: 20px;
}

.sheet .primary {
  width: 100%;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.stat {
  padding: 12px 6px;
  border-radius: 16px;
  background: var(--sky);
  text-align: center;
}

.stat strong {
  display: block;
  font-family: var(--display);
  font-size: 24px;
  font-variant-numeric: tabular-nums;
}

.stat span {
  font-size: 12px;
  color: var(--ink-2);
}

.foot {
  width: min(560px, 100%);
  margin: 0 auto;
  padding: 10px 16px 20px;
  text-align: center;
  font-size: 12px;
  color: var(--ink-2);
}

.foot p {
  margin: 0;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
