/* ASHWORD — warm letterpress: paper, ink, char. Deliberately not a neon HUD. */
:root {
  --paper: #efe6d6;
  --paper-deep: #e4d8c3;
  --ink: #241d17;
  --ink-soft: #6d6053;
  --rule: #c9bba1;
  --block: #f8f2e5;
  --ember: #b8451f;
  --gold: #9a742a;
  --char: #2b2521;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  padding: clamp(16px, 4vw, 44px) clamp(14px, 4vw, 40px) 48px;
  background:
    radial-gradient(
      120% 90% at 50% 0%,
      #f6efe2 0%,
      var(--paper) 45%,
      var(--paper-deep) 100%
    ),
    var(--paper);
  color: var(--ink);
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  transition: background 0.6s ease;
}

body.danger {
  background: radial-gradient(
    120% 90% at 50% 0%,
    #efe1cc 0%,
    #dfcdb1 60%,
    #cbb392 100%
  );
}

.press {
  max-width: 940px;
  margin: 0 auto;
}

.masthead {
  text-align: center;
  border-bottom: 3px double var(--rule);
  padding-bottom: 14px;
}

.masthead h1 {
  margin: 0;
  font-size: clamp(40px, 9vw, 76px);
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-shadow:
    1px 1px 0 #fffaf0,
    3px 3px 0 rgba(36, 29, 23, 0.08);
}

.sub {
  margin: 6px 0 0;
  color: var(--ink-soft);
  font-size: 12px;
  letter-spacing: 0.42em;
  text-transform: uppercase;
}

.ledger {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: clamp(18px, 6vw, 62px);
  padding: 14px 0 12px;
  border-bottom: 1px solid var(--rule);
}

.stat {
  text-align: center;
  min-width: 74px;
}

.stat small {
  display: block;
  color: var(--ink-soft);
  font-size: 10px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
}

.stat b {
  display: block;
  margin-top: 2px;
  font-size: clamp(22px, 4vw, 30px);
  font-variant-numeric: tabular-nums;
}

body.danger .stat-ash b {
  color: var(--ember);
}

.callout {
  min-height: 1.6em;
  margin: 18px 0 8px;
  text-align: center;
  color: var(--ink-soft);
  font-size: clamp(14px, 2.4vw, 17px);
  font-style: italic;
}

.callout.good {
  color: var(--gold);
  font-style: normal;
}
.callout.bad,
.callout.warn {
  color: var(--ember);
  font-style: normal;
}

.composing {
  text-align: center;
}

.slot-row {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  min-height: 66px;
  padding: 8px 12px;
  border-bottom: 2px solid var(--ink);
  cursor: pointer;
}

.slot-row.empty::after {
  content: "compose here";
  color: #b6a68c;
  font-size: 13px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
}

.chip {
  display: grid;
  place-items: center;
  width: clamp(30px, 6vw, 40px);
  height: clamp(38px, 7.5vw, 50px);
  border: 1px solid var(--ink);
  border-radius: 3px;
  background: var(--ink);
  color: var(--paper);
  font-size: clamp(18px, 3.6vw, 24px);
  font-weight: 700;
  letter-spacing: 0.02em;
  animation: drop 0.14s ease-out;
}

@keyframes drop {
  from {
    transform: translateY(-8px);
    opacity: 0;
  }
}

.slot-row.reject {
  animation: reject 0.24s ease;
}

@keyframes reject {
  25% {
    transform: translateX(-7px);
  }
  75% {
    transform: translateX(7px);
  }
}

.pop {
  position: absolute;
  right: 8px;
  top: 4px;
  color: var(--gold);
  font-size: 22px;
  font-weight: 700;
  animation: rise 0.9s ease-out forwards;
  pointer-events: none;
}

.pop.chained {
  color: var(--ember);
}

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

