/* Carve — KG Studio. Self-contained so it can't disturb the
   shipped game's stylesheet. Palette matches the main build. */

* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --ink: #4a3b49;
  --ink-soft: #9c8a97;
  --mint: #7fb2a6;
  --rose: #ff6b8a;
  --card: #fffafc;
}

html, body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

/* The gradient lives on two stacked layers rather than on body, because a
   CSS gradient cannot be transitioned — the incoming one fades over the
   outgoing one when the pack changes. */
.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  opacity: 0;
  transition: opacity .9s ease;
  pointer-events: none;
}

body {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
  touch-action: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#stage { grid-row: 2; position: relative; min-height: 0; overflow: hidden; }

#stage canvas {
  display: block;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#hud { grid-row: 1; padding: 12px 18px 10px; }

#hud-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 9px;
}

/* Half stars are a gradient clipped to the glyph — a real half, not two
   images that have to stay in sync. */
#stars { display: flex; gap: 1px; font-size: 14px; line-height: 1; margin-right: auto; }
#banner-stars { font-size: 26px; letter-spacing: 2px; margin: 2px 0 8px; }

.star { color: #e8dce3; }
.star.full { color: #f0b73f; }

.star.half {
  background: linear-gradient(90deg, #f0b73f 50%, #e8dce3 50%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.zen-tag {
  padding: 3px 9px;
  border-radius: 99px;
  background: #e2f1ec;
  color: #4f8d7d;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .09em;
  text-transform: uppercase;
}

#level-tag { display: flex; align-items: center; gap: 8px; }

#level-name {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

/* Three blocks, filling in as a set is worked through. The set is the unit
   of "one more go" — a short arc with an end in sight. */
#pips { display: flex; gap: 3px; }

.pip {
  width: 9px;
  height: 9px;
  border-radius: 2.5px;
  background: #e4d6dd;
  transition: background .3s ease, transform .3s cubic-bezier(.34,1.4,.64,1);
}

.pip.done { background: var(--mint); }
.pip.current { background: var(--rose); transform: scale(1.18); }

#hearts { display: flex; gap: 3px; font-size: 19px; line-height: 1; }
.heart { color: var(--rose); transition: color .25s ease, transform .25s ease; }
.heart.spent { color: #e4d6dd; transform: scale(.82); }

#progress { flex: 1; min-width: 0; }

#progress-label {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 10px; font-weight: 600; letter-spacing: .09em;
  text-transform: uppercase; color: var(--ink-soft); margin-bottom: 5px;
}

#left { font-size: 13px; font-variant-numeric: tabular-nums; color: var(--ink); }

#progress-track { height: 7px; border-radius: 99px; background: #efe2e9; overflow: hidden; }

#progress-fill {
  height: 100%; width: 100%; border-radius: 99px;
  background: linear-gradient(90deg, #9fd0c4, var(--mint));
  transition: width .38s cubic-bezier(.34, 1.3, .64, 1);
}

#hint {
  position: fixed; left: 50%; bottom: 56px; transform: translateX(-50%);
  padding: 9px 17px; border-radius: 99px;
  background: rgba(255,255,255,.82);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  box-shadow: 0 3px 14px rgba(74,59,73,.13);
  font-size: 12.5px; font-weight: 600; color: var(--ink-soft);
  white-space: nowrap; pointer-events: none;
  transition: opacity .4s ease;
}

#hint.gone { opacity: 0; }

#brand {
  grid-row: 3; padding: 6px 18px 16px; text-align: center;
  font-size: 10px; font-weight: 500; letter-spacing: .3em; text-indent: .3em;
  color: #bda9b8; pointer-events: none;
}

#brand b { font-weight: 800; color: #a1889c; }

/* The brand line ignores pointer events so it never eats a drag near the
   bottom of the stage — the link has to opt back in or it is decoration. */
#brand a {
  pointer-events: auto;
  margin-left: .55em;
  color: #bda9b8;
  text-decoration: none;
  border-bottom: 1px solid rgba(189,169,184,.45);
}

#brand a:hover { color: #a1889c; }

/* Bottom-right thumb zone, stacked so neither is a stretch one-handed. */
#controls {
  position: fixed;
  right: 14px;
  bottom: 108px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
}

.pill {
  padding: 9px 14px;
  border: 0;
  border-radius: 99px;
  background: rgba(255,255,255,.86);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  box-shadow: 0 3px 14px rgba(74,59,73,.14);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .02em;
  color: var(--ink-soft);
  cursor: pointer;
  white-space: nowrap;
  text-transform: capitalize;
  transition: transform .12s ease, opacity .2s ease, color .2s ease;
}

a.pill { text-decoration: none; display: inline-block; }
.pill:active { transform: scale(.94); }
.pill:disabled { opacity: .45; cursor: default; }
.pill:focus-visible { outline: 2px solid var(--mint); outline-offset: 2px; }

/* The clue button carries its own state in its colour as well as its text. */
#clue-btn[data-mode="chips"] { color: #4a3b49; }
#clue-btn[data-mode="ghost"] { color: #9c8a97; }
#clue-btn[data-mode="off"]   { color: #c9b6c4; text-decoration: line-through; }

#sheet {
  position: fixed;
  inset: 0;
  z-index: 12;
  display: flex;
  align-items: flex-end;
  background: rgba(74,59,73,.34);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

#sheet[hidden] { display: none; }

#sheet-card {
  width: 100%;
  padding: 20px 18px calc(18px + env(safe-area-inset-bottom));
  border-radius: 24px 24px 0 0;
  background: var(--card);
  box-shadow: 0 -12px 40px rgba(74,59,73,.22);
  animation: sheet-up .34s cubic-bezier(.22,1,.36,1) both;
}

