/* The Wine Thief — a candlelit vaulted cellar seen from above, a cheeky altar
   boy, the Red Cantor's lantern. Colours that depend on the chosen cellar
   arrive as custom properties from themes.js. Game-specific classes are
   prefixed wt-. */

:root {
  --light: #ffb257;
  --bg-a: #1d130f;
  --bg-b: #0b0706;
  --text: #f4e8d0;
  --text-dim: rgba(244, 232, 208, 0.62);
  --gold: #dcb75e;
  --wine: #94272a;
  --wine-deep: #5a1214;
  --ink: #2b211a;
  --ink-soft: #6e5f4f;
  --paper: #f7f0e2;
  --paper-2: #ece2ce;
  --line: rgba(60, 45, 30, 0.14);
  --radius: 18px;
  --ease: cubic-bezier(0.4, 0.1, 0.2, 1);
  --t: 40px;
  --step: 190ms;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  font-family: var(--sans);
  color: var(--text);
  background: radial-gradient(130% 90% at 50% 0%, #2c1b13, var(--bg-a) 48%, var(--bg-b));
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

/* ---------------------------------------------------------- background */
.bg {
  position: fixed;
  inset: 0;
  overflow: hidden;
  z-index: 0;
  pointer-events: none;
}
.bg .blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.2;
  will-change: transform;
}
.bg .b1 { width: 60vmax; height: 60vmax; left: -25vmax; top: -30vmax; background: var(--light); animation: drift 50s ease-in-out infinite alternate; }
.bg .b2 { width: 50vmax; height: 50vmax; right: -25vmax; bottom: -22vmax; background: var(--wine); animation: drift 64s ease-in-out infinite alternate-reverse; }
.bg .b3 { width: 36vmax; height: 36vmax; left: 35vw; bottom: -26vmax; background: var(--light); opacity: 0.1; animation: drift 76s ease-in-out infinite alternate; }
@keyframes drift {
  from { transform: translate(0, 0) scale(1); }
  to { transform: translate(8vmax, 6vmax) scale(1.12); }
}

/* -------------------------------------------------------------- layout */
.app {
  position: fixed;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  max-width: 1100px;
  margin: 0 auto;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px 4px 16px;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand img { width: 40px; height: 40px; flex: 0 0 auto; filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5)); }
