@font-face {
  font-family: "GemRound";
  src: url("../fonts/GemRound.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --ink: #3B2A22;
  --cream: #FFF6E8;
  --card: #FFFDF8;
  --candy: #FF8A6A;
  --gold: #FFC857;
  --mint: #8BE38A;
  --line: 3px solid var(--ink);
  --shadow: 0 5px 0 var(--ink);
  --radius: 22px;
  --font: "GemRound", "PingFang SC", "Hiragino Maru Gothic ProN", "Yuanti SC", sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
  --stage: #E4E0DC;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  position: fixed;
  inset: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--stage);
  color: var(--ink);
  font-family: var(--font);
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

[hidden] { display: none !important; }

/* Parsed before any script: this is the only first-frame loading surface. */
#boot-loader {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 13px;
  justify-items: center;
  background: var(--stage);
  color: var(--ink);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .08em;
  transition: opacity .22s ease;
}

#boot-loader.out { opacity: 0; pointer-events: none; }

/* DOM only. The first polished draw stalls the compositor, so this has to
   be on screen before that draw. The mark stays put: a transform animation
   does not keep moving while Metal is building the pipeline. */
#open-curtain[hidden] { display: none !important; }
/* A badge over the stone, not a full-screen cover: the pipeline stall is a
   fraction of a second now, and blanking the whole stage for it blinked. */
#open-curtain {
  position: fixed;
  z-index: 80;
  left: 50%;
  top: 38%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  border: var(--line);
  border-radius: 999px;
  background: var(--cream);
  box-shadow: 0 3px 0 var(--ink);
  color: var(--ink);
  font-size: 17px;
  font-weight: 700;
}

@media (orientation: landscape) {
  #open-curtain { left: calc((100% - min(420px, 46vw)) / 2); top: 50%; }
}

#open-curtain p { margin: 0; letter-spacing: .08em; }

#open-curtain i {
  display: block;
  width: 22px;
  height: 22px;
  background: #B86DE8;
  clip-path: polygon(18% 0, 82% 0, 100% 31%, 50% 100%, 0 31%);
  box-shadow: inset 0 0 0 4px var(--ink);
}

.boot-gem {
  position: relative;
  display: block;
  width: 34px;
  height: 34px;
  background: #B86DE8;
  clip-path: polygon(18% 0, 82% 0, 100% 31%, 50% 100%, 0 31%);
  box-shadow: inset 0 0 0 4px var(--ink);
  animation: boot-gem-bob .76s steps(2, end) infinite;
}

.boot-gem::before,
.boot-gem::after {
  content: "";
  position: absolute;
  background: var(--ink);
}

/* Pixel gem: a dark girdle line under the crown and one white glint. */
.boot-gem::before { width: 6px; height: 4px; left: 9px; top: 3px; background: #FFFFFF; }
.boot-gem::after { width: 34px; height: 3px; left: 0; top: 9px; }

@keyframes boot-gem-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

img, canvas, button, a {
  -webkit-user-drag: none;
  user-select: none;
  -webkit-touch-callout: none;
}

#app {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  max-height: 100dvh;
  overflow: hidden;
  background: var(--stage);
}

#top {
  position: relative;
  z-index: 5;
  flex: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: calc(4px + var(--safe-top)) 10px 4px;
  pointer-events: none;
}

#gold-pill, #mute {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  border: var(--line);
  border-radius: 999px;
  background: var(--cream);
  box-shadow: 0 3px 0 var(--ink);
}

#gold-pill { padding: 4px 12px 4px 6px; }

#gold-ico .ico { width: 26px; height: 26px; flex: none; }

#gold {
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

#gold.pop { animation: pop 0.38s cubic-bezier(.2, 1.5, .4, 1); }

#gem-name {
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  opacity: 0.8;
}

#gem-name:empty { display: none; }

#mute {
  appearance: none;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  min-width: 44px;
  padding: 4px 12px 4px 8px;
  cursor: pointer;
}

