/* Pass the Pen: a two-ink risograph look. Blue and fluorescent pink printed
   slightly off-register on lilac paper, with sunflower for "your turn". */

@font-face {
  font-family: "Bricolage Grotesque";
  src: url("/bricolage.woff2") format("woff2");
  font-weight: 200 800;
  font-stretch: 75% 100%;
  font-style: normal;
  font-display: swap;
}

:root {
  --paper: #f3f1fa;
  --card: #ffffff;
  --ink: #241a4f;
  --ink-soft: #625a8a;
  --rule: #dcd7ee;
  --blue: #3157ff;
  --pink: #ff4f9a;
  --sun: #ffd23f;
  --mint: #1fbf8f;
  --orange: #ff7a3d;
  --violet: #8b5cf6;

  --font: "Bricolage Grotesque", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --radius: 18px;

  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: inherit; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font: 400 1rem/1.5 var(--font);
  font-optical-sizing: auto;
}

/* Halftone dots fading down from the top of the page */
body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto 0;
  height: 22rem;
  z-index: -1;
  pointer-events: none;
  background: radial-gradient(circle, color-mix(in srgb, var(--blue) 22%, transparent) 1.2px, transparent 1.7px) 0 0 / 13px 13px;
  -webkit-mask-image: linear-gradient(#000, transparent);
  mask-image: linear-gradient(#000, transparent);
}

.masthead, main {
  width: min(36rem, 100% - 2rem);
  margin-inline: auto;
}
.masthead { padding: 1.1rem 0 0.25rem; }

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--ink);
  text-decoration: none;
  font-weight: 800;
  font-stretch: 85%;
  font-size: 1.2rem;
  letter-spacing: -0.01em;
}
.wordmark img { display: block; border-radius: 8px; }

main {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  padding: 1.25rem 0 4rem;
}

h1, h2 { margin: 0; font-weight: 800; letter-spacing: -0.02em; }
h2 { font-size: 1.1rem; font-stretch: 90%; }
p { margin: 0; }

/* The off-register print: the signature move, used on headlines only */
.print {
  color: var(--blue);
  text-shadow: 0.06em 0.06em 0 var(--pink);
  font-stretch: 78%;
  font-size: clamp(2.2rem, 9vw, 3.1rem);
  line-height: 0.98;
  overflow-wrap: anywhere;
}
.print.giant { font-size: clamp(3.2rem, 17vw, 5.4rem); line-height: 0.9; }

.intro { display: flex; flex-direction: column; gap: 0.75rem; }
.intro p { font-size: 1.08rem; color: var(--ink-soft); max-width: 30rem; }
.hint, .note, .upnext { color: var(--ink-soft); font-size: 0.92rem; }
.center { text-align: center; }

