/* ---- What I built, and what's next ---- */
.built li { padding: 0.55rem 0; border-top: 1px solid var(--hair); }
.built li:last-child { border-bottom: 1px solid var(--hair); }
.built strong { font-weight: 700; margin-right: 0.35em; color: var(--accent-text); }
.built-note { margin-top: 0.8rem; }
.chapter--built .actions { margin-top: 1.6rem; }
.bars { margin: 1.2rem 0 0; }
.bars figcaption { color: var(--ivory); font-weight: 600; font-size: 0.9375rem; margin-bottom: 0.6rem; }
.bars ul { display: grid; grid-template-columns: 1fr 1fr; column-gap: 2rem; }
.bars li { display: grid; grid-template-columns: 5.6rem 1fr 3ch; align-items: center; gap: 0.7rem; padding: 0.3rem 0; }
.b-name { font-size: 0.9375rem; color: var(--ivory); }
.b-bar { display: block; height: 0.75rem; background: rgba(var(--ivory-rgb), 0.07); border-radius: 2px; overflow: hidden; }
.b-bar i { display: block; height: 100%; width: calc(var(--v) / 160 * 100%); background: var(--ivory); opacity: 0.86; transform-origin: 0 50%; transform: scaleX(var(--grow, 1)); }
.bars li[style*="--v:152"] .b-bar i { background: var(--noodle); opacity: 1; }
.b-val { text-align: right; font-weight: 650; font-size: 0.9375rem; }
.bars-note { margin-top: 0.9rem; max-width: 34rem; }
@media (max-width: 520px) {
  .bars ul { grid-template-columns: 1fr; }
  .bars li { grid-template-columns: 6.2rem 1fr 3ch; gap: 0.6rem; }
}

/* ---- Sandbox ---- */
.sandbox-row { display: flex; align-items: flex-start; gap: 1.5rem; margin: 1.6rem 0 0.9rem; }
.picker-wrap { flex: none; }
.picker-arm { text-align: center; font-size: var(--fs-micro); color: var(--dim); margin: 0 0 0.5rem; max-width: none !important; padding-bottom: 0.4rem; border-bottom: 1px solid var(--hair); margin-bottom: 0.6rem; }
.picker { display: grid; grid-template-columns: repeat(3, 4.5rem); gap: 0.5rem; }
.cell-btn {
  aspect-ratio: 1; display: grid; place-items: center; border-radius: 4px; font-stretch: 100%; font-weight: 700; font-size: 1.05rem;
  color: var(--ivory); background: linear-gradient(rgba(var(--trained-rgb), 0.18), rgba(var(--trained-rgb), 0.18)), rgba(var(--veil-rgb), 0.85); box-shadow: inset 0 0 0 1px rgba(var(--trained-rgb), 0.6);
  font-variant-numeric: tabular-nums; transition: background-color 0.25s, transform 0.25s var(--ease-out), opacity 0.25s;
}
.cell-btn:hover:not([aria-disabled="true"]) { background: linear-gradient(rgba(var(--trained-rgb), 0.34), rgba(var(--trained-rgb), 0.34)), rgba(var(--veil-rgb), 0.85); transform: translateY(-2px); }
.cell-btn--held { color: var(--held-text); background: linear-gradient(rgba(var(--held-rgb), 0.18), rgba(var(--held-rgb), 0.18)), rgba(var(--veil-rgb), 0.88); box-shadow: inset 0 0 0 1px var(--held); }
.cell-btn--held:hover:not([aria-disabled="true"]) { background: linear-gradient(rgba(var(--held-rgb), 0.34), rgba(var(--held-rgb), 0.34)), rgba(var(--veil-rgb), 0.88); }
.cell-btn.is-running { background: var(--noodle); color: var(--on-accent); box-shadow: none; }
.cell-btn[aria-disabled="true"] { cursor: progress; opacity: 0.45; }
.cell-btn.is-running[aria-disabled="true"] { opacity: 1; }
.no-webgl .cell-btn[aria-disabled="true"] { cursor: not-allowed; }
.picker-status { min-height: 1.6em; color: var(--ivory); font-weight: 600; font-variant-numeric: tabular-nums; }
.save-btn { margin-top: 1rem; min-height: 2.75rem; }
.disclaimer {
  margin-top: 1.4rem; padding: 0.15rem 0 0.15rem 1.1rem; border-left: 3px solid var(--noodle);
  font-size: 1rem; line-height: 1.55; color: var(--ivory);
}

