/* Emberwake
   Layout: one tall stage, 100 units wide, everything sized in rem where
   1rem = one stage unit (set from script), so a phone and a desktop window
   show the same composition at different scales. */

:root {
  color-scheme: dark;

  /* ink and ash */
  --ink: #0c0a09;
  --soot: #15110f;
  --char: #231b16;
  --ash: #8d8379;
  --bone: #eadec8;
  --bone-dim: #b9ad98;

  /* fire */
  --ember: #ff7a1c;
  --ember-deep: #b83c0e;
  --gold: #ffc46b;
  --blood: #d2493b;

  /* the four kinds of memory, and what is left of them */
  --bond: #f2b266;
  --scar: #d6574a;
  --oath: #a9c2d8;
  --small: #b5c596;
  --ashen: #9a9189;

  --display: 'IM Fell English SC', 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, serif;
  --story: 'IM Fell English', 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, serif;
  --ui: 'Alegreya Sans', 'Gill Sans', 'Gill Sans MT', 'Trebuchet MS', Verdana, sans-serif;

  --gut: max(4.5rem, 16px);
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

html {
  height: 100%;
  box-sizing: border-box;
  /* keep clear of a phone's status bar and home indicator */
  padding: env(safe-area-inset-top, 0px) 0 env(safe-area-inset-bottom, 0px);
  font-size: 3.6px; /* one stage unit; script keeps this in step with the window */
  background: var(--ink);
}

body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--ink);
  color: var(--bone);
  font-family: var(--ui);
  font-size: 4rem;
  line-height: 1.35;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  cursor: pointer;
  touch-action: manipulation;
}

button:focus-visible {
  outline: 0.5rem solid var(--gold);
  outline-offset: 0.5rem;
}

.ico {
  width: 1em;
  height: 1em;
  fill: currentColor;
  vertical-align: -0.14em;
  flex: none;
}

/* ── stage ─────────────────────────────────────────────────────────── */

#app {
  height: 100%;
  display: grid;
  place-items: center;
  background: radial-gradient(120% 80% at 50% 60%, #1c120c 0%, var(--ink) 70%);
}

#stage {
  position: relative;
  width: 100rem;
  height: 100%;
  overflow: hidden;
  background: var(--ink);
  isolation: isolate;
}

.backdrop {
  position: absolute;
  inset: 0;
  z-index: 0;
  transition: transform 1400ms var(--ease);
}

/* In story scenes the words fill the lower half, so the painting rides up
   to keep its subject clear of them. */
#stage.in-scene .backdrop { transform: translateY(-34%); }

.backdrop div {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  opacity: 0;
  transition: opacity 1100ms ease;
}

.backdrop div.on { opacity: 1; }

#fx {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 3;
  pointer-events: none;
}

#screen { position: absolute; inset: 0; z-index: 2; }
#overlay { position: absolute; inset: 0; z-index: 5; pointer-events: none; }
#overlay > * { pointer-events: auto; }

#veil {
  position: absolute;
  inset: 0;
  z-index: 9;
  background: var(--ink);
  opacity: 0;
  pointer-events: none;
  transition: opacity 450ms ease;
}

#veil.on { opacity: 1; pointer-events: auto; }

#stage.shake { animation: shake 320ms; }

@keyframes shake {
  10% { transform: translate(-1.6rem, 0.6rem); }
  30% { transform: translate(1.4rem, -0.8rem); }
  50% { transform: translate(-1rem, 0.4rem); }
  70% { transform: translate(0.6rem, -0.3rem); }
}

#stage.hurt::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  background: radial-gradient(90% 70% at 50% 50%, transparent 40%, rgba(190, 30, 20, 0.55) 100%);
  animation: fade-out 600ms forwards;
}

@keyframes fade-out { to { opacity: 0; } }
@keyframes fade-in { from { opacity: 0; } }

/* ── buttons ───────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 1.6rem;
  min-height: 12rem;
  padding: 0 5rem;
  border: 0.3rem solid rgba(234, 222, 200, 0.4);
  border-radius: 1rem;
  background: rgba(20, 15, 12, 0.72);
  color: var(--bone);
  font-family: var(--display);
  font-size: 4.6rem;
  letter-spacing: 0.06em;
  transition: transform 120ms var(--ease), background 160ms, border-color 160ms, opacity 160ms;
}

.btn:active { transform: scale(0.97); }
.btn small { font-family: var(--ui); font-size: 3.2rem; letter-spacing: 0.02em; opacity: 0.8; }

.btn.primary {
  border-color: rgba(255, 196, 107, 0.75);
  background: linear-gradient(180deg, rgba(184, 60, 14, 0.9), rgba(96, 30, 8, 0.92));
  color: #fff1d6;
  box-shadow: 0 0 5rem rgba(255, 122, 28, 0.28);
}

.btn[disabled] { opacity: 0.38; pointer-events: none; }

.icon-btn {
  width: 10rem;
  height: 10rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: 5rem;
  color: var(--bone-dim);
  background: rgba(12, 10, 9, 0.45);
}

.icon-btn:active { color: var(--bone); }

/* ── title ─────────────────────────────────────────────────────────── */

