:root {
  --cream: #fff6e9;
  --paper: #ffffff;
  --ink: #1d1b3a;
  --muted: #5d5a7a;
  --coral: #ff5a4e;
  --coral-dark: #d93a2f;
  --sun: #ffc93c;
  --line: #ecdcc4;
  --radius: 18px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--cream);
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  line-height: 1.5;
  background:
    radial-gradient(circle at 12% 8%, rgba(255, 201, 60, .35), transparent 40%),
    radial-gradient(circle at 92% 90%, rgba(255, 90, 78, .18), transparent 45%),
    var(--cream);
}

.top {
  padding: 20px 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -.01em;
}

.brand b { color: var(--coral-dark); }

main {
  flex: 1;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 4vh 16px 40px;
}

.card {
  width: 100%;
  max-width: 680px;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: 8px 8px 0 var(--ink);
  padding: clamp(22px, 5vw, 44px);
}

h1 {
  font-size: clamp(1.6rem, 4.4vw, 2.5rem);
  line-height: 1.15;
  letter-spacing: -.02em;
  margin: 0 0 14px;
}

h1 em {
  font-style: normal;
  background: linear-gradient(transparent 60%, var(--sun) 60%);
}

.lede {
  color: var(--muted);
  font-size: 1.05rem;
  margin: 0 0 24px;
}

textarea, input[type="text"] {
  width: 100%;
  font: inherit;
  font-size: 1.1rem;
  color: var(--ink);
  background: var(--cream);
  border: 2px solid var(--ink);
  border-radius: 12px;
  padding: 14px 16px;
}

textarea {
  resize: vertical;
  min-height: 64px;
  max-height: 260px;
}

textarea:focus, input:focus, .btn:focus-visible, a:focus-visible {
  outline: 3px solid var(--coral);
  outline-offset: 2px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font: inherit;
  font-weight: 700;
  font-size: 1rem;
  padding: 12px 20px;
  border-radius: 12px;
  border: 2px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: transform .08s ease, box-shadow .08s ease;
  box-shadow: 3px 3px 0 var(--ink);
}

.btn:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--ink); }
.btn:active, .btn.pressed { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--ink); }

.btn-primary { background: var(--coral); color: #fff; }
.btn-primary:hover { background: var(--coral-dark); }
.btn-ghost { box-shadow: none; border-color: transparent; text-decoration: underline; }
.btn-ghost:hover { box-shadow: none; transform: none; }

#make-form { display: grid; gap: 14px; }
#make-form .btn { justify-self: start; }

.error {
  margin: 0;
  color: var(--coral-dark);
  font-weight: 600;
}

.result {
  margin-top: 28px;
  padding-top: 22px;
  border-top: 2px dashed var(--line);
}

.result label { display: block; font-weight: 700; margin-bottom: 8px; }

.share-row { display: flex; gap: 10px; }
.share-row input { flex: 1; min-width: 0; font-size: 1rem; }

.share-meta { margin: 10px 0 0; display: flex; gap: 14px; flex-wrap: wrap; }
.share-meta a { color: var(--coral-dark); font-weight: 700; }
#copy-status { color: var(--muted); }

.player .step {
  font-weight: 700;
  margin: 0 0 14px;
  min-height: 1.5em;
}

.ask-box {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.fake-input {
  flex: 1;
  min-width: 0;
  min-height: 56px;
  max-height: 168px;
  overflow: hidden;
  font-size: 1.1rem;
  background: var(--cream);
  border: 2px solid var(--ink);
  border-radius: 12px;
  padding: 13px 16px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  transition: box-shadow .2s ease;
}

.fake-input.focused { box-shadow: 0 0 0 4px rgba(255, 90, 78, .35); }

.caret {
  display: inline-block;
  width: 2px;
  height: 1.15em;
  margin-left: 1px;
  vertical-align: text-bottom;
  background: var(--ink);
  visibility: hidden;
}

.fake-input.focused .caret {
  visibility: visible;
  animation: blink 1s steps(1) infinite;
}

@keyframes blink { 50% { opacity: 0; } }

.roast {
  margin: 26px 0 0;
  font-size: clamp(1.3rem, 3.6vw, 1.75rem);
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: -.01em;
  animation: pop .35s cubic-bezier(.2, 1.4, .4, 1);
}

@keyframes pop {
  from { opacity: 0; transform: scale(.92) translateY(6px); }
  to { opacity: 1; transform: none; }
}

.send-note {
  margin: 12px 0 0;
  padding: 8px 12px;
  border-left: 4px solid var(--sun);
  background: rgba(255, 201, 60, .14);
  border-radius: 0 8px 8px 0;
  font-weight: 600;
  font-size: .98rem;
}

.ts-box:empty { display: none; }
.ts-box { margin: 18px 0 0; }

.loading {
  margin: 18px 0 0;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-weight: 600;
}
.dots { display: inline-flex; gap: 5px; }
.dots i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--coral);
  animation: bounce 1s ease-in-out infinite;
}
.dots i:nth-child(2) { animation-delay: .15s; }
.dots i:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 80%, 100% { transform: translateY(0); opacity: .5; } 40% { transform: translateY(-6px); opacity: 1; } }