/* ---- Limits list + footer ---- */
.limits li { padding: 1rem 0; border-top: 1px solid var(--hair); }
.limits li:last-child { border-bottom: 1px solid var(--hair); }
.footer {
  position: relative; z-index: 1; margin: 0; padding: 3rem var(--gutter) 3.5rem;
  font-size: 0.875rem; color: var(--dim); display: grid; gap: 0.35rem;
}
.footer::before { /* soft feathered veil behind the credits, same column as the panels above */
  content: ""; position: absolute; inset: 0 auto 0 0; width: 62%; z-index: -1; pointer-events: none;
  background: rgba(var(--veil-rgb), 0.55); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  -webkit-mask-image: linear-gradient(to right, #000 55%, transparent); mask-image: linear-gradient(to right, #000 55%, transparent);
}
.footer p { margin: 0; }
.footer-name { color: var(--ivory); font-stretch: 100%; font-weight: 700; font-size: 1.125rem; margin-bottom: 0.4rem !important; }
.footer a { color: var(--ivory); }
@media (max-width: 820px), (orientation: portrait) and (max-width: 1100px) {
  /* Sandbox on phones: the top ~45svh is a clear window onto the 3D scene; the controls live in a bottom sheet below it */
  #sandbox { min-height: 100svh; padding: 0; align-items: flex-end; overflow: clip; }
  #sandbox .panel {
    display: flex; flex-direction: column; position: relative; width: 100%;
    max-height: 56svh; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
    padding: 1.1rem var(--gutter) calc(env(safe-area-inset-bottom, 0px) + 1.4rem);
    background: linear-gradient(to bottom, rgba(var(--veil-rgb), 0.86), rgba(var(--veil-rgb), 0.94) 2.5rem);
    border-radius: 1.1rem 1.1rem 0 0; box-shadow: 0 -1px 0 var(--hair), 0 -18px 40px -20px var(--shadow);
    -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  }
  #sandbox .display { order: 0; font-size: 1.35rem; margin-bottom: 0.4rem; }
  #sandbox .sandbox-row { order: 1; margin: 0.2rem 0 0.4rem; }
  #sandbox .picker-wrap { display: block; margin: 0; width: 100%; }
  #sandbox .sandbox-row { align-items: stretch; }
  #sandbox .picker-arm { margin: 0 0 0.35rem; padding-bottom: 0.25rem; }
  #sandbox .picker-status { order: 2; font-size: 0.9375rem; }
  #sandbox .disclaimer { order: 3; margin-top: 0.4rem; font-size: 0.8125rem; line-height: 1.45; }
  #sandbox .save-btn { order: 4; align-self: flex-start; margin-top: 0.7rem; }
  #sandbox .sandbox-intro { order: 5; margin-top: 0.9rem; font-size: 0.875rem; line-height: 1.45; color: var(--caption); }
  #sandbox .cell-btn { aspect-ratio: auto; min-height: 2.6rem; height: 2.6rem; font-size: 0.95rem; }
  #sandbox .picker { gap: 0.4rem; }
  .picker { grid-template-columns: repeat(3, 1fr); gap: 0.5rem; }
  .cell-btn { aspect-ratio: 1.5; min-height: 3.25rem; }
}

@media (max-width: 820px), (orientation: portrait) and (max-width: 1100px) { /* phones: panels carry their own scrim, so the veil spans the width */
  .footer::before { width: 100%; -webkit-mask-image: none; mask-image: none; background: rgba(var(--veil-rgb), 0.8); }
}