.preview {
  margin: 10px 0 26px;
  min-height: 1.4em;
  color: var(--ink-soft);
  font-size: 13px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.preview.live {
  color: var(--gold);
}
.preview.live.chained {
  color: var(--ember);
}
.preview.dim {
  color: #b6a68c;
}

.rack {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: clamp(5px, 1.2vw, 12px);
}

.rack.shudder {
  animation: shudder 0.3s ease;
}

@keyframes shudder {
  30% {
    transform: translateY(3px) rotate(-0.25deg);
  }
  70% {
    transform: translateY(-2px) rotate(0.2deg);
  }
}

.tile {
  position: relative;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  padding: 0;
  border: 1px solid #b9a888;
  border-radius: 4px;
  background: linear-gradient(180deg, var(--block), #efe4d0);
  box-shadow:
    0 3px 0 #c4b394,
    0 6px 12px rgba(43, 37, 33, 0.14);
  color: var(--ink);
  font-family: inherit;
  cursor: pointer;
  transition:
    transform 0.12s ease,
    box-shadow 0.12s ease,
    opacity 0.12s ease;
}

.tile:hover:not(:disabled) {
  transform: translateY(-2px);
}

.tile .face {
  position: relative;
  z-index: 2;
  display: grid;
  place-items: center;
  height: 100%;
  font-size: clamp(22px, 5.6vw, 46px);
  font-weight: 700;
}

.tile .pip {
  position: absolute;
  z-index: 2;
  right: 5px;
  bottom: 3px;
  color: var(--ink-soft);
  font-size: clamp(9px, 1.4vw, 12px);
  font-variant-numeric: tabular-nums;
}

/* The stain climbs the block as the tile rots. */
.tile .rot {
  position: absolute;
  z-index: 1;
  inset: auto 0 0 0;
  height: var(--rot, 0%);
  background: linear-gradient(
    180deg,
    rgba(43, 37, 33, 0.16),
    rgba(43, 37, 33, 0.5)
  );
  transition: height 0.2s linear;
}

.tile.ember {
  border-color: var(--ember);
  box-shadow:
    0 3px 0 #a53f1d,
    0 0 18px rgba(184, 69, 31, 0.35);
}

.tile.ember .rot {
  background: linear-gradient(
    180deg,
    rgba(184, 69, 31, 0.35),
    rgba(120, 32, 12, 0.72)
  );
}

.tile.ember .face {
  color: #fff4e8;
}

.tile.gold {
  border-color: var(--gold);
  background: linear-gradient(180deg, #fdf3d8, #f0dfb4);
}

.tile.gold .pip {
  color: var(--gold);
  font-weight: 700;
}

.tile.used {
  opacity: 0.42;
  transform: translateY(4px);
  box-shadow: none;
}

.tile.ash {
  border-color: #4c433c;
  background: repeating-linear-gradient(
    48deg,
    #3a322c 0 6px,
    var(--char) 6px 12px
  );
  box-shadow: inset 0 0 14px rgba(0, 0, 0, 0.6);
  cursor: not-allowed;
}

.hint {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 22px;
  margin: 26px 0 0;
  color: var(--ink-soft);
  font-size: 12px;
  letter-spacing: 0.08em;
}

kbd {
  padding: 1px 6px;
  border: 1px solid var(--rule);
  border-bottom-width: 2px;
  border-radius: 3px;
  background: #fbf6ea;
  font-family: inherit;
  font-size: 11px;
}

.ghost {
  display: block;
  margin: 22px auto 0;
  padding: 6px 14px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: transparent;
  color: var(--ink-soft);
  font-family: inherit;
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  cursor: pointer;
}

.ghost[hidden] {
  display: none;
}

.ghost:hover {
  border-color: var(--ink-soft);
  color: var(--ink);
}

.overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(36, 29, 23, 0.55);
  backdrop-filter: blur(3px);
  z-index: 10;
}

.overlay[hidden] {
  display: none;
}

.card {
  width: min(560px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  padding: clamp(24px, 4vw, 38px);
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--paper);
  box-shadow: 0 24px 60px rgba(20, 15, 10, 0.4);
  text-align: center;
}

.card h2 {
  margin: 0 0 16px;
  font-size: clamp(28px, 6vw, 40px);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.rules {
  margin: 0 auto;
  padding: 0;
  max-width: 42ch;
  text-align: left;
  list-style: none;
}

.rules li {
  padding: 9px 0;
  border-top: 1px solid var(--rule);
  font-size: 14px;
  line-height: 1.5;
}

.rules-head {
  margin: 22px 0 6px;
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.28em;
  text-transform: uppercase;
}

.steps li {
  position: relative;
  padding-left: 28px;
}

.steps li::before {
  content: counter(list-item);
  position: absolute;
  top: 9px;
  left: 0;
  color: var(--ember);
  font-weight: 700;
}

.goal {
  color: var(--ink);
  font-size: 15px;
  line-height: 1.55;
}

.lines {
  margin: 12px 0;
  color: var(--ink-soft);
  font-size: 14px;
}

.final {
  margin: 0 0 4px;
  font-size: clamp(48px, 12vw, 78px);
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.final small {
  display: block;
  margin-top: 6px;
  color: var(--ink-soft);
  font-size: 11px;
  letter-spacing: 0.36em;
  text-transform: uppercase;
}

/* The shareable recap, previewed at whatever width the card allows. */
.recap {
  display: block;
  width: min(360px, 100%);
  height: auto;
  margin: 0 auto 14px;
  border: 1px solid var(--rule);
  border-radius: 5px;
  box-shadow: 0 10px 26px rgba(20, 15, 10, 0.28);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 22px;
}

.primary {
  flex-basis: 100%; /* the lead action gets a row to itself */
  padding: 12px 26px;
  border: 2px solid var(--ink);
  border-radius: 4px;
  background: var(--ink);
  color: var(--paper);
  font-family: inherit;
  font-size: 13px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  cursor: pointer;
}

.primary:hover:not(:disabled) {
  background: var(--ember);
  border-color: var(--ember);
}

.primary:disabled {
  opacity: 0.5;
  cursor: default;
}

.secondary {
  padding: 12px 26px;
  border: 2px solid var(--rule);
  border-radius: 4px;
  background: transparent;
  color: var(--ink-soft);
  font-family: inherit;
  font-size: 13px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  cursor: pointer;
}

.secondary:hover {
  border-color: var(--ink);
  color: var(--ink);
}

.secondary[hidden] {
  display: none;
}

@media (max-width: 620px) {
  .rack {
    grid-template-columns: repeat(5, 1fr);
  }
  .hint {
    gap: 4px 14px;
    font-size: 11px;
  }
}

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

/* Tutorial coach marks. The whole layer is fixed and pointer-transparent, so
   pointing at something never moves anything on the board. */
.coach {
  position: fixed;
  inset: 0;
  z-index: 9;
  pointer-events: none;
}

.coach[hidden] {
  display: none;
}

/* One element does the dimming: everything outside its box is covered by its
   own shadow, so the box itself reads as a hole cut in the dark. */
.spotlight {
  position: fixed;
  border-radius: 8px;
  box-shadow: 0 0 0 9999px rgba(34, 27, 21, 0.72);
  transition:
    top 0.25s ease,
    left 0.25s ease,
    width 0.25s ease,
    height 0.25s ease;
}

.coach-card {
  position: fixed;
  width: min(340px, calc(100vw - 32px));
  padding: 16px 18px 14px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--paper);
  box-shadow: 0 18px 44px rgba(20, 15, 10, 0.5);
  text-align: center;
  pointer-events: auto;
  transition:
    top 0.25s ease,
    left 0.25s ease;
}

.coach-card p {
  margin: 0;
  font-size: 14px;
  line-height: 1.55;
}

.coach-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 14px;
}

.coach-actions .ghost {
  margin: 0;
}

.advance {
  padding: 9px 20px;
  border: 2px solid var(--ink);
  border-radius: 4px;
  background: var(--ink);
  color: var(--paper);
  font-family: inherit;
  font-size: 12px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  cursor: pointer;
}

.advance:hover {
  background: var(--ember);
  border-color: var(--ember);
}

.advance[hidden] {
  display: none;
}

/* A tile the current beat wants the player to use. */
.tile.wanted {
  border-color: var(--ember);
  animation: wanted 1.4s ease-in-out infinite;
}

@keyframes wanted {
  50% {
    box-shadow: 0 0 0 3px rgba(168, 58, 34, 0.35);
  }
}
