/* Le Bestiaire — paper, graphite, colored pencil */
:root {
  --paper: #fdfcf6;
  --graphite: #33312e;
  --pencil-lilac: #b48ee0;
  --pencil-sun: #f2c14e;
  --pencil-rose: #f078a6;
  --pencil-leaf: #7fb069;
  --line: #d8d3c5;
  --hand: 255px 15px 225px 15px / 15px 225px 15px 255px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  background-image: radial-gradient(#00000007 1px, transparent 1px);
  background-size: 22px 22px;
  color: var(--graphite);
  font-family: "Shantell Sans", "Comic Sans MS", system-ui, sans-serif;
  line-height: 1.5;
}
header { text-align: center; padding: 1.4rem 1rem 0.2rem; }
.wordmark {
  font-size: clamp(1.9rem, 6vw, 2.8rem);
  font-weight: 700;
  color: var(--graphite);
  text-decoration: none;
  border-bottom: 4px solid var(--pencil-sun);
}
.tagline { display: block; font-style: italic; opacity: 0.65; font-size: 0.95rem; margin-top: 0.3rem; }

nav {
  display: flex; gap: 0.4rem; justify-content: center; align-items: center;
  flex-wrap: wrap; padding: 0.8rem 1rem;
}
nav a {
  color: var(--graphite); text-decoration: none; padding: 0.3rem 0.9rem;
  border: 2px solid transparent; border-radius: var(--hand);
}
nav a.active, nav a:hover { border-color: var(--graphite); background: #fff; }
nav .logout { margin-left: 0.6rem; }
nav .logout button {
  font: inherit; font-size: 0.85rem; background: none; border: none;
  opacity: 0.6; cursor: pointer; text-decoration: underline;
}

main { max-width: 1050px; margin: 0 auto; padding: 0.5rem 1rem 3rem; }
footer { text-align: center; opacity: 0.5; font-size: 0.85rem; padding: 1.5rem; font-style: italic; }

h1 { font-size: clamp(1.4rem, 4.5vw, 2rem); }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.empty { text-align: center; opacity: 0.7; font-style: italic; padding: 2rem 0; }
.center { justify-content: center; }
.center-col { text-align: center; max-width: 640px; margin: 0 auto; }
.meta { opacity: 0.6; font-size: 0.9rem; }
.error { color: #c0392b; }

/* buttons */
button, .btnlike { font-family: inherit; cursor: pointer; }
.big {
  font-size: 1.05rem; font-weight: 700; color: var(--graphite);
  background: var(--pencil-sun); border: 2.5px solid var(--graphite);
  border-radius: var(--hand); padding: 0.55rem 1.3rem;
  box-shadow: 3px 3px 0 var(--graphite);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.big:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--graphite); }
.big:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--graphite); }
.big.alt { background: var(--pencil-lilac); }
.ghost, .btnlike.ghost {
  background: none; border: none; font-size: 0.85rem; opacity: 0.65;
  text-decoration: underline; color: inherit; padding: 0.4rem;
}
.row { display: flex; gap: 0.8rem; flex-wrap: wrap; align-items: center; }

/* cards */
.grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1.4rem; margin-top: 1.2rem;
}
.card {
  margin: 0; background: #fff; padding: 0.7rem 0.7rem 0.9rem;
  border: 2px solid var(--graphite); border-radius: var(--hand);
  transform: rotate(var(--tilt, 0deg));
  position: relative;
  transition: transform 0.15s ease;
}
.card:hover { transform: rotate(0deg) scale(1.02); z-index: 2; }
.card img { width: 100%; height: auto; display: block; border-radius: 6px; }
.card .tape {
  position: absolute; top: -10px; left: 50%; width: 70px; height: 22px;
  transform: translateX(-50%) rotate(-3deg);
  background: var(--pencil-lilac); opacity: 0.55; border-radius: 2px;
}
.card:nth-child(3n) .tape { background: var(--pencil-rose); }
.card:nth-child(4n) .tape { background: var(--pencil-leaf); }
figcaption { padding-top: 0.5rem; font-size: 0.95rem; }
figcaption strong { display: block; }
figcaption em { display: block; opacity: 0.7; font-size: 0.85rem; }
figcaption form { display: inline; }

.detail .card { max-width: 560px; margin: 1rem auto; transform: none; }
.detail { text-align: center; }

