:root {
  --bg: #0c0c0e;
  --fg: #ebe7e0;
  --dim: #8a867f;
  --faint: rgba(235, 231, 224, 0.07);
  --line: rgba(235, 231, 224, 0.15);
  --glow: #f3d18a;
  --cool: #9fd3e6;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; background: var(--bg); color: var(--fg); }
body {
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  transition: transform 1.2s var(--ease), filter 1.2s var(--ease);
}
body.folding { animation: fold 1.2s var(--ease); }
@keyframes fold {
  40% { transform: scaleY(.02); filter: brightness(3) blur(2px); }
}

main { width: min(800px, 100% - 32px); margin: 0 auto; padding: 7vh 0 25vh; }

#title {
  font: 400 .85rem/1 var(--mono);
  letter-spacing: .7em;
  text-align: center;
  color: var(--dim);
  margin: 0 0 7vh;
  padding-left: .7em;
}
#title span { display: inline-block; }

/* numbers */
/* Digits roll up into place; the box clips them like an odometer window. */
.counter {
  display: inline-block;
  overflow: hidden;
  vertical-align: bottom;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  white-space: pre;
}
.counter span { display: inline-block; }

.card { display: flex; flex-direction: column; align-items: center; min-width: 4.5rem; }
.card .glyph { color: var(--dim); font-size: 1rem; line-height: 1.4; }
.card .counter { font-size: 1.55rem; line-height: 1.2; }
.card .meta { display: flex; gap: .6em; min-height: 1.2em; font-size: .72rem; color: var(--dim); }
.card .rate { color: var(--cool); opacity: .8; font-family: var(--mono); }

.hero { margin-bottom: 4vh; }
.hero .glyph { font-size: 1.4rem; }
.hero .counter {
  font-size: clamp(3.2rem, 14vw, 7.5rem);
  font-weight: 200;
  letter-spacing: -.03em;
  line-height: 1.05;
}

#numbers { display: flex; flex-wrap: wrap; justify-content: center; gap: 1.4rem 2.8rem; }

.omen { opacity: .3; animation: breathe 3.6s ease-in-out infinite; }
.omen .hint { font: .75rem var(--mono); color: var(--dim); }
@keyframes breathe { 50% { opacity: .08; } }

/* the hand */
#hand { display: flex; justify-content: center; margin: 6vh 0; }
#plus {
  width: 5.5rem;
  height: 5.5rem;
  border-radius: 50%;
  font-size: 2rem;
  font-weight: 200;
  transition: transform .12s var(--ease), border-color .3s, box-shadow .4s;
}
#plus:hover { box-shadow: 0 0 50px -12px var(--glow); }
#plus:active { transform: scale(.9); }

/* controls */
button {
  font: inherit;
  color: inherit;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: .5rem .8rem;
  cursor: pointer;
  touch-action: manipulation;
  transition: border-color .25s, background .25s, opacity .25s, box-shadow .3s, color .25s;
}
button:hover:not(:disabled) { border-color: rgba(235, 231, 224, .38); background: rgba(255, 255, 255, .03); }
button:disabled { opacity: .32; cursor: default; }
button:focus-visible { outline: 1px solid var(--glow); outline-offset: 2px; }

.row { display: flex; align-items: center; justify-content: space-between; gap: .6rem; }
.row + .row { margin-top: .5rem; }
.stack { display: grid; gap: .5rem; }
.buy { flex: 1; width: 100%; display: flex; justify-content: space-between; gap: 1rem; font-family: var(--mono); font-size: .9rem; }
.buy > :first-child { text-align: left; }
.cost { color: var(--dim); white-space: nowrap; }
.auto { font-family: var(--mono); opacity: .5; }
.auto.on { opacity: 1; color: var(--glow); border-color: rgba(243, 209, 138, .4); }

