/* Dino Escape page. Mobile first. The island is a window onto one painted plate with
   stones and travellers laid on it; the dock beneath holds the pack, the dice, and the
   one button. Chrome matches the arcade: header, taper, framed cards, pill buttons. */
* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

html, body {
  margin: 0;
  min-height: 100%;
  background-color: var(--bg);
  background-image: radial-gradient(circle, rgba(155, 107, 224, 0.12) var(--dot), transparent var(--dot-edge));
  background-size: 4px 4px;
  color: var(--ink);
  font-family: var(--font-body);
}

button, input { font: inherit; color: inherit; }
button, a { touch-action: manipulation; }
[hidden] { display: none !important; }
a { color: var(--green-bright); }
img { user-select: none; -webkit-user-drag: none; }

.app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  width: 100%;
  max-width: 32rem;
  margin: 0 auto;
  padding: 0.35rem 0.45rem 0;
  padding-left: max(0.45rem, env(safe-area-inset-left));
  padding-right: max(0.45rem, env(safe-area-inset-right));
}

/* ---- header ---- */

.top {
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
  padding-bottom: 0.15rem;
  margin-bottom: 0.3rem;
}

.header-mascot {
  display: block;
  flex: none;
  height: calc(1.05rem + 0.78rem + 0.35rem);
  width: auto;
  object-fit: contain;
  pointer-events: none;
}

.title-block {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
}