#mute .ico { width: 22px; height: 22px; flex: none; }

#mute.on { background: #F3E6D4; }

#stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 26dvh;
  min-width: 0;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

#view {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

#float {
  position: absolute;
  z-index: 3;
  left: 12px;
  right: 12px;
  top: 8px;
  text-align: center;
  pointer-events: none;
}

.flo {
  display: inline-block;
  margin: 0 4px;
  padding: 8px 14px;
  border: var(--line);
  border-radius: 999px;
  background: var(--cream);
  box-shadow: var(--shadow);
  font-size: 18px;
  font-weight: 700;
  animation: rise 2.4s ease forwards;
}

.flo.perfect { background: var(--mint); }
.flo.short { background: #B7E4FF; }
.flo.over { background: var(--candy); }
.flo.crack { background: var(--ink); color: #FFE08A; }

.preview-bar {
  position: absolute;
  z-index: 6;
  left: 10px;
  right: 10px;
  bottom: 46px;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 60px;
  padding: 8px 8px 8px 12px;
  border: var(--line);
  border-radius: 18px;
  background: var(--cream);
  box-shadow: 0 4px 0 var(--ink);
  pointer-events: auto;
}

.preview-copy { flex: 1; min-width: 0; }

.preview-copy .name {
  display: block;
  font-size: 16px;
  white-space: nowrap;
  text-overflow: ellipsis;
  -webkit-line-clamp: unset;
}

.preview-copy .sub { display: block; font-size: 13px; -webkit-line-clamp: 1; }

.preview-price {
  display: flex;
  align-items: center;
  gap: 4px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.preview-price .ico { width: 18px; height: 18px; }

#preview-buy { flex: none; min-width: 72px; min-height: 44px; height: 44px; padding: 0 14px; }

#drawer {
  position: relative;
  z-index: 4;
  flex: none;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 42dvh;
  max-width: 100%;
  box-sizing: border-box;
  padding-bottom: var(--safe-bot);
  border-radius: 26px 26px 0 0;
  background: var(--cream);
  border-top: var(--line);
  box-shadow: 0 -3px 0 var(--ink);
  overflow: hidden;
  touch-action: manipulation;
  transition: height 0.42s cubic-bezier(.22, 1.22, .36, 1), width 0.42s cubic-bezier(.22, 1.22, .36, 1);
}

#drawer.dragging { transition: none; }

#handle {
  appearance: none;
  flex: none;
  width: 100%;
  height: 44px;
  min-height: 44px;
  min-width: 44px;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  cursor: grab;
  touch-action: none;
}

#handle:active,
#handle.is-down {
  transform: none;
  box-shadow: none;
  background: rgba(59, 42, 34, 0.06);
}

.grab {
  display: block;
  width: 52px;
  height: 6px;
  margin: 0 auto;
  border-radius: 999px;
  background: var(--ink);
}

#nav.nav {
  flex: none;
  display: flex;
  gap: 4px;
  margin: 0 10px 6px;
  padding: 2px;
  border: var(--line);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 3px 0 var(--ink);
}

#drawer[data-snap="peek"] #nav,
#drawer[data-snap="peek"] #viewport { display: none !important; }

#peek { display: none; flex: none; padding: 0 12px; }

#drawer[data-snap="peek"] #peek { display: block; }

#drawer[data-snap="peek"]:not([data-mode="cutting"]) #peek { padding-top: 8px; }

#peek button { width: 100%; min-height: 44px; }

#peek .cut-row { display: flex; flex-wrap: wrap; gap: 10px; }

#peek .cut-row button { min-height: 60px; white-space: nowrap; }

/* Side by side on a phone; stacked in the narrow landscape side panel. */
#peek .cut-row .auto-go { flex: 1.5 1 130px; }

#peek .cut-row .polish-go { flex: 1 1 96px; }

#peek .cut-row .auto-go.running { background: var(--mint); }