.brand span { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
.brand b { font-family: var(--serif); font-weight: 600; font-size: 21px; letter-spacing: 0.01em; color: #f7e6c4; text-shadow: 0 1px 10px rgba(255, 170, 80, 0.25); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand small { font-size: 11px; color: var(--text-dim); letter-spacing: 0.1em; text-transform: uppercase; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu { display: flex; gap: 2px; flex: 0 0 auto; }

.icon-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text);
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
}
.icon-btn:hover { background: rgba(255, 235, 210, 0.1); }
.icon-btn:active { transform: scale(0.92); }
.icon-btn:focus-visible, .btn:focus-visible { outline: 2px solid #ffd27a; outline-offset: 2px; }
.icon-btn svg, .btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 4px 16px 6px;
}
.stat {
  background: rgba(255, 236, 210, 0.06);
  border: 1px solid rgba(255, 236, 210, 0.1);
  border-radius: 12px;
  padding: 5px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.15;
  min-width: 0;
}
.stat span { font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.stat b { font-family: var(--serif); font-size: 19px; font-weight: 600; font-variant-numeric: tabular-nums; color: #f7e6c4; white-space: nowrap; }
.stat b small { font-size: 0.72em; font-weight: 500; color: var(--text-dim); }

.stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 6px 12px;
}

.actions {
  display: flex;
  gap: 8px;
  padding: 6px 12px 14px;
}

.btn {
  appearance: none;
  flex: 1;
  min-width: 0;
  border: 1px solid rgba(255, 235, 210, 0.16);
  background: rgba(255, 235, 210, 0.08);
  color: var(--text);
  font: 500 15px var(--sans);
  padding: 11px 10px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  transition: transform 0.15s, background 0.2s, opacity 0.2s, box-shadow 0.2s;
}
.btn svg { width: 19px; height: 19px; flex: 0 0 auto; }
.btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn:hover { background: rgba(255, 235, 210, 0.14); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.38; cursor: default; transform: none; }
.btn.primary {
  background: linear-gradient(180deg, #b23a34, var(--wine-deep));
  color: #fff3dc;
  border-color: #3e0c0d;
  box-shadow: 0 4px 14px -4px rgba(120, 20, 20, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.22);
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.3);
}
.btn.primary:hover { background: linear-gradient(180deg, #c2443d, #6a1618); }
.btn.subtle { flex: 0 0 auto; background: transparent; box-shadow: none; color: var(--ink-soft); border-color: transparent; font-size: 13.5px; margin: 18px auto 0; display: flex; }

/* ---------------------------------------------------------------- board */
.wt-board {
  position: relative;
  isolation: isolate;
  width: 300px;
  height: 300px;
  border-radius: 12px;
  overflow: hidden;
  outline: none;
  touch-action: none;
  cursor: pointer;
  background: #0b0706;
  box-shadow:
    0 0 0 1px rgba(255, 236, 210, 0.07),
    0 0 0 6px rgba(20, 12, 8, 0.6),
    0 0 0 7px rgba(255, 236, 210, 0.05),
    0 24px 50px -16px rgba(0, 0, 0, 0.95);
}
.wt-board:focus-visible { box-shadow: 0 0 0 1px rgba(255, 210, 122, 0.55), 0 0 0 6px rgba(20, 12, 8, 0.6), 0 0 0 7px rgba(255, 210, 122, 0.18), 0 24px 50px -16px rgba(0, 0, 0, 0.95); }
.wt-floor, .wt-light { position: absolute; left: 0; top: 0; display: block; }
.wt-light { animation: lantern-flicker 3.4s ease-in-out infinite; }
@keyframes lantern-flicker {
  0%, 100% { opacity: 1; }
  12% { opacity: 0.92; }
  19% { opacity: 0.99; }
  43% { opacity: 0.94; }
  52% { opacity: 1; }
  74% { opacity: 0.9; }
  83% { opacity: 0.97; }
}
.wt-warm {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(80% 70% at 50% 55%, rgba(255, 150, 80, 0.16), rgba(255, 110, 60, 0.06) 60%, transparent);
  transition: opacity 1.6s ease;
}
.wt-warm.wt-on { opacity: 1; }
.wt-sprites { position: absolute; inset: 0; pointer-events: none; }
.wt-board.wt-shake { animation: shake 0.42s var(--ease); }
@keyframes shake {
  20% { transform: translateX(-5px); }
  40% { transform: translateX(4px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(2px); }
}

/* ---------------------------------------------------------------- sprites */
.wt-sprite {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--t);
  height: calc(var(--t) * 1.4);
  transition: transform var(--step) cubic-bezier(0.35, 0.05, 0.25, 1);
  will-change: transform;
}
.wt-instant .wt-sprite, .wt-instant .wt-hintmark { transition: none !important; }
.wt-fig { width: 100%; height: 100%; transform-origin: 50% 92%; }
.wt-fig svg, .wt-gate svg { display: block; width: 100%; height: 100%; overflow: visible; }

.wt-fig.wt-hop { animation: hop var(--step) ease-out; }
@keyframes hop { 45% { transform: translateY(-9%) scale(0.98, 1.03); } 100% { transform: none; } }
.wt-fig.wt-walk { animation: walk var(--step) ease-in-out; }
@keyframes walk { 50% { transform: translateY(-3.5%) rotate(1.5deg); } }
.wt-fig.wt-prowl { animation: prowl var(--step) ease-in-out; }
@keyframes prowl { 50% { transform: translateY(-2.5%) scale(1.03, 0.97); } }
.wt-fig.wt-turn { animation: turn calc(var(--step) * 1.1) ease-in-out; }
@keyframes turn { 45% { transform: scaleX(0.12); } 100% { transform: none; } }
.wt-fig.wt-bump { animation: bump-n 0.22s ease-out; }
.wt-fig.wt-bump[data-bump="E"] { animation-name: bump-e; }
.wt-fig.wt-bump[data-bump="W"] { animation-name: bump-w; }
.wt-fig.wt-bump[data-bump="S"] { animation-name: bump-s; }
@keyframes bump-n { 40% { transform: translateY(-7%); } }
@keyframes bump-s { 40% { transform: translateY(5%); } }
@keyframes bump-e { 40% { transform: translateX(10%); } }
@keyframes bump-w { 40% { transform: translateX(-10%); } }

/* idle life */
.wt-boy .wt-body { animation: tiptoe 1.5s ease-in-out infinite; transform-origin: 50% 92%; }
@keyframes tiptoe { 50% { transform: translateY(-1.6%) scale(0.99, 1.012); } }
.wt-boy .wt-eyes { animation: blink 4.6s infinite; transform-box: fill-box; transform-origin: 50% 50%; }
@keyframes blink { 0%, 95%, 100% { transform: none; } 97% { transform: scaleY(0.12); } }
.wt-cheek { fill: #ff8080; opacity: 0.3; transition: opacity 0.8s, fill 0.8s; }
.wt-sipped .wt-cheek { fill: #ff3e55; opacity: 0.82; }
.wt-sipped .wt-mouth { stroke: #9a2a20; }
.wt-cantor .wt-body { animation: breathe 3.4s ease-in-out infinite; transform-origin: 50% 92%; }
@keyframes breathe { 50% { transform: scale(1.012, 0.992); } }
.wt-lantern { transform-box: fill-box; transform-origin: 50% 0%; animation: swing 2.6s ease-in-out infinite; }
@keyframes swing { 0%, 100% { transform: rotate(-6deg); } 50% { transform: rotate(6deg); } }
.wt-halo { animation: halo 1.9s ease-in-out infinite; transform-box: fill-box; transform-origin: 50% 50%; }
@keyframes halo { 50% { opacity: 0.7; transform: scale(0.92); } }
.wt-glint { opacity: 0; animation: glint 4.2s ease-in-out infinite; }
@keyframes glint { 0%, 78%, 100% { opacity: 0; } 84% { opacity: 0.95; } 90% { opacity: 0; } }
.wt-sexton .wt-head { animation: nod 4s ease-in-out infinite; transform-box: fill-box; transform-origin: 50% 90%; }
@keyframes nod { 0%, 100% { transform: none; } 55% { transform: translateY(2%) rotate(-3deg); } 70% { transform: translateY(2.4%) rotate(-3deg); } }
.wt-zzz text { opacity: 0; animation: zzz 3.2s ease-out infinite; }
.wt-zzz text:nth-child(2) { animation-delay: 1.1s; }
@keyframes zzz { 0% { opacity: 0; transform: translate(-4px, 6px); } 30% { opacity: 0.9; } 100% { opacity: 0; transform: translate(6px, -10px); } }
.wt-flick { transform-box: fill-box; transform-origin: 50% 100%; animation: flicker 2.2s ease-in-out infinite; }
.wt-tail { transform-box: fill-box; transform-origin: 0% 100%; animation: swish 2.4s ease-in-out infinite; }
.wt-tail.wt-tail-side { transform-origin: 100% 100%; animation-name: swish-side; }
@keyframes swish { 0%, 100% { transform: rotate(-4deg); } 50% { transform: rotate(9deg); } }
@keyframes swish-side { 0%, 100% { transform: rotate(5deg); } 50% { transform: rotate(-10deg); } }
.wt-cat .wt-eyes { animation: blink 5.2s 1s infinite; transform-box: fill-box; transform-origin: 50% 50%; }
.wt-float { animation: float 2.6s ease-in-out infinite; }
@keyframes float { 50% { transform: translateY(-3%); } }
.wt-sparkle { transform-box: fill-box; transform-origin: 50% 50%; animation: sparkle 2.8s ease-in-out infinite; }
@keyframes sparkle { 0%, 60%, 100% { opacity: 0; transform: scale(0.3); } 75% { opacity: 1; transform: scale(1); } }

/* items, gates, light fittings */
.wt-grapes, .wt-key { transition: opacity 0.4s, transform var(--step); }
.wt-sprite.wt-gone { opacity: 0; visibility: hidden; }
.wt-sprite.wt-picked .wt-fig { animation: picked 0.6s ease-out forwards; }
@keyframes picked { 0% { transform: none; } 40% { transform: translateY(-30%) scale(1.25); opacity: 1; } 100% { transform: translateY(-55%) scale(0.6); opacity: 0; } }
.wt-gate-leaf { transition: transform 0.7s var(--ease), opacity 0.7s; transform-box: fill-box; transform-origin: 0% 50%; }
.wt-gate.wt-open .wt-gate-leaf { transform: scaleX(0.14); opacity: 0.75; }
.wt-gate[data-kind="along"] .wt-gate-leaf { transform-origin: 50% 0%; }
.wt-gate[data-kind="along"].wt-open .wt-gate-leaf { transform: scaleY(0.16); }
.wt-flame {
  position: absolute;
  left: 0;
  top: 0;
  width: calc(var(--t) * 0.12);
  height: calc(var(--t) * 0.22);
  margin: calc(var(--t) * -0.22) 0 0 calc(var(--t) * -0.06);
  border-radius: 50% 50% 45% 45% / 62% 62% 38% 38%;
  background: radial-gradient(ellipse at 50% 76%, #fffbe6 0 22%, #ffd75e 42%, #ff8d2c 68%, rgba(255, 120, 30, 0) 72%);
  transform-origin: 50% 100%;
  animation: flicker 2.8s ease-in-out infinite;
}
.wt-flame::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 55%;
  width: calc(var(--t) * 1.5);
  height: calc(var(--t) * 1.5);
  margin: calc(var(--t) * -0.75) 0 0 calc(var(--t) * -0.75);
  border-radius: 50%;
  background: radial-gradient(color-mix(in oklab, var(--light) 38%, transparent), transparent 62%);
  animation: halo 2.8s ease-in-out infinite;
}
.wt-flame:nth-child(odd) { animation-duration: 3.3s; }
@keyframes flicker {
  0%, 100% { transform: scale(1) rotate(-1deg); }
  22% { transform: scale(1.06, 0.95) rotate(1.8deg); }
  46% { transform: scale(0.95, 1.07) rotate(-2deg); }
  71% { transform: scale(1.03, 0.98) rotate(1deg); }
}
.wt-drip {
  position: absolute;
  left: 0;
  top: 0;
  width: calc(var(--t) * 0.05);
  height: calc(var(--t) * 0.07);
  margin-left: calc(var(--t) * -0.025);
  border-radius: 50% 50% 50% 50% / 35% 35% 65% 65%;
  background: #a31826;
  opacity: 0;
  animation: drip 2.6s ease-in infinite;
}
@keyframes drip { 0%, 40% { opacity: 0; translate: 0 0; } 45% { opacity: 1; translate: 0 0; } 70% { opacity: 1; translate: 0 calc(var(--t) * 0.1); } 72%, 100% { opacity: 0; translate: 0 calc(var(--t) * 0.11); } }
.wt-exit {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--t);
  height: var(--t);
  z-index: 1;
  opacity: 0;
  transition: opacity 1s;
  background: radial-gradient(circle at 50% 50%, rgba(255, 214, 140, 0.55), rgba(255, 180, 90, 0.18) 45%, transparent 70%);
}
.wt-exit svg { position: absolute; inset: 18%; width: 64%; height: 64%; opacity: 0.85; filter: drop-shadow(0 0 4px rgba(255, 190, 100, 0.9)); animation: beckon 1.3s ease-in-out infinite; }
.wt-exit[data-dir="E"] svg { rotate: 90deg; }
.wt-exit[data-dir="S"] svg { rotate: 180deg; }
.wt-exit[data-dir="W"] svg { rotate: 270deg; }
@keyframes beckon { 50% { transform: translateY(-10%); opacity: 0.55; } }
.wt-exit.wt-on { opacity: 1; animation: exit-glow 2.2s ease-in-out infinite; }
@keyframes exit-glow { 50% { opacity: 0.7; } }
.wt-hintmark {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--t);
  height: var(--t);
  border-radius: 50%;
  border: calc(var(--t) * 0.06) solid #b7f0c2;
  box-shadow: 0 0 calc(var(--t) * 0.3) rgba(160, 255, 190, 0.7), inset 0 0 calc(var(--t) * 0.2) rgba(160, 255, 190, 0.5);
  animation: hintpulse 1.1s ease-in-out infinite;
  scale: 0.78;
}
.wt-hintmark.wt-wait { border-style: dashed; }
@keyframes hintpulse { 50% { scale: 0.9; opacity: 0.6; } }

/* bubbles: caught, hiccup */
.wt-alert {
  position: absolute;
  left: 50%;
  top: 0;
  translate: -50% -15%;
  min-width: min(calc(var(--t) * 0.42), 24px);
  height: min(calc(var(--t) * 0.5), 30px);
  display: grid;
  place-items: center;
  padding: 0 min(calc(var(--t) * 0.1), 6px);
  border-radius: min(calc(var(--t) * 0.14), 9px);
  background: #fff3d6;
  color: #b0141f;
  font: 900 min(calc(var(--t) * 0.4), 24px) / 1 var(--serif);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.5);
  animation: pop 0.35s cubic-bezier(0.3, 1.6, 0.5, 1);
}
@keyframes pop { from { transform: scale(0.2); opacity: 0; } }
.wt-alerted .wt-fig { animation: alerted 0.3s ease-out; }
@keyframes alerted { 40% { transform: translateY(-10%); } }
.wt-startled .wt-fig { animation: startled 0.4s ease-out; }
@keyframes startled { 30% { transform: translateY(-12%) scale(1.04, 0.96); } 60% { transform: translateY(-4%); } }
.wt-say {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 999;
  max-width: min(64%, 260px);
  width: max-content;
  padding: 7px 11px 8px;
  border-radius: 12px;
  background: #fff6e2;
  color: #2b1d12;
  font: italic 600 14px/1.3 var(--serif);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.55);
  animation: say 0.32s var(--ease);
}
@keyframes say { from { opacity: 0; scale: 0.9; } }
.wt-hukk {
  position: absolute;
  left: 58%;
  top: 4%;
  padding: 2px 7px 3px;
  border-radius: 10px;
  background: rgba(255, 246, 226, 0.95);
  color: #8e1b2a;
  font: italic 700 calc(max(12px, var(--t) * 0.28)) / 1.1 var(--serif);
  white-space: nowrap;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.4);
  animation: hukk 2.2s ease-out forwards;
}
@keyframes hukk { 0% { opacity: 0; transform: translateY(20%) scale(0.6); } 15% { opacity: 1; transform: none; } 75% { opacity: 1; } 100% { opacity: 0; transform: translateY(-60%); } }
.wt-climb .wt-fig { animation: climb-n 0.9s ease-in forwards; }
.wt-climb .wt-fig[data-climb="E"] { animation-name: climb-e; }
.wt-climb .wt-fig[data-climb="W"] { animation-name: climb-w; }
.wt-climb .wt-fig[data-climb="S"] { animation-name: climb-s; }
@keyframes climb-n { to { transform: translateY(-45%) scale(0.85); opacity: 0; } }
@keyframes climb-s { to { transform: translateY(30%) scale(0.85); opacity: 0; } }
@keyframes climb-e { to { transform: translate(55%, -18%) scale(0.85); opacity: 0; } }
@keyframes climb-w { to { transform: translate(-55%, -18%) scale(0.85); opacity: 0; } }

/* ------------------------------------------------------------- goals */
.wt-levelstat > span i { font-style: normal; color: #f7e6c4; letter-spacing: 0.04em; }
.wt-goals { display: flex; gap: 4px; align-items: center; height: 22px; }
.wt-goal { width: 20px; height: 20px; display: grid; place-items: center; border-radius: 50%; transition: background 0.4s, transform 0.3s; }
.wt-goal svg { width: 18px; height: 18px; opacity: 0.32; filter: grayscale(1) brightness(1.4); transition: opacity 0.4s, filter 0.4s; }
.wt-goal.wt-done { background: radial-gradient(circle, rgba(255, 190, 110, 0.35), transparent 70%); animation: goal 0.5s cubic-bezier(0.3, 1.6, 0.5, 1); }
.wt-goal.wt-done svg { opacity: 1; filter: none; }
@keyframes goal { from { transform: scale(0.5); } }

/* ------------------------------------------------- intro card & caught */
.wt-intro, .wt-caught {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  padding: 16px;
  background: radial-gradient(80% 70% at 50% 50%, rgba(10, 6, 4, 0.55), rgba(10, 6, 4, 0.8));
  animation: fade 0.25s;
}
.wt-caught { place-items: end center; background: linear-gradient(180deg, transparent 40%, rgba(10, 6, 4, 0.75)); }
.wt-card {
  position: relative;
  width: min(100%, 400px);
  padding: 20px 20px 18px;
  border-radius: 20px;
  background: var(--paper);
  color: var(--ink);
  color-scheme: light;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
  animation: card 0.35s var(--ease);
}
@keyframes card { from { opacity: 0; transform: translateY(14px) scale(0.97); } }
.wt-card h2 { margin: 2px 0 8px; font: 600 25px/1.15 var(--serif); }
.wt-card p { margin: 0 0 12px; color: var(--ink-soft); font-size: 15px; line-height: 1.45; }
.wt-card .btn { color: var(--ink); background: rgba(255, 255, 255, 0.6); border-color: rgba(60, 45, 30, 0.16); box-shadow: 0 1px 2px rgba(60, 45, 30, 0.1); }
.wt-card .btn.primary { color: #fff3dc; background: linear-gradient(180deg, #b23a34, var(--wine-deep)); border-color: #3e0c0d; }
.wt-card .row { display: flex; gap: 10px; }
.wt-kicker { font-size: 11.5px !important; letter-spacing: 0.14em; text-transform: uppercase; margin: 0 0 4px !important; color: var(--wine) !important; font-weight: 600; }
.wt-new { display: flex; align-items: center; gap: 12px; text-align: left; margin: 6px 0 12px; padding: 10px 12px; border-radius: 14px; background: var(--paper-2); }
.wt-new p { margin: 0; font-size: 14.5px; color: var(--ink); }
.wt-new-art { flex: 0 0 auto; width: 54px; height: 56px; display: grid; place-items: center; }
.wt-new-art .wt-art { width: 54px; height: 56px; border-radius: 12px; display: grid; place-items: center; overflow: hidden; }
.wt-new-art .wt-art svg.wt-icon { width: 30px; height: 30px; fill: none; stroke: #ffd98a; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.wt-new-art svg { width: 100%; height: 100%; }
.wt-par { font-size: 13px !important; margin-bottom: 14px !important; }
#intro-go { width: 100%; }
.wt-caught .wt-card { margin-bottom: 4px; padding: 16px 16px 14px; }
.wt-caught h2 { color: var(--wine); }

/* -------------------------------------------------------- sheets, dialogs */
.backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(8, 5, 3, 0.55);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  animation: fade 0.25s;
}
@keyframes fade { from { opacity: 0; } }

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  margin: 0 auto;
  z-index: 21;
  max-width: 560px;
  max-height: 86dvh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--ink);
  color-scheme: light;
  border-radius: 24px 24px 0 0;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.45);
  padding-bottom: env(safe-area-inset-bottom);
  animation: rise 0.32s var(--ease);
  -webkit-user-select: text;
  user-select: text;
}
@keyframes rise { from { transform: translateY(40px); opacity: 0; } }
.sheet header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 12px 6px 22px;
  flex: 0 0 auto;
}
.sheet .icon-btn, .dialog .icon-btn { color: var(--ink); }
.sheet .icon-btn:hover { background: rgba(60, 45, 30, 0.08); }
.sheet h2, .dialog h2 { font-family: var(--serif); font-weight: 600; font-size: 24px; margin: 0; letter-spacing: 0.01em; }
.sheet-body {
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 2px 22px 26px;
  font-size: 15px;
  line-height: 1.55;
}
.sheet-body h3 { font-family: var(--serif); font-weight: 600; font-size: 17px; margin: 20px 0 8px; color: var(--ink); }
.prose p { margin: 0 0 12px; }
.prose ul { margin: 0; padding-left: 20px; }
.prose li { margin: 4px 0; }
.muted { color: var(--ink-soft); }
.about { font-size: 13px; margin-top: 22px; text-align: center; }