/* Home demo: folded strips */
.demo {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.5rem 0 0.75rem;
}
.strip.mini {
  width: min(22rem, 92%);
  font-size: 0.98rem;
  padding: 0.6rem 0.9rem;
  margin-top: -0.35rem;
}
.strip.mini:nth-child(1) { --tilt: -2deg; color: transparent; text-shadow: 0 0 7px color-mix(in srgb, var(--ink) 45%, transparent); background: #e8e4f6; }
.strip.mini:nth-child(2) { --tilt: 1.4deg; z-index: 1; }
.strip.mini:nth-child(3) { --tilt: -0.8deg; background: var(--sun); }

/* Cards and forms */
.card {
  background: var(--card);
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  padding: 1.15rem;
}
.stack { display: flex; flex-direction: column; gap: 1.1rem; }
.stack.tight { gap: 0.6rem; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.9rem; align-items: end; }
.field { display: flex; flex-direction: column; gap: 0.4rem; min-width: 0; }
.field > label, legend { font-weight: 700; font-size: 0.98rem; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend { padding: 0; margin-bottom: 0.55rem; }

input[type="text"], input[type="number"], select, textarea {
  width: 100%;
  font: inherit;
  font-size: 1rem; /* 16px keeps iOS from zooming */
  color: var(--ink);
  background: #faf9ff;
  border: 2px solid var(--ink);
  border-radius: 12px;
  padding: 0.7rem 0.8rem;
  transition: box-shadow 0.15s;
}
textarea { resize: vertical; font-size: 1.12rem; line-height: 1.45; }
::placeholder { color: color-mix(in srgb, var(--ink-soft) 70%, transparent); }
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px var(--sun);
}

.inline { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; }
.inline input[type="number"] { width: 5.5rem; }
.inline select { width: auto; flex: 1; }

.choices .choice {
  display: flex;
  gap: 0.7rem;
  align-items: center;
  padding: 0.65rem 0.85rem;
  border: 2px solid var(--rule);
  border-radius: 12px;
  cursor: pointer;
  font-weight: 500;
  transition: border-color 0.15s, background-color 0.15s;
}
.choices .choice + .choice { margin-top: 0.45rem; }
.choices .choice:hover { border-color: var(--ink-soft); }
.choices .choice:has(input:checked) { border-color: var(--ink); background: var(--sun); }
.choices input { accent-color: var(--blue); margin: 0; width: 1.1rem; height: 1.1rem; flex: none; }

.counter-row { display: flex; justify-content: flex-end; margin-top: -0.7rem; }
.counter { font-size: 0.85rem; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.counter.over { color: #d0105c; font-weight: 700; }

/* Buttons: pressable, with a hard printed shadow */
button, .button {
  font: 700 1rem/1.2 var(--font);
  color: var(--ink);
  background: var(--card);
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 0.75rem 1.2rem;
  box-shadow: 3px 3px 0 var(--ink);
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  display: inline-block;
  transition: transform 0.08s, box-shadow 0.08s;
}
button:active:not(:disabled), .button:active {
  transform: translate(3px, 3px);
  box-shadow: 0 0 0 var(--ink);
}
.primary {
  width: 100%;
  background: var(--blue);
  color: #fff;
  font-size: 1.12rem;
  font-weight: 800;
  padding: 0.95rem 1.2rem;
  box-shadow: 4px 4px 0 var(--pink);
}
.primary:active:not(:disabled) { transform: translate(4px, 4px); }
a.button.primary { width: auto; align-self: stretch; }
.danger { background: var(--pink); color: var(--ink); align-self: flex-start; }
.ghost {
  background: none;
  border: 0;
  box-shadow: none;
  padding: 0.3rem 0;
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--ink-soft);
  text-decoration: underline;
  text-underline-offset: 3px;
  align-self: flex-start;
}
button:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; }
button:focus-visible, .button:focus-visible, a:focus-visible, .choice:has(input:focus-visible) {
  outline: 3px solid var(--blue);
  outline-offset: 3px;
}

/* Avatars: one ink color per person */
.avatar {
  --size: 2.4rem;
  width: var(--size);
  height: var(--size);
  flex: none;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  border: 2px solid var(--ink);
  font-weight: 800;
  font-size: calc(var(--size) * 0.45);
  line-height: 1;
  color: var(--ink);
  background: var(--card);
}
.avatar.big { --size: 3.6rem; }
.avatar.small { --size: 1.55rem; border-width: 1.5px; }
.avatar.c0 { background: var(--pink); }
.avatar.c1 { background: var(--blue); color: #fff; }
.avatar.c2 { background: var(--sun); }
.avatar.c3 { background: var(--mint); }
.avatar.c4 { background: var(--orange); }
.avatar.c5 { background: var(--violet); color: #fff; }
.avatar.empty { background: transparent; border: 2px dashed color-mix(in srgb, var(--ink) 35%, transparent); }

.seats { display: flex; flex-wrap: wrap; padding-left: 0.4rem; }
.seats .avatar { margin-left: -0.4rem; box-shadow: 0 0 0 3px var(--paper); }

.players { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.3rem; }
.players li {
  display: flex;
  gap: 0.65rem;
  align-items: center;
  padding: 0.45rem 0.6rem;
  border-radius: 14px;
}
.players li.current { background: color-mix(in srgb, var(--sun) 55%, transparent); }
.pname { font-weight: 700; overflow-wrap: anywhere; min-width: 0; }
.tag {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  border: 1.5px solid var(--rule);
  color: var(--ink-soft);
  white-space: nowrap;
}
.tag.hot { border-color: var(--ink); background: var(--pink); color: var(--ink); margin-left: auto; }

.invite input { font-size: 0.9rem; }

.settings {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
  margin: 0;
}
.settings div {
  border: 2px solid var(--rule);
  border-radius: 14px;
  padding: 0.6rem 0.75rem;
}
.settings dt { font-size: 0.8rem; color: var(--ink-soft); }
.settings dd { margin: 0.1rem 0 0; font-weight: 700; font-size: 0.95rem; line-height: 1.3; }

/* Pills: countdowns and waiting notes */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  align-self: flex-start;
  padding: 0.4rem 0.9rem;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--card);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.pill .dot {
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  background: var(--pink);
  animation: pulse 1.6s ease-in-out infinite;
}
.pill.wait { align-self: stretch; justify-content: center; }
@keyframes pulse { 50% { transform: scale(0.55); opacity: 0.5; } }

/* Progress */
.progress { display: flex; flex-direction: column; gap: 0.4rem; }
.progress-text { display: flex; justify-content: space-between; font-size: 0.85rem; font-weight: 600; color: var(--ink-soft); }
.bar {
  height: 0.75rem;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--card);
  overflow: hidden;
}
.bar span {
  display: block;
  height: 100%;
  min-width: 0.5rem;
  background: repeating-linear-gradient(-45deg, var(--blue) 0 6px, #4d6dff 6px 12px);
  border-right: 2px solid var(--ink);
  transition: width 0.6s ease;
}

/* Whose turn */
.hero { display: flex; flex-direction: column; gap: 0.8rem; padding: 0.5rem 0 0.25rem; }
.hero-label { font-weight: 700; color: var(--ink-soft); }
.hero-who { display: flex; align-items: center; gap: 0.9rem; min-width: 0; }
.hero.mine .print { color: var(--ink); text-shadow: 0.06em 0.06em 0 var(--sun); }

/* Paper: the writer's context and the finished story */
.sheet {
  position: relative;
  background: var(--card);
  border: 2px solid var(--ink);
  border-radius: 6px;
  padding: 1.1rem 1.15rem 1.2rem;
  font-size: 1.15rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
  box-shadow: 5px 5px 0 color-mix(in srgb, var(--blue) 30%, transparent);
}
.sheet p + p { margin-top: 0.7rem; }
.sheet-label { font-size: 0.82rem; font-weight: 700; color: var(--ink-soft); margin-bottom: 0.35rem; letter-spacing: 0; }
.sheet .prompt { font-weight: 600; }
.fold {
  position: relative;
  height: 2.6rem;
  margin: -1.1rem -1.15rem 1rem;
  border-radius: 4px 4px 0 0;
  border-bottom: 2px dashed color-mix(in srgb, var(--ink) 40%, transparent);
  background: linear-gradient(#ebe7f8, #f7f5fd);
}
/* Two blurred bars stand in for the lines folded out of sight */
.fold::before, .fold::after {
  content: "";
  position: absolute;
  left: 1.15rem;
  height: 0.45rem;
  border-radius: 99px;
  background: #cdc5ea;
  filter: blur(1.5px);
}
.fold::before { top: 0.7rem; right: 25%; }
.fold::after { top: 1.55rem; right: 45%; }

.strips {
  list-style: none;
  margin: 0;
  padding: 0.25rem 0;
  display: flex;
  flex-direction: column;
}
.strip {
  --tilt: 0deg;
  position: relative;
  background: var(--card);
  border: 2px solid var(--ink);
  border-radius: 4px;
  padding: 0.9rem 1.1rem;
  font-size: 1.12rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
  transform: rotate(var(--tilt));
}
.strips .strip + .strip { margin-top: -2px; }
.strips .strip:nth-child(odd) { --tilt: -0.6deg; }
.strips .strip:nth-child(even) { --tilt: 0.5deg; }
.strips .strip:nth-child(3n) { --tilt: -0.25deg; }
.prompt-strip { background: var(--sun); font-weight: 600; }
.byline {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.45rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-soft);
}

.reveal { opacity: 0; transform-origin: top center; animation: unfold 0.7s cubic-bezier(0.2, 0.9, 0.3, 1.2) forwards; }
.revealed .reveal { animation: none; opacity: 1; }
@keyframes unfold {
  from { opacity: 0; transform: perspective(700px) rotateX(-85deg) rotate(var(--tilt)); }
  to { opacity: 1; transform: perspective(700px) rotateX(0) rotate(var(--tilt)); }
}

.message { display: flex; flex-direction: column; gap: 1rem; }
.message p { color: var(--ink-soft); font-size: 1.05rem; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px));
  transform: translate(-50%, 1rem);
  width: max-content;
  max-width: calc(100% - 2rem);
  background: var(--ink);
  color: #fff;
  padding: 0.7rem 1.1rem;
  border-radius: 999px;
  font-weight: 600;
  box-shadow: 3px 3px 0 var(--pink);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast:empty { display: none; }

.noscript { padding: 2rem; text-align: center; }
[hidden] { display: none !important; }

@media (max-width: 380px) {
  .row, .settings { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