.title {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 var(--gut);
  padding-left: max(var(--gut), env(safe-area-inset-left, 0px));
  padding-right: max(var(--gut), env(safe-area-inset-right, 0px));
  background: linear-gradient(180deg, rgba(12, 10, 9, 0.62) 0%, rgba(12, 10, 9, 0) 34%, rgba(12, 10, 9, 0) 56%, rgba(12, 10, 9, 0.9) 100%);
  animation: fade-in 900ms both;
}

.title-top {
  position: absolute;
  top: 3rem;
  right: max(3rem, env(safe-area-inset-right, 0px));
}

.title-mark { margin-top: 22rem; text-align: center; }

.title h1 {
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  font-size: 15.5rem;
  line-height: 1;
  letter-spacing: 0.1em;
  margin-right: -0.1em;
  color: #fff0d2;
  text-shadow: 0 0 7rem rgba(255, 122, 28, 0.75), 0 0 2rem rgba(255, 170, 80, 0.6), 0 0.6rem 1rem rgba(0, 0, 0, 0.8);
}

.title .tag {
  margin: 3.2rem 0 0;
  font-family: var(--story);
  font-style: italic;
  font-size: 4.6rem;
  color: var(--bone);
  text-shadow: 0 0.3rem 1.5rem #000;
  text-wrap: balance;
}

.title-actions {
  margin-top: auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 3rem;
  padding-bottom: 8rem;
}

.title-actions .btn { width: 100%; min-height: 14rem; }

.title .progress {
  font-size: 3.4rem;
  color: var(--bone-dim);
  text-align: center;
  min-height: 5rem;
}

.title .foot {
  text-align: center;
  font-size: 3rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ash);
  padding-bottom: 5rem;
}

/* ── story scenes ──────────────────────────────────────────────────── */

.scene {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  background: linear-gradient(180deg, rgba(12, 10, 9, 0) 36%, rgba(12, 10, 9, 0.86) 60%, var(--ink) 72%);
}

.scene-top {
  position: absolute;
  top: 3rem;
  right: max(3rem, env(safe-area-inset-right, 0px));
  display: flex;
  gap: 1rem;
}

.scene-text {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 3.4rem;
  max-height: 58%;
  overflow: hidden;
  padding: 10rem var(--gut) 0;
  padding-left: max(var(--gut), env(safe-area-inset-left, 0px));
  padding-right: max(var(--gut), env(safe-area-inset-right, 0px));
  -webkit-mask-image: linear-gradient(180deg, transparent 0, #000 22%);
  mask-image: linear-gradient(180deg, transparent 0, #000 22%);
}

.scene-text p {
  margin: 0;
  flex: none;
  font-family: var(--story);
  font-size: 5rem;
  line-height: 1.42;
  color: var(--bone);
  text-shadow: 0 0.2rem 1.4rem rgba(0, 0, 0, 0.9);
  animation: line-in 620ms var(--ease) both;
  transition: opacity 600ms;
}

.scene-text p.old { opacity: 0.42; }
.scene-text p em { color: var(--gold); }

.scene-text p.say { padding-left: 4rem; border-left: 0.5rem solid var(--ember-deep); }

.scene-text p.say b {
  display: block;
  font-family: var(--display);
  font-weight: 400;
  font-size: 3.4rem;
  letter-spacing: 0.14em;
  color: var(--gold);
}

.scene-text p.note {
  font-family: var(--ui);
  font-size: 3.6rem;
  color: var(--gold);
  letter-spacing: 0.04em;
}

@keyframes line-in {
  from { opacity: 0; transform: translateY(2.4rem); }
}

.scene-foot {
  min-height: 15rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2.4rem;
  padding: 4rem var(--gut) 7rem;
  padding-left: max(var(--gut), env(safe-area-inset-left, 0px));
  padding-right: max(var(--gut), env(safe-area-inset-right, 0px));
}

.scene-next {
  align-self: center;
  font-size: 3.2rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--ash);
  animation: breathe 2.4s ease-in-out infinite;
}

@keyframes breathe { 50% { opacity: 0.35; } }

.choice {
  width: 100%;
  min-height: 14rem;
  padding: 2rem 4rem;
  flex-direction: column;
  gap: 0.2rem;
  animation: line-in 500ms var(--ease) both;
}

.choice:nth-child(2) { animation-delay: 120ms; }

.chapter-card {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
  gap: 2rem;
  padding: 0 var(--gut);
  background: rgba(12, 10, 9, 0.55);
  animation: fade-in 900ms both;
}

.chapter-card small {
  font-size: 3.4rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--gold);
}