.hero .note { font-size: 14px; font-weight: 700; color: #8A766C; }

.hero .note.good { color: var(--ink); background: var(--mint); padding: 2px 10px; border-radius: 999px; }

#peek button.hold-go {
  min-height: 64px;
  position: relative;
  touch-action: none;
  overflow: hidden;
}

#peek button.hold-go.is-down { transform: translateY(2px); }

#peek button .charge-ring {
  position: absolute;
  inset: 4px;
  border-radius: 999px;
  border: 4px solid transparent;
  pointer-events: none;
}

#peek button.charging .charge-ring {
  border-color: #fff;
  box-shadow: inset 0 0 12px #fff;
  animation: charge 0.9s ease-in-out infinite;
}

@keyframes charge {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 1; }
}

#meter {
  position: relative;
  flex: none;
  height: 28px;
  margin: 0 12px 8px;
  pointer-events: none;
}

#drawer[data-snap="peek"] #meter {
  height: 18px;
  margin: 0 12px;
}

#coach {
  position: absolute;
  left: 0;
  right: 0;
  top: -34px;
  height: 36px;
}

.cw {
  position: absolute;
  left: 8px;
  top: 4px;
  font-size: 14px;
  font-weight: 700;
  opacity: 0;
  animation: word 2.4s infinite;
}

.w2 { animation-delay: 0.8s; }
.w3 { animation-delay: 1.6s; }

.finger {
  position: absolute;
  left: 18%;
  top: 2px;
  width: 32px;
  height: 36px;
  animation: finger 2.4s ease-in-out infinite;
}

.finger .ico { width: 32px; height: 36px; }

#meter-track {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 22px;
  border: var(--line);
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 3px 0 var(--ink);
  overflow: visible;
}

#fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0;
  background: var(--mint);
  border-radius: 999px;
}

#meter.catalogue #band,
#meter.catalogue #band-label,
#meter.catalogue #needle { display: none; }

#band {
  position: absolute;
  top: 0;
  bottom: 0;
  background: var(--mint);
  border-radius: 999px;
}

.shape-banner {
  position: absolute;
  z-index: 9;
  left: 50%;
  top: 18%;
  transform: translateX(-50%);
  max-width: calc(100% - 24px);
  padding: 14px 22px;
  border: var(--line);
  border-radius: 18px;
  background: #fff;
  text-align: center;
  box-shadow: 0 6px 0 var(--ink);
  white-space: nowrap;
}

.shape-banner b { display: block; font-size: 26px; white-space: nowrap; }
.shape-banner.rare { background: #ffe7a3; }
.shape-banner.legend { background: #f3d4ff; }

#app.edge-flash::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 7;
  box-shadow: inset 0 0 0 8px #fff, inset 0 0 36px #ffe08a;
  animation: edge 0.45s ease-out;
}

@keyframes edge {
  from { opacity: 1; }
  to { opacity: 0; }
}

#band-label {
  position: absolute;
  top: 0;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #1B5C30;
  white-space: nowrap;
  line-height: 1;
}

#needle {
  position: absolute;
  top: 50%;
  width: 18px;
  height: 18px;
  margin-top: -9px;
  margin-left: -9px;
  border-radius: 50%;
  background: #fff;
  border: var(--line);
  box-shadow: 0 2px 0 var(--ink);
}

#viewport {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
  padding: 0 10px 8px;
  container-type: size;
  container-name: drawer;
}

button {
  appearance: none;
  border: var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
  min-width: 44px;
  min-height: 44px;
  padding: 10px 14px;
  box-shadow: var(--shadow);
  cursor: pointer;
  touch-action: manipulation;
}

button:active,
button.is-down {
  transform: translateY(4px);
  box-shadow: 0 1px 0 var(--ink);
}

button.bounce { animation: release 0.28s cubic-bezier(.2, 1.4, .4, 1); }

button.primary { background: var(--candy); }

button:disabled,
button.poor {
  background: #E7E0D6;
  color: #8A766C;
  box-shadow: 0 3px 0 #C8B8AC;
}

