:root {
  color-scheme: dark;
  --night: #243e3a;
  --night-deep: #183432;
  --slate: #526a78;
  --sage: #81987c;
  --sage-dark: #60755f;
  --oat: #e7d9bd;
  --moon: #ede9dc;
  --terra: #c8735a;
  --terra-dark: #9a5244;
  --butter: #f6ca67;
  --ink: #29312f;
  --safe-top: max(13px, env(safe-area-inset-top));
  --safe-bottom: max(13px, env(safe-area-inset-bottom));
  font-family: ui-rounded, "SF Pro Rounded", "Nunito", system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}

* { box-sizing: border-box; }

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #112b29;
  overscroll-behavior: none;
}

button { font: inherit; }
button:focus-visible { outline: 3px solid var(--butter); outline-offset: 3px; }

#game-shell {
  position: fixed;
  inset: 0;
  overflow: hidden;
  isolation: isolate;
  background: var(--night);
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--night);
}

.hidden { display: none !important; }

.hud {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
}

.status-strip {
  position: absolute;
  top: var(--safe-top);
  left: 16px;
  right: 14px;
  display: grid;
  grid-template-columns: .9fr 1.15fr .8fr auto;
  gap: 7px;
  align-items: center;
  min-height: 47px;
}

.charm-strip {
  position: absolute;
  top: calc(var(--safe-top) + 45px);
  left: 50%;
  z-index: 5;
  display: flex;
  max-width: calc(100vw - 32px);
  gap: 6px;
  transform: translateX(-50%);
  pointer-events: none;
}

.charm-pill {
  display: flex;
  min-width: 0;
  height: 26px;
  align-items: center;
  gap: 4px;
  padding: 3px 8px 3px 5px;
  color: var(--oat);
  background: rgba(24, 52, 50, .78);
  border: 1px solid rgba(231, 217, 189, .16);
  border-radius: 999px;
  box-shadow: 0 5px 12px rgba(10, 31, 29, .16);
  backdrop-filter: blur(5px);
  animation: charm-arrive 420ms cubic-bezier(.2, .78, .24, 1.1) both;
}