/* forms */
dialog {
  border: 2.5px solid var(--graphite); border-radius: var(--hand);
  background: var(--paper); max-width: 420px; width: calc(100% - 2rem);
}
dialog::backdrop { background: #33312e66; }
.stack { display: flex; flex-direction: column; gap: 0.9rem; }
.stack label { display: flex; flex-direction: column; gap: 0.25rem; font-weight: 700; font-size: 0.9rem; }
input, textarea {
  font: inherit; padding: 0.5rem 0.6rem; background: #fff;
  border: 2px solid var(--graphite); border-radius: 10px;
}
textarea { resize: vertical; }
.login { max-width: 380px; margin: 2rem auto; text-align: center; }

/* summon */
.summon { text-align: center; }
.stage {
  display: flex; gap: 1.5rem; justify-content: center; align-items: flex-start;
  flex-wrap: wrap; min-height: 260px; margin-top: 1.8rem; perspective: 900px;
}
.stage .card { width: min(300px, 80vw); }
.stage .card.enter { animation: summonIn 0.7s cubic-bezier(0.2, 1.4, 0.4, 1) both; }
.stage .card.enter:nth-child(2) { animation-delay: 0.25s; }
@keyframes summonIn {
  0% { opacity: 0; transform: rotateY(90deg) rotate(var(--tilt)) translateY(24px); }
  100% { opacity: 1; transform: rotateY(0) rotate(var(--tilt)); }
}
.stage .versus { align-self: center; font-size: 1.6rem; font-weight: 700; color: var(--pencil-rose); }

/* game */
.sentence-form textarea { font-size: 1.05rem; }
.seal { color: var(--pencil-leaf); }
.history { text-align: left; margin-top: 2.5rem; }
.history ul { list-style: none; padding: 0; }
.history li { padding: 0.4rem 0; border-bottom: 1px dashed var(--line); font-size: 0.92rem; }

/* reveal */
.reveal h1 { text-align: center; }
.meeting {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 2rem; margin: 1.5rem 0 2rem; align-items: start;
}
.speaker { display: flex; flex-direction: column; gap: 0.8rem; }
.speaker .card { max-width: 340px; margin: 0 auto; }
.bubble {
  position: relative; background: #fff; border: 2.5px solid var(--graphite);
  border-radius: var(--hand); padding: 0.9rem 1.1rem; margin: 0 0.5rem;
  font-size: 1.08rem;
}
.bubble::after {
  content: ""; position: absolute; bottom: -14px; left: 42px;
  border: 8px solid transparent; border-top-color: var(--graphite);
}
.bubble.right::after { left: auto; right: 42px; }
.bubble .by { display: block; margin-top: 0.5rem; font-size: 0.85rem; opacity: 0.65; }
.reveal .row { margin-top: 1rem; }
.reveal .meta.center { text-align: center; }

/* ============ v2 ============ */

/* nav "your turn" badge */
.turnbadge {
  background: var(--pencil-rose); color: #fff !important; border: 2px solid var(--graphite) !important;
  font-weight: 700; font-size: 0.85rem;
}
.turnbadge b { background: #fff; color: var(--graphite); border-radius: 8px; padding: 0 0.35rem; margin-left: 0.2rem; }
.turnbanner {
  max-width: 1050px; margin: 0.5rem auto; padding: 0.6rem 1rem; background: #fff;
  border: 2px solid var(--graphite); border-radius: var(--hand);
}
.turnbanner a { color: var(--graphite); }

/* view toggle + mini headings */
.viewtoggle { display: inline-flex; border: 2px solid var(--graphite); border-radius: 999px; overflow: hidden; }
.viewtoggle a { padding: 0.3rem 0.8rem; text-decoration: none; color: var(--graphite); font-size: 0.85rem; }
.viewtoggle a.on { background: var(--graphite); color: var(--paper); }
h3.mini, h2.mini { font-size: 0.95rem; margin: 0.2rem 0; opacity: 0.85; }
.check { flex-direction: row !important; align-items: center; gap: 0.5rem; }
.check input { width: auto; }
hr { border: none; border-top: 1px dashed var(--line); margin: 0.4rem 0; }
.danger { margin-top: 0.8rem; }

/* question-mark tile + pixel avatars */
.qtile {
  aspect-ratio: 1; display: grid; place-items: center; background: #fff;
  border: 2px dashed var(--graphite); border-radius: var(--hand);
}
.qtile span { font-size: 2.4rem; font-weight: 700; opacity: 0.55; }
.qtile.sm { width: 100%; height: 100%; border-width: 2px; border-radius: 10px; }
.qtile.sm span { font-size: 1.1rem; }
.pixav, .big-pix, .critter img, .card-pix { image-rendering: pixelated; }
.card-pix { display: block; width: 100%; aspect-ratio: 1; object-fit: contain; background: #fff; border-radius: 6px; }
.card .qtile { width: 100%; }
.pixav { width: 96px; height: 96px; object-fit: contain; }

/* list view */
.pixlist { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; margin-top: 1.2rem; }
.pixlist a { display: flex; align-items: center; gap: 0.7rem; padding: 0.5rem 0.7rem; text-decoration: none; color: var(--graphite); border: 2px solid var(--graphite); border-radius: var(--hand); background: #fff; }
.pixlist .pixav, .pixlist .qtile { width: 140px; height: 140px; flex: 0 0 140px; }
.pixlist span { font-weight: 700; }

/* stitched segments */
.stitch { display: flex; flex-direction: column; }
.stitch img { width: 100%; height: auto; display: block; border-radius: 0; }
.stitch img:first-child { border-radius: 6px 6px 0 0; }
.stitch img:last-child { border-radius: 0 0 6px 6px; }

/* creature detail v2 */
.detail-top { display: grid; grid-template-columns: 2fr 1fr; gap: 1.4rem; align-items: start; text-align: left; }
.detail-pic .pic, .detail-pic .stitch, .detail-pic .qtile { width: 100%; border: 2px solid var(--graphite); border-radius: var(--hand); background: #fff; }
.detail-pic .pic { display: block; }
.pixel-slot { display: grid; place-items: center; padding: 0.6rem; background: #fff; border: 2px solid var(--graphite); border-radius: var(--hand); }
.pixel-slot .big-pix { width: 240px; height: 240px; max-width: 100%; }
.pixel-slot .qtile { width: 240px; height: 240px; max-width: 100%; }
.pictoggle .btns { display: flex; gap: 0.4rem; margin-bottom: 0.5rem; }
.pictoggle .btns button { border: 2px solid var(--graphite); background: #fff; border-radius: 999px; padding: 0.2rem 0.7rem; font-size: 0.8rem; }
.pictoggle .btns button.on { background: var(--graphite); color: var(--paper); }
.editbox { margin: 1.4rem 0; border: 2px dashed var(--line); border-radius: var(--hand); padding: 0.6rem 1rem; }
.editbox summary { cursor: pointer; font-weight: 700; }
.editgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 1rem; margin-top: 0.8rem; }
.grid.small { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.scenes, .paroles { text-align: left; margin-top: 2rem; }
.paroles ul { list-style: none; padding: 0; }
.paroles li { padding: 0.5rem 0; border-bottom: 1px dashed var(--line); }
.paroles .by { opacity: 0.6; font-size: 0.85rem; }

/* draft flow */
.draft .stack { text-align: left; max-width: 460px; margin: 1rem auto; }
.pliprog { text-align: center; }
.quickadd { margin-top: 0.4rem; }
.quickadd summary { cursor: pointer; font-size: 0.9rem; opacity: 0.75; }
.quickadd .stack { margin-top: 0.7rem; }
.reveal-pic {
  max-width: 340px; margin: 1rem auto; border: 2.5px solid var(--graphite);
  border-radius: var(--hand); background: #fff; overflow: hidden;
  animation: revealPop 0.6s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}
.reveal-pic .pic, .reveal-pic .stitch img { width: 100%; display: block; }
@keyframes revealPop { 0% { opacity: 0; transform: scale(0.9) rotate(-2deg); } 100% { opacity: 1; transform: none; } }

/* La Prairie */
body.fullbleed { }
main.wide { max-width: 1200px; }
:root { --critter: 112px; --stage-h: 30%; }
.prairie {
  position: relative; height: min(82vh, 820px); min-height: 460px; margin-top: 0.6rem;
  border: 2px solid var(--graphite); border-radius: var(--hand);
  /* a calm green meadow */
  background: linear-gradient(180deg, #d7e8bd 0%, #c6e0a6 42%, #b1d68a 74%, #9ecd76 100%);
  overflow: hidden;
}
/* the stage at the bottom */
.stage {
  position: absolute; left: 4%; right: 4%; bottom: 0; height: var(--stage-h);
  background: repeating-linear-gradient(90deg, #c9a06a 0 26px, #c19961 26px 27px);
  border: 2px solid #9c7038; border-bottom: none; border-radius: 14px 14px 0 0;
  box-shadow: inset 0 6px 0 #d8b483, inset 0 -3px 0 #a97c46;
}
.stage::before { /* front lip */
  content: ""; position: absolute; left: -2px; right: -2px; top: -6px; height: 8px;
  background: #b5824a; border: 2px solid #9c7038; border-radius: 4px;
}
.stage .curtain {
  position: absolute; top: -6px; width: 26%; height: 58%;
  background:
    radial-gradient(14px 16px at 50% 100%, transparent 70%, var(--drape) 72%) 0 100% / 28px 18px repeat-x,
    linear-gradient(90deg, #b95c86, var(--drape) 45%, #c76e95);
  --drape: #d67aa3;
  border-radius: 0 0 10px 10px; box-shadow: inset -6px 0 10px #0002;
}
.stage .curtain.left { left: -2px; border-radius: 0 0 12px 4px; }
.stage .curtain.right { right: -2px; transform: scaleX(-1); }
.stage .spotlight {
  position: absolute; left: 50%; top: -14%; width: 60%; height: 120%; transform: translateX(-50%);
  background: radial-gradient(ellipse at 50% 0%, #fff6d688 0%, #fff6d600 62%); pointer-events: none;
}
.stage .footlights { position: absolute; left: 6%; right: 6%; top: -3px; display: flex; justify-content: space-between; }
.stage .footlights i { width: 8px; height: 8px; border-radius: 50%; background: var(--pencil-sun); box-shadow: 0 0 6px 2px #f2c14e88; }
.prairie-empty { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; z-index: 3; }
.prairie-empty[hidden] { display: none; }
.critter { position: absolute; width: var(--critter); height: var(--critter); transform: translate(-50%, -50%) scale(var(--s, 1)); cursor: pointer; z-index: 2; opacity: 1; }
.critter.performing { --s: 1.5; z-index: 5; } /* bigger under the spotlight */
.critter.enter, .critter.leave { opacity: 0; }
.critter img, .critter .qtile { width: var(--critter); height: var(--critter); object-fit: contain; animation: bob 3s ease-in-out infinite; }
.critter.flip img { transform: scaleX(-1); }
@keyframes bob { 0%, 100% { translate: 0 0; } 50% { translate: 0 -6px; } }
.critter .speech {
  position: absolute; bottom: calc(var(--critter) + 6px); left: 50%; transform: translateX(-50%) scale(0.9);
  background: #fff; border: 2px solid var(--graphite); border-radius: 12px; padding: 0.35rem 0.6rem;
  font-size: 0.8rem; line-height: 1.3; text-align: center;
  white-space: normal; overflow-wrap: break-word; width: max-content; max-width: min(240px, 60vw);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
  opacity: 0; transition: opacity 0.3s, transform 0.3s; pointer-events: none;
}
/* on-stage dialogue bubbles: narrower so the two never meet in the middle */
.critter.performing .speech { max-width: min(240px, 40vw); z-index: 4; }
.critter .speech.show { opacity: 1; transform: translateX(-50%) scale(1); }
.critter .speech::after { content: ""; position: absolute; bottom: -8px; left: 50%; transform: translateX(-50%); border: 6px solid transparent; border-top-color: var(--graphite); }
.popover {
  position: absolute; transform: translate(-50%, -110%); z-index: 5;
  background: #fff; border: 2px solid var(--graphite); border-radius: var(--hand); padding: 0.6rem 0.8rem;
  display: flex; flex-direction: column; gap: 0.2rem; min-width: 130px; box-shadow: 3px 3px 0 var(--graphite);
}
.popover em { opacity: 0.7; font-size: 0.85rem; }
.popover a { color: var(--graphite); font-size: 0.85rem; }

@media (max-width: 560px) {
  .detail-top { grid-template-columns: 1fr; }
}

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