/* ---- Sandbox coach mark: sits over the 3D table, above the stage's ghost target ---- */
.place-hint { position: fixed; left: 0; top: 0; z-index: 12; pointer-events: none; will-change: transform; }
.place-hint[hidden] { display: none; }
.no-stage .place-hint, .no-webgl .place-hint { display: none; }
.place-hint__pill {
  --caret-x: 0px;
  position: absolute; left: 0; bottom: 0; width: max-content; max-width: min(22rem, calc(100vw - 24px));
  transform: translate(-50%, 0); transform-origin: 50% 100%;
  display: flex; align-items: center; gap: 0.7rem; padding: 0.55rem 0.95rem 0.55rem 0.7rem;
  border-radius: 999px; pointer-events: none;
  background: linear-gradient(rgba(var(--noodle-rgb), 0.07), rgba(var(--noodle-rgb), 0.07)), rgba(var(--veil-rgb), 0.72);
  -webkit-backdrop-filter: blur(14px) saturate(1.3); backdrop-filter: blur(14px) saturate(1.3);
  box-shadow: inset 0 0 0 1px rgba(var(--noodle-rgb), 0.5), 0 10px 30px -8px rgba(var(--shadow-rgb), 0.7), 0 0 26px -6px rgba(var(--noodle-rgb), 0.35);
  color: var(--ivory); font-family: 'Archivo', system-ui, sans-serif; font-stretch: 100%; font-weight: 550;
  font-size: var(--fs-caption); line-height: 1.3; opacity: 0; visibility: hidden;
}
.place-hint__pill::after { /* tail toward the target */
  content: ""; position: absolute; left: calc(50% + var(--caret-x)); bottom: -5px; width: 10px; height: 10px;
  transform: translateX(-50%) rotate(45deg); background: rgba(var(--veil-rgb), 0.9);
  box-shadow: 1px 1px 0 0 rgba(var(--noodle-rgb), 0.5); border-radius: 0 0 2px 0;
}
.place-hint__pill.is-below::after { bottom: auto; top: -5px; transform: translateX(-50%) rotate(225deg); }
.place-hint__pill.is-nocaret::after { display: none; }
.place-hint__pill.is-in { visibility: visible; animation: place-hint-in 0.7s var(--ease-out) both; }
.place-hint__text { min-width: 0; max-width: 18rem; text-wrap: balance; }
.place-hint__icon { flex: none; color: var(--noodle); overflow: visible; }
.ph-cursor { transform-origin: 9px 9px; animation: ph-tap 2.4s var(--ease-io) 0.9s infinite; }
.ph-ripple { transform-box: fill-box; transform-origin: center; opacity: 0; animation: ph-ripple 2.4s ease-out 0.9s infinite; }
.ph-ripple--2 { animation-delay: 1.15s; }
@keyframes place-hint-in { from { opacity: 0; transform: translate(-50%, 10px) scale(0.92); } to { opacity: 1; transform: translate(-50%, 0) scale(1); } }
@keyframes ph-tap { 0%, 55%, 100% { transform: translate(0, 0) scale(1); } 65% { transform: translate(-1px, -1px) scale(0.86); } 78% { transform: translate(0, 0) scale(1); } }
@keyframes ph-ripple { 0%, 60% { opacity: 0; transform: scale(0.5); } 66% { opacity: 0.9; } 100% { opacity: 0; transform: scale(2.2); } }
@media (prefers-reduced-motion: reduce) {
  .place-hint__pill.is-in { animation: none; opacity: 1; }
  .ph-cursor, .ph-ripple { animation: none; }
  .ph-ripple { opacity: 0; }
}
@media (max-width: 820px), (orientation: portrait) and (max-width: 1100px) { .place-hint__pill { max-width: min(17rem, calc(100vw - 32px)); font-size: 0.75rem; } }

/* ---- Portrait tablets (stacked layout, >= 600px wide): the phone composition with tablet-sized type and panels. Query = stacked.js isTabletStacked ---- */
@media (min-width: 600px) and (max-width: 820px) and (min-height: 700px), (orientation: portrait) and (min-width: 821px) and (max-width: 1100px) {
  #sandbox .panel { max-height: 46svh; padding-top: 1.6rem; padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 2rem); }
  #sandbox .display { font-size: 1.9rem; margin-bottom: 0.5rem; }
  #sandbox .sandbox-intro { order: 1; margin: 0 0 0.9rem; font-size: 1rem; }
  #sandbox .sandbox-row { order: 2; flex-direction: row; align-items: stretch; gap: 1.4rem; margin: 0 0 0.6rem; }
  #sandbox .picker-wrap { flex: none; width: 19rem; }
  #sandbox .sandbox-hud { flex: 1; min-width: 0; display: flex; }
  #sandbox .cell-btn { min-height: 3rem; height: 3rem; font-size: 1.0625rem; }
  #sandbox .picker { gap: 0.45rem; }
  #sandbox .picker-status { order: 3; font-size: 1.0625rem; }
  #sandbox .disclaimer { order: 4; font-size: 0.9375rem; max-width: 42rem; }
  #sandbox .save-btn { order: 5; }
  .place-hint__pill { max-width: min(22rem, calc(100vw - 48px)); font-size: 0.9375rem; }
}