@media (min-width: 700px) and (min-height: 560px) {
  .sheet {
    bottom: auto;
    top: 50%;
    transform: translateY(-50%);
    border-radius: 24px;
    max-height: 80dvh;
    animation: pop-sheet 0.28s var(--ease);
  }
}
@keyframes pop-sheet { from { opacity: 0; transform: translateY(-50%) scale(0.96); } }

.dialog {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 22;
  width: min(92vw, 410px);
  max-height: 94dvh;
  overflow: auto;
  background: var(--paper);
  color: var(--ink);
  color-scheme: light;
  border-radius: 24px;
  padding: 24px 22px 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
  text-align: center;
  animation: popc 0.3s var(--ease);
}
@keyframes popc { from { opacity: 0; transform: translate(-50%, -50%) scale(0.94); } }
.dialog p { margin: 8px 0 18px; color: var(--ink-soft); font-size: 15.5px; line-height: 1.5; }
.dialog .row { display: flex; gap: 10px; }
.dialog .btn { color: var(--ink); background: rgba(255, 255, 255, 0.6); border-color: rgba(60, 45, 30, 0.16); box-shadow: 0 1px 2px rgba(60, 45, 30, 0.1); }
.dialog .btn:hover { background: #fff; }
.dialog .btn.primary { color: #fff3dc; background: linear-gradient(180deg, #b23a34, var(--wine-deep)); border-color: #3e0c0d; }

/* Rules */
.wt-rules { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.wt-rules li { display: grid; grid-template-columns: 46px 1fr; gap: 12px; align-items: center; }
.wt-art { background: radial-gradient(circle at 50% 42%, #8a5a3a, #4a2e1f 58%, #24160f); }
.wt-rules .wt-art { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; overflow: hidden; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.2); }
.wt-rules .wt-art svg { width: 40px; height: 42px; }
.wt-rules .wt-art svg.wt-icon { width: 26px; height: 26px; fill: none; stroke: #ffd98a; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.wt-rules .wt-art.wt-alert-art { color: #b0141f; font: 900 26px/1 var(--serif); background: #fff3d6; }

/* Result */
.wt-result .glow {
  position: absolute;
  inset: -30% -20% auto;
  height: 70%;
  background: radial-gradient(ellipse at 50% 40%, color-mix(in oklab, var(--light) 50%, transparent), transparent 65%);
  pointer-events: none;
  opacity: 0.7;
}
.wt-result h2 { position: relative; font-size: 28px; }
.wt-result-art { position: relative; width: 62px; height: 96px; margin: -6px auto 2px; }
.wt-result-art svg { width: 100%; height: 100%; overflow: visible; }
.wt-hic {
  position: absolute;
  left: 78%;
  top: 2px;
  padding: 2px 8px 3px;
  border-radius: 10px;
  background: #fff;
  color: #8e1b2a;
  font: italic 700 13px/1.1 var(--serif);
  white-space: nowrap;
  box-shadow: 0 3px 8px rgba(60, 30, 10, 0.25);
  animation: hic 2.4s ease-in-out infinite;
}
@keyframes hic { 0%, 100% { transform: translateY(0) rotate(-4deg); } 50% { transform: translateY(-4px) rotate(3deg); } }
.wt-stars { position: relative; display: flex; justify-content: center; gap: 6px; margin: 0 0 8px; }
.wt-stars svg { width: 50px; height: 50px; fill: #d9cdb6; filter: drop-shadow(0 2px 2px rgba(80, 50, 20, 0.25)); }
.wt-stars svg:nth-child(2) { width: 60px; height: 60px; margin-top: -8px; }
.wt-stars svg.wt-lit { fill: url(#u-gold); animation: star 0.5s cubic-bezier(0.3, 1.7, 0.5, 1) both; }
.wt-stars svg.wt-lit:nth-child(2) { animation-delay: 0.18s; }
.wt-stars svg.wt-lit:nth-child(3) { animation-delay: 0.36s; }
@keyframes star { from { transform: scale(0.2) rotate(-40deg); opacity: 0; } }
.wt-checks { list-style: none; padding: 0; margin: -6px 0 14px; display: grid; gap: 3px; font-size: 14px; color: var(--ink-soft); }
.wt-checks li::before { content: "○ "; color: #b6a88f; }
.wt-checks li.wt-ok { color: var(--ink); }
.wt-checks li.wt-ok::before { content: "★ "; color: #c98e1f; }
.result-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 12px;
}
.result-stats div, .summary div { display: flex; flex-direction: column; align-items: center; background: var(--paper-2); border-radius: 12px; padding: 8px 4px; line-height: 1.2; min-width: 0; }
.result-stats span, .summary span { font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.result-stats b, .summary b { font-family: var(--serif); font-size: 17px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.score { display: flex; flex-direction: column; align-items: center; margin: 4px 0 18px; }
.score span { font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-soft); }
.score b { font-family: var(--serif); font-size: 44px; font-weight: 600; line-height: 1.05; color: var(--wine); }
.score em { font: italic 600 13px var(--serif); color: #b8741c; }

/* ------------------------------------------------------------- results */
.summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 8px; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; font-variant-numeric: tabular-nums; }
th { text-align: left; vertical-align: bottom; font-weight: 500; color: var(--ink-soft); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; padding: 4px; border-bottom: 1px solid var(--line); }
td { padding: 7px 4px; border-bottom: 1px solid var(--line); white-space: nowrap; vertical-align: middle; }
.wt-col-moves, .wt-col-par, .wt-col-undos, .wt-col-hints, .wt-col-score { text-align: right !important; }
td.wt-col-score { font-family: var(--serif); font-weight: 600; font-size: 15px; }
.wt-col-stars { text-align: center !important; }
td.wt-col-stars { color: #c98e1f; letter-spacing: 1px; }
td.wt-col-stars i { color: #d6cab2; font-style: normal; }
td.wt-col-level small { color: var(--ink-soft); margin-left: 5px; }
tr.wt-chapter td { padding-top: 12px; font: 600 12px var(--sans); letter-spacing: 0.08em; text-transform: uppercase; color: var(--wine); border-bottom: 0; }
tr.wt-locked td { color: #b3a690; }
@media (max-width: 420px) {
  .wt-col-hints, td.wt-col-level small { display: none; }
  td { padding: 7px 3px; }
}

/* ------------------------------------------------------------ level map */
.wt-chapter-card {
  position: relative;
  margin: 10px 0 14px;
  padding: 12px 12px 14px;
  border-radius: 18px;
  background: linear-gradient(180deg, #efe4cd, #e6d7bb);
  box-shadow: inset 0 0 0 1px rgba(90, 60, 30, 0.12);
}
.wt-chapter-card header { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 0 4px 2px; }
.wt-chapter-card h3 { margin: 0; font: 600 17px var(--serif); display: flex; align-items: center; gap: 8px; min-width: 0; }
.wt-chapter-card h3 .wt-art { flex: 0 0 auto; width: 34px; height: 36px; border-radius: 10px; display: grid; place-items: center; overflow: hidden; }
.wt-chapter-card h3 .wt-art svg { width: 30px; height: 33px; }
.wt-gold { color: #c98e1f; letter-spacing: 1px; }
.wt-chapter-card .wt-cstars { font-size: 12.5px; color: var(--ink-soft); white-space: nowrap; }
.wt-chapter-card p { margin: 0 4px 10px; font-size: 13px; color: var(--ink-soft); }
.wt-nodes { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; position: relative; }
.wt-nodes::before { content: ""; position: absolute; left: 8%; right: 8%; top: 25px; border-top: 2px dashed rgba(120, 80, 40, 0.3); }
.wt-node {
  appearance: none;
  position: relative;
  border: 0;
  background: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  cursor: pointer;
  font: inherit;
  color: var(--ink);
}
.wt-node .wt-seal {
  width: 100%;
  max-width: 50px;
  aspect-ratio: 1;
  height: auto;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font: 700 17px var(--serif);
  color: #fbe8c8;
  background: radial-gradient(circle at 35% 30%, #c84a3e, #8e1e22 60%, #5a0f12);
  box-shadow: 0 3px 6px rgba(70, 20, 10, 0.35), inset 0 0 0 3px rgba(255, 210, 160, 0.25), inset 0 -3px 4px rgba(0, 0, 0, 0.3);
  transition: transform 0.15s;
}
.wt-node:hover .wt-seal { transform: scale(1.06); }
.wt-node:active .wt-seal { transform: scale(0.95); }
.wt-node:focus-visible { outline: none; }
.wt-node:focus-visible .wt-seal { outline: 2px solid var(--wine); outline-offset: 3px; }
.wt-node[aria-current="true"] .wt-seal { box-shadow: 0 0 0 3px #f0c45a, 0 3px 10px rgba(200, 140, 30, 0.55), inset 0 0 0 3px rgba(255, 210, 160, 0.25); }
.wt-node.wt-locked { cursor: default; }
.wt-node.wt-locked .wt-seal { background: radial-gradient(circle at 35% 30%, #c9bba2, #a8987c 60%, #8c7c62); color: #6f6350; }
.wt-node.wt-locked .wt-seal svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.wt-node .wt-nstars { display: flex; gap: 1px; }
.wt-node .wt-nstars svg { width: 12px; height: 12px; fill: #cfc2a8; }
.wt-node .wt-nstars svg.wt-lit { fill: #d69a1e; }
.wt-node .wt-ntitle { font-size: 10.5px; line-height: 1.15; color: var(--ink-soft); text-align: center; max-width: 100%; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

/* ------------------------------------------------------------- settings */
.opts { display: flex; flex-wrap: wrap; gap: 8px; }
.opt {
  appearance: none;
  border: 1.5px solid var(--line);
  background: var(--paper-2);
  color: var(--ink);
  font: 500 14px var(--sans);
  padding: 8px 14px 8px 10px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.15s;
}
.opt:active { transform: scale(0.97); }
.opt[aria-checked="true"] { border-color: var(--wine); background: #fff; box-shadow: 0 0 0 3px rgba(148, 39, 42, 0.14); }
.opt:focus-visible { outline: 2px solid var(--wine); outline-offset: 2px; }
.opts.lang .opt { padding-left: 14px; min-width: 96px; justify-content: center; }
.swatch {
  display: inline-block;
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
  border-radius: 7px;
  background: linear-gradient(180deg, var(--sw) 0 40%, var(--sw2) 40% 100%);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.3), inset 0 -8px 10px -6px var(--sw3);
}
.toggle { display: flex; align-items: center; gap: 12px; margin-top: 16px; cursor: pointer; font-size: 15px; line-height: 1.35; }
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle .track { flex: 0 0 auto; width: 46px; height: 28px; border-radius: 999px; background: #cfc6b8; position: relative; transition: background 0.25s; }
.toggle .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); transition: transform 0.25s var(--ease); }
.toggle input:checked + .track { background: var(--wine); }
.toggle input:checked + .track::after { transform: translateX(18px); }
.toggle input:focus-visible + .track { outline: 2px solid var(--wine); outline-offset: 2px; }

/* ---------------------------------------------------------------- toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(86px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(10px);
  z-index: 15;
  background: rgba(250, 238, 214, 0.96);
  color: #2b1d12;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 14px;
  width: max-content;
  max-width: min(90vw, 460px);
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ------------------------------------------------------- small screens */
@media (max-height: 680px) {
  .top { padding-top: 6px; }
  .brand small { display: none; }
  .brand b { font-size: 19px; }
  .stat b { font-size: 16px; }
  .stat { padding: 3px 6px; }
  .actions { padding-bottom: 10px; }
  .btn { padding: 9px 8px; }
  .wt-card { padding: 16px 16px 14px; }
  .wt-card h2 { font-size: 22px; }
}
@media (max-width: 560px) {
  .actions { gap: 6px; padding-left: 10px; padding-right: 10px; }
  .actions .btn { flex-direction: column; gap: 3px; padding: 8px 2px 7px; font-size: 12px; }
  .actions .btn svg { width: 21px; height: 21px; }
  .brand b { font-size: 18px; }
  .brand img { width: 36px; height: 36px; }
  .stage { padding: 4px 8px; }
}
@media (max-width: 420px) {
  .top { padding-left: 12px; padding-right: 8px; }
  .brand { gap: 8px; }
  .brand img { width: 32px; height: 32px; }
  .brand b { font-size: 16.5px; letter-spacing: 0; }
  html[lang="es"] .brand b { font-size: 14.2px; letter-spacing: -0.01em; }
  .icon-btn { width: 38px; height: 38px; }
  .stats { gap: 6px; padding-left: 12px; padding-right: 12px; }
  .wt-node .wt-ntitle { display: none; }
}
@media (min-width: 900px) and (min-height: 700px) {
  .brand b { font-size: 25px; }
  .stage { padding: 10px 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .bg .blob, .wt-light, .wt-flame, .wt-flame::after, .wt-body, .wt-lantern, .wt-halo, .wt-glint, .wt-head, .wt-zzz text, .wt-tail, .wt-float, .wt-sparkle, .wt-eyes, .wt-flick, .wt-drip, .wt-exit svg, .wt-exit.wt-on, .wt-hintmark { animation: none !important; }
  .wt-sprite, .wt-gate-leaf, .wt-warm { transition-duration: 0.01s !important; }
  .wt-fig { animation: none !important; }
  .sheet, .dialog, .backdrop, .wt-card, .wt-intro, .wt-caught, .wt-say, .wt-alert, .wt-stars svg.wt-lit, .wt-hic { animation: none !important; }
  .wt-zzz text:first-child { opacity: 0.8; }
}

/* The symbol sprite must stay rendered (not display:none), or its gradients vanish. */
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