h1 {
  margin: 0;
  max-width: 100%;
  overflow: hidden;
  font-size: 1.05rem;
  line-height: 1.05;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.title-btn {
  display: block;
  margin: 0;
  padding: 0.15rem 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.brand-line {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  max-width: 100%;
  margin: 0.08rem 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
  line-height: 1.1;
  text-decoration: none;
  white-space: nowrap;
}

.brand-mark { width: 14px; height: 14px; display: block; flex: none; }

.help-open {
  flex: 0 0 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 2px solid var(--green-deep);
  border-radius: 999px;
  background: #000;
  color: var(--green-bright);
  font-weight: 800;
  font-size: 1.15rem;
  line-height: 1;
}

.header-share svg { display: block; }

.taper { flex: none; }

/* ---- ribbon ---- */

.ribbon {
  flex: none;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0 0 0.35rem;
  padding: 0.1rem 0.1rem;
  font-size: 0.78rem;
  font-weight: 700;
}

.ribbon-badge { flex: none; font-size: 1.05rem; line-height: 1; letter-spacing: 0.05em; }

.ribbon-text {
  flex: 1 1 auto;
  display: grid;
  gap: 0.05rem;
  min-width: 0;
  line-height: 1.2;
}

.ribbon-head, .ribbon-status { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ribbon-status { color: var(--muted); }
.app[data-screen="turn"] .ribbon-status { color: var(--green-bright); }

.ribbon-games {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  min-height: 32px;
  padding: 0 0.6rem;
  border: 2px solid var(--green-deep);
  border-radius: 999px;
  background: #000;
  color: var(--green-bright);
  font: inherit;
  font-size: 0.74rem;
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

/* ---- framed cards ---- */

.panel {
  position: relative;
  width: min(26rem, 100%);
  margin: 0.4rem auto;
  padding: 0.9rem 0.9rem 1rem;
  text-align: center;
}

.panel > * { position: relative; z-index: 1; }

.wizard { margin: auto; }

.challenge {
  margin: 0.1rem 0 0.45rem;
  font-size: clamp(1.3rem, 6.2vw, 1.65rem);
  line-height: 1.15;
  font-weight: 800;
}

.lede { margin: 0 0 0.65rem; color: var(--ink); line-height: 1.4; font-size: 0.95rem; }
.hint { margin: 0.4rem 0 0; color: var(--muted); font-size: 0.82rem; line-height: 1.35; }
.seed-line { color: var(--crystal-bright); }

.eyebrow {
  margin: 0 0 0.15rem;
  color: var(--green-bright);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ---- mascot (shared/art/dino-rider.webp) ---- */

.mascot {
  display: block;
  width: 132px;
  height: auto;
  margin: 0 auto 0.4rem;
  transform-origin: 50% 90%;
  pointer-events: none;
  filter: drop-shadow(0 6px 8px rgba(0, 0, 0, 0.45));
}
.mascot.mascot-small { width: 96px; margin-bottom: 0.3rem; }

.mascot-welcome { animation: mascot-hop 0.55s ease-out both, mascot-idle 5s ease-in-out 1.1s infinite; }
.mascot-wait { animation: mascot-bob 3.2s ease-in-out infinite; }

@keyframes mascot-hop {
  0% { transform: translateY(14px) scale(0.92, 0.9); opacity: 0; }
  55% { transform: translateY(-7px) scale(1.03, 1.04); opacity: 1; }
  100% { transform: none; }
}
@keyframes mascot-idle {
  0%, 72%, 100% { transform: translateY(0) scaleY(1); }
  80% { transform: translateY(-3px) scaleY(1.02); }
  88% { transform: translateY(0) scaleY(0.96); }
}
@keyframes mascot-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6.5px); }
}

.field { display: grid; gap: 0.35rem; margin: 0.4rem 0 0.7rem; text-align: left; }
.field label { font-size: 0.82rem; font-weight: 750; color: var(--muted); }

input[type="text"] {
  width: 100%;
  min-height: 48px;
  padding: 0 0.9rem;
  border: 2px solid var(--green-deep);
  border-radius: 12px;
  background: #06090C;
  color: var(--ink-bright);
  font-size: 1.05rem;
  font-weight: 700;
}

input[type="text"]:focus { outline: 2px solid var(--green-bright); outline-offset: 1px; }

.actions { display: flex; flex-wrap: wrap; gap: 0.45rem; justify-content: center; margin-top: 0.6rem; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  min-width: 9.5rem;
  padding: 0 1.2rem;
  border: 0;
  border-radius: 999px;
  background: var(--amber-deep);
  color: #fff;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}

.btn.primary { background: var(--green-deep); }
.btn.slim { min-width: 0; }
.btn[disabled] { opacity: 0.45; cursor: default; }

.link-box {
  margin: 0.4rem 0 0;
  padding: 0.6rem 0.7rem;
  border-radius: 12px;
  background: #06090C;
  color: var(--green-bright);
  font-size: 0.8rem;
  white-space: pre-wrap;
  word-break: break-word;
  text-align: left;
}

.qr { width: min(160px, 48vw); height: auto; background: #fff; padding: 0.35rem; border-radius: 8px; }
.qr-panel { display: grid; justify-items: center; gap: 0.4rem; margin: 0.8rem auto 0; padding-top: 0.7rem; border-top: 1px solid rgba(255, 255, 255, 0.12); }

/* ---- the seed sheet ---- */

.seed-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.45rem; margin: 0.2rem 0; }

.seed-row {
  display: grid;
  gap: 0.15rem;
  min-height: 74px;
  padding: 0.55rem 0.6rem;
  border: 2px solid var(--amber-deep);
  border-radius: 14px;
  background: #06090C;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}
.seed-row b { font-size: 0.9rem; color: var(--ink-bright); }
.seed-row span { font-size: 0.72rem; line-height: 1.3; color: var(--muted); }
.seed-row:active { transform: translateY(1px); }
.seed-row[disabled] { opacity: 0.4; cursor: default; }
.seed-row.picked { border-color: var(--crystal-bright); box-shadow: 0 0 0 2px rgba(201, 169, 255, 0.35); opacity: 1; }
.seed-row.seed-shake { border-style: dashed; }

.seed-status { min-height: 1.4em; margin: 0.5rem 0 0; color: var(--crystal-bright); font-size: 0.86rem; font-weight: 750; }

.meter { height: 10px; margin: 0.6rem 0 0; border-radius: 999px; background: #06090C; overflow: hidden; border: 1px solid var(--amber-deep); }
.meter-fill { display: block; width: 0; height: 100%; background: linear-gradient(90deg, var(--green), var(--crystal-bright)); transition: width 0.12s linear; }

.strip { display: grid; grid-template-columns: repeat(12, 1fr); gap: 3px; margin: 0.3rem auto 0.4rem; max-width: 20rem; }
.dot { display: block; height: 12px; border-radius: 3px; background: #2A3238; }
.dot.t1 { background: var(--green); }
.dot.t2 { background: var(--lava-deep); }
.dot.t3 { background: #4B5A66; }
.dot.t4 { background: #6E5A3A; }
.dot.t5 { background: #7A6A55; }
.dot.t6 { background: #5A6A3A; }
.dot.t7 { background: #8A8A7A; }
.dot.t8 { background: var(--amber-gem); }
.dot.t9 { background: var(--lava); }
.dot.t10, .dot.altar { background: var(--crystal); box-shadow: 0 0 0 1px var(--crystal-bright); }

.mode-pick.busy { opacity: 0.5; pointer-events: none; }

/* ---- score plate: each traveller, their crystals, amber, stone ---- */

.score-plate {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
  width: min(28rem, 100%);
  margin: 0.1rem auto 0.4rem;
}

.score {
  display: grid;
  grid-template-columns: 36px 1fr;
  align-items: center;
  column-gap: 0.4rem;
  padding: 0.3rem 0.5rem;
  border-radius: 12px;
  border: 2px solid var(--amber-deep);
  background: #06090C;
  text-align: left;
}
.score-face { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; object-position: 50% 6%; background: #1a1f26; border: 2px solid #2A3238; }
.score.a .score-face { border-color: var(--green); }
.score.b .score-face { border-color: var(--amber-gem); }
.score-text { display: grid; gap: 0.08rem; min-width: 0; }
.score small { font-size: 0.72rem; font-weight: 750; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.score.active { border-color: var(--green-bright); }
.score.active small { color: var(--green-bright); }
.score.me { background: #0E1218; }
.gems { display: inline-flex; gap: 0.2rem; }
.gem {
  width: 11px;
  height: 15px;
  clip-path: polygon(50% 0, 100% 35%, 50% 100%, 0 35%);
  background: #23282E;
}
.gem.on { background: linear-gradient(180deg, var(--crystal-bright), var(--crystal)); box-shadow: 0 0 6px rgba(201, 169, 255, 0.5); }
.score-line { display: flex; gap: 0.5rem; align-items: center; font-size: 0.78rem; color: var(--ink); white-space: nowrap; }
.amber-n { display: inline-flex; align-items: center; gap: 0.2rem; }
.amber-ico { width: 13px; height: 13px; object-fit: contain; }
.score-line b { color: var(--amber-gem); }
.stone-n { color: var(--muted); }

/* ---- the island ---- */

.island {
  position: relative;
  width: min(28rem, 100%);
  height: clamp(250px, 42dvh, 470px);
  margin: 0 auto 0.4rem;
  border-radius: 16px;
  overflow: hidden;
  background: #06090C;
  box-shadow: 0 0 0 2px var(--amber-deep), 5px 5px 0 var(--amber-deep);
  -webkit-tap-highlight-color: transparent;
}

.cam {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  aspect-ratio: 9 / 16;
  transition: transform 0.7s cubic-bezier(0.25, 0.8, 0.3, 1);
  will-change: transform;
}
.cam.instant { transition: none; }

.plate { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.plate-next { opacity: 0; transition: opacity 0.4s ease; }
.plate-next.show { opacity: 1; }

.stones { position: absolute; inset: 0; }

.stone {
  position: absolute;
  width: 17%;
  padding: 0;
  border: 0;
  background: none;
  transform: translate(-50%, -50%);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.stone .base { display: block; width: 100%; height: auto; }
.stone .prop { position: absolute; left: 50%; bottom: 38%; width: 62%; height: auto; transform: translateX(-50%); filter: drop-shadow(0 3px 3px rgba(0, 0, 0, 0.45)); }
.stone .prop-bronto, .stone .prop-ptero { width: 120%; bottom: 30%; }
.stone .prop-altar-lit { width: 100%; bottom: 8%; }
.stone .prop-ship { width: 118%; bottom: -12%; }
.stone .prop-geyser { width: 70%; bottom: 40%; }
.stone .prop-cache { width: 70%; }
.stone .num {
  position: absolute;
  left: 50%;
  top: 46%;
  transform: translate(-50%, -50%);
  font-size: clamp(9px, 2.7vw, 12px);
  font-weight: 800;
  color: #fff;
  text-shadow: 0 1px 2px #000, 0 0 4px #000;
  pointer-events: none;
}
.stone.t10 .num, .stone .prop ~ .num { top: 62%; }
.stone.lit .prop { animation: altar-lit 1.1s ease-out both; }
.stone.erupt .prop { animation: erupt 0.9s ease-out both; }
.stone.hum .prop { animation: hum 1.2s ease-in-out 3; }

@keyframes altar-lit {
  0% { filter: drop-shadow(0 0 0 rgba(201, 169, 255, 0)); }
  40% { filter: drop-shadow(0 0 18px rgba(201, 169, 255, 1)) brightness(1.5); transform: translateX(-50%) scale(1.08); }
  100% { filter: drop-shadow(0 3px 3px rgba(0, 0, 0, 0.45)); transform: translateX(-50%); }
}
@keyframes erupt {
  0% { transform: translateX(-50%) scaleY(1); }
  40% { transform: translateX(-50%) scaleY(1.7) translateY(-10%); filter: brightness(1.6); }
  100% { transform: translateX(-50%) scaleY(1); }
}
@keyframes hum {
  0%, 100% { transform: translateX(-50%) translateY(0); filter: drop-shadow(0 3px 3px rgba(0, 0, 0, 0.45)); }
  50% { transform: translateX(-50%) translateY(-4%); filter: drop-shadow(0 0 14px rgba(140, 217, 143, 0.9)); }
}

.trav {
  position: absolute;
  width: 9.5%;
  transform: translate(-50%, -90%);
  transition: left 0.24s linear, top 0.24s linear, opacity 0.3s ease;
  pointer-events: none;
}
.trav.instant { transition: none; }
.trav.off { opacity: 0; visibility: hidden; }
.trav .body { display: block; width: 100%; height: auto; transform-origin: 50% 100%; }
.trav.face-left .body { transform: scaleX(-1); }
.trav .shadow { position: absolute; left: 15%; right: 15%; bottom: -3%; height: 8%; border-radius: 50%; background: rgba(0, 0, 0, 0.45); filter: blur(2px); z-index: -1; }
.trav.walking .body { animation: trav-step 0.24s ease-in-out infinite; }
.trav.face-left.walking .body { animation-name: trav-step-left; }
.trav .mount { position: absolute; left: 50%; bottom: -6%; width: 230%; height: auto; transform: translateX(-50%); }
.trav.riding { width: 9.5%; }
.trav.riding .body { position: relative; width: 70%; margin: 0 0 88% 22%; z-index: 1; }
.trav.on-ptero .body { margin: 0 0 100% 14%; }
.trav.flying { transition: left 1.3s cubic-bezier(0.3, 0.6, 0.3, 1), top 1.3s cubic-bezier(0.3, 0.6, 0.3, 1); }
.trav.flying .mount { animation: flap 0.5s ease-in-out infinite; }
.trav.blast { animation: blast 0.9s ease-in both; }
.trav.drop { animation: drop 0.7s cubic-bezier(0.2, 0.8, 0.4, 1.2) both; }
.trav.blink { animation: blink 0.5s ease-in-out both; }
.trav.aboard { opacity: 0.001; transition: opacity 0.9s ease 0.4s; }

@keyframes trav-step {
  0%, 100% { transform: translateY(0) rotate(0); }
  50% { transform: translateY(-9%) rotate(3deg); }
}
@keyframes trav-step-left {
  0%, 100% { transform: scaleX(-1) translateY(0) rotate(0); }
  50% { transform: scaleX(-1) translateY(-9%) rotate(3deg); }
}
@keyframes flap {
  0%, 100% { transform: translateX(-50%) translateY(0) rotate(-2deg); }
  50% { transform: translateX(-50%) translateY(-6%) rotate(3deg); }
}
@keyframes blast {
  0% { transform: translate(-50%, -90%) rotate(0); opacity: 1; }
  100% { transform: translate(-50%, -400%) rotate(380deg); opacity: 0; }
}
@keyframes drop {
  0% { transform: translate(-50%, -260%); opacity: 0; }
  60% { opacity: 1; }
  100% { transform: translate(-50%, -90%); }
}
@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

.trike { position: absolute; width: 22%; transform: translate(-50%, -80%); transition: left 0.35s ease-in; filter: drop-shadow(0 3px 3px rgba(0, 0, 0, 0.5)); }
.trike.charge { animation: charge 0.35s ease-in both; }
@keyframes charge {
  0% { transform: translate(-50%, -80%); }
  100% { transform: translate(10%, -80%); opacity: 0; }
}

.bubble {
  position: absolute;
  left: 50%;
  top: -8%;
  z-index: 3;
  transform: translate(-50%, -100%);
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  border: 2px solid #fff;
  background: #1F2A34;
  color: #fff;
  font-size: 0.8rem;
  font-weight: 800;
  white-space: nowrap;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.5);
  animation: bubble-pop 0.4s ease-out both;
}
.bubble.good { background: var(--green-deep); border-color: var(--green-bright); }
.bubble.bad { background: #7A2A12; border-color: var(--lava); }
.bubble.crystal { background: var(--amber-deep); border-color: var(--crystal-bright); }
.bubble.gadget { background: #1E2523; border-color: var(--crystal); }

@keyframes bubble-pop {
  0% { transform: translate(-50%, -80%) scale(0.4); opacity: 0; }
  60% { transform: translate(-50%, -100%) scale(1.12); opacity: 1; }
  100% { transform: translate(-50%, -100%) scale(1); }
}

.island-fog {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(6, 9, 12, 0.45), transparent 14%, transparent 88%, rgba(6, 9, 12, 0.5));
}

.seg-chip {
  position: absolute;
  left: 0.5rem;
  top: 0.45rem;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  background: rgba(6, 9, 12, 0.7);
  color: var(--ink);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  pointer-events: none;
}

.valley-card {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  grid-template-rows: 1fr auto;
  background: #06090C;
  animation: fade-in 0.4s ease both;
}
.valley-card img { width: 100%; height: 100%; object-fit: cover; }
.valley-card p { margin: 0; padding: 0.5rem 0.7rem 0.6rem; background: #06090C; color: var(--amber-gem); font-weight: 800; text-align: center; }
.valley-card.fade { opacity: 0; transition: opacity 0.4s ease; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* ---- the dock ---- */

.dock { width: min(28rem, 100%); padding: 0.6rem 0.8rem 0.8rem; margin-top: 0; }

.turn-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  margin: 0 0 0.35rem;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--muted);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.strip-btn {
  min-height: 28px;
  padding: 0 0.55rem;
  border: 1.5px solid var(--amber-deep);
  border-radius: 999px;
  background: #06090C;
  color: var(--crystal-bright);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.recap {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0 0 0.45rem;
  padding: 0.4rem 0.6rem;
  border-radius: 10px;
  background: #06090C;
  color: var(--ink);
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1.3;
  text-align: left;
}
.recap-face { flex: none; width: 28px; height: 28px; border-radius: 50%; object-fit: cover; object-position: 50% 6%; background: #1a1f26; }

.notice {
  min-height: 2.6em;
  margin: 0 0 0.4rem;
  text-align: center;
  font-size: 0.86rem;
  font-weight: 750;
  line-height: 1.3;
  color: var(--ink);
}
.notice.warn { color: var(--red); }
.notice.good { color: var(--green-bright); }

.pack { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 0.35rem; min-height: 34px; margin: 0 0 0.4rem; }
.pack-label, .pack-empty { font-size: 0.74rem; font-weight: 800; color: var(--muted); letter-spacing: 0.03em; text-transform: uppercase; }
.pack-empty { text-transform: none; letter-spacing: 0; font-weight: 700; }
.pack-note { width: 100%; font-size: 0.7rem; color: var(--muted); }
.chip {
  min-height: 34px;
  padding: 0 0.75rem;
  border: 2px solid var(--crystal);
  border-radius: 999px;
  background: #06090C;
  color: var(--crystal-bright);
  font-size: 0.8rem;
  font-weight: 800;
}
.chip[disabled] { opacity: 0.45; }
.chip.armed { background: var(--crystal); color: #fff; box-shadow: 0 0 0 2px var(--crystal-bright); }

.dice-row { display: grid; justify-items: center; gap: 0.25rem; margin: 0 0 0.2rem; }
.dice { display: flex; gap: 0.4rem; }
.die {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 12px;
  border: 2px solid var(--amber-deep);
  background: #06090C;
  color: var(--ink-bright);
  font-size: 1.35rem;
  font-weight: 800;
}
.dice.rolling .die { animation: tumble 0.14s linear infinite; border-color: var(--crystal); }
.dice.landed .die { animation: land 0.45s ease-out both; border-color: var(--green-bright); color: var(--green-bright); }
@keyframes tumble {
  0% { transform: rotate(-8deg) translateY(0); }
  50% { transform: rotate(8deg) translateY(-4px); }
  100% { transform: rotate(-8deg) translateY(0); }
}
@keyframes land {
  0% { transform: scale(1.25); }
  100% { transform: scale(1); }
}
.source-line { margin: 0; min-height: 1.2em; font-size: 0.72rem; font-weight: 700; color: var(--muted); text-align: center; }

.turn-actions { margin-top: 0.4rem; }
.turn-actions .btn.primary { min-width: min(100%, 14rem); }

/* ---- sheets ---- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: end center;
  padding: 1rem 0.6rem;
  background: rgba(0, 0, 0, 0.72);
}

.modal-card {
  position: relative;
  width: min(24rem, 100%);
  max-height: 86dvh;
  overflow: auto;
  padding: 1rem 0.9rem 1rem;
  text-align: center;
}

.modal-card > * { position: relative; z-index: 1; }
.modal-card h2 { margin: 0 0 0.4rem; font-size: 1.1rem; }

.sheet-x {
  position: absolute;
  top: 0.45rem;
  right: 0.45rem;
  z-index: 2;
  width: 2.2rem;
  height: 2.2rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--green-bright);
  font-size: 1.35rem;
  font-weight: 800;
  line-height: 1;
}

.offer-art { display: block; width: auto; max-width: 60%; max-height: 110px; margin: 0 auto 0.4rem; filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.5)); }

.cache-list { display: grid; gap: 0.4rem; margin: 0.2rem 0; text-align: left; }
.cache-item {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "name price" "line price";
  column-gap: 0.5rem;
  padding: 0.5rem 0.7rem;
  border: 2px solid var(--crystal);
  border-radius: 12px;
  background: #06090C;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}
.cache-item b { grid-area: name; color: var(--ink-bright); }
.cache-item span { grid-area: line; font-size: 0.76rem; color: var(--muted); line-height: 1.3; }
.cache-item i { grid-area: price; align-self: center; font-style: normal; font-weight: 800; color: var(--amber-gem); white-space: nowrap; }
.cache-item[disabled] { opacity: 0.4; cursor: default; border-color: var(--amber-deep); }

.game-list { display: grid; gap: 0.4rem; text-align: left; }
.game-row {
  display: grid;
  gap: 0.1rem;
  padding: 0.55rem 0.7rem;
  border-radius: 12px;
  background: #06090C;
  color: var(--ink);
  text-decoration: none;
}
.game-row b { color: var(--ink-bright); }
.game-row small { color: var(--muted); }

.ledger { margin: 0; padding: 0; list-style: none; display: grid; gap: 0.35rem; text-align: left; }
.ledger li { display: grid; grid-template-columns: 2.2rem 1fr; gap: 0.4rem; padding: 0.4rem 0.55rem; border-radius: 10px; background: #06090C; font-size: 0.8rem; line-height: 1.3; }
.ledger-turn { font-weight: 800; color: var(--muted); }
.ledger-body { display: grid; gap: 0.05rem; }
.ledger-body b { color: var(--ink-bright); }
.ledger-src { color: var(--crystal-bright); font-size: 0.72rem; }

.modal-card h3.sheet-next { margin: 0.9rem 0 0.3rem; font-size: 0.95rem; color: var(--ink-bright); }

.install-app { margin-top: 0.6rem; }
.install-btn { width: 100%; min-height: 44px; }
.install-steps {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  margin: 0;
  padding: 0.65rem 0.9rem;
  border-radius: 999px;
  background: var(--amber);
  color: #fff;
  font-weight: 800;
  text-align: center;
}

.help-list { margin: 0.2rem 0 0.4rem; padding: 0; list-style: none; text-align: left; display: grid; gap: 0.5rem; }
.help-list li { display: grid; grid-template-columns: 38px 1fr; gap: 0.5rem; align-items: start; font-size: 0.88rem; line-height: 1.35; }
.help-list b { color: var(--ink-bright); }
.legend-ico { display: grid; place-items: center; width: 38px; height: 36px; }
.legend-ico .sprite { max-width: 36px; max-height: 36px; width: auto; height: auto; }
.legend-ico.gadget-ico { width: 30px; height: 30px; margin-left: 4px; border-radius: 999px; border: 2px solid var(--crystal); color: var(--crystal-bright); font-size: 0.8rem; font-weight: 800; }

.legal-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.35rem 0.45rem;
  margin: auto 0 0;
  padding: 0.6rem 0 max(0.4rem, env(safe-area-inset-bottom));
  color: var(--muted);
  font-size: 0.72rem;
}
.legal-foot a { color: var(--muted); text-decoration: none; }

.copied-toast {
  position: fixed;
  left: 50%;
  bottom: max(1rem, env(safe-area-inset-bottom));
  z-index: 40;
  transform: translateX(-50%);
  width: max-content;
  max-width: min(92vw, 30rem);
  margin: 0;
  padding: 0.55rem 0.9rem;
  border: 2px solid var(--green-bright);
  border-radius: 999px;
  background: #000;
  color: #fff;
  font-size: 0.84rem;
  font-weight: 750;
  text-align: center;
}

/* the waiting and result cards carry a smaller window onto the island */
.wait-plate .island, .result-panel .island { height: clamp(200px, 30dvh, 320px); }

/* ---- narrow phones ---- */

@media (max-width: 380px) {
  .panel { padding-left: 0.5rem; padding-right: 0.5rem; }
  .seed-row { min-height: 66px; padding: 0.45rem 0.5rem; }
  .seed-row span { font-size: 0.68rem; }
  .score { padding: 0.25rem 0.4rem; }
  .die { width: 40px; height: 40px; font-size: 1.2rem; }
}

/* ---- short phones: a shorter island so the button stays on screen ---- */

@media (max-height: 700px) {
  .island { height: clamp(220px, 36dvh, 470px); }
}

/* ---- wide ---- */

@media (min-width: 720px) {
  .app { max-width: 34rem; }
}

@media (prefers-reduced-motion: reduce) {
  .taper::before, .glint::before, .mascot, .bubble, .dice .die, .stone .prop, .trav .body, .trav .mount { animation: none !important; }
  .cam, .trav, .plate-next { transition: none; }
}
