/* Build a Biscuit */
:root {
  --paper: #fff4e2;
  --paper-2: #ffe8c7;
  --card: #fffaf1;
  --ink: #3b2416;
  --ink-2: #6b4a33;
  --muted: #7a5b45;
  --accent: #c8452b;
  --accent-2: #e8755a;
  --gold: #e9b66e;
  --mint: #7fb6a8;
  --blue: #4f7cc0;
  --ring: #2c6fd1;
  --radius: 18px;
  --shadow: 0 2px 0 var(--ink), 0 10px 24px rgba(59, 36, 22, 0.12);
  --font: ui-rounded, "SF Pro Rounded", "Segoe UI Rounded", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: Georgia, "Times New Roman", Times, serif;
  color-scheme: light;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh;
  font-family: var(--font); color: var(--ink); line-height: 1.45;
  background:
    radial-gradient(circle at 20% 10%, rgba(255, 255, 255, 0.7), transparent 40%),
    radial-gradient(rgba(200, 120, 60, 0.09) 1.5px, transparent 1.6px) 0 0 / 22px 22px,
    var(--paper);
  display: flex; flex-direction: column;
}
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: 12px; top: -60px; background: var(--ink); color: var(--paper); padding: 10px 14px; border-radius: 10px; z-index: 10; }
.skip:focus { top: 12px; }
:focus-visible { outline: 3px solid var(--ring); outline-offset: 3px; }
button { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

/* header */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px clamp(16px, 4vw, 40px) 4px; max-width: 1200px; width: 100%; margin: 0 auto; }
.logo { margin: 0; font-size: clamp(1.5rem, 4.5vw, 2.2rem); font-weight: 900; letter-spacing: -0.02em; display: flex; align-items: center; gap: 10px; }
.logo em { font-style: normal; color: var(--accent); display: inline-block; transform: rotate(-3deg); }
.logo-b { width: 1.3em; height: 1.3em; border-radius: 50%; background: radial-gradient(circle at 30% 35%, var(--ink) 0 6%, transparent 7%), radial-gradient(circle at 68% 35%, var(--ink) 0 6%, transparent 7%), radial-gradient(circle at 50% 68%, var(--ink) 0 6%, transparent 7%), radial-gradient(circle at 35% 30%, #f6cf8f, var(--gold) 60%, #c98d47); border: 3px solid var(--ink); box-shadow: 0 3px 0 #c98d47; animation: bob 4s ease-in-out infinite; }
@keyframes bob { 0%, 100% { transform: rotate(-8deg) translateY(0); } 50% { transform: rotate(8deg) translateY(-2px); } }

.chip { display: inline-flex; align-items: center; gap: 8px; border: 2px solid var(--ink); background: var(--card); border-radius: 999px; padding: 8px 14px; cursor: pointer; font-weight: 700; font-size: 0.9rem; box-shadow: 0 2px 0 var(--ink); transition: transform 0.12s; }
.chip:active { transform: translateY(2px); box-shadow: 0 0 0 var(--ink); }
.sound-icon { width: 18px; height: 14px; position: relative; display: inline-block; }
.sound-icon::before { content: ""; position: absolute; left: 0; top: 3px; width: 7px; height: 8px; background: var(--ink); clip-path: polygon(0 25%, 45% 25%, 100% 0, 100% 100%, 45% 75%, 0 75%); }
.sound-icon::after { content: ""; position: absolute; left: 9px; top: 6px; width: 9px; height: 2.5px; background: var(--accent); transform: rotate(45deg); box-shadow: 0 0 0 0 var(--accent); }
.chip[aria-pressed="true"] .sound-icon::after { width: 5px; height: 8px; top: 3px; background: none; border: 2.5px solid var(--ink); border-left: 0; border-radius: 0 8px 8px 0; transform: none; }

/* progress */
.progress { max-width: 1200px; width: 100%; margin: 0 auto; padding: 8px clamp(16px, 4vw, 40px); }
.progress ol { list-style: none; margin: 0; padding: 0; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.progress li > * { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px 5px 5px; border-radius: 999px; border: 2px solid transparent; background: none; font-size: 0.85rem; font-weight: 700; color: var(--muted); white-space: nowrap; }
.progress li > button { cursor: pointer; }
.progress li > button:hover { border-color: rgba(59, 36, 22, 0.2); }
.progress .dot { width: 24px; height: 24px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 0.75rem; border: 2px solid currentColor; }
.progress li.done > * { color: var(--ink-2); }
.progress li.done .dot { background: var(--gold); color: var(--ink); border-color: var(--ink); }
.progress li.current > * { color: var(--ink); border-color: var(--ink); background: var(--card); }
.progress li.current .dot { background: var(--accent); color: #fff; border-color: var(--ink); }

main { flex: 1; width: 100%; max-width: 1200px; margin: 0 auto; padding: 8px clamp(16px, 4vw, 40px) 24px; }
.screen { animation: rise 0.35s ease-out both; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* builder */
.build-grid { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: clamp(16px, 3vw, 40px); align-items: start; }
.stage { position: sticky; top: 12px; }
.stage-card { background: linear-gradient(#ffe3bc, #ffd6a3); border: 3px solid var(--ink); border-radius: 28px; box-shadow: var(--shadow); padding: 8px; overflow: hidden; position: relative; }
.stage-card::after { content: ""; position: absolute; inset: auto 0 0 0; height: 26%; background: repeating-linear-gradient(90deg, rgba(200, 69, 43, 0.12) 0 18px, transparent 18px 36px); pointer-events: none; }
#preview { display: block; width: 100%; height: auto; position: relative; z-index: 1; }
.desc { margin: 12px 4px 0; font-size: 0.98rem; color: var(--ink-2); min-height: 3em; }
.kicker { margin: 0 0 2px; text-transform: uppercase; letter-spacing: 0.14em; font-size: 0.75rem; font-weight: 800; color: var(--accent); }
.step-title { margin: 0; font-size: clamp(1.6rem, 4vw, 2.4rem); line-height: 1.1; font-weight: 900; letter-spacing: -0.02em; }
.step-title:focus { outline: none; }
.step-title:focus-visible { outline: none; }
.hint { margin: 6px 0 14px; color: var(--ink-2); }
.options { border: 0; margin: 0; padding: 0; min-width: 0; }
.option-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.opt { position: relative; display: block; cursor: pointer; }
.opt input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.opt-card { display: flex; align-items: center; gap: 10px; padding: 8px 12px 8px 6px; border: 2px solid rgba(59, 36, 22, 0.25); border-radius: var(--radius); background: var(--card); min-height: 76px; transition: transform 0.15s cubic-bezier(.3, 1.6, .5, 1), border-color 0.15s, background 0.15s, box-shadow 0.15s; position: relative; }
.opt:hover .opt-card { transform: translateY(-2px) rotate(-0.4deg); border-color: var(--ink); }
.opt input:checked + .opt-card { border-color: var(--ink); background: #fff0d6; box-shadow: 0 3px 0 var(--ink); transform: translateY(-2px); }
.opt input:focus-visible + .opt-card { outline: 3px solid var(--ring); outline-offset: 2px; }
.thumb { width: 64px; height: 64px; flex: none; transition: transform 0.25s cubic-bezier(.3, 1.8, .5, 1); }
.opt input:checked + .opt-card .thumb { transform: scale(1.1) rotate(-6deg); }
.opt-text { display: flex; flex-direction: column; min-width: 0; }
.opt-name { font-weight: 800; font-size: 1rem; }
.opt-blurb { font-size: 0.82rem; color: var(--muted); line-height: 1.25; }
.tick { position: absolute; top: 8px; right: 8px; width: 22px; height: 22px; border-radius: 50%; border: 2px solid rgba(59, 36, 22, 0.3); }
.opt input:checked + .opt-card .tick { background: var(--accent); border-color: var(--ink); }
.opt input:checked + .opt-card .tick::after { content: ""; position: absolute; left: 6px; top: 2px; width: 5px; height: 10px; border: solid #fff; border-width: 0 3px 3px 0; transform: rotate(45deg); }
.option-grid:not(.multi) .tick { border-radius: 50%; }
.multi .tick { border-radius: 6px; }

.nav { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; align-items: center; }
.nav.column { flex-direction: column; align-items: stretch; }
.btn { border: 2.5px solid var(--ink); border-radius: 999px; padding: 12px 20px; font-weight: 800; font-size: 1rem; cursor: pointer; background: var(--card); box-shadow: 0 3px 0 var(--ink); transition: transform 0.1s, box-shadow 0.1s, background 0.15s; touch-action: manipulation; }
.btn:hover:not(:disabled) { background: #fff; transform: translateY(-1px); box-shadow: 0 4px 0 var(--ink); }
.btn:active:not(:disabled), .btn.down { transform: translateY(3px); box-shadow: 0 0 0 var(--ink); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: #fff; margin-left: auto; }
.btn.primary:hover:not(:disabled) { background: #b23b23; }
.nav.column .btn.primary { margin-left: 0; }
.btn.ghost { background: transparent; }
.linkish { background: none; border: 0; padding: 8px 0; margin-top: 10px; cursor: pointer; font-weight: 700; color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; }

/* dunk */
.dunk-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr); gap: clamp(16px, 3vw, 40px); align-items: center; }
.dunk-stage { position: relative; }
#dunk { display: block; width: 100%; height: auto; max-height: 72vh; object-fit: contain; border: 3px solid var(--ink); border-radius: 28px; box-shadow: var(--shadow); background: #ffe8c7; touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.dunking #dunk { cursor: grabbing; }
.dunk-tip { margin: 8px 0 0; text-align: center; font-size: 0.85rem; color: var(--muted); }
.meter-wrap { background: var(--card); border: 2px solid var(--ink); border-radius: var(--radius); padding: 14px 16px; margin: 6px 0 16px; box-shadow: 0 3px 0 var(--ink); }
.meter-head { display: flex; justify-content: space-between; font-weight: 800; }
.meter { height: 22px; border: 2.5px solid var(--ink); border-radius: 999px; background: repeating-linear-gradient(90deg, #fff 0 10px, #fff6e9 10px 20px); margin: 8px 0 4px; overflow: hidden; position: relative; }
.meter::after { content: ""; position: absolute; left: 38%; width: 37%; top: 0; bottom: 0; border-left: 2px dashed rgba(59, 36, 22, 0.35); border-right: 2px dashed rgba(59, 36, 22, 0.35); pointer-events: none; }
.meter-fill { --hue: 40; height: 100%; width: 0%; background: linear-gradient(90deg, #e9b66e, hsl(calc(var(--hue) * 1deg) 70% 45%)); border-right: 2.5px solid var(--ink); transition: width 0.1s linear; }
.meter-scale { display: flex; justify-content: space-between; font-size: 0.75rem; color: var(--muted); font-weight: 700; }
.soggy-word { margin: 8px 0 0; display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.dunk-status { margin: 8px 0 0; font-weight: 800; color: var(--accent); min-height: 1.4em; }
.dunk-status:empty { display: none; }
.hold, .hold:hover:not(:disabled) { background: var(--mint); }
.hold.down { background: #6aa596 !important; }
.hold { width: 100%; padding: 20px; font-size: 1.2rem; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: none; }
.hold kbd { font: inherit; font-size: 0.75rem; border: 2px solid var(--ink); border-radius: 6px; padding: 1px 6px; margin-left: 6px; background: var(--card); vertical-align: middle; }

/* certificate */
.cert-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 0.8fr); gap: clamp(16px, 3vw, 40px); align-items: start; }
#cert { display: block; width: 100%; height: auto; max-width: min(560px, calc((100vh - 150px) * 0.75)); margin: 0 auto; border-radius: 14px; box-shadow: var(--shadow); animation: present 0.6s cubic-bezier(.2, 1.4, .4, 1) both; }
@keyframes present { from { transform: rotate(-6deg) scale(0.85); opacity: 0; } to { transform: rotate(-1deg); opacity: 1; } }
.cert-facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 14px 0; background: var(--card); border: 2px solid var(--ink); border-radius: var(--radius); padding: 14px 16px; }
.cert-facts dt { font-weight: 800; }
.cert-facts dd { margin: 0; }
.verdict { font-family: var(--serif); font-style: italic; font-size: 1.25rem; margin: 0; }

.foot { text-align: center; padding: 16px; font-size: 0.85rem; color: var(--muted); }
.foot a { color: var(--ink-2); font-weight: 700; }

@media (max-width: 820px) {
  .top { padding-top: 10px; }
  .build-grid, .dunk-grid, .cert-grid { grid-template-columns: 1fr; }
  .build-grid { gap: 10px; }
  .stage { position: sticky; top: 0; z-index: 3; background: var(--paper); padding: 4px 4px 8px; margin: 0 -4px; box-shadow: 0 10px 12px -10px rgba(59, 36, 22, 0.25); }
  .stage-card { border-radius: 22px; padding: 2px; }
  #preview { max-height: 25vh; width: auto; max-width: 100%; margin: 0 auto; }
  .desc { min-height: 0; margin-top: 6px; font-size: 0.82rem; text-align: center; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .plabel { display: none; }
  .progress li.current .plabel { display: inline; }
  .progress ol { justify-content: flex-start; gap: 2px; }
  .progress li > * { padding: 3px 8px 3px 3px; }
  .step-title { font-size: 1.5rem; }
  .hint { margin: 2px 0 10px; font-size: 0.9rem; }
  .option-grid { gap: 8px; }
  .opt-card { gap: 8px; padding: 6px 8px 6px 4px; min-height: 60px; }
  .thumb { width: 48px; height: 48px; }
  .opt-name { font-size: 0.92rem; line-height: 1.15; }
  .opt-blurb { font-size: 0.72rem; }
  .tick { width: 16px; height: 16px; top: 5px; right: 5px; }
  .opt input:checked + .opt-card .tick::after { left: 3px; top: 0; width: 4px; height: 8px; border-width: 0 2.5px 2.5px 0; }
  #screen-build .nav { position: sticky; bottom: 0; background: linear-gradient(rgba(255, 244, 226, 0), var(--paper) 35%); padding: 14px 0 calc(10px + env(safe-area-inset-bottom)); margin-top: 6px; z-index: 2; }
  .btn { padding: 11px 16px; }
  #dunk { max-height: 46vh; width: auto; max-width: 100%; margin: 0 auto; }
  .dunk-tip { margin-top: 4px; }
  .dunk-side { display: flex; flex-direction: column; }
  .dunk-side .step-title, .dunk-side .kicker, .dunk-side .hint { display: none; }
  .dunk-side .meter-wrap { order: 2; margin: 0 0 10px; padding: 10px 14px; }
  .dunk-side .hold { order: 1; margin-bottom: 10px; padding: 16px; }
  .dunk-side .nav { order: 3; margin-top: 4px; flex-wrap: nowrap; }
  .dunk-side .nav .btn { flex: 1; padding: 11px 10px; font-size: 0.92rem; }
  .dunk-side .linkish { order: 4; align-self: flex-start; }
  .hold kbd { display: none; }
  #cert { max-width: 420px; }
}
@media (max-width: 380px) {
  .option-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .opt-name { font-size: 0.9rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}
@media (forced-colors: active) {
  .opt input:checked + .opt-card { outline: 3px solid Highlight; }
}