.chapter-card h2 {
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  font-size: 10rem;
  line-height: 1.05;
  letter-spacing: 0.06em;
  color: #fff0d2;
  text-shadow: 0 0 6rem rgba(255, 122, 28, 0.55);
  text-wrap: balance;
}

/* ── battle ────────────────────────────────────────────────────────── */

.battle {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto auto auto;
}

.b-top {
  display: flex;
  align-items: center;
  gap: 2rem;
  padding: 2.4rem max(3rem, env(safe-area-inset-right, 0px)) 0 max(var(--gut), env(safe-area-inset-left, 0px));
}

.b-top .chapter {
  flex: 1;
  font-family: var(--display);
  font-size: 3.6rem;
  letter-spacing: 0.14em;
  color: var(--bone-dim);
  text-shadow: 0 0.2rem 1rem #000;
}

.b-top .turn { font-size: 3.2rem; color: var(--ash); letter-spacing: 0.1em; text-transform: uppercase; }

/* the foe */

.foe {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 0;
  padding: 0 var(--gut);
}

.intent {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 1.6rem;
  min-height: 9rem;
  max-width: 100%;
  padding: 0.8rem 3.4rem;
  border-radius: 5rem;
  background: rgba(12, 10, 9, 0.72);
  border: 0.3rem solid rgba(234, 222, 200, 0.22);
  font-size: 3.6rem;
  color: var(--bone);
  box-shadow: 0 0.6rem 3rem rgba(0, 0, 0, 0.5);
}