/* panels */
#panels {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 330px), 1fr));
  gap: 1rem;
  align-items: start;
}
.panel {
  border: 1px solid var(--faint);
  border-radius: 16px;
  padding: 1rem 1.1rem 1.1rem;
  background: rgba(255, 255, 255, .015);
  transition: border-color .6s, box-shadow .6s;
}
.panel h2 { margin: 0 0 .85rem; font: 400 .85rem/1 var(--mono); color: var(--dim); letter-spacing: .3em; }

/* the lock */
.lock { display: grid; gap: .6rem; }
.lock h2 { margin-bottom: .2rem; }
.lock .sigil {
  font: 300 2rem/1.2 var(--mono);
  text-align: center;
  letter-spacing: .08em;
  min-height: 2.4rem;
  color: var(--dim);
  transition: color .4s, text-shadow .6s;
}
.lock .legend { text-align: center; font-size: .8rem; color: var(--dim); min-height: 1.2em; }
.lock .ttl { height: 1px; background: var(--line); transform-origin: left; transition: transform 1s linear; }
.lock.ok { border-color: rgba(243, 209, 138, .35); box-shadow: 0 0 60px -30px var(--glow); }
.lock.ok .sigil { color: var(--glow); text-shadow: 0 0 22px rgba(243, 209, 138, .55); }
.lock.ok .strike { border-color: rgba(243, 209, 138, .55); color: var(--glow); }

/* the loom */
.chips { display: flex; flex-wrap: wrap; gap: .45rem; margin-bottom: .7rem; }
.chip { min-width: 2.6rem; font-size: 1.1rem; padding: .35rem .6rem; position: relative; }
.chip.on { border-color: var(--glow); color: var(--glow); box-shadow: 0 0 24px -8px var(--glow); }
.chip .dots { position: absolute; left: 0; right: 0; bottom: -.15rem; font-size: .55rem; color: var(--cool); letter-spacing: .1em; }
.fuse { width: 100%; font-size: 1.1rem; }
.woven, .known, .log { list-style: none; margin: .8rem 0 0; padding: 0; font-size: .8rem; color: var(--dim); display: grid; gap: .3rem; }
.woven .pair { font-family: var(--mono); color: var(--fg); margin-right: .4em; }

/* elsewhere */
.rank { float: right; margin-top: -1.8rem; font: .75rem var(--mono); color: var(--dim); }
.others { list-style: none; margin: 0; padding: 0; font-family: var(--mono); font-size: .85rem; display: grid; gap: .15rem; }
.others li { display: flex; justify-content: space-between; padding: .1rem .4rem; border-radius: 6px; transition: background 1s, color 1s; }
.others .who { color: var(--dim); }
.others .me .who, .others .me { color: var(--fg); }
.others li.echo { background: rgba(159, 211, 230, .1); color: var(--cool); }
.well { margin-top: .9rem; font-family: var(--mono); }
.log { font-style: italic; opacity: .75; }

.armed { border-color: var(--glow); color: var(--glow); }

/* ephemera */
#toasts {
  position: fixed;
  left: 50%;
  bottom: 1.2rem;
  transform: translateX(-50%);
  width: min(520px, 100% - 32px);
  display: grid;
  gap: .4rem;
  pointer-events: none;
  z-index: 10;
}
.toast {
  background: rgba(20, 20, 23, .92);
  border: 1px solid var(--faint);
  border-radius: 12px;
  padding: .55rem .9rem;
  font-size: .85rem;
  text-align: center;
  backdrop-filter: blur(6px);
  animation: rise .6s var(--ease);
  transition: opacity .8s, transform .8s var(--ease);
}
.toast.out { opacity: 0; transform: translateY(6px); }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }

.float {
  position: fixed;
  pointer-events: none;
  font: .95rem var(--mono);
  color: var(--glow);
  text-shadow: 0 0 12px rgba(243, 209, 138, .5);
  z-index: 20;
}

footer { text-align: center; padding: 0 0 6rem; }
#forget { border: none; color: var(--dim); opacity: .35; font-size: .75rem; }
#forget:hover { opacity: .8; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