.charm-pill img { width: 17px; height: 18px; flex: 0 0 auto; object-fit: contain; }
.charm-pill strong {
  overflow: hidden;
  font-size: 7px;
  font-weight: 850;
  letter-spacing: .025em;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@keyframes charm-arrive {
  from { opacity: 0; transform: translateY(-5px) scale(.88); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.status-block {
  display: grid;
  min-width: 0;
  grid-template-columns: 20px auto auto;
  grid-template-rows: 1fr;
  column-gap: 5px;
  align-items: center;
  color: var(--moon);
}

.status-icon {
  width: 19px;
  height: 22px;
  object-fit: contain;
}

.status-label {
  color: var(--oat);
  font-size: 8px;
  font-weight: 850;
  letter-spacing: .1em;
  line-height: 1;
  text-transform: uppercase;
}

.status-block strong {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .02em;
  line-height: 1;
}

.meter {
  display: none;
}

.meter i {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--terra);
  border-radius: inherit;
  transition: width 180ms ease;
}

.quiet-button {
  min-width: 49px;
  min-height: 43px;
  padding: 0 5px;
  pointer-events: auto;
  color: var(--oat);
  background: transparent;
  border: 0;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .07em;
  text-transform: uppercase;
}

.turn-panel {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: max(8px, env(safe-area-inset-bottom));
  pointer-events: none;
}

.turn-info-card {
  position: relative;
  min-height: 44px;
  color: var(--moon);
  text-align: center;
}

.turn-copy {
  display: flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  padding: 0 52px;
}

.turn-copy .eyebrow {
  margin: 0 0 1px;
  color: var(--butter);
}

.turn-copy strong {
  display: block;
  overflow: hidden;
  color: var(--moon);
  font-size: 20px;
  font-weight: 660;
  letter-spacing: .01em;
  line-height: 1.05;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#turn-description {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.card-hand {
  position: relative;
  display: flex;
  height: 224px;
  align-items: flex-end;
  justify-content: center;
  margin-top: 0;
  padding: 36px 6px 0;
  isolation: isolate;
  overflow: visible;
  pointer-events: auto;
}

.hand-card {
  --fan-rise: 8px;
  --fan-rotate: 0deg;
  --fan-scale: .98;
  --fan-shift: 0px;
  position: relative;
  flex: 0 0 122px;
  width: 122px;
  min-width: 104px;
  height: 186px;
  margin-left: -38px;
  padding: 14px 8px 36px;
  overflow: visible;
  color: var(--ink);
  background: var(--sage);
  border: 1px solid rgba(41, 49, 47, .18);
  border-radius: 22px;
  box-shadow: 0 5px 0 rgba(25, 50, 44, .5), 0 12px 20px rgba(10, 31, 29, .24);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .02em;
  line-height: 1.05;
  text-align: center;
  text-transform: uppercase;
  transform-origin: 50% 118%;
  transform: translate(var(--fan-shift), var(--fan-rise)) rotate(var(--fan-rotate)) scale(var(--fan-scale));
  transition: transform 160ms ease, filter 160ms ease, opacity 160ms ease, box-shadow 160ms ease;
}

.hand-card:first-child { margin-left: 0; }
.hand-card:nth-child(1) { --fan-rise: 14px; --fan-rotate: -13deg; --fan-scale: .95; z-index: 1; }
.hand-card:nth-child(2) { --fan-rise: 3px; --fan-rotate: -5deg; --fan-scale: 1.03; z-index: 3; }
.hand-card:nth-child(3) { --fan-rise: 3px; --fan-rotate: 5deg; --fan-scale: 1.03; z-index: 4; }
.hand-card:nth-child(4) { --fan-rise: 14px; --fan-rotate: 13deg; --fan-scale: .95; z-index: 2; }
.hand-card:only-child { --fan-rise: 0px; --fan-rotate: 0deg; --fan-scale: 1; }
.hand-card.tone-oat { background: var(--oat); }
.hand-card.tone-terra { background: var(--terra); }
.hand-card.tone-butter { background: var(--butter); }
.hand-card.tone-sage { background: var(--sage); }

.hand-card-title {
  display: block;
  min-height: 30px;
  padding: 0 2px;
  font-size: 10.5px;
  line-height: 1.08;
}

.hand-card-art {
  display: block;
  width: 78px;
  height: 78px;
  margin: 4px auto 0;
  object-fit: contain;
}

.hand-card-effect {
  position: absolute;
  top: 0;
  left: 9px;
  right: 9px;
  z-index: 2;
  display: flex;
  min-height: 25px;
  align-items: center;
  justify-content: center;
  padding: 6px 8px 11px;
  overflow: hidden;
  color: var(--ink);
  background: var(--oat);
  border: 1px solid rgba(41, 49, 47, .12);
  border-radius: 13px 13px 7px 7px;
  box-shadow: 0 3px 0 rgba(25, 50, 44, .18);
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: .01em;
  line-height: 1.15;
  text-transform: none;
  transform: translateY(calc(-100% + 11px));
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.hand-card-cost {
  position: absolute;
  left: 50%;
  bottom: 10px;
  display: flex;
  min-width: 38px;
  height: 28px;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 0 8px;
  color: var(--ink);
  background: var(--moon);
  border-radius: 14px;
  box-shadow: 0 2px 0 rgba(41, 49, 47, .16);
  font-size: 12px;
  transform: translateX(-50%);
}

.hand-card-cost img { width: 14px; height: 16px; object-fit: contain; }

.card-hand.has-selection .hand-card:not(.selected) {
  opacity: .84;
  filter: saturate(.88);
}
.card-hand.has-selection .hand-card:nth-child(1):not(.selected) {
  --fan-rise: 14px;
  --fan-rotate: -15deg;
  --fan-scale: .94;
  --fan-shift: 4px;
}
.card-hand.has-selection .hand-card:nth-child(2):not(.selected) {
  --fan-rise: 4px;
  --fan-rotate: -6deg;
  --fan-scale: .97;
  --fan-shift: 2px;
}
.card-hand.has-selection .hand-card:nth-child(3):not(.selected) {
  --fan-rise: 4px;
  --fan-rotate: 6deg;
  --fan-scale: .97;
  --fan-shift: -2px;
}
.card-hand.has-selection .hand-card:nth-child(4):not(.selected) {
  --fan-rise: 14px;
  --fan-rotate: 15deg;
  --fan-scale: .94;
  --fan-shift: -4px;
}

.hand-card.selected,
.hand-card.selected:first-child,
.hand-card.selected:nth-child(1),
.hand-card.selected:nth-child(2),
.hand-card.selected:nth-child(3),
.hand-card.selected:nth-child(4) {
  --fan-rise: 0px;
  --fan-rotate: 0deg;
  --fan-scale: 1.04;
  --fan-shift: 0px;
  z-index: 8;
  opacity: 1;
  filter: none;
  box-shadow:
    0 0 0 3px var(--oat),
    0 7px 0 rgba(25, 50, 44, .42),
    0 18px 22px rgba(10, 31, 29, .26);
}

.hand-card.selected .hand-card-effect {
  opacity: 1;
  visibility: visible;
}

.hand-card.selected:nth-child(1) { --fan-shift: 126px; }
.hand-card.selected:nth-child(2) { --fan-shift: 42px; }
.hand-card.selected:nth-child(3) { --fan-shift: -42px; }
.hand-card.selected:nth-child(4) { --fan-shift: -126px; }

.hand-card.selected .hand-card-title {
  min-height: 34px;
  font-size: 13px;
}

.hand-card.selected .hand-card-art {
  width: 90px;
  height: 90px;
  margin-top: 6px;
}

.hand-card.selected .hand-card-cost {
  min-width: 48px;
  height: 34px;
  padding: 0 10px;
  font-size: 14px;
}

.hand-card.selected .hand-card-cost img { width: 16px; height: 18px; }

.hand-card:active:not(:disabled):not(.selected) {
  filter: brightness(1.04);
}

.hand-card.selected:active:not(:disabled) {
  --fan-rise: 2px;
  --fan-scale: 1.02;
}

.hand-card:disabled {
  opacity: .72;
  filter: saturate(.7);
}

.card-hand.has-selection .hand-card:disabled:not(.selected) {
  opacity: .64;
  filter: saturate(.66);
}

.deck-bar {
  position: relative;
  z-index: 12;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: 44px;
  padding: 6px 4px 0;
  color: var(--oat);
  pointer-events: auto;
}

.pile-count {
  display: flex;
  align-items: center;
  gap: 5px;
  color: rgba(231, 217, 189, .72);
  font-size: 6.5px;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.pile-count > img { width: 22px; height: 25px; object-fit: contain; }
.pile-count strong { display: inline; margin-right: 2px; color: var(--moon); font-size: 13px; }
.pile-count-discard { justify-content: flex-end; text-align: right; }
.pile-count-discard > img { opacity: .56; transform: rotate(180deg); }

.wait-button {
  display: grid;
  min-width: 64px;
  min-height: 40px;
  place-items: center;
  padding: 0 7px 1px;
  pointer-events: auto;
  color: var(--oat);
  background: transparent;
  border: 0;
  border-radius: 13px;
  box-shadow: none;
  font-size: 6px;
  font-weight: 900;
  letter-spacing: .07em;
  line-height: 1;
  text-transform: uppercase;
}

.wait-button img { width: 31px; height: 31px; margin-bottom: -2px; object-fit: contain; }
.wait-button:active:not(:disabled) { transform: translateY(2px) scale(.97); }
.wait-button:disabled { opacity: .4; }

.toast {
  position: absolute;
  top: 75px;
  left: 50%;
  z-index: 9;
  width: max-content;
  max-width: calc(100vw - 42px);
  padding: 9px 14px;
  transform: translateX(-50%);
  color: var(--ink);
  background: rgba(231, 217, 189, .94);
  border: 0;
  border-radius: 18px;
  box-shadow: 0 7px 18px rgba(13, 39, 36, .22);
  font-size: 10px;
  font-weight: 670;
  line-height: 1.3;
  text-align: center;
  animation: toast-in 180ms ease both;
}

@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, -5px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.eyebrow {
  display: block;
  margin-bottom: 7px;
  color: var(--terra);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.screen,
.modal-layer {
  position: absolute;
  inset: 0;
  z-index: 20;
}

.start-screen {
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: var(--safe-top) 26px var(--safe-bottom);
  text-align: center;
  background: var(--night) url("./assets/cozy-night-garden.png") center / cover no-repeat;
}

.start-screen::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(24, 52, 50, .16);
}

.start-copy {
  position: relative;
  z-index: 4;
  width: min(100%, 350px);
  margin-top: -8px;
}

.start-copy h1 {
  margin: 0 0 14px;
  color: var(--moon);
  font-size: clamp(40px, 12.8vw, 52px);
  font-weight: 820;
  letter-spacing: -.065em;
  line-height: .9;
}

.start-copy p {
  max-width: 304px;
  margin: 0 auto 23px;
  color: var(--oat);
  font-size: 13px;
  font-weight: 560;
  line-height: 1.5;
}

.start-boss {
  position: absolute;
  top: 7%;
  right: -10%;
  z-index: 1;
  width: min(49vw, 250px);
  opacity: .25;
}

.start-hero {
  position: absolute;
  bottom: 4%;
  left: -8%;
  z-index: 1;
  width: min(42vw, 210px);
  opacity: .42;
}

.primary-button,
.secondary-button,
.text-button {
  width: min(100%, 282px);
  min-height: 50px;
  padding: 12px 18px;
  border-radius: 24px;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .04em;
}

.primary-button {
  color: var(--ink);
  background: var(--butter);
  border: 0;
  box-shadow: 0 5px 0 #b78c42;
}

.secondary-button {
  margin-top: 10px;
  color: var(--ink);
  background: var(--sage);
  border: 0;
  box-shadow: 0 5px 0 var(--sage-dark);
}

.text-button {
  color: var(--sage-dark);
  background: transparent;
  border: 0;
}

.primary-button:active,
.secondary-button:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(41, 49, 47, .42); }

.memory-count,
.start-note {
  color: var(--sage);
  font-size: 9px;
  font-weight: 700;
}

.memory-count { display: block; min-height: 18px; margin-top: 13px; }
.start-note {
  position: absolute;
  bottom: calc(var(--safe-bottom) + 3px);
  z-index: 5;
  color: rgba(231, 217, 189, .6);
  letter-spacing: .03em;
}

.modal-layer {
  display: grid;
  place-items: center;
  padding: var(--safe-top) 16px var(--safe-bottom);
  background: rgba(24, 52, 50, .82);
  backdrop-filter: blur(7px);
}

.modal {
  width: min(100%, 380px);
  max-height: calc(100vh - var(--safe-top) - var(--safe-bottom) - 20px);
  overflow: auto;
  padding: 25px 21px 22px;
  color: var(--ink);
  background: var(--oat);
  border: 0;
  border-radius: 28px;
  box-shadow: 0 14px 0 rgba(15, 42, 39, .38), 0 26px 54px rgba(10, 31, 29, .28);
  text-align: center;
}

.modal h2 {
  margin: 0 0 17px;
  color: var(--ink);
  font-size: 29px;
  font-weight: 820;
  letter-spacing: -.04em;
  line-height: 1.04;
}

.modal > p {
  margin: 0 auto 20px;
  color: rgba(41, 49, 47, .72);
  font-size: 12px;
  font-weight: 570;
  line-height: 1.52;
}

.tutorial-card { text-align: left; }
.tutorial-card h2 { margin-bottom: 18px; }
.tutorial-card > .primary-button { display: block; margin: 20px auto 0; }

.tutorial-row {
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 11px;
  align-items: center;
  min-height: 66px;
  margin: 7px 0;
  padding: 8px 10px;
  background: rgba(129, 152, 124, .14);
  border: 0;
  border-radius: 18px;
}

.tutorial-row img { width: 54px; height: 54px; object-fit: contain; }
.tutorial-row p { margin: 0; color: rgba(41, 49, 47, .7); font-size: 11px; line-height: 1.35; }
.tutorial-row strong { color: var(--ink); font-size: 12px; }

.reward-copy { margin-top: -8px !important; }
.reward-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.reward-list.is-charms { align-items: stretch; }
.reward-list.is-charms .charm-card { display: flex; min-height: 202px; flex-direction: column; }
.reward-list.is-charms .charm-card img { width: 58px; height: 58px; }
.reward-list.is-charms .charm-card span { font-size: 8.5px; line-height: 1.36; }
.reward-list.is-charms .charm-card small { margin-top: auto; padding-top: 9px; }
.reward-list.is-deck { grid-template-columns: 1fr; max-height: 43vh; overflow: auto; padding: 2px; }
.reward-card {
  position: relative;
  width: 100%;
  min-width: 0;
  min-height: 176px;
  padding: 12px 7px 9px;
  color: var(--ink);
  background: var(--sage);
  border: 1px solid rgba(41, 49, 47, .14);
  border-radius: 19px;
  text-align: center;
}
.reward-card.tone-oat { background: var(--oat); }
.reward-card.tone-terra { background: var(--terra); }
.reward-card.tone-butter { background: var(--butter); }
.reward-card img { display: block; width: 64px; height: 64px; margin: 7px auto; object-fit: contain; }
.reward-card strong { display: block; min-height: 31px; color: var(--ink); font-size: 11px; font-weight: 900; line-height: 1.12; text-transform: uppercase; }
.reward-card span { display: block; color: rgba(41, 49, 47, .72); font-size: 8px; line-height: 1.28; }
.reward-card small { display: block; margin-top: 8px; color: var(--terra-dark); font-size: 7px; font-weight: 900; letter-spacing: .06em; text-transform: uppercase; }
.reward-card:active { transform: scale(.98); filter: brightness(1.06); }
.reward-card:disabled { opacity: .36; }

.reward-list.is-deck .reward-card {
  display: grid;
  min-height: 64px;
  grid-template-columns: 48px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 8px 12px;
  text-align: left;
}
.reward-list.is-deck .reward-card img { width: 46px; height: 46px; margin: 0; }
.reward-list.is-deck .reward-card strong { min-height: 0; font-size: 12px; }
.reward-list.is-deck .reward-card small { margin: 0; }

.reward-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 13px; }
.reward-actions .secondary-button,
.reward-actions .text-button { width: 100%; min-height: 42px; margin: 0; font-size: 9px; }
#reward-back-button { margin: 12px auto 0; }

.pause-modal .primary-button,
.pause-modal .secondary-button,
.pause-modal .text-button,
.end-modal .primary-button,
.end-modal .secondary-button { display: block; margin-left: auto; margin-right: auto; }
.pause-modal .text-button { margin-top: 8px; }

.deck-summary {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin: -4px 0 18px;
}
.deck-summary span { padding: 6px 9px; color: var(--ink); background: rgba(129, 152, 124, .2); border-radius: 14px; font-size: 8px; font-weight: 800; }
.deck-summary span.is-charm { color: var(--moon); background: var(--sage-dark); }

.victory-layer {
  background: var(--night) url("./assets/cozy-night-garden.png") center / cover no-repeat;
}
.victory-layer::before { content: ""; position: absolute; inset: 0; background: rgba(24, 52, 50, .36); }
.victory-modal { position: relative; z-index: 1; }

.victory-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
  margin: 0 0 20px;
}
.victory-stats div { padding: 11px 6px; color: rgba(41, 49, 47, .62); background: rgba(129, 152, 124, .18); border-radius: 16px; font-size: 8px; font-weight: 850; text-transform: uppercase; }
.victory-stats strong { display: block; margin-bottom: 3px; color: var(--ink); font-size: 21px; font-weight: 850; }

.rotate-message {
  position: absolute;
  inset: 0;
  z-index: 100;
  display: none;
  place-items: center;
  padding: 35px;
  color: var(--oat);
  background: var(--night);
  font-size: 13px;
  text-align: center;
}

@media (orientation: landscape) and (max-height: 600px) {
  .rotate-message { display: grid; }
}

@media (max-height: 720px) {
  .status-strip { top: max(8px, env(safe-area-inset-top)); min-height: 42px; }
  .status-icon { width: 17px; height: 19px; }
  .status-block strong { font-size: 12px; }
  .turn-panel { bottom: max(5px, env(safe-area-inset-bottom)); }
  .turn-info-card { min-height: 35px; }
  .turn-copy { min-height: 34px; }
  .turn-copy strong { font-size: 16px; }
  #turn-description { display: none; }
  .card-hand { height: 178px; margin-top: 0; padding: 28px 5px 0; }
  .hand-card {
    flex-basis: 104px;
    width: 104px;
    min-width: 88px;
    height: 148px;
    margin-left: -32px;
    padding: 10px 6px 28px;
    border-radius: 18px;
  }
  .hand-card:nth-child(1) { --fan-rise: 12px; --fan-rotate: -11deg; --fan-scale: .95; }
  .hand-card:nth-child(2) { --fan-rise: 2px; --fan-rotate: -4deg; --fan-scale: 1.02; }
  .hand-card:nth-child(3) { --fan-rise: 2px; --fan-rotate: 4deg; --fan-scale: 1.02; }
  .hand-card:nth-child(4) { --fan-rise: 12px; --fan-rotate: 11deg; --fan-scale: .95; }
  .card-hand.has-selection .hand-card:nth-child(1):not(.selected) {
    --fan-rise: 12px;
    --fan-rotate: -13deg;
    --fan-scale: .94;
    --fan-shift: 3px;
  }
  .card-hand.has-selection .hand-card:nth-child(2):not(.selected) {
    --fan-rise: 3px;
    --fan-rotate: -5deg;
    --fan-scale: .96;
    --fan-shift: 2px;
  }
  .card-hand.has-selection .hand-card:nth-child(3):not(.selected) {
    --fan-rise: 3px;
    --fan-rotate: 5deg;
    --fan-scale: .96;
    --fan-shift: -2px;
  }
  .card-hand.has-selection .hand-card:nth-child(4):not(.selected) {
    --fan-rise: 12px;
    --fan-rotate: 13deg;
    --fan-scale: .94;
    --fan-shift: -3px;
  }
  .hand-card-title { min-height: 24px; font-size: 8.5px; }
  .hand-card-art { width: 58px; height: 58px; margin-top: 2px; }
  .hand-card-effect {
    left: 7px;
    right: 7px;
    min-height: 21px;
    padding: 5px 6px 9px;
    font-size: 8px;
    transform: translateY(calc(-100% + 9px));
  }
  .hand-card-cost { min-width: 32px; height: 24px; bottom: 7px; padding: 0 6px; font-size: 10px; }
  .hand-card-cost img { width: 12px; height: 14px; }
  .hand-card.selected,
  .hand-card.selected:first-child,
  .hand-card.selected:nth-child(1),
  .hand-card.selected:nth-child(2),
  .hand-card.selected:nth-child(3),
  .hand-card.selected:nth-child(4) {
    --fan-rise: 0px;
    --fan-rotate: 0deg;
    --fan-scale: 1.03;
    --fan-shift: 0px;
  }
  .hand-card.selected:nth-child(1) { --fan-shift: 108px; }
  .hand-card.selected:nth-child(2) { --fan-shift: 36px; }
  .hand-card.selected:nth-child(3) { --fan-shift: -36px; }
  .hand-card.selected:nth-child(4) { --fan-shift: -108px; }
  .hand-card.selected .hand-card-title { min-height: 26px; font-size: 11px; }
  .hand-card.selected .hand-card-art { width: 70px; height: 70px; margin-top: 4px; }
  .hand-card.selected .hand-card-cost { min-width: 42px; height: 29px; font-size: 12px; }
  .hand-card.selected:active:not(:disabled) { --fan-rise: 2px; --fan-scale: 1.01; }
  .deck-bar { min-height: 38px; padding-top: 4px; }
  .wait-button { min-height: 34px; }
  .wait-button img { width: 26px; height: 26px; }
}

@media (max-width: 360px) {
  .card-hand { height: 208px; padding-top: 32px; }
  .hand-card { flex-basis: 108px; width: 108px; min-width: 96px; height: 172px; margin-left: -32px; }
  .hand-card-title { font-size: 9.5px; }
  .hand-card-art { width: 68px; height: 68px; }
  .hand-card.selected .hand-card-art { width: 78px; height: 78px; }
}

@media (min-width: 720px) {
  #game-shell {
    left: 50%;
    width: min(100vw, 520px);
    transform: translateX(-50%);
    box-shadow: 0 0 70px rgba(8, 28, 26, .45);
  }
}