.ico { width: 22px; height: 22px; display: block; }

.sheet {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
  padding: 0 0 6px;
}

.sheet.dock { padding: 0; gap: 6px; }

.row { display: flex; gap: 8px; flex-wrap: wrap; }

.row > button, .actions > button { flex: 1; min-width: 44px; }

.hint, .sub, .blurb, .kicker, .name, .pop-title, .price, .short {
  margin: 0;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.hint { font-size: 15px; font-weight: 700; }

.market-list, .tool-list, .job-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.stone, .tool, .job, .slot, .hero, .pro-detail {
  border: var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: 0 4px 0 var(--ink);
}

.stone {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto auto;
  gap: 6px;
  align-items: center;
  padding: 8px;
  height: 66px;
  min-height: 64px;
  max-height: 72px;
  min-width: 0;
  overflow: hidden;
}

.stone { cursor: pointer; }

.stone.poor { background: #F4EEE6; }

.stone.on {
  background: #FFF1C9;
  box-shadow: 0 4px 0 var(--ink), inset 0 0 0 3px #E0A100;
}

.stone.poor .thumb { filter: grayscale(1); opacity: 0.65; }

.thumb {
  width: 44px;
  height: 44px;
  object-fit: contain;
  image-rendering: pixelated;
  background: #F3E6D4;
  border-radius: 12px;
  border: 2px solid var(--ink);
}

.stone-info, .stone-side { min-width: 0; }

.stone-info .name,
.stone-info .sub {
  display: block;
  white-space: nowrap;
  text-overflow: ellipsis;
  -webkit-line-clamp: unset;
}

.name { font-size: 16px; }

.locked-row {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  min-height: 44px;
  padding: 8px 12px;
  border: var(--line);
  border-radius: 16px;
  background: #F4EEE6;
  box-shadow: 0 3px 0 var(--ink);
}

.locked-row .name { font-size: 14px; }

.locked-row .sub { font-size: 12px; color: #8A766C; }

.sub, .blurb, .short { font-size: 13px; }

.price-line {
  display: flex;
  align-items: center;
  gap: 4px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.price-line .ico { width: 18px; height: 18px; }

.stone-side { display: contents; }

.price-line { white-space: nowrap; }

.stone-side button,
.stone button { min-width: 64px; min-height: 44px; height: 44px; padding: 0 12px; }

.short { color: #A24B32; font-weight: 700; }

.tool, .job {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.tool button { width: 100%; min-height: 44px; }

.tool-top, .job-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.nav button {
  flex: 1;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 4px 2px;
  border-color: transparent;
  background: transparent;
  box-shadow: none;
  font-size: 11px;
  line-height: 1.1;
}

.nav button .ico { width: 22px; height: 22px; }

.nav button.on {
  background: var(--gold);
  border-color: var(--ink);
  box-shadow: 0 3px 0 var(--ink);
}

.nav button:active,
.nav button.is-down {
  transform: none;
  background: #FFE3A3;
  box-shadow: none;
}

.nav button.on:active,
.nav button.on.is-down {
  background: #F0B93A;
  box-shadow: 0 1px 0 var(--ink);
}

.hero { padding: 12px; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }

.hero .title {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.1;
}

.kicker { font-size: 14px; font-weight: 700; }

.stars { display: flex; gap: 4px; }

.stars .ico { width: 28px; height: 28px; }

.price {
  font-size: 28px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.actions button.primary { grid-column: 1 / -1; }

.pro-detail { padding: 8px 12px; display: flex; flex-direction: column; gap: 4px; }

.pro-detail[hidden] { display: none !important; }

.pro-detail div { font-size: 14px; font-weight: 700; }

.cabinet {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.slot { padding: 6px; min-height: 96px; }

.slot img {
  width: 100%;
  height: 72px;
  object-fit: contain;
  image-rendering: pixelated;
  background: #F3E6D4;
  border-radius: 14px;
  display: block;
}

.codex-block { display: flex; flex-direction: column; gap: 4px; min-width: 0; }

.codex-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.codex-head .name { font-size: 15px; }

.codex-head .sub {
  flex: none;
  font-size: 12px;
  color: #8A766C;
  -webkit-line-clamp: 1;
}

/* Cells wrap instead of scrolling sideways: a sideways row hid the last
   cuts behind the panel edge with nothing to say there were more. */
.codex {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
  gap: 6px;
  min-width: 0;
  padding-bottom: 2px;
}

.codex i {
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  width: 100%;
  aspect-ratio: 1;
  max-width: 52px;
  min-height: 40px;
  border: 2px solid var(--ink);
  border-radius: 12px;
  background: #F4EEE6;
  font-style: normal;
  font-size: 18px;
  font-weight: 700;
  color: #8A766C;
}

.codex i.on,
.codex i.got {
  background: var(--cell, var(--mint));
  color: transparent;
  padding: 0;
  overflow: hidden;
}

.codex i.got img,
.codex i .sil {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.codex i .sil {
  background:
    linear-gradient(160deg, #fff 0%, transparent 42%),
    var(--cell, var(--mint));
  clip-path: polygon(50% 8%, 88% 38%, 72% 88%, 28% 88%, 12% 38%);
}

.guide, .shade {
  position: absolute;
  z-index: 8;
  pointer-events: auto;
}

.guide {
  width: min(232px, calc(100vw - 24px));
  padding: 10px;
  border: var(--line);
  border-radius: 18px;
  background: var(--cream);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.guide .hint { font-size: 14px; }

.tip-actions { display: flex; gap: 8px; }

.tip-actions button { flex: 1; min-height: 44px; padding: 8px 10px; }

.tip-tail {
  position: absolute;
  width: 14px;
  height: 14px;
  background: var(--cream);
  border-right: var(--line);
  border-bottom: var(--line);
  transform: rotate(45deg);
  bottom: -8px;
  left: 28px;
}

.guide[data-side="left"] .tip-tail { display: none; }

.guide[data-side="below"] .tip-tail {
  bottom: auto;
  top: -8px;
  border: none;
  border-left: var(--line);
  border-top: var(--line);
}

.shade {
  inset: 0;
  background: rgba(59, 42, 34, 0.28);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.popup {
  width: min(320px, 100%);
  padding: 16px;
  border: var(--line);
  border-radius: 28px;
  background: var(--cream);
  box-shadow: 0 8px 0 var(--ink);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.popup .ico { width: 42px; height: 42px; }

.popup button.primary { align-self: stretch; min-height: 44px; }

.pop-title { font-size: 22px; }

.popup img {
  width: 140px;
  max-width: 100%;
  border-radius: 16px;
  border: var(--line);
  align-self: center;
}

#veil {
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
  background:
    radial-gradient(circle at 30% 40%, rgba(255, 248, 220, 0.55), transparent 42%),
    radial-gradient(circle at 70% 60%, rgba(255, 186, 214, 0.4), transparent 46%);
}

#land-note {
  display: none;
  position: absolute;
  z-index: 7;
  left: 12px;
  bottom: calc(12px + var(--safe-bot));
  margin: 0;
  padding: 8px 12px;
  border: var(--line);
  border-radius: 999px;
  background: var(--cream);
  box-shadow: var(--shadow);
  font-size: 14px;
  font-weight: 700;
  pointer-events: none;
}

#safe-probe {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 0;
  height: var(--safe-bot);
  overflow: hidden;
  pointer-events: none;
  visibility: hidden;
}

.coin-fly {
  position: fixed;
  z-index: 9;
  width: 26px;
  height: 26px;
  pointer-events: none;
}

@keyframes pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.28); }
  100% { transform: scale(1); }
}

@keyframes release {
  0% { transform: translateY(4px); }
  55% { transform: translateY(-3px); }
  100% { transform: translateY(0); }
}

@keyframes rise {
  0% { transform: translateY(6px) scale(0.92); opacity: 0; }
  12% { transform: translateY(0) scale(1); opacity: 1; }
  78% { opacity: 1; }
  100% { transform: translateY(-6px) scale(1); opacity: 0; }
}

@keyframes word {
  0% { opacity: 0; }
  8% { opacity: 1; }
  28% { opacity: 1; }
  36% { opacity: 0; }
  100% { opacity: 0; }
}

@keyframes finger {
  0% { transform: translate(0, 0) rotate(-8deg); }
  18% { transform: translate(0, 6px) rotate(0); }
  68% { transform: translate(120px, 6px) rotate(0); }
  86% { transform: translate(120px, -6px) rotate(-14deg); }
  100% { transform: translate(0, 0) rotate(-8deg); }
}

/* A short list pane cannot show three full-width cards. Fold the shelf
   into two columns so the buy buttons stay on screen. */
@container drawer (max-height: 180px) {
  .market-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
  }

  .market-list .stone {
    height: 64px;
    min-height: 64px;
    padding: 6px;
    gap: 4px;
    grid-template-columns: minmax(0, 1fr) auto auto;
  }

  .market-list .thumb { display: none; }

  /* Every card is "神秘原石"; in the folded shelf that name only pushed
     the carat and rarity into an ellipsis.  Show those instead. */
  .market-list .name { display: none; }

  .market-list .stone-info .sub {
    white-space: normal;
    overflow: hidden;
    font-size: 12px;
    line-height: 15px;
  }

  .market-list .stone-info .sub .sep,
  .market-list .stone-info .sub .approx { display: none; }

  .market-list .stone-info .sub .fact {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .market-list .stone button {
    min-width: 52px;
    padding: 0 8px;
  }

  .locked-row { grid-column: 1 / -1; }
}

@media (max-height: 700px) and (orientation: portrait) {
  #nav.nav { margin: 0 8px 0; padding: 0 2px; }
  #viewport { padding: 0 8px 0; }
  .sheet { padding: 0; }
}

/* The grabber hangs on the stage/drawer seam so it does not eat a row
   of the list. Portrait only; landscape keeps it in the column. */
@media (orientation: portrait) {
  #drawer { overflow: visible; }

  #handle {
    position: absolute;
    top: -40px;
    left: 50%;
    width: 88px;
    height: 44px;
    transform: translateX(-50%);
    z-index: 5;
  }

  .grab { margin-top: 34px; }

  #drawer[data-snap="peek"] #peek { padding-top: 6px; }
}

@media (orientation: landscape) {
  #app { flex-direction: row; flex-wrap: nowrap; }

  #top {
    position: absolute;
    top: 0;
    left: 0;
    right: auto;
    max-width: calc(100% - 140px);
  }

  #stage { flex: 1 1 auto; height: 100%; }

  #drawer {
    height: 100% !important;
    width: min(420px, 46vw);
    max-height: 100%;
    border-radius: 26px 0 0 26px;
    border-top: none;
    border-left: var(--line);
    box-shadow: -3px 0 0 var(--ink);
  }

  #drawer[data-snap="peek"] { width: 148px; }

  #drawer[data-snap="full"] { width: min(560px, 68vw); }

  #drawer[data-snap="peek"] #nav,
  #drawer[data-snap="peek"] #viewport { display: none !important; }

  #land-note {
    display: block;
    bottom: calc(148px + var(--safe-bot));
  }
}

/* A desktop or tablet in landscape is a fine way to play; the hint is only
   for a phone turned on its side. */
@media (orientation: landscape) and (min-height: 560px) {
  #land-note { display: none; }
}

/* The wallet answers each landing coin. */
#gold-pill.bump { animation: gold-bump .22s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes gold-bump {
  0% { transform: scale(1); }
  45% { transform: scale(1.12); }
  100% { transform: scale(1); }
}

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

#viewport.more {
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 22px), transparent);
  mask-image: linear-gradient(to bottom, #000 calc(100% - 22px), transparent);
}