.answer {
  margin: 22px 0 0;
  padding: 16px 18px;
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 14px;
  box-shadow: 5px 5px 0 var(--sun);
  animation: pop .35s cubic-bezier(.2, 1.4, .4, 1);
}
.answer-label {
  margin: 0 0 6px;
  font-size: .8rem;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--coral-dark);
}
.answer-label a { color: var(--ink); text-transform: none; letter-spacing: 0; }
.answer-text {
  margin: 0;
  font-size: 1.08rem;
  white-space: pre-line;
  overflow-wrap: anywhere;
}
.answer-text a { color: var(--coral-dark); font-weight: 700; }
.answer.kind { box-shadow: 5px 5px 0 var(--line); }
.answer.kind .answer-label { color: var(--ink); }
.answer.fallback { box-shadow: 5px 5px 0 var(--coral); }

.prose h2 { margin: 26px 0 6px; font-size: 1.15rem; }
.prose p { margin: 0 0 10px; }
.prose a:not(.btn) { color: var(--coral-dark); font-weight: 700; }
.prose .btn { margin-top: 14px; }
.prose ul { margin: 0 0 10px; padding-left: 1.25em; }
.prose li { margin: 0 0 6px; }
.prose li::marker { color: var(--coral-dark); }
.tldr {
  margin: 22px 0 8px;
  padding: 16px 18px 8px;
  background: #fff3d6;
  border: 2px solid var(--ink);
  border-radius: 14px;
}
.tldr-label {
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .06em;
  font-size: .8rem;
  color: var(--coral-dark);
}
.prose .updated { margin-top: 22px; color: var(--muted); font-size: .9rem; }