.intent .ico { font-size: 4.6rem; color: var(--blood); }
.intent.k-guard .ico { color: var(--oath); }
.intent.k-windup .ico, .intent.k-special .ico { color: var(--gold); }
.intent.k-frozen .ico { color: var(--oath); }
.intent b { font-size: 5.4rem; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.intent .then { color: var(--gold); font-weight: 700; }
.intent .halved { color: var(--small); }
.intent.pop { animation: pop 380ms var(--ease); }

@keyframes pop {
  0% { transform: scale(0.8); opacity: 0.2; }
  60% { transform: scale(1.08); }
}

.foe-figure {
  position: relative;
  flex: 1;
  min-height: 0;
  width: 100%;
  display: grid;
  place-items: end center;
}

.sprite {
  position: relative;
  height: 100%;
  max-height: 78rem;
  aspect-ratio: 420 / 540;
  max-width: 100%;
  background-size: contain;
  background-position: bottom center;
  background-repeat: no-repeat;
  filter: drop-shadow(0 1.5rem 3rem rgba(0, 0, 0, 0.75));
  transform-origin: 50% 100%;
  animation: sprite-in 1100ms var(--ease) both, idle 5.2s ease-in-out 1.1s infinite;
}

@keyframes sprite-in {
  from { opacity: 0; transform: translateY(4rem) scale(0.94); filter: brightness(0) drop-shadow(0 0 0 #000); }
}

@keyframes idle {
  50% { transform: translateY(-0.9rem) scale(1.012); }
}

.sprite .heart {
  position: absolute;
  width: 34%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 190, 110, 0.85) 0%, rgba(255, 110, 30, 0.45) 30%, rgba(255, 90, 20, 0) 68%);
  mix-blend-mode: screen;
  animation: pulse 2.6s ease-in-out infinite;
}

@keyframes pulse {
  50% { opacity: 0.55; transform: translate(-50%, -50%) scale(0.86); }
}

.sprite.hit { animation: hit 300ms; }

@keyframes hit {
  0% { transform: translateX(0); filter: brightness(3) drop-shadow(0 0 3rem #fff); }
  25% { transform: translateX(-2.6rem) rotate(-2deg); }
  55% { transform: translateX(1.8rem) rotate(1.4deg); filter: brightness(1.3); }
  100% { transform: translateX(0); }
}

.sprite.lunge { animation: lunge 460ms var(--ease); }

@keyframes lunge {
  35% { transform: translateY(7rem) scale(1.18); }
}

.sprite.brace { animation: brace 460ms var(--ease); }

@keyframes brace {
  40% { transform: scale(0.95, 0.92); filter: brightness(1.5) drop-shadow(0 0 3rem var(--oath)); }
}

.sprite.feed { animation: feed 1200ms ease; }

@keyframes feed {
  30% { transform: scale(1.06); filter: brightness(2.2) saturate(1.6) drop-shadow(0 0 6rem var(--ember)); }
  60% { transform: scale(1.02); filter: brightness(1.5) drop-shadow(0 0 4rem var(--ember)); }
}

.sprite.frozen { filter: grayscale(0.7) brightness(1.2) drop-shadow(0 0 2.4rem var(--oath)); animation: none; }

.sprite.dying { animation: dying 1500ms ease-in forwards; }

@keyframes dying {
  20% { filter: brightness(2.4) drop-shadow(0 0 5rem var(--ember)); }
  100% { opacity: 0; transform: translateY(3rem) scale(0.96); filter: grayscale(1) brightness(0.6) blur(0.8rem); }
}

.foe-plate {
  flex: none;
  width: 72rem;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  margin-top: -1rem;
}

.foe-name {
  font-family: var(--display);
  font-size: 5rem;
  letter-spacing: 0.08em;
  line-height: 1.1;
  text-align: center;
  color: #fff0d2;
  text-shadow: 0 0.3rem 1.4rem #000, 0 0 3rem #000;
  transition: opacity 900ms, filter 900ms;
}

.foe-name small {
  display: block;
  font-family: var(--story);
  font-style: italic;
  font-size: 3.4rem;
  letter-spacing: 0.02em;
  color: var(--bone-dim);
}

.foe-name.forgetting { opacity: 0; filter: blur(1.4rem); }

/* bars and chips, shared by both sides */

.bar {
  position: relative;
  width: 100%;
  height: 4.4rem;
  border-radius: 0.8rem;
  background: rgba(12, 10, 9, 0.8);
  border: 0.3rem solid rgba(234, 222, 200, 0.28);
  overflow: hidden;
}

.bar i {
  position: absolute;
  inset: 0 auto 0 0;
  width: 100%;
  background: linear-gradient(180deg, #e0563f, #8a2015);
  transition: width 420ms var(--ease);
}

.bar .lag {
  background: #f3d9a2;
  transition: width 900ms 260ms ease;
}

.bar span {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 3rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #fff;
  text-shadow: 0 0.2rem 0.6rem #000, 0 0 0.4rem #000;
  font-variant-numeric: tabular-nums;
}

.chips { display: flex; flex-wrap: wrap; gap: 1rem; justify-content: center; min-height: 5.4rem; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.8rem;
  height: 5.4rem;
  padding: 0 1.8rem;
  border-radius: 3rem;
  background: rgba(12, 10, 9, 0.78);
  border: 0.25rem solid currentColor;
  font-size: 3rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  white-space: nowrap;
  color: var(--bone-dim);
  animation: pop 320ms var(--ease);
}

.chip.guard { color: var(--oath); }
.chip.good { color: var(--gold); }
.chip.bad { color: var(--blood); }
.chip.cold { color: var(--oath); }

/* the line of narration between the two sides */

.whisper {
  min-height: 15rem;
  display: grid;
  place-items: center;
  padding: 1rem var(--gut);
  padding-left: max(var(--gut), env(safe-area-inset-left, 0px));
  padding-right: max(var(--gut), env(safe-area-inset-right, 0px));
  text-align: center;
}

.whisper p {
  margin: 0;
  font-family: var(--story);
  font-style: italic;
  font-size: 3.8rem;
  line-height: 1.3;
  color: var(--bone);
  text-shadow: 0 0.2rem 1.2rem #000, 0 0 2.4rem #000;
  text-wrap: balance;
  animation: line-in 420ms var(--ease) both;
}

.whisper p.coach {
  font-family: var(--ui);
  font-style: normal;
  font-weight: 500;
  color: var(--gold);
  padding: 1.6rem 3rem;
  border-radius: 1.4rem;
  background: rgba(12, 10, 9, 0.82);
  border: 0.25rem solid rgba(255, 196, 107, 0.45);
}

/* you */

.me {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 2rem;
  padding: 0 var(--gut);
  padding-left: max(var(--gut), env(safe-area-inset-left, 0px));
  padding-right: max(var(--gut), env(safe-area-inset-right, 0px));
}

.me-left { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }

.me-name {
  font-family: var(--display);
  font-size: 4.4rem;
  letter-spacing: 0.1em;
  line-height: 1;
  color: #fff0d2;
  text-shadow: 0 0.3rem 1.2rem #000;
  transition: opacity 900ms, filter 900ms;
}

.me-name.forgetting { opacity: 0; filter: blur(1.4rem); }
.me .chips { justify-content: flex-start; }
.me-right { display: flex; flex-direction: column; align-items: flex-end; gap: 1rem; min-width: 0; }
.me-right .chips { justify-content: flex-end; }

.breath { display: flex; align-items: center; gap: 1rem; }

.breath .label {
  font-size: 3rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--bone-dim);
  margin-right: 0.6rem;
}

.pip {
  width: 4.2rem;
  height: 5.6rem;
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
  background: rgba(234, 222, 200, 0.18);
  transition: background 200ms, transform 200ms var(--ease), filter 200ms;
}

.pip.on { background: linear-gradient(180deg, #d9f0ff, #7fb6dc); filter: drop-shadow(0 0 1.2rem rgba(140, 200, 255, 0.9)); }
.pip.spent { transform: scale(0.82); }
.breath.pulse .pip.on { animation: pop 320ms var(--ease); }

/* the fire in your chest: also where memories go to burn */

.ember {
  position: relative;
  width: 17rem;
  height: 17rem;
  display: grid;
  place-items: center;
  --heat: 0;
}

.ember::before {
  content: '';
  position: absolute;
  inset: -3rem;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 122, 28, calc(0.3 + var(--heat) * 0.5)) 0%, rgba(255, 122, 28, 0) 66%);
  animation: pulse-plain 2.2s ease-in-out infinite;
}

@keyframes pulse-plain { 50% { opacity: 0.6; transform: scale(0.9); } }

.ember .flame {
  position: relative;
  width: 9rem;
  height: 12rem;
  transform: scale(calc(0.72 + var(--heat) * 0.7));
  transform-origin: 50% 90%;
  transition: transform 900ms var(--ease);
}

.ember .flame i {
  position: absolute;
  left: 50%;
  bottom: 0;
  border-radius: 50% 50% 50% 50% / 62% 62% 38% 38%;
  transform-origin: 50% 100%;
  translate: -50% 0;
  animation: flicker 1.3s ease-in-out infinite alternate;
}

.ember .flame i:nth-child(1) { width: 100%; height: 100%; background: radial-gradient(circle at 50% 70%, #e4521a, #7a1c06 78%); }
.ember .flame i:nth-child(2) { width: 66%; height: 72%; background: radial-gradient(circle at 50% 70%, #ffb23f, #f0661a 80%); animation-duration: 0.9s; }
.ember .flame i:nth-child(3) { width: 36%; height: 42%; background: radial-gradient(circle at 50% 70%, #fff6d8, #ffd36a 80%); animation-duration: 0.7s; }

@keyframes flicker {
  0% { transform: scale(1, 1) rotate(-2deg); }
  50% { transform: scale(0.94, 1.08) rotate(2deg); }
  100% { transform: scale(1.05, 0.95) rotate(-1deg); }
}

.ember .ring { position: absolute; inset: 0; transform: rotate(-90deg); opacity: 0; transition: opacity 160ms; }
.ember .ring circle { fill: none; stroke: var(--gold); stroke-width: 3; stroke-linecap: round; stroke-dasharray: 289; stroke-dashoffset: calc(289 * (1 - var(--p, 0))); }
.ember.target { animation: beckon 900ms ease-in-out infinite; }
.ember.feeding .ring { opacity: 1; }
.ember.feeding .flame { transform: scale(1.5); }

@keyframes beckon { 50% { transform: scale(1.14); } }

.ember .hint {
  position: absolute;
  top: 100%;
  left: 50%;
  translate: -50% -1rem;
  white-space: nowrap;
  font-size: 2.8rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
  opacity: 0;
  transition: opacity 160ms;
  text-shadow: 0 0 1rem #000;
}

.ember.target .hint { opacity: 1; }

/* the hand */

.hand {
  position: relative;
  height: 37rem;
  margin: 1rem 0 0;
}

.card {
  position: absolute;
  left: 0;
  top: 3.4rem;
  width: 21rem;
  height: 30.5rem;
  border-radius: 1.5rem;
  background: var(--soot);
  box-shadow: 0 0 0 0.3rem var(--kind-dark, #3a302a), 0 1.2rem 2.6rem rgba(0, 0, 0, 0.7);
  overflow: hidden;
  text-align: center;
  transition: transform 300ms var(--ease), opacity 260ms, filter 200ms, box-shadow 200ms;
  will-change: transform;
  touch-action: none;
  --kind: var(--bone-dim);
}

.card.static { position: relative; top: 0; touch-action: manipulation; flex: none; }

.t-bond { --kind: var(--bond); --kind-dark: #6d4a22; }
.t-scar { --kind: var(--scar); --kind-dark: #6d261f; }
.t-oath { --kind: var(--oath); --kind-dark: #46586a; }
.t-small { --kind: var(--small); --kind-dark: #4c5a3a; }
.t-ash { --kind: var(--ashen); --kind-dark: #3d3935; }

.card-art {
  position: absolute;
  inset: 0 0 47% 0;
  background-size: cover;
  background-position: center;
}

.card-art::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(21, 17, 15, 0) 55%, var(--soot) 100%);
}

.card-cost {
  position: absolute;
  top: 0.9rem;
  left: 0.9rem;
  width: 5.8rem;
  height: 5.8rem;
  display: grid;
  place-items: center;
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
  background: linear-gradient(180deg, #e6f4ff, #6fa6cf);
  color: #0c1a26;
  font-size: 3.6rem;
  font-weight: 800;
  line-height: 1;
}

.card-name {
  position: absolute;
  left: 0.8rem;
  right: 0.8rem;
  top: 50%;
  height: 10.4rem;
  display: grid;
  place-items: center;
  font-family: var(--display);
  font-size: 3.05rem;
  line-height: 1.08;
  letter-spacing: 0.02em;
  color: #fff0d2;
  text-wrap: balance;
}

.card-glyphs {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 1.3rem;
  display: flex;
  justify-content: center;
  gap: 1.6rem;
  font-size: 3.6rem;
  font-weight: 800;
  color: var(--kind);
  font-variant-numeric: tabular-nums;
}

.card-glyphs span { display: inline-flex; align-items: center; gap: 0.5rem; }
.card-glyphs .ico { font-size: 3.4rem; }

.card::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  border-top: 0.7rem solid var(--kind);
  opacity: 0.85;
  pointer-events: none;
}

.card.dim { filter: brightness(0.55) saturate(0.7); }
.card.t-ash .card-name { color: var(--ashen); font-size: 2.9rem; }
.card.t-ash .card-name small { display: block; font-family: var(--story); font-style: italic; font-size: 2.5rem; letter-spacing: 0; opacity: 0.85; }

.card.drag {
  transition: none;
  z-index: 30;
  box-shadow: 0 0 0 0.3rem var(--kind), 0 3rem 6rem rgba(0, 0, 0, 0.8);
}

.card.armed { box-shadow: 0 0 0 0.5rem #bfe3ff, 0 0 5rem rgba(140, 200, 255, 0.8); }
.card.kindling { box-shadow: 0 0 0 0.5rem var(--ember), 0 0 7rem rgba(255, 122, 28, 0.95); filter: brightness(1.25) saturate(1.3); }
.card.gone { opacity: 0; pointer-events: none; }
.card.nope { animation: nope 280ms; }

@keyframes nope {
  25% { translate: -1.4rem 0; }
  75% { translate: 1.4rem 0; }
}

/* bottom bar */

.b-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 3rem;
  padding: 1.4rem var(--gut) 4rem;
  padding-left: max(var(--gut), env(safe-area-inset-left, 0px));
  padding-right: max(var(--gut), env(safe-area-inset-right, 0px));
}

.pile {
  display: inline-flex;
  align-items: center;
  gap: 1.6rem;
  min-height: 11rem;
  padding: 0 3rem;
  border-radius: 1rem;
  background: rgba(12, 10, 9, 0.6);
  border: 0.25rem solid rgba(234, 222, 200, 0.22);
  font-size: 3.4rem;
  color: var(--bone-dim);
  font-variant-numeric: tabular-nums;
}

.pile .ico { font-size: 4.4rem; }
.pile b { color: var(--bone); font-weight: 800; }
.pile .lost { color: var(--ashen); margin-left: 1.2rem; }
.pile.flash { animation: pop 380ms var(--ease); }

.end-turn { min-height: 11rem; min-width: 36rem; }

/* floating numbers */

.float {
  position: absolute;
  z-index: 6;
  translate: -50% -50%;
  font-family: var(--ui);
  font-weight: 800;
  font-size: 8rem;
  line-height: 1;
  color: #fff;
  text-shadow: 0 0.4rem 1rem #000, 0 0 1.6rem #000;
  pointer-events: none;
  white-space: nowrap;
  animation: float 950ms var(--ease) forwards;
}

.float.dmg { color: #ff6a52; }
.float.block { color: var(--oath); font-size: 5rem; }
.float.heal { color: #ffd98a; }
.float.word { font-family: var(--display); font-weight: 400; font-size: 5rem; letter-spacing: 0.08em; color: var(--gold); }

@keyframes float {
  0% { opacity: 0; transform: translateY(2rem) scale(0.6); }
  18% { opacity: 1; transform: translateY(0) scale(1.15); }
  100% { opacity: 0; transform: translateY(-11rem) scale(1); }
}

/* ── the card held up to the light ─────────────────────────────────── */

.focus {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3rem;
  padding: 4rem var(--gut);
  padding-left: max(var(--gut), env(safe-area-inset-left, 0px));
  padding-right: max(var(--gut), env(safe-area-inset-right, 0px));
  background: rgba(8, 6, 5, 0.94);
  animation: fade-in 180ms both;
}

.bigcard {
  position: relative;
  flex: none;
  width: 70rem;
  max-width: 100%;
  border-radius: 2.4rem;
  background: var(--soot);
  box-shadow: 0 0 0 0.4rem var(--kind-dark), 0 3rem 8rem rgba(0, 0, 0, 0.8);
  overflow: hidden;
  animation: rise 260ms var(--ease) both;
  --kind: var(--bone-dim);
}

@keyframes rise { from { transform: translateY(5rem) scale(0.92); opacity: 0; } }

.bigcard header {
  display: flex;
  align-items: center;
  gap: 2.4rem;
  padding: 2.4rem 3rem;
  border-top: 1rem solid var(--kind);
}

.bigcard .cost {
  flex: none;
  width: 9rem;
  height: 9rem;
  display: grid;
  place-items: center;
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
  background: linear-gradient(180deg, #e6f4ff, #6fa6cf);
  color: #0c1a26;
  font-size: 5.4rem;
  font-weight: 800;
}

.bigcard h3 {
  flex: 1;
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  font-size: 6rem;
  line-height: 1.05;
  letter-spacing: 0.03em;
  color: #fff0d2;
}

.bigcard h3 small { display: block; font-family: var(--story); font-style: italic; font-size: 3.6rem; color: var(--ashen); }

.bigcard .kind {
  flex: none;
  font-size: 2.8rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--kind);
}

.bigart { height: 39rem; background-size: cover; background-position: center; }

.bigcard .flavour {
  margin: 0;
  padding: 2.6rem 3.4rem 1rem;
  font-family: var(--story);
  font-style: italic;
  font-size: 3.8rem;
  line-height: 1.3;
  color: var(--bone-dim);
  text-wrap: pretty;
}

.rule {
  display: grid;
  grid-template-columns: 15rem minmax(0, 1fr);
  gap: 2rem;
  align-items: baseline;
  margin: 1.6rem 3rem 0;
  padding: 2rem 2.4rem;
  border-radius: 1.2rem;
  background: rgba(234, 222, 200, 0.06);
  font-size: 3.8rem;
  line-height: 1.28;
}

.rule:last-of-type { margin-bottom: 3rem; }

.rule b.tag {
  font-family: var(--display);
  font-weight: 400;
  font-size: 3.6rem;
  letter-spacing: 0.1em;
  color: var(--oath);
}

.rule.burn { background: rgba(184, 60, 14, 0.2); }
.rule.burn b.tag { color: var(--ember); }
.rule b.up { color: var(--small); }

.focus .warn {
  margin: 0;
  max-width: 78rem;
  text-align: center;
  font-family: var(--story);
  font-style: italic;
  font-size: 3.8rem;
  line-height: 1.3;
  color: var(--bone-dim);
  text-wrap: balance;
}

.focus .warn em { color: var(--gold); }

.focus-actions { display: flex; gap: 3rem; width: 100%; max-width: 80rem; }
.focus-actions .btn { flex: 1; min-height: 14rem; padding: 0 2rem; flex-direction: column; gap: 0; }

.btn.burn-btn {
  position: relative;
  overflow: hidden;
  border-color: rgba(255, 122, 28, 0.8);
  color: #ffd9b0;
  background: rgba(60, 16, 6, 0.85);
  touch-action: none;
}

.btn.burn-btn .fill {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, #7a1c06, #ff7a1c 85%, #ffd36a);
  transform-origin: 0 50%;
  transform: scaleX(var(--p, 0));
}

.btn.burn-btn span { position: relative; }
.btn.burn-btn.holding { box-shadow: 0 0 6rem rgba(255, 122, 28, 0.7); color: #fff; }

.bigcard.smoulder { animation: smoulder 160ms linear infinite; box-shadow: 0 0 0 0.5rem var(--ember), 0 0 9rem rgba(255, 122, 28, 0.8); }

@keyframes smoulder {
  25% { transform: translate(0.3rem, -0.2rem) rotate(0.2deg); }
  75% { transform: translate(-0.3rem, 0.2rem) rotate(-0.2deg); }
}

/* the burning itself */

.ceremony {
  position: absolute;
  inset: 0;
  z-index: 25;
  display: grid;
  place-items: center;
  padding: 4rem var(--gut);
  background: rgba(8, 6, 5, 0.965);
}

.ceremony .bigcard { animation: none; }

.ceremony .bigcard.burning {
  box-shadow: 0 0 0 0.5rem var(--ember), 0 0 12rem rgba(255, 122, 28, 0.9);
  -webkit-mask-image: linear-gradient(0deg, transparent calc(var(--b, 0) * 118% - 18%), #000 calc(var(--b, 0) * 118%));
  mask-image: linear-gradient(0deg, transparent calc(var(--b, 0) * 118% - 18%), #000 calc(var(--b, 0) * 118%));
  filter: sepia(calc(var(--b, 0) * 0.8)) brightness(calc(1 + var(--b, 0) * 0.9)) contrast(calc(1 + var(--b, 0) * 0.3));
}

.ceremony .lost-line {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 4rem;
  padding: 0 var(--gut);
  text-align: center;
  opacity: 0;
  transition: opacity 900ms;
}

.ceremony .lost-line.on { opacity: 1; }

.ceremony .lost-line p {
  margin: 0;
  font-family: var(--story);
  font-size: 6.4rem;
  line-height: 1.3;
  color: #fff0d2;
  text-wrap: balance;
}

.ceremony .lost-line small {
  font-family: var(--story);
  font-style: italic;
  font-size: 4rem;
  color: var(--ashen);
}

.ceremony.flash::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 50%, #fff3d6, #ff7a1c 40%, rgba(255, 122, 28, 0) 75%);
  animation: fade-out 700ms forwards;
  pointer-events: none;
}

/* ── overlays: memories, menus, the fall ───────────────────────────── */

.sheet {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  background: rgba(8, 6, 5, 0.95);
  animation: fade-in 200ms both;
}

.sheet-head {
  display: flex;
  align-items: center;
  gap: 2rem;
  padding: 3rem max(3rem, env(safe-area-inset-right, 0px)) 2rem max(var(--gut), env(safe-area-inset-left, 0px));
}

.sheet-head h2 {
  flex: 1;
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  font-size: 6.4rem;
  letter-spacing: 0.06em;
  color: #fff0d2;
}

.sheet-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  padding: 0 var(--gut) 8rem;
  padding-left: max(var(--gut), env(safe-area-inset-left, 0px));
  padding-right: max(var(--gut), env(safe-area-inset-right, 0px));
}

.sheet-body h3 {
  margin: 5rem 0 0.6rem;
  font-family: var(--display);
  font-weight: 400;
  font-size: 4.4rem;
  letter-spacing: 0.1em;
  color: var(--gold);
}

.sheet-body h3.cold { color: var(--ashen); }
.sheet-body .sub { margin: 0 0 3rem; font-family: var(--story); font-style: italic; font-size: 3.8rem; color: var(--bone-dim); }

.grid {
  display: grid;
  grid-template-columns: repeat(4, 21rem);
  justify-content: space-between;
  row-gap: 3rem;
}

.grid .card.static { animation: fade-in 400ms both; }

.card.burnt .card-art { filter: none; }
.card.burnt .card-name { font-family: var(--story); font-style: italic; font-size: 2.9rem; color: var(--ashen); }
.card.burnt .card-glyphs { color: var(--ashen); font-weight: 500; font-size: 2.4rem; letter-spacing: 0.1em; text-transform: uppercase; }

.modal {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: grid;
  place-content: center;
  gap: 4rem;
  padding: 0 max(8rem, 16px);
  text-align: center;
  background: rgba(8, 6, 5, 0.965);
  animation: fade-in 500ms both;
}

.modal h2 {
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  font-size: 10rem;
  letter-spacing: 0.06em;
  color: #fff0d2;
}

.modal.fall h2 { color: #ff8a6a; text-shadow: 0 0 6rem rgba(200, 40, 20, 0.7); }
.modal p { margin: 0; font-family: var(--story); font-size: 4.6rem; line-height: 1.4; color: var(--bone); text-wrap: balance; }
.modal .row { display: flex; flex-direction: column; gap: 2.4rem; margin-top: 2rem; }

.gain {
  position: absolute;
  inset: 0;
  z-index: 22;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3.4rem;
  padding: 4rem var(--gut);
  background: rgba(8, 6, 5, 0.9);
  animation: fade-in 400ms both;
}

.gain .eyebrow { font-size: 3.4rem; letter-spacing: 0.3em; text-transform: uppercase; color: var(--gold); }
.gain .bigcard { box-shadow: 0 0 0 0.4rem var(--kind), 0 0 10rem rgba(255, 196, 107, 0.35); }

/* ── the tally at the end ──────────────────────────────────────────── */

.tally .sheet-head { flex-direction: column; align-items: flex-start; gap: 0.6rem; padding-top: 6rem; }
.tally .sheet-head small { font-size: 3.2rem; letter-spacing: 0.3em; text-transform: uppercase; color: var(--gold); }
.tally .verdict { margin: 0; font-family: var(--story); font-style: italic; font-size: 4.6rem; color: var(--bone); }
.tally .where { margin: 0.6rem 0 0; font-size: 2.4rem; line-height: 1.15; color: var(--ashen); }
.tally .next { margin: 6rem 0 3rem; font-family: var(--story); font-size: 4.2rem; line-height: 1.4; color: var(--bone-dim); text-wrap: pretty; }
.tally .btn { width: 100%; }

/* ── calm for those who ask for it ─────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  .sprite { animation: none; }
  .ember .flame i, .ember::before, .sprite .heart, .scene-next { animation: none; }
  #stage.shake { animation: none; }
  .bigcard.smoulder { animation: none; }
  .scene-text p, .whisper p { animation-duration: 1ms; }
}

/* small text-only buttons (put it back, close) */
.btn.back {
  min-height: 10rem;
  border-color: transparent;
  background: none;
  font-family: var(--ui);
  font-size: 3.6rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--bone-dim);
}

/* said while a dragged memory is being held in the fire */
.burn-hint {
  position: absolute;
  left: var(--gut);
  right: var(--gut);
  top: 30%;
  z-index: 35;
  padding: 3rem 3.4rem;
  border-radius: 1.6rem;
  background: rgba(40, 12, 4, 0.94);
  border: 0.3rem solid var(--ember);
  box-shadow: 0 0 8rem rgba(255, 122, 28, 0.5);
  text-align: center;
  font-family: var(--story);
  font-size: 4.6rem;
  line-height: 1.3;
  color: #fff0d2;
  text-wrap: balance;
  opacity: 0;
  transform: translateY(2rem);
  pointer-events: none;
  transition: opacity 160ms, transform 160ms var(--ease);
}

.burn-hint.on { opacity: 1; transform: none; }
.burn-hint em { color: var(--gold); }
.burn-hint small { display: block; margin-top: 1rem; font-family: var(--ui); font-size: 3.2rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--bone-dim); }