/* Desktop / tablet landscape: one fixed side panel.  shell.js sets
   data-desk on the drawer and .desk on #app (see deskPanel). */
#drawer[data-desk] {
  width: clamp(320px, 30vw, 420px) !important;
  padding-top: 14px;
}

#drawer[data-desk] #handle { display: none; }

#drawer[data-desk] #meter {
  height: 24px;
  margin: 46px 16px 4px;
}

#drawer[data-desk] #coach { top: -40px; }

#drawer[data-desk][data-mode="cutting"] #peek {
  display: block;
  padding: 10px 16px 0;
}

#drawer[data-desk][data-mode="cutting"] #peek .cut-row { flex-wrap: nowrap; }

#drawer[data-desk][data-mode="cutting"] #viewport { flex: 1 1 auto; }

#drawer[data-desk] #nav { margin-top: 0; }

.desk #land-note { display: none !important; }

.desk .preview-bar {
  left: 50%;
  right: auto;
  width: min(560px, calc(100% - 32px));
  transform: translateX(-50%);
  bottom: 28px;
}

@media (orientation: landscape) {
  .desk #open-curtain { left: calc((100% - clamp(320px, 30vw, 420px)) / 2); }
}

.tips { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }

.tips li {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
  border: var(--line);
  border-radius: 14px;
  background: #fff;
}