.player-actions {
  margin-top: 26px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.fake-cursor {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 10;
  pointer-events: none;
  filter: drop-shadow(1px 2px 1px rgba(0, 0, 0, .2));
}

.lost { text-align: left; }
.big-404 {
  margin: 0;
  font-size: clamp(4rem, 14vw, 7rem);
  font-weight: 900;
  line-height: 1;
  color: var(--coral);
  -webkit-text-stroke: 2px var(--ink);
}

.foot {
  text-align: center;
  padding: 18px 16px 28px;
  color: var(--muted);
  font-size: .9rem;
}
.foot p { margin: 0; }
.foot p + p { margin-top: 6px; }
.foot a { color: var(--muted); font-weight: 600; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

[hidden] { display: none !important; }

@media (max-width: 520px) {
  .top { padding: 16px; }
  .brand { font-size: 1rem; }
  .card { box-shadow: 5px 5px 0 var(--ink); }
  .share-row { flex-direction: column; }
  .ask-box { flex-direction: column; }
  .ask-box .btn { align-self: flex-end; }
  #make-form .btn { justify-self: stretch; }
}

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

.levels { border: 0; margin: 0; padding: 0; min-width: 0; }
.levels legend { font-weight: 700; padding: 0; margin-bottom: 8px; }
.level-pick { display: inline-flex; border: 2px solid var(--ink); border-radius: 12px; overflow: hidden; background: var(--paper); }
.level-pick label { position: relative; cursor: pointer; }
.level-pick label + label { border-left: 2px solid var(--ink); }
.level-pick input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.level-pick span { display: block; padding: 8px 16px; font-weight: 700; }
.level-pick input:checked + span { background: var(--ink); color: var(--cream); }
.level-pick input[value="savage"]:checked + span { background: var(--coral); color: #fff; }
.level-pick input[value="gentle"]:checked + span { background: var(--sun); color: var(--ink); }
.level-pick input:focus-visible + span { outline: 3px solid var(--coral); outline-offset: -5px; }

.share-label { margin: 18px 0 8px; font-weight: 700; }
.share-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.sbtn {
  display: inline-flex; align-items: center; gap: 6px;
  font: inherit; font-weight: 700; font-size: .95rem;
  padding: 8px 12px; border: 2px solid var(--ink); border-radius: 10px;
  background: var(--paper); color: var(--ink); text-decoration: none; cursor: pointer;
  box-shadow: 2px 2px 0 var(--ink); transition: transform .08s ease, box-shadow .08s ease;
}
.sbtn:hover { transform: translate(-1px, -1px); box-shadow: 3px 3px 0 var(--ink); background: #fff3d6; }
.sbtn:active { transform: translate(2px, 2px); box-shadow: 0 0 0 var(--ink); }
.sbtn:focus-visible { outline: 3px solid var(--coral); outline-offset: 2px; }
.sbtn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

.btn-sun { background: var(--sun); }
.btn-sun:hover { background: #ffb800; }
.your-turn { margin-top: 18px; width: 100%; font-size: 1.1rem; padding: 14px 20px; animation: pop .35s cubic-bezier(.2, 1.4, .4, 1); }

.qr-dialog {
  border: 2px solid var(--ink); border-radius: var(--radius); box-shadow: 8px 8px 0 var(--ink);
  padding: 24px; max-width: min(420px, calc(100vw - 32px)); background: var(--paper); color: var(--ink); text-align: center;
}
.qr-dialog::backdrop { background: rgba(29, 27, 58, .55); }
.qr-dialog h2 { margin: 0 0 4px; font-size: 1.25rem; }
.qr-sub { margin: 0 0 14px; color: var(--muted); }
.qr-dialog canvas { width: 100%; max-width: 300px; height: auto; aspect-ratio: 1; border: 2px solid var(--line); border-radius: 10px; image-rendering: pixelated; }
.qr-actions { margin-top: 14px; display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

.req-form { display: grid; gap: 16px; }
.req-form label { font-weight: 700; display: block; margin-bottom: 6px; }
.req-form .opt { font-weight: 400; color: var(--muted); }
.req-form textarea, .req-form input[type="text"] { font-size: 1rem; }
.req-form .hint { margin: 6px 0 0; color: var(--muted); font-size: .9rem; }
.req-form .btn { justify-self: start; }
.req-done { padding: 16px 18px; border: 2px solid var(--ink); border-radius: 14px; background: #fff3d6; font-weight: 600; }

@media (max-width: 520px) {
  .level-pick { display: flex; }
  .level-pick label { flex: 1; text-align: center; }
  .level-pick span { padding: 8px 6px; }
  .sbtn { flex: 1 1 calc(33% - 8px); justify-content: center; padding: 8px 6px; }
  .req-form .btn { justify-self: stretch; }
}