/* Motion language ---------------------------------------------------------
   JS only toggles the state classes below. The layer and flight elements are
   transient, so none of this changes the resting layout of the portrait UI. */

.animation-layer {
  position: absolute;
  inset: 0;
  z-index: 30;
  overflow: hidden;
  contain: strict;
  isolation: isolate;
  pointer-events: none;
}

.phase-banner {
  position: absolute;
  top: 21%;
  left: 50%;
  display: grid;
  min-width: 184px;
  padding: 10px 20px 11px;
  place-items: center;
  color: var(--moon);
  background: rgba(24, 52, 50, .88);
  border: 1px solid rgba(231, 217, 189, .22);
  border-radius: 22px;
  box-shadow: 0 12px 28px rgba(10, 31, 29, .28), inset 0 1px rgba(255, 255, 255, .05);
  opacity: 0;
  transform: translate(-50%, 10px) scale(.94);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.phase-banner[data-tone="night"] {
  border-color: rgba(200, 115, 90, .32);
}

.phase-banner[data-tone="night"] span { color: #e3a08d; }

.phase-banner[data-tone="dawn"] {
  border-color: rgba(246, 202, 103, .34);
  box-shadow: 0 12px 28px rgba(10, 31, 29, .28), 0 0 22px rgba(246, 202, 103, .08), inset 0 1px rgba(255, 255, 255, .05);
}

.phase-banner span {
  color: var(--butter);
  font-size: 7px;
  font-weight: 900;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.phase-banner strong {
  margin-top: 2px;
  font-size: 16px;
  font-weight: 720;
  letter-spacing: .01em;
}

.phase-banner.is-visible {
  animation: cozy-phase-banner 620ms cubic-bezier(.2, .74, .3, 1) both;
}

@keyframes cozy-phase-banner {
  0% { opacity: 0; filter: blur(3px); transform: translate(-50%, 12px) scale(.93); }
  18%, 68% { opacity: 1; filter: none; transform: translate(-50%, 0) scale(1); }
  100% { opacity: 0; filter: blur(1px); transform: translate(-50%, -7px) scale(.98); }
}

.hand-card.is-dealing {
  animation: cozy-card-deal 520ms cubic-bezier(.2, .78, .24, 1.12) backwards;
  animation-delay: var(--deal-delay, 0ms);
}

@keyframes cozy-card-deal {
  0% {
    opacity: 0;
    filter: blur(4px) saturate(.72) brightness(.88);
    transform: translate(var(--fan-shift), calc(var(--fan-rise) + 72px)) rotate(var(--fan-rotate)) scale(.72);
  }
  62% {
    opacity: 1;
    filter: blur(0) saturate(1.04) brightness(1.06);
    transform: translate(var(--fan-shift), calc(var(--fan-rise) - 8px)) rotate(var(--fan-rotate)) scale(calc(var(--fan-scale) + .035));
  }
  82% {
    filter: none;
    transform: translate(var(--fan-shift), calc(var(--fan-rise) + 3px)) rotate(var(--fan-rotate)) scale(calc(var(--fan-scale) - .012));
  }
  100% {
    opacity: 1;
    filter: none;
    transform: translate(var(--fan-shift), var(--fan-rise)) rotate(var(--fan-rotate)) scale(var(--fan-scale));
  }
}

.animation-layer .card-flight {
  --card-flight-x: 0px;
  --card-flight-y: -180px;
  --card-flight-rotate: -7deg;
  position: absolute;
  z-index: 2;
  margin: 0;
  opacity: 1;
  pointer-events: none;
  transform-origin: 50% 50%;
  transition: none;
  will-change: transform, opacity, filter;
}

.animation-layer .card-flight.is-css-flight {
  animation: cozy-card-flight 560ms cubic-bezier(.22, .76, .25, 1) both !important;
}

@keyframes cozy-card-flight {
  0% {
    opacity: 1;
    filter: brightness(1) saturate(1);
    transform: translate3d(0, 0, 0) rotate(0) scale(1);
  }
  22% {
    opacity: 1;
    filter: brightness(1.12) saturate(1.05);
    transform: translate3d(0, -22px, 0) rotate(-2deg) scale(1.075);
  }
  74% {
    opacity: .96;
    filter: brightness(1.08) saturate(1.02);
  }
  100% {
    opacity: 0;
    filter: brightness(1.24) saturate(.8) blur(1px);
    transform: translate3d(var(--card-flight-x), var(--card-flight-y), 0) rotate(var(--card-flight-rotate)) scale(.34);
  }
}

.animation-layer .card-impact {
  position: absolute;
  z-index: 1;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  border-radius: 50%;
  background: var(--butter);
  box-shadow: 0 0 12px 4px rgba(246, 202, 103, .7);
  animation: cozy-card-impact 440ms cubic-bezier(.18, .8, .3, 1) both;
}

.animation-layer .card-impact::before,
.animation-layer .card-impact::after {
  content: "";
  position: absolute;
  inset: 50%;
  border: 2px solid rgba(246, 202, 103, .82);
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

.animation-layer .card-impact::after {
  border-color: rgba(231, 217, 189, .64);
  animation: cozy-impact-ring 420ms 70ms ease-out both;
}

@keyframes cozy-card-impact {
  0% { opacity: 0; transform: scale(.3); }
  24% { opacity: 1; transform: scale(1.14); }
  100% { opacity: 0; transform: scale(2.3); }
}

@keyframes cozy-impact-ring {
  0% { width: 0; height: 0; opacity: 1; }
  100% { width: 58px; height: 58px; opacity: 0; }
}

.turn-info-card::before {
  content: "";
  position: absolute;
  left: 18%;
  right: 18%;
  bottom: 1px;
  height: 2px;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, rgba(246, 202, 103, .9), transparent);
  opacity: 0;
  transform: scaleX(.22);
  pointer-events: none;
}

.turn-info-card.is-turn-pulse::before,
.turn-info-card.is-pulsing::before {
  animation: cozy-turn-line 520ms ease-out both;
}

.turn-info-card.is-turn-pulse .turn-copy,
.turn-info-card.is-pulsing .turn-copy {
  animation: cozy-turn-copy 520ms cubic-bezier(.2, .75, .25, 1) both;
}

@keyframes cozy-turn-copy {
  0% { opacity: .38; filter: blur(2px); transform: translateY(7px) scale(.985); }
  46% { opacity: 1; filter: none; transform: translateY(-2px) scale(1.025); }
  100% { opacity: 1; filter: none; transform: translateY(0) scale(1); }
}

@keyframes cozy-turn-line {
  0% { opacity: 0; transform: scaleX(.22); }
  38% { opacity: .88; transform: scaleX(1); }
  100% { opacity: 0; transform: scaleX(.72); }
}

.health-block,
.ember-block {
  position: relative;
  isolation: isolate;
  transform-origin: 50% 55%;
}

.health-block::after,
.ember-block::after {
  content: "";
  position: absolute;
  inset: -8px -7px;
  z-index: -1;
  border-radius: 17px;
  opacity: 0;
  pointer-events: none;
}

.health-block.is-hit {
  animation: cozy-health-hit 430ms cubic-bezier(.36, .07, .19, .97) both;
}

.health-block.is-hit::after {
  background: radial-gradient(circle, rgba(200, 115, 90, .34), transparent 70%);
  animation: cozy-hud-aura 430ms ease-out both;
}

.health-block.is-hit .status-icon {
  animation: cozy-heart-hit 430ms ease-out both;
}

.health-block.is-hit strong {
  animation: cozy-value-hit 430ms ease-out both;
}

.health-block.is-healed::after {
  background: radial-gradient(circle, rgba(129, 152, 124, .46), transparent 70%);
  animation: cozy-hud-aura 560ms ease-out both;
}

.health-block.is-healed .status-icon,
.health-block.is-healed strong {
  animation: cozy-health-heal 560ms cubic-bezier(.2, .78, .3, 1) both;
}

.ember-block.is-gain::after,
.ember-block.is-pulsing::after {
  background: radial-gradient(circle, rgba(246, 202, 103, .5), transparent 72%);
  animation: cozy-hud-aura 520ms ease-out both;
}

.ember-block.is-gain .status-icon,
.ember-block.is-pulsing .status-icon {
  animation: cozy-ember-gain 520ms cubic-bezier(.18, .8, .3, 1) both;
}

.ember-block.is-gain strong,
.ember-block.is-pulsing strong {
  animation: cozy-value-gain 520ms cubic-bezier(.18, .8, .3, 1) both;
}

.ember-block.is-spend .status-icon,
.ember-block.is-spend strong {
  animation: cozy-ember-spend 360ms ease-out both;
}

@keyframes cozy-health-hit {
  0%, 100% { transform: translateX(0); }
  18% { transform: translateX(-3px) rotate(-1deg); }
  38% { transform: translateX(3px) rotate(1deg); }
  58% { transform: translateX(-2px); }
  78% { transform: translateX(1px); }
}

@keyframes cozy-heart-hit {
  0% { filter: none; transform: scale(1); }
  26% { filter: brightness(1.3) saturate(1.25); transform: scale(.82); }
  54% { filter: brightness(1.12) saturate(1.15); transform: scale(1.17); }
  100% { filter: none; transform: scale(1); }
}

@keyframes cozy-value-hit {
  0%, 100% { color: var(--moon); transform: scale(1); }
  34% { color: #f4a48d; transform: scale(1.14); }
}

@keyframes cozy-health-heal {
  0% { filter: none; transform: scale(1); }
  35% { filter: brightness(1.28) saturate(1.12); transform: translateY(-2px) scale(1.16); }
  68% { transform: translateY(0) scale(.97); }
  100% { filter: none; transform: scale(1); }
}

@keyframes cozy-ember-gain {
  0% { filter: brightness(.85); transform: translateY(2px) scale(.76); }
  42% { filter: brightness(1.4) saturate(1.35) drop-shadow(0 0 5px rgba(246, 202, 103, .75)); transform: translateY(-3px) scale(1.23) rotate(-4deg); }
  72% { transform: translateY(0) scale(.95) rotate(2deg); }
  100% { filter: none; transform: scale(1); }
}

@keyframes cozy-value-gain {
  0% { color: var(--moon); transform: scale(.9); }
  44% { color: var(--butter); transform: translateY(-2px) scale(1.2); }
  100% { color: var(--moon); transform: scale(1); }
}

@keyframes cozy-ember-spend {
  0% { opacity: 1; filter: none; transform: scale(1); }
  42% { opacity: .5; filter: saturate(.55); transform: translateY(2px) scale(.84); }
  100% { opacity: 1; filter: none; transform: scale(1); }
}

@keyframes cozy-hud-aura {
  0% { opacity: 0; transform: scale(.62); }
  32% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.2); }
}

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

  .animation-layer .card-flight.is-css-flight,
  .animation-layer .card-impact {
    animation: cozy-motion-fade 80ms linear both !important;
  }
}

@keyframes cozy-motion-fade {
  from { opacity: 1; }
  to { opacity: 0; }
}

/* Mobile UX overhaul: keep the garden, make every decision readable. */
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  white-space: nowrap !important;
}