.tips b { font-size: 15px; }

.tips span { font-size: 13px; font-weight: 700; color: #8A766C; line-height: 1.35; }

#drawer[data-desk] #viewport { padding: 14px 16px 12px; }

/* ---------- 排行与每日挑战 ---------- */
.challenge {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px;
  border: var(--line);
  border-radius: var(--radius);
  background: #FFF1C9;
  box-shadow: 0 4px 0 var(--ink);
}

.challenge-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.challenge-head .name { font-size: 17px; }
.challenge-head .sub { font-size: 13px; font-weight: 700; color: #8A766C; }
.challenge-done { margin: 0; font-size: 20px; font-weight: 800; }
.challenge .hint { font-size: 13px; color: #8A766C; }

.chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

.chips button {
  min-height: 36px;
  padding: 6px 12px;
  font-size: 13px;
  box-shadow: 0 3px 0 var(--ink);
}

.chips button.on { background: var(--gold); }
.rank-boards { flex-wrap: nowrap; overflow-x: auto; padding: 0 2px 4px; scrollbar-width: none; }
.rank-boards::-webkit-scrollbar { display: none; }
.rank-boards button { flex: none; padding: 6px 10px; }
.chips .sub { font-size: 14px; font-weight: 700; }
.chips .rank-refresh { margin-left: auto; }

.rank-join {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: var(--line);
  border-radius: var(--radius);
  background: var(--card);
}

.rank-join .hint { flex: 1; font-size: 13px; }

.rank-box { display: flex; flex-direction: column; gap: 6px; min-width: 0; }

.rank-mine {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 8px 12px;
  border: var(--line);
  border-radius: 16px;
  background: #E5F4FF;
  font-weight: 700;
}

.rank-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.rank-row {
  display: grid;
  grid-template-columns: 28px 32px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 6px 10px;
  border: 2px solid var(--ink);
  border-radius: 14px;
  background: var(--card);
}

.rank-row.top { background: #FFF1C9; }
.rank-no { text-align: center; font-size: 15px; }
.rank-face {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--ink);
  background: #F3E6D4;
  object-fit: cover;
}
.rank-name { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-weight: 700; }
.rank-score { font-weight: 800; }

/* ---------- 分享海报 ---------- */
.share-pop { align-items: stretch; max-height: calc(100% - 20px); overflow-y: auto; }
.share-pop .actions { display: flex; gap: 8px; }
.popup img.poster {
  width: min(240px, 100%);
  border-radius: 14px;
  image-rendering: auto;
}
.save-link { align-self: center; text-decoration: underline; color: var(--ink); }