@keyframes sheet-up { from { transform: translateY(100%) } to { transform: translateY(0) } }

#sheet-card h3 {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 10px;
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 13px 14px;
  margin-bottom: 8px;
  border: 0;
  border-radius: 14px;
  background: #f6eff4;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
}

.row b { color: var(--mint); text-transform: capitalize; }

.sheet-note {
  margin: -2px 4px 10px;
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--ink-soft);
}
.row:active { transform: scale(.985); }

/* ---------- Examine mode ----------
   Everything that belongs to PLAYING gets out of the way, so the finished
   sculpture has the screen to itself. The HUD stays but stops changing —
   it's a record of the run now, not a live gauge. */

body.examining #controls,
body.examining #hint,
body.examining #progress { opacity: 0; pointer-events: none; }

body.examining #hud { transition: opacity .4s ease; }
#controls, #hint, #progress { transition: opacity .4s ease; }

#examine-exit {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top));
  right: 14px;
  z-index: 11;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  background: rgba(255,255,255,.88);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  box-shadow: 0 3px 14px rgba(74,59,73,.16);
  color: var(--ink-soft);
  font: inherit;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  animation: fade-in .5s ease .35s both;
  transition: transform .12s ease;
}

#examine-exit[hidden] { display: none; }
#examine-exit:active { transform: scale(.9); }
#examine-exit:focus-visible { outline: 2px solid var(--mint); outline-offset: 2px; }

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

#zen-sheet {
  position: fixed;
  inset: 0;
  z-index: 14;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(74,59,73,.38);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

#zen-sheet[hidden] { display: none; }

#zen-card {
  width: 100%;
  max-width: 320px;
  padding: 24px 22px 18px;
  border-radius: 26px;
  background: var(--card);
  text-align: center;
  box-shadow: 0 18px 44px rgba(74,59,73,.24);
  animation: drop .62s cubic-bezier(.22,1,.36,1) both;
}

#zen-card .zen-icon {
  font-size: 26px;
  color: #4f8d7d;
  margin-bottom: 6px;
}

#zen-card h3 { font-size: 20px; font-weight: 800; margin-bottom: 8px; }

#zen-card p {
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--ink-soft);
  margin-bottom: 18px;
}

#zen-card .zen-note {
  font-size: 11.5px;
  margin: 9px 0 4px;
  color: #4f8d7d;
}

/* Consent. Deliberately NOT a slim bottom strip with a giant Accept and a
   buried "manage preferences" — that pattern is designed to get a yes, and
   this asks a question we genuinely accept no as an answer to. Both buttons
   are full width, adjacent, and equally easy to hit. */
#consent {
  position: fixed;
  inset: 0;
  z-index: 16;              /* above the win banner: it gates what loads */
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(74,59,73,.38);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

#consent[hidden] { display: none; }

#consent-card {
  width: 100%;
  max-width: 330px;
  padding: 24px 22px 18px;
  border-radius: 26px;
  background: var(--card);
  text-align: center;
  box-shadow: 0 18px 44px rgba(74,59,73,.24);
  animation: drop .62s cubic-bezier(.22,1,.36,1) both;
}

#consent-card h3 { font-size: 19px; font-weight: 800; margin-bottom: 9px; }

#consent-card p {
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--ink-soft);
  margin-bottom: 12px;
}

#consent-card .consent-note {
  font-size: 12px;
  color: #4f8d7d;
  margin-bottom: 18px;
}

#consent-card .consent-link {
  display: block;
  margin-top: 12px;
  font-size: 11.5px;
  color: var(--ink-soft);
  text-decoration: underline;
}

#toast {
  position: fixed;
  left: 50%;
  bottom: 168px;
  transform: translate(-50%, 8px);
  max-width: calc(100% - 48px);
  padding: 9px 16px;
  border-radius: 99px;
  background: rgba(74,59,73,.9);
  color: #fff;
  font-size: 12.5px;
  font-weight: 600;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
}

#toast.show { opacity: 1; transform: translate(-50%, 0); }

#banner {
  position: fixed; inset: 0; z-index: 10; display: grid; place-items: center;
  padding: 24px; background: rgba(74,59,73,.34);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
}

#banner[hidden] { display: none; }

#banner-card {
  width: 100%; max-width: 320px; padding: 26px 22px 20px;
  border-radius: 26px; background: var(--card); text-align: center;
  box-shadow: 0 18px 44px rgba(74,59,73,.24);
  animation: drop .62s cubic-bezier(.22,1,.36,1) both;
}

@keyframes drop {
  0%   { transform: translateY(-130%) scale(.88); opacity: 0 }
  55%  { transform: translateY(6%) scale(1.03); opacity: 1 }
  75%  { transform: translateY(-2.5%) scale(.99) }
  100% { transform: translateY(0) scale(1) }
}

#banner-emoji { font-size: 42px; margin-bottom: 10px; }
#banner-title { font-size: 22px; font-weight: 700; margin-bottom: 7px; }
#banner-body { font-size: 14px; line-height: 1.5; color: var(--ink-soft); margin-bottom: 20px; }

.btn {
  display: block; width: 100%; padding: 14px; border: 0; border-radius: 15px;
  font: inherit; font-size: 15px; font-weight: 600; cursor: pointer;
  background: var(--mint); color: #fff;
  transition: transform .12s ease;
}

.btn:active { transform: scale(.97); }
.btn + .btn { margin-top: 9px; }
.btn[hidden] { display: none; }
.btn:disabled { opacity: .65; cursor: default; transform: none; }
.btn-ghost { background: transparent; color: var(--ink-soft); }

@media (prefers-reduced-motion: reduce) {
  #banner-card { animation: none; }
  #progress-fill, .heart, #hint { transition: none; }
}