.board-controls {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}

.board-target {
  position: absolute;
  display: grid;
  place-items: center;
  padding: 4px;
  pointer-events: auto;
  color: #243e3a;
  background: rgba(246, 202, 103, .08);
  border: 2px solid rgba(246, 202, 103, .78);
  border-radius: 18%;
  font-size: 10px;
  font-weight: 950;
  transition: background 140ms ease, border-color 140ms ease, transform 140ms ease;
}

.board-target span {
  display: grid;
  min-width: 24px;
  min-height: 24px;
  place-items: center;
  background: rgba(246, 202, 103, .92);
  border-radius: 999px;
  box-shadow: 0 3px 8px rgba(18, 45, 41, .24);
}

.board-target span:empty { opacity: 0; }
.board-target.is-selected { background: rgba(246, 202, 103, .26); border-width: 4px; transform: scale(.94); }
.board-target.is-attack span { color: #fff7e4; background: #9a5244; }
.board-target.is-passive { opacity: .01; border-color: transparent; background: transparent; }
.board-target.is-passive:focus-visible { opacity: 1; }

.status-strip {
  top: var(--safe-top);
  left: 12px;
  right: 12px;
  min-height: 50px;
  grid-template-columns: .9fr 1.15fr .8fr 54px;
  gap: 5px;
  padding: 4px 6px 4px 8px;
  background: rgba(24, 52, 50, .72);
  border: 1px solid rgba(231, 217, 189, .12);
  border-radius: 18px;
  box-shadow: 0 8px 20px rgba(11, 35, 32, .12);
  backdrop-filter: blur(8px);
}

.status-label { font-size: 9px; letter-spacing: .07em; }
.status-block strong { font-size: 14px; }
.quiet-button { min-width: 48px; min-height: 44px; font-size: 10px; }

.charm-strip {
  top: calc(var(--safe-top) + 55px);
  z-index: 7;
  pointer-events: auto;
}

.charm-pill {
  height: 32px;
  min-height: 32px;
  padding: 4px 10px 4px 6px;
  color: var(--oat);
  background: rgba(24, 52, 50, .9);
  border: 1px solid rgba(231, 217, 189, .24);
  appearance: none;
  pointer-events: auto;
}

.charm-pill img { width: 21px; height: 22px; }
.charm-pill strong { font-size: 9px; }

.threat-summary {
  position: absolute;
  top: calc(var(--safe-top) + 92px);
  left: 50%;
  z-index: 6;
  display: flex;
  min-height: 34px;
  max-width: calc(100vw - 34px);
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  color: var(--moon);
  background: rgba(24, 52, 50, .88);
  border: 1px solid rgba(231, 217, 189, .15);
  border-radius: 15px;
  box-shadow: 0 6px 14px rgba(10, 31, 29, .18);
  font-size: 10px;
  white-space: nowrap;
  transform: translateX(-50%);
  backdrop-filter: blur(7px);
}

.threat-summary strong { color: var(--oat); font-size: 10px; }
.threat-summary span { color: rgba(237, 233, 220, .78); font-size: 9px; }
.threat-summary.is-danger { background: rgba(122, 65, 54, .94); border-color: rgba(246, 202, 103, .46); }

.turn-panel {
  left: 8px;
  right: 8px;
  bottom: max(6px, env(safe-area-inset-bottom));
  display: grid;
  gap: 5px;
}

.turn-info-card.action-guide {
  display: grid;
  min-height: 66px;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 9px 10px 9px 14px;
  color: var(--moon);
  background: rgba(24, 52, 50, .94);
  border: 1px solid rgba(231, 217, 189, .18);
  border-radius: 19px;
  box-shadow: 0 8px 18px rgba(10, 31, 29, .22);
  text-align: left;
  backdrop-filter: blur(10px);
}

.turn-copy {
  min-height: 0;
  justify-content: flex-start;
  padding: 0;
}

.turn-copy .eyebrow { margin: 0 0 2px; font-size: 9px; }
.turn-copy strong { font-size: 16px; line-height: 1.08; white-space: normal; }
#turn-description {
  position: static;
  width: auto;
  height: auto;
  margin: 3px 0 0;
  overflow: visible;
  clip: auto;
  color: rgba(237, 233, 220, .78);
  font-size: 11px;
  font-weight: 620;
  line-height: 1.22;
  white-space: normal;
}

.action-buttons { display: grid; grid-template-columns: 52px 76px; gap: 6px; pointer-events: auto; }
.action-cancel,
.action-confirm {
  min-height: 46px;
  padding: 0 8px;
  border-radius: 14px;
  font-size: 10px;
  font-weight: 900;
}
.action-cancel { color: var(--oat); background: transparent; border: 1px solid rgba(231, 217, 189, .28); }
.action-confirm { color: var(--ink); background: var(--butter); border: 0; box-shadow: 0 3px 0 #b78c42; }
.action-confirm:disabled { color: rgba(237, 233, 220, .6); background: rgba(129, 152, 124, .34); box-shadow: none; }

.card-hand,
.card-hand.is-dealing {
  display: grid;
  height: 150px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: end;
  gap: 6px;
  margin: 0;
  padding: 5px 0 2px;
  overflow: visible;
}

.hand-card,
.hand-card:first-child,
.hand-card:nth-child(1),
.hand-card:nth-child(2),
.hand-card:nth-child(3),
.hand-card:nth-child(4) {
  --fan-rise: 0px;
  --fan-rotate: 0deg;
  --fan-scale: 1;
  --fan-shift: 0px;
  width: 100%;
  min-width: 0;
  height: 142px;
  margin: 0;
  padding: 10px 6px 29px;
  overflow: hidden;
  color: #1b2422;
  border-radius: 18px;
  box-shadow: 0 4px 0 rgba(25, 50, 44, .5), 0 9px 16px rgba(10, 31, 29, .2);
  transform: none;
  transform-origin: 50% 100%;
}

.hand-card-title {
  min-height: 24px;
  padding: 0;
  font-size: 10px;
  line-height: 1.08;
}

.hand-card-art { width: 52px; height: 52px; margin: 1px auto 0; }
.hand-card-effect,
.hand-card.selected .hand-card-effect {
  position: static;
  display: -webkit-box;
  min-height: 26px;
  padding: 0;
  overflow: hidden;
  color: #1b2422;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  font-size: 9.5px;
  font-weight: 780;
  line-height: 1.18;
  text-transform: none;
  transform: none;
  opacity: 1;
  visibility: visible;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.hand-card-cost,
.hand-card.selected .hand-card-cost {
  bottom: 6px;
  min-width: 48px;
  height: 21px;
  padding: 0 7px;
  font-size: 9px;
  text-transform: uppercase;
}

.hand-card-cost img,
.hand-card.selected .hand-card-cost img { width: 11px; height: 13px; }

.hand-card.selected,
.hand-card.selected:first-child,
.hand-card.selected:nth-child(1),
.hand-card.selected:nth-child(2),
.hand-card.selected:nth-child(3),
.hand-card.selected:nth-child(4) {
  --fan-shift: 0px;
  --fan-scale: 1;
  z-index: 4;
  box-shadow: 0 0 0 3px var(--butter), 0 5px 0 rgba(25, 50, 44, .42), 0 14px 20px rgba(10, 31, 29, .28);
  transform: translateY(-5px);
}

.hand-card.selected .hand-card-title { min-height: 24px; font-size: 10px; }
.hand-card.selected .hand-card-art { width: 52px; height: 52px; margin-top: 1px; }

.hand-card.is-unavailable { opacity: .9; filter: saturate(.7); }
.hand-card-state {
  position: absolute;
  top: 31px;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 7px 24px;
  color: #fff7e4;
  background: rgba(36, 62, 58, .82);
  font-size: 10px;
  font-weight: 850;
  line-height: 1.25;
  text-transform: none;
  border-radius: 0 0 17px 17px;
  backdrop-filter: blur(2px);
}

.deck-bar { min-height: 50px; grid-template-columns: 1fr 1.3fr 1fr; gap: 6px; padding: 0; }
.pile-count,
.wait-button {
  min-height: 46px;
  justify-content: center;
  padding: 4px 8px;
  color: var(--oat);
  background: rgba(24, 52, 50, .88);
  border: 1px solid rgba(231, 217, 189, .15);
  border-radius: 15px;
  font-size: 9px;
  line-height: 1.05;
  appearance: none;
}
.pile-count { justify-content: center; }
.pile-count strong { font-size: 15px; }
.pile-count > img { width: 20px; height: 23px; }
.wait-button { display: flex; gap: 6px; font-size: 11px; }
.wait-button img { width: 25px; height: 25px; margin: 0; }
.pile-count:disabled,
.wait-button:disabled { opacity: .42; }

.start-copy p { font-size: 14px; }
.start-meta { display: flex; justify-content: center; gap: 7px; margin: -8px 0 20px; }
.start-meta span {
  padding: 6px 9px;
  color: var(--oat);
  background: rgba(24, 52, 50, .72);
  border: 1px solid rgba(231, 217, 189, .18);
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  backdrop-filter: blur(5px);
}
.start-note,
.memory-count { font-size: 10px; }

.modal { width: min(100%, 360px); padding: 24px 20px 22px; }
.modal h2 { margin-bottom: 14px; font-size: 28px; }
.modal > p { font-size: 13px; line-height: 1.45; }
.tutorial-row { grid-template-columns: 60px 1fr; min-height: 78px; padding: 10px 12px; }
.tutorial-row p { font-size: 13px; line-height: 1.35; }
.tutorial-row strong { font-size: 14px; }
.tutorial-note { margin: 14px 2px 0 !important; font-size: 12px !important; text-align: center; }

.reward-list { gap: 9px; }
.reward-list.is-paths { grid-template-columns: 1fr; }
.reward-path {
  display: grid;
  min-height: 76px;
  grid-template-columns: 58px 1fr;
  gap: 11px;
  align-items: center;
  padding: 9px 13px;
  color: #1b2422;
  background: var(--oat);
  border: 1px solid rgba(41, 49, 47, .14);
  border-radius: 19px;
  text-align: left;
}
.reward-path.tone-butter { background: var(--butter); }
.reward-path.tone-sage { background: var(--sage); }
.reward-path img { width: 54px; height: 54px; object-fit: contain; }
.reward-path strong { display: block; font-size: 14px; font-weight: 900; }
.reward-path small { display: block; margin-top: 3px; color: #1b2422; font-size: 11px; font-weight: 680; }
.reward-path:disabled { opacity: .4; }

.reward-card { min-height: 188px; padding: 12px 7px 10px; }
.reward-card strong { min-height: 34px; color: #1b2422; font-size: 11px; }
.reward-card span { color: #1b2422; font-size: 10.5px; line-height: 1.3; }
.reward-card small { color: #1b2422; font-size: 9px; }
.reward-card[aria-pressed="true"],
.reward-card.is-selected { box-shadow: 0 0 0 4px var(--butter), 0 8px 18px rgba(18, 45, 41, .2); transform: translateY(-3px); }
.reward-list.is-charms .charm-card { min-height: 228px; }
.reward-list.is-charms .charm-card span { font-size: 10.5px; line-height: 1.34; }
.reward-actions .secondary-button,
.reward-actions .text-button { min-height: 46px; font-size: 11px; }
.reward-confirm { display: block; margin: 14px auto 0; }
#reward-back-button { min-height: 44px; font-size: 11px; }

.deck-summary span { padding: 7px 10px; font-size: 10px; }
.pause-modal .secondary-button { min-height: 46px; margin-top: 8px; }
.pause-modal .text-button { min-height: 44px; margin-top: 4px; }

.deck-modal { overflow: hidden; }
.deck-list {
  display: grid;
  max-height: min(52vh, 450px);
  gap: 8px;
  margin: 0 0 16px;
  padding: 3px;
  overflow-y: auto;
}
.deck-card-row {
  display: grid;
  min-height: 68px;
  grid-template-columns: 52px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  color: var(--ink);
  background: rgba(129, 152, 124, .18);
  border-radius: 17px;
  text-align: left;
}
.deck-card-row.tone-terra { background: rgba(200, 115, 90, .28); }
.deck-card-row.tone-butter { background: rgba(246, 202, 103, .35); }
.deck-card-row img { width: 48px; height: 48px; object-fit: contain; }
.deck-card-row strong { display: block; font-size: 12px; }
.deck-card-row span { display: block; margin-top: 2px; color: #36423f; font-size: 11px; line-height: 1.25; }
.deck-card-row small { color: #5c352e; font-size: 9px; font-weight: 850; text-transform: uppercase; }
.deck-empty { margin: 20px 0; color: #36423f; font-size: 13px; }

#game-shell.reduced-motion *,
#game-shell.reduced-motion *::before,
#game-shell.reduced-motion *::after {
  animation-duration: .01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: .01ms !important;
}

@media (max-height: 720px) {
  .status-strip { min-height: 44px; }
  .charm-strip { top: calc(var(--safe-top) + 48px); }
  .threat-summary { top: calc(var(--safe-top) + 80px); min-height: 30px; padding: 5px 10px; }
  .turn-panel { gap: 3px; }
  .turn-info-card.action-guide { min-height: 56px; padding: 7px 9px 7px 11px; }
  .turn-copy strong { font-size: 14px; }
  #turn-description { display: block; font-size: 10px; }
  .action-buttons { grid-template-columns: 48px 68px; }
  .action-cancel,
  .action-confirm { min-height: 42px; font-size: 9px; }
  .card-hand,
  .card-hand.is-dealing { height: 121px; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; padding: 2px 0; }
  .hand-card,
  .hand-card:first-child,
  .hand-card:nth-child(1),
  .hand-card:nth-child(2),
  .hand-card:nth-child(3),
  .hand-card:nth-child(4) { width: 100%; min-width: 0; height: 116px; margin: 0; padding: 7px 5px 25px; }
  .hand-card-title,
  .hand-card.selected .hand-card-title { min-height: 20px; font-size: 9px; }
  .hand-card-art,
  .hand-card.selected .hand-card-art { width: 40px; height: 40px; }
  .hand-card-effect,
  .hand-card.selected .hand-card-effect { min-height: 23px; font-size: 8.5px; }
  .hand-card-cost,
  .hand-card.selected .hand-card-cost { bottom: 4px; height: 19px; min-width: 42px; font-size: 8px; }
  .deck-bar { min-height: 44px; }
  .hand-card-state { top: 27px; padding: 7px 5px 21px; font-size: 8.5px; }
  .pile-count,
  .wait-button { min-height: 42px; }
  .wait-button img { width: 21px; height: 21px; }
}

@media (max-width: 360px) {
  .status-strip { left: 7px; right: 7px; }
  .status-label { font-size: 8px; }
  .threat-summary span { display: none; }
  .turn-panel { left: 5px; right: 5px; }
  .card-hand { height: 144px; padding-top: 4px; }
  .hand-card,
  .hand-card:first-child,
  .hand-card:nth-child(1),
  .hand-card:nth-child(2),
  .hand-card:nth-child(3),
  .hand-card:nth-child(4) { width: 100%; min-width: 0; height: 137px; margin: 0; }
  .action-buttons { grid-template-columns: 50px 70px; }
}

@media (max-width: 360px) and (max-height: 720px) {
  .card-hand,
  .card-hand.is-dealing { height: 121px; }
  .hand-card,
  .hand-card:first-child,
  .hand-card:nth-child(1),
  .hand-card:nth-child(2),
  .hand-card:nth-child(3),
  .hand-card:nth-child(4) { height: 116px; padding: 7px 4px 25px; }
}

/* Moonlit card reveal ------------------------------------------------------
   The selected visual direction is tactile, full-screen and theatrical.
   These rules intentionally override the earlier utility-first mobile pass. */

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

#atmosphere.is-unavailable { display: none; }
#game-shell.reward-open #atmosphere { z-index: 21; }

.status-strip {
  top: calc(var(--safe-top) + 3px);
  left: 12px;
  right: 10px;
  min-height: 49px;
  gap: 3px;
  padding: 4px 5px;
  background: rgba(17, 43, 40, .7);
  border: 1px solid rgba(231, 217, 189, .11);
  border-radius: 19px;
  box-shadow: 0 8px 22px rgba(5, 22, 20, .18), inset 0 1px rgba(255, 255, 255, .035);
  -webkit-backdrop-filter: blur(7px);
  backdrop-filter: blur(7px);
}

.status-block { min-height: 38px; padding: 0 3px; }
.status-icon { filter: drop-shadow(0 3px 3px rgba(5, 22, 20, .34)); }
.status-label { color: rgba(231, 217, 189, .72); font-size: 7.5px; }
.status-block strong { color: #fff5dc; font-size: 13px; text-shadow: 0 2px 4px rgba(6, 24, 22, .3); }
.quiet-button {
  min-width: 48px;
  min-height: 38px;
  color: #fff0cf;
  border-left: 1px solid rgba(231, 217, 189, .12);
  border-radius: 0 14px 14px 0;
}

.charm-strip { top: calc(var(--safe-top) + 57px); }
.charm-pill {
  background: rgba(17, 43, 40, .86);
  border-color: rgba(231, 217, 189, .13);
  box-shadow: 0 7px 16px rgba(5, 22, 20, .2), inset 0 1px rgba(255, 255, 255, .04);
}

.threat-summary {
  top: calc(var(--safe-top) + 91px);
  min-height: 36px;
  padding: 6px 13px 7px;
  background: rgba(23, 52, 48, .88);
  border-color: rgba(231, 217, 189, .14);
  border-radius: 15px;
  box-shadow: 0 7px 16px rgba(5, 22, 20, .18), inset 0 1px rgba(255, 255, 255, .04);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.threat-summary.is-danger { background: rgba(116, 62, 51, .91); border-color: rgba(246, 202, 103, .28); }

.turn-panel { left: 8px; right: 8px; bottom: max(7px, env(safe-area-inset-bottom)); }
.turn-info-card.action-guide {
  min-height: 62px;
  padding: 8px 9px 8px 13px;
  background: rgba(18, 47, 43, .91);
  border: 1px solid rgba(231, 217, 189, .14);
  border-radius: 20px;
  box-shadow: 0 8px 20px rgba(5, 22, 20, .2), inset 0 1px rgba(255, 255, 255, .04);
  -webkit-backdrop-filter: blur(7px);
  backdrop-filter: blur(7px);
}
.turn-copy { justify-content: flex-start; padding: 0 136px 0 0; text-align: left; }
.turn-copy strong { color: #fff2d5; font-size: 17px; font-weight: 760; }
#turn-description {
  position: static;
  display: -webkit-box;
  width: auto;
  height: auto;
  margin: 3px 0 0;
  overflow: hidden;
  clip: auto;
  color: rgba(237, 233, 220, .72);
  font-size: 10.5px;
  font-weight: 620;
  line-height: 1.22;
  white-space: normal;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.action-buttons { position: absolute; top: 8px; right: 8px; grid-template-columns: 50px 72px; }
.action-cancel,
.action-confirm { min-height: 44px; border-radius: 14px; }
.action-confirm { box-shadow: 0 4px 0 #a97c35, 0 8px 12px rgba(5, 22, 20, .18); }

.card-hand,
.card-hand.is-dealing {
  display: flex;
  height: 168px;
  align-items: flex-end;
  justify-content: center;
  gap: 0;
  padding: 13px 5px 1px;
  overflow: visible;
}

.hand-card,
.hand-card:first-child,
.hand-card:nth-child(1),
.hand-card:nth-child(2),
.hand-card:nth-child(3),
.hand-card:nth-child(4) {
  --fan-rise: 0px;
  --fan-rotate: 0deg;
  --fan-scale: 1;
  --fan-shift: 0px;
  flex: 0 0 108px;
  width: 108px;
  min-width: 108px;
  height: 155px;
  margin: 0 0 0 -24px;
  padding: 11px 7px 29px;
  overflow: hidden;
  border: 2px solid rgba(255, 244, 218, .48);
  border-radius: 20px;
  box-shadow: 0 5px 0 rgba(34, 50, 43, .62), 0 12px 22px rgba(5, 22, 20, .24), inset 0 1px rgba(255, 255, 255, .26);
  transform: translate(var(--fan-shift), var(--fan-rise)) rotate(var(--fan-rotate)) scale(var(--fan-scale));
  transform-origin: 50% 112%;
  transition: transform 240ms cubic-bezier(.2,.78,.24,1.08), filter 180ms ease, opacity 180ms ease, box-shadow 220ms ease;
}
.hand-card:first-child { margin-left: 0; }
.hand-card:nth-child(1) { --fan-rise: 9px; --fan-rotate: -8deg; z-index: 1; }
.hand-card:nth-child(2) { --fan-rise: 1px; --fan-rotate: -3deg; z-index: 2; }
.hand-card:nth-child(3) { --fan-rise: 1px; --fan-rotate: 3deg; z-index: 3; }
.hand-card:nth-child(4) { --fan-rise: 9px; --fan-rotate: 8deg; z-index: 2; }
.hand-card-title,
.hand-card.selected .hand-card-title { min-height: 24px; padding: 0 2px; font-size: 9.5px; line-height: 1.08; }
.hand-card-art,
.hand-card.selected .hand-card-art { width: 54px; height: 54px; margin: 2px auto 0; filter: drop-shadow(0 4px 4px rgba(41,49,47,.18)); }
.hand-card-effect,
.hand-card.selected .hand-card-effect {
  position: static;
  display: -webkit-box;
  min-height: 27px;
  padding: 0;
  overflow: hidden;
  color: #1b2422;
  background: transparent;
  border: 0;
  box-shadow: none;
  font-size: 9px;
  font-weight: 760;
  line-height: 1.18;
  text-transform: none;
  transform: none;
  opacity: 1;
  visibility: visible;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.hand-card-cost,
.hand-card.selected .hand-card-cost { bottom: 6px; min-width: 49px; height: 21px; padding: 0 7px; font-size: 8.5px; text-transform: uppercase; }
.hand-card-cost img,
.hand-card.selected .hand-card-cost img { width: 11px; height: 13px; }
.card-hand.has-selection .hand-card:not(.selected) { opacity: .7; filter: saturate(.72) brightness(.88); }
.hand-card.selected,
.hand-card.selected:first-child,
.hand-card.selected:nth-child(1),
.hand-card.selected:nth-child(2),
.hand-card.selected:nth-child(3),
.hand-card.selected:nth-child(4) {
  --fan-rise: -13px;
  --fan-rotate: 0deg;
  --fan-scale: 1.055;
  --fan-shift: 0px;
  z-index: 9;
  box-shadow: 0 0 0 3px rgba(246, 202, 103, .82), 0 7px 0 rgba(34, 50, 43, .58), 0 18px 28px rgba(5, 22, 20, .34), inset 0 1px rgba(255,255,255,.28);
}
.hand-card-state { top: 29px; padding: 7px 6px 23px; background: rgba(24,52,50,.84); border-radius: 0 0 18px 18px; }

.deck-bar { min-height: 47px; gap: 5px; padding-top: 3px; }
.pile-count,
.wait-button {
  min-height: 43px;
  color: #f6ead0;
  background: rgba(18, 47, 43, .86);
  border: 1px solid rgba(231, 217, 189, .12);
  border-radius: 14px;
  box-shadow: 0 5px 12px rgba(5, 22, 20, .16), inset 0 1px rgba(255,255,255,.035);
}
.wait-button { display: flex; gap: 5px; padding: 3px 9px; font-size: 9px; }
.wait-button img { width: 27px; height: 27px; margin: 0; }

.start-screen::before { background: rgba(8, 29, 27, .28); }
.start-copy h1 { color: #fff1d2; text-shadow: 0 7px 18px rgba(5,22,20,.32); }
.start-copy p { color: rgba(255, 241, 210, .88); }
.primary-button {
  background: var(--butter);
  border: 2px solid rgba(255, 242, 205, .5);
  box-shadow: 0 6px 0 #9e7332, 0 13px 22px rgba(5,22,20,.22), inset 0 1px rgba(255,255,255,.28);
}
.secondary-button {
  border: 1px solid rgba(255, 244, 218, .28);
  box-shadow: 0 5px 0 #4e654f, 0 11px 19px rgba(5,22,20,.18), inset 0 1px rgba(255,255,255,.18);
}

.modal-layer:not(#reward-screen) {
  background: rgba(8, 31, 29, .82);
  -webkit-backdrop-filter: blur(9px);
  backdrop-filter: blur(9px);
}
.modal-layer:not(#reward-screen) .modal {
  border: 2px solid rgba(255, 244, 218, .4);
  box-shadow: 0 9px 0 rgba(52, 70, 59, .72), 0 28px 55px rgba(5,22,20,.36), inset 0 1px rgba(255,255,255,.3);
  animation: moonlit-modal-arrive 460ms cubic-bezier(.2,.78,.24,1.08) both;
}

@keyframes moonlit-modal-arrive {
  from { opacity: 0; filter: blur(5px); transform: translateY(26px) scale(.94); }
  to { opacity: 1; filter: none; transform: translateY(0) scale(1); }
}

#reward-screen {
  display: block;
  padding: 0;
  overflow: hidden;
  background: #132e2b url("./assets/reward-grove.webp") center / cover no-repeat;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}
#reward-screen::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(7, 27, 25, .38);
  pointer-events: none;
}
.reward-modal {
  position: relative;
  z-index: 22;
  display: grid;
  width: 100%;
  height: 100%;
  max-height: none;
  grid-template-rows: auto minmax(0, 1fr) 98px 68px;
  align-items: center;
  overflow: hidden;
  padding: calc(var(--safe-top) + 24px) 12px calc(var(--safe-bottom) + 10px);
  color: #fff0d1;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}
.reward-heading { position: relative; z-index: 5; max-width: 350px; margin: 0 auto; text-align: center; }
.reward-heading .eyebrow { margin-bottom: 6px; color: #aeba8a; font-size: 9px; letter-spacing: .2em; }
.reward-modal h2 { margin: 0; color: #fff0d1; font-size: clamp(36px, 10.5vw, 46px); font-weight: 820; letter-spacing: -.045em; line-height: .98; text-shadow: 0 7px 18px rgba(5,22,20,.34); }
.reward-modal > .reward-heading > p {
  min-height: 35px;
  max-width: 340px;
  margin: 10px auto 0 !important;
  color: rgba(255, 240, 209, .83);
  font-size: 12px;
  font-weight: 590;
  line-height: 1.35;
}
.reward-list,
.reward-list.is-offers {
  position: relative;
  z-index: 4;
  display: flex;
  width: 100%;
  min-height: 0;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 22px 0 8px;
  overflow: visible;
  isolation: isolate;
}
.reward-card.reward-offer {
  --reward-rotate: 0deg;
  --reward-deal-rotate: 0deg;
  position: relative;
  display: grid;
  flex: 0 0 116px;
  width: 116px;
  min-width: 116px;
  height: 282px;
  grid-template-rows: 42px 82px minmax(0, 1fr) 31px;
  align-items: center;
  margin-left: -5px;
  padding: 29px 9px 10px;
  overflow: visible;
  color: #1b2422;
  background: var(--oat);
  border: 2px solid rgba(255, 246, 224, .64);
  border-radius: 23px;
  box-shadow: 0 7px 0 rgba(46, 61, 52, .72), 0 20px 30px rgba(5,22,20,.31), inset 0 1px rgba(255,255,255,.33);
  text-align: center;
  transform: translateY(7px) rotate(var(--reward-rotate));
  transform-origin: 50% 100%;
  transition: transform 260ms cubic-bezier(.2,.78,.24,1.1), opacity 190ms ease, filter 190ms ease, box-shadow 230ms ease;
}
.reward-card.reward-offer:first-child { --reward-rotate: -5deg; --reward-deal-rotate: -12deg; z-index: 1; margin-left: 0; }
.reward-card.reward-offer:nth-child(2) { --reward-rotate: 0deg; z-index: 3; transform: translateY(-1px) rotate(0); }
.reward-card.reward-offer:nth-child(3) { --reward-rotate: 5deg; --reward-deal-rotate: 12deg; z-index: 2; }
.reward-card.reward-offer.tone-terra { background: #cf7a62; }
.reward-card.reward-offer.tone-sage { background: #94a68c; }
.reward-card.reward-offer.tone-butter { background: #efc66d; }
.reward-card.reward-offer.tone-oat { background: #e9d9b8; }
.reward-ribbon {
  position: absolute;
  top: -13px;
  left: 50%;
  z-index: 3;
  min-width: 82px;
  padding: 7px 10px 6px;
  color: #fff2d6;
  background: #9f5547;
  border: 1px solid rgba(255, 238, 205, .33);
  border-radius: 9px 9px 13px 13px;
  box-shadow: 0 4px 0 rgba(86, 54, 45, .55), 0 7px 12px rgba(5,22,20,.2);
  font-size: 8px;
  font-weight: 900;
  letter-spacing: .09em;
  text-transform: uppercase;
  transform: translateX(-50%);
}
.reward-offer.is-upgrade .reward-ribbon { background: #687d63; }
.reward-offer > strong { display: block; min-height: 0; color: #202a27; font-size: 13px; font-weight: 900; line-height: 1.08; text-transform: uppercase; }
.reward-card.reward-offer .reward-art { display: grid; width: 100%; height: 82px; place-items: center; }
.reward-card.reward-offer .reward-art img { width: 78px; height: 78px; margin: 0; object-fit: contain; filter: drop-shadow(0 7px 5px rgba(41,49,47,.18)); }
.reward-card.reward-offer .reward-effect { display: block; color: #25312e; font-size: 10.5px; font-weight: 680; line-height: 1.3; }
.reward-card.reward-offer.is-upgrade { grid-template-rows: 38px 70px minmax(0, 1fr) 31px; }
.reward-offer.is-upgrade .reward-art { height: 70px; }
.reward-offer.is-upgrade .reward-art img { width: 66px; height: 66px; }
.reward-card.reward-offer .reward-evolution {
  display: grid;
  min-height: 0;
  align-self: stretch;
  align-content: center;
  gap: 4px;
  padding: 2px 0;
  color: #25312e;
  line-height: 1.14;
}
.reward-card.reward-offer .reward-evolution-before,
.reward-card.reward-offer .reward-evolution-after { min-width: 0; border-radius: 9px; }
.reward-card.reward-offer .reward-evolution-before {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 4px;
  padding: 3px 5px;
  color: rgba(37, 49, 46, .68);
  background: rgba(255, 244, 218, .18);
  font-size: 7.5px;
  font-weight: 720;
}
.reward-card.reward-offer .reward-evolution-after {
  display: block;
  padding: 5px 5px 6px;
  background: rgba(255, 247, 226, .5);
  border: 1px solid rgba(255, 255, 255, .22);
  box-shadow: 0 2px 0 rgba(64, 72, 61, .08), inset 0 1px rgba(255, 255, 255, .22);
}
.reward-card.reward-offer .reward-evolution small {
  display: block;
  margin: 0;
  color: #5b6e55;
  font-size: 6.5px;
  font-weight: 900;
  letter-spacing: .08em;
  line-height: 1.05;
  text-transform: uppercase;
}
.reward-card.reward-offer .reward-evolution-before small { color: rgba(75, 91, 71, .75); }
.reward-card.reward-offer .reward-evolution-before > span { min-width: 0; }
.reward-card.reward-offer .reward-evolution-after > span {
  display: block;
  margin-top: 3px;
  color: #25312e;
  font-size: 9px;
  font-weight: 900;
  line-height: 1.12;
  text-wrap: balance;
}
.reward-card.reward-offer .reward-cost {
  display: inline-flex;
  position: relative;
  z-index: 2;
  height: 27px;
  min-width: 66px;
  min-height: 27px;
  align-items: center;
  justify-content: center;
  gap: 3px;
  justify-self: center;
  padding: 3px 9px;
  color: #27322f;
  background: rgba(255, 247, 226, .72);
  border: 1px solid rgba(68, 75, 64, .12);
  border-radius: 14px;
  box-shadow: 0 2px 0 rgba(41,49,47,.16);
  font-size: 8.5px;
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
}
.reward-card.reward-offer .reward-cost img { width: 15px !important; height: 17px !important; margin: 0 !important; object-fit: contain; }
#reward-screen.has-selection .reward-offer:not(.is-selected) { opacity: .58; filter: saturate(.68) brightness(.78); }
.reward-card.reward-offer.is-selected,
.reward-card.reward-offer[aria-pressed="true"] {
  z-index: 8;
  box-shadow: 0 0 0 4px rgba(246,202,103,.68), 0 8px 0 rgba(46,61,52,.68), 0 25px 38px rgba(5,22,20,.42), inset 0 1px rgba(255,255,255,.38);
  transform: translateY(-17px) rotate(0deg) scale(1.055);
}
.reward-card.reward-offer:first-child.is-selected { transform: translate(8px, -17px) rotate(0deg) scale(1.045); }
.reward-card.reward-offer:nth-child(3).is-selected { transform: translate(-8px, -17px) rotate(0deg) scale(1.045); }
.reward-keeper { position: relative; z-index: 3; width: 90px; height: 102px; align-self: end; justify-self: center; object-fit: contain; filter: drop-shadow(0 9px 8px rgba(5,22,20,.36)); }
.reward-confirm {
  position: relative;
  z-index: 6;
  display: flex;
  width: min(100%, 270px);
  min-height: 54px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  margin: 0 auto;
  color: #fff0d1;
  background: #65775a;
  border-color: rgba(255, 244, 218, .32);
  box-shadow: 0 6px 0 #384a3d, 0 14px 25px rgba(5,22,20,.3), inset 0 1px rgba(255,255,255,.15);
  font-size: 16px;
  text-transform: none;
  animation: moonlit-confirm-arrive 360ms cubic-bezier(.2,.78,.24,1.1) both;
}
.reward-confirm img { width: 29px; height: 32px; object-fit: contain; filter: drop-shadow(0 3px 3px rgba(5,22,20,.2)); }
.reward-confirm:disabled { opacity: .55; }
.reward-leaf-flight { position: absolute; z-index: 30; width: 24px; height: 28px; object-fit: contain; pointer-events: none; }

@keyframes moonlit-confirm-arrive {
  from { opacity: 0; transform: translateY(12px) scale(.92); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes moonlit-heading-reveal {
  from { opacity: 0; filter: blur(4px); transform: translateY(-12px); }
  to { opacity: 1; filter: none; transform: translateY(0); }
}
@keyframes moonlit-card-deal {
  0% { opacity: 0; filter: blur(5px) saturate(.65); transform: translateY(170px) rotate(var(--reward-deal-rotate)) scale(.62); }
  66% { opacity: 1; filter: blur(0) saturate(1.06); transform: translateY(-12px) rotate(0deg) scale(1.035); }
  84% { transform: translateY(7px) rotate(var(--reward-rotate)) scale(.985); }
  100% { opacity: 1; filter: none; transform: translateY(7px) rotate(var(--reward-rotate)) scale(1); }
}
@keyframes moonlit-keeper-arrive {
  from { opacity: 0; filter: blur(3px); transform: translateY(32px) scale(.88); }
  to { opacity: 1; filter: none; transform: translateY(0) scale(1); }
}
#reward-screen.is-revealing .reward-heading { animation: moonlit-heading-reveal 520ms 80ms ease-out both; }
#reward-screen.is-revealing .reward-offer { animation: moonlit-card-deal 720ms cubic-bezier(.2,.78,.24,1.08) both; animation-delay: calc(220ms + var(--reward-delay)); }
#reward-screen.is-revealing .reward-keeper { animation: moonlit-keeper-arrive 520ms 590ms cubic-bezier(.2,.78,.24,1.08) both; }

#reward-screen.is-charms-scene .reward-list { align-items: center; padding-top: 18px; }
#reward-screen.is-charms-scene .reward-card { min-height: 260px; }
#reward-screen.is-charms-scene .reward-keeper { opacity: .82; }

@media (max-width: 370px) {
  .reward-card.reward-offer { flex-basis: 104px; width: 104px; min-width: 104px; height: 270px; margin-left: -3px; padding-right: 5px; padding-left: 5px; }
  .reward-offer > strong { font-size: 12px; }
  .reward-card.reward-offer .reward-art img { width: 70px; height: 70px; }
  .reward-card.reward-offer .reward-effect { font-size: 9.5px; }
  .reward-card.reward-offer .reward-evolution-before { font-size: 7px; }
  .reward-card.reward-offer .reward-evolution-after > span { font-size: 8.5px; }
  .hand-card,
  .hand-card:first-child,
  .hand-card:nth-child(1),
  .hand-card:nth-child(2),
  .hand-card:nth-child(3),
  .hand-card:nth-child(4) { flex-basis: 103px; width: 103px; min-width: 103px; margin-left: -23px; }
  .hand-card:first-child { margin-left: 0; }
}

@media (max-height: 740px) {
  .reward-modal { grid-template-rows: auto minmax(0, 1fr) 68px 57px; padding-top: calc(var(--safe-top) + 13px); }
  .reward-heading .eyebrow { margin-bottom: 4px; }
  .reward-modal h2 { font-size: 34px; }
  .reward-modal > .reward-heading > p { min-height: 30px; margin-top: 6px !important; font-size: 10.5px; }
  .reward-list,
  .reward-list.is-offers { padding-top: 16px; }
  .reward-card.reward-offer { flex-basis: min(110px, calc((100vw - 48px) / 3)); width: min(110px, calc((100vw - 48px) / 3)); min-width: min(110px, calc((100vw - 48px) / 3)); height: 238px; grid-template-rows: 34px 62px minmax(0,1fr) 27px; margin-left: -4px; padding: 26px 6px 8px; }
  .reward-offer > strong { font-size: 11px; }
  .reward-card.reward-offer .reward-art { height: 62px; }
  .reward-card.reward-offer .reward-art img { width: 58px; height: 58px; }
  .reward-card.reward-offer .reward-effect { font-size: 8.5px; }
  .reward-card.reward-offer.is-upgrade { grid-template-rows: 30px 48px minmax(0, 1fr) 27px; }
  .reward-offer.is-upgrade .reward-art { height: 48px; }
  .reward-offer.is-upgrade .reward-art img { width: 48px; height: 48px; }
  .reward-card.reward-offer .reward-evolution { gap: 3px; padding: 1px 0; }
  .reward-card.reward-offer .reward-evolution-before { gap: 3px; padding: 2px 4px; font-size: 6.8px; }
  .reward-card.reward-offer .reward-evolution-after { padding: 4px; }
  .reward-card.reward-offer .reward-evolution small { font-size: 6px; }
  .reward-card.reward-offer .reward-evolution-after > span { margin-top: 2px; font-size: 8px; line-height: 1.08; }
  .reward-card.reward-offer .reward-cost { height: 25px; min-height: 25px; font-size: 8px; }
  .reward-ribbon { top: -10px; min-width: 72px; padding: 5px 8px; font-size: 7px; }
  .reward-keeper { width: 64px; height: 72px; }
  .reward-confirm { min-height: 48px; font-size: 14px; }

  .status-strip { top: max(7px, env(safe-area-inset-top)); min-height: 44px; }
  .charm-strip { top: calc(var(--safe-top) + 49px); }
  .threat-summary { top: calc(var(--safe-top) + 77px); min-height: 30px; padding: 4px 10px; }
  .turn-info-card.action-guide { min-height: 52px; padding: 6px 7px 6px 10px; }
  .turn-copy strong { font-size: 14px; }
  #turn-description { margin-top: 1px; font-size: 9px; }
  .action-buttons { top: 5px; right: 6px; grid-template-columns: 46px 66px; }
  .action-cancel,
  .action-confirm { min-height: 40px; font-size: 8.5px; }
  .card-hand,
  .card-hand.is-dealing { height: 126px; padding-top: 7px; }
  .hand-card,
  .hand-card:first-child,
  .hand-card:nth-child(1),
  .hand-card:nth-child(2),
  .hand-card:nth-child(3),
  .hand-card:nth-child(4) { flex-basis: 95px; width: 95px; min-width: 95px; height: 119px; margin-left: -21px; padding: 7px 5px 24px; border-radius: 16px; }
  .hand-card:first-child { margin-left: 0; }
  .hand-card-title,
  .hand-card.selected .hand-card-title { min-height: 19px; font-size: 8px; }
  .hand-card-art,
  .hand-card.selected .hand-card-art { width: 39px; height: 39px; margin-top: 0; }
  .hand-card-effect,
  .hand-card.selected .hand-card-effect { min-height: 21px; font-size: 7.5px; }
  .hand-card-cost,
  .hand-card.selected .hand-card-cost { bottom: 4px; min-width: 40px; height: 18px; font-size: 7px; }
  .hand-card-state { top: 24px; padding: 6px 5px 19px; font-size: 7.5px; }
  .deck-bar { min-height: 41px; }
  .pile-count,
  .wait-button { min-height: 39px; }
}

/* Dynamic mobile viewport -------------------------------------------------
   Safari's layout viewport can remain taller than the actually visible area
   while its browser chrome is present. JS mirrors visualViewport into these
   variables so the canvas and HUD share one, truly visible coordinate space. */

:root {
  --app-width: 100vw;
  --app-height: 100dvh;
  --app-offset-top: 0px;
  --app-offset-left: 0px;
}

html,
body {
  width: var(--app-width, 100vw);
  height: var(--app-height, 100dvh);
  min-height: 0;
}

#game-shell {
  inset: auto;
  top: var(--app-offset-top, 0px);
  left: var(--app-offset-left, 0px);
  width: var(--app-width, 100vw);
  height: var(--app-height, 100dvh);
}

@media (min-width: 720px) {
  #game-shell {
    top: 0;
    left: 50%;
    width: min(var(--app-width, 100vw), 520px);
    transform: translateX(-50%);
  }
}

@media (max-height: 640px) and (orientation: portrait) {
  .status-strip { min-height: 40px; }
  .status-label { font-size: 7px; }
  .status-block strong { font-size: 11px; }
  .charm-strip { top: calc(var(--safe-top) + 43px); }
  .threat-summary { top: calc(var(--safe-top) + 70px); min-height: 28px; }
  .turn-info-card.action-guide { min-height: 46px; }
  .turn-copy strong { font-size: 13px; }
  #turn-description { font-size: 8.5px; -webkit-line-clamp: 1; }
  .card-hand,
  .card-hand.is-dealing { height: 112px; padding-top: 5px; }
  .hand-card,
  .hand-card:first-child,
  .hand-card:nth-child(1),
  .hand-card:nth-child(2),
  .hand-card:nth-child(3),
  .hand-card:nth-child(4) { height: 105px; flex-basis: 88px; width: 88px; min-width: 88px; margin-left: -19px; }
  .hand-card:first-child { margin-left: 0; }
  .hand-card-title,
  .hand-card.selected .hand-card-title { min-height: 17px; font-size: 7.5px; }
  .hand-card-art,
  .hand-card.selected .hand-card-art { width: 34px; height: 34px; }
  .hand-card-effect,
  .hand-card.selected .hand-card-effect { min-height: 18px; font-size: 7px; }
  .deck-bar { min-height: 38px; }
  .pile-count,
  .wait-button { min-height: 36px; }
}

@media (max-width: 340px) {
  .status-strip {
    left: 7px;
    right: 7px;
    grid-template-columns: .78fr .88fr .64fr auto;
    gap: 1px;
  }
  .status-block {
    grid-template-columns: 16px auto;
    column-gap: 3px;
    padding: 0 2px;
  }
  .status-label { display: none; }
  .status-icon { width: 15px; height: 18px; }
  .quiet-button { min-width: 43px; padding-inline: 5px; }
}

/* Moonbook --------------------------------------------------------------- */

.start-copy .moonbook-button {
  width: auto;
  min-height: 38px;
  margin-top: 5px;
  padding: 7px 15px;
  color: rgba(246, 234, 208, .82);
}

.shared-night {
  display: block;
  margin-top: 7px;
  color: var(--butter);
  font-size: 9px;
  font-weight: 820;
  letter-spacing: .035em;
}

.pause-seed {
  margin: -6px 0 12px !important;
  color: var(--sage-dark) !important;
  font-size: 9px !important;
  font-weight: 850 !important;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.moonbook-modal {
  width: min(100%, 430px);
  max-height: calc(var(--app-height, 100dvh) - var(--safe-top) - var(--safe-bottom) - 16px);
  padding: 22px 16px 18px;
  overflow-x: hidden;
  text-align: left;
}

#moonbook-title:focus {
  outline: none;
}

.moonbook-modal > header { text-align: center; }
.moonbook-modal > header h2 { margin-bottom: 7px; }
.moonbook-modal > header p {
  margin: 0 auto 15px;
  color: rgba(41, 49, 47, .68);
  font-size: 11px;
  font-weight: 650;
}

.moonbook-progress {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  margin-bottom: 17px;
}

.moonbook-progress div {
  padding: 9px 5px 8px;
  background: rgba(129, 152, 124, .18);
  border-radius: 14px;
  text-align: center;
}

.moonbook-progress strong { display: block; color: var(--ink); font-size: 17px; }
.moonbook-progress span { color: var(--sage-dark); font-size: 7px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }

.moonbook-section { margin-top: 18px; }
.moonbook-section-heading { margin: 0 3px 9px; }
.moonbook-section-heading h3 { margin: 0; color: var(--ink); font-size: 15px; }
.moonbook-section-heading span { color: rgba(41,49,47,.6); font-size: 9px; font-weight: 650; }

.omen-list { display: grid; gap: 8px; }
.omen-card {
  display: grid;
  width: 100%;
  min-height: 79px;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto 1fr;
  gap: 2px 8px;
  padding: 10px 12px;
  color: var(--ink);
  background: rgba(129, 152, 124, .28);
  border: 2px solid transparent;
  border-radius: 17px;
  text-align: left;
}
.omen-card.tone-terra { background: rgba(200,115,90,.26); }
.omen-card.tone-butter { background: rgba(246,202,103,.34); }
.omen-card.tone-oat { background: rgba(237,233,220,.72); }
.omen-card > span { grid-column: 2; grid-row: 1; color: var(--sage-dark); font-size: 7px; font-weight: 900; letter-spacing: .07em; text-transform: uppercase; }
.omen-card > strong { grid-column: 1; grid-row: 1; font-size: 13px; }
.omen-card > small { grid-column: 1 / -1; grid-row: 2; color: rgba(41,49,47,.72); font-size: 10px; font-weight: 680; line-height: 1.25; }
.omen-card.is-selected { border-color: var(--terra); box-shadow: 0 3px 0 rgba(154,82,68,.5); }
.omen-card.is-locked { opacity: .52; filter: saturate(.35); }

.moonbook-discoveries { display: grid; gap: 13px; }
.moonbook-group h4 { margin: 0 3px 6px; color: var(--terra-dark); font-size: 9px; letter-spacing: .1em; text-transform: uppercase; }
.moonbook-group > div { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.moonbook-entry {
  display: grid;
  min-width: 0;
  min-height: 55px;
  grid-template-columns: 39px minmax(0, 1fr);
  align-items: center;
  gap: 7px;
  padding: 6px 8px;
  background: rgba(255,255,255,.25);
  border-radius: 14px;
}
.moonbook-entry img { width: 38px; height: 38px; object-fit: contain; }
.moonbook-entry strong { display: block; overflow: hidden; color: var(--ink); font-size: 9.5px; line-height: 1.08; text-overflow: ellipsis; white-space: nowrap; }
.moonbook-entry small { color: var(--sage-dark); font-size: 7px; font-weight: 850; text-transform: uppercase; }
.moonbook-entry.is-locked img { filter: grayscale(1) brightness(.56); opacity: .35; }
.moonbook-entry.is-locked strong { color: rgba(41,49,47,.44); }

.moonbook-modal > .primary-button { display: block; margin: 18px auto 2px; }

.dawn-unlock {
  padding: 11px 13px;
  color: var(--ink) !important;
  background: rgba(246, 202, 103, .35);
  border: 1px solid rgba(154,82,68,.2);
  border-radius: 15px;
  font-size: 10.5px !important;
  font-weight: 760 !important;
  line-height: 1.35 !important;
}

.charm-pill.is-omen { border-color: rgba(246,202,103,.35); }

@media (max-height: 640px) {
  .moonbook-modal { padding-top: 17px; }
  .moonbook-modal > header h2 { font-size: 25px; }
  .moonbook-progress { margin-bottom: 12px; }
  .moonbook-section { margin-top: 14px; }
}
