/* GhostPhone — "a note passed around class".
   A notebook page on a dark desk: ruled lines, red margin, masking tape, ballpoint ink,
   sticky-note players, a rubber-stamp room code. Built on top of PaperCSS. */

:root {
  --desk: #221e1a;
  --desk-2: #2d2823;
  --paper: #fbf7ec;
  --paper-edge: #efe8d6;
  --rule: #c9dbe9;
  --margin: #e79a92;
  --ink: #1f3a6e;          /* ballpoint blue */
  --ink-soft: #5b6f94;
  --graphite: #3b3935;
  --marker: #ffe066;       /* highlighter */
  --stamp: #c8372d;
  --tape: rgba(236, 224, 190, .82);
  --note-1: #fff08a;
  --note-2: #ffc2d4;
  --note-3: #bdf0d0;
  --note-4: #bfe1ff;
  --note-5: #ffd8a8;

  --f-display: "Marhey", "Gochi Hand", cursive;
  --f-body: "Baloo Bhaijaan 2", "Patrick Hand", sans-serif;
  --line: 34px;            /* ruled line height — text sits on it */
}

*, *::before, *::after { box-sizing: border-box; }

html, body, button, input, textarea, select, p, li, label, a, span {
  font-family: var(--f-body);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--graphite);
  background:
    radial-gradient(1200px 700px at 50% -10%, #3a332c 0%, transparent 60%),
    radial-gradient(900px 600px at 110% 110%, #1a1714 0%, transparent 60%),
    var(--desk);
  padding: clamp(16px, 5vw, 64px) 16px 80px;
  overflow-x: hidden;
}
/* faint wood grain on the desk */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .18;
  background: repeating-linear-gradient(97deg, transparent 0 22px, rgba(255,255,255,.03) 22px 23px, transparent 23px 61px);
}

/* ---------- the notebook page ---------- */
.page {
  position: relative;
  max-width: 620px;
  margin: 0 auto;
  padding: 56px 88px 64px 44px;   /* wide right side = RTL margin */
  background:
    linear-gradient(to left, transparent 71px, var(--margin) 71px, var(--margin) 73px, transparent 73px),
    repeating-linear-gradient(to bottom, transparent 0 calc(var(--line) - 1px), var(--rule) calc(var(--line) - 1px) var(--line)),
    var(--paper);
  background-position: 0 0, 0 18px, 0 0;
  border-radius: 3px 3px 2px 2px;
  box-shadow:
    0 1px 0 var(--paper-edge),
    0 22px 40px -12px rgba(0,0,0,.55),
    0 3px 8px rgba(0,0,0,.25);
  transform: rotate(-.6deg);
}
/* paper grain */
.page::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  opacity: .35;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .55 0 0 0 0 .5 0 0 0 0 .4 0 0 0 .18 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
/* three punched holes on the binding side (left in RTL) */
.page::before {
  content: "";
  position: absolute;
  left: 14px;
  top: 0;
  bottom: 0;
  width: 16px;
  background: radial-gradient(circle at 8px 50%, var(--desk-2) 0 6px, rgba(0,0,0,.25) 6.5px, transparent 7.5px) 0 0 / 16px 33.3% repeat-y;
  background-position: 0 16.6%;
}

.tape {
  position: absolute;
  width: 110px;
  height: 30px;
  background: var(--tape);
  box-shadow: 0 1px 2px rgba(0,0,0,.12);
  clip-path: polygon(3% 0, 97% 4%, 100% 50%, 96% 100%, 2% 96%, 0 45%);
  z-index: 2;
}
.tape-r { top: -12px; right: 40px; transform: rotate(4deg); }
.tape-l { top: -10px; left: 30px; transform: rotate(-6deg); }

/* ---------- type ---------- */
h1, h2, h3, .display {
  font-family: var(--f-display);
  font-weight: 400;
  color: var(--ink);
  letter-spacing: 0;
  margin: 0;
}
h2 { font-size: 1.9rem; line-height: 1.2; margin-bottom: 8px; }

.masthead { position: relative; margin-bottom: 28px; }
.logo {
  font-family: var(--f-display);
  font-size: clamp(2.4rem, 8vw, 3.4rem);
  line-height: 1;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  direction: ltr;
}
.logo .ghost { width: 1em; height: 1em; flex: none; transform: rotate(-8deg) translateY(-4px); }
.logo > span { font-family: "Gochi Hand", var(--f-display); }
.logo em {
  font-style: normal;
  color: var(--stamp);
}
.tagline {
  margin: 14px 0 0;
  font-size: 1.2rem;
  line-height: var(--line);
  color: var(--ink-soft);
}
mark, .hl {
  background: linear-gradient(100deg, transparent 2%, var(--marker) 4%, var(--marker) 94%, transparent 97%) 0 60% / 100% 70% no-repeat;
  color: inherit;
  padding: 0 4px;
}

.muted { color: var(--ink-soft); font-size: 1.05rem; line-height: var(--line); margin: 0; }
.hidden { display: none !important; }
.stack > * + * { margin-top: 18px; }

/* ---------- hand-drawn border helper: border lives on a pseudo layer run through the wobble filter ---------- */
.hand { position: relative; isolation: isolate; }
.hand::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border: 2.2px solid currentColor;
  border-radius: 14px 6px 16px 5px / 6px 14px 5px 16px;
  filter: url(#wobble);
  pointer-events: none;
}

/* ---------- fields: you write on the line ---------- */
.field { display: block; }
.field > span {
  display: block;
  font-family: var(--f-display);
  color: var(--ink);
  font-size: 1.15rem;
  margin-bottom: 2px;
}
.page input[type="text"],
.page textarea {
  width: 100%;
  border: 0;
  border-bottom: 2px dashed var(--ink-soft);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  padding: 4px 2px;
  font-size: 1.35rem;
  line-height: var(--line);
  color: var(--ink);
  outline: none;
  transition: border-color .2s;
}
.page textarea {
  min-height: calc(var(--line) * 4);
  resize: vertical;
  border: 2px dashed rgba(31,58,110,.35);
  border-radius: 10px 4px 12px 4px;
  padding: 6px 12px;
  background: rgba(255,253,245,.7);
}
.page textarea:focus { border: 2px solid var(--ink); }
.page input[type="text"]:focus { border-bottom: 2px solid var(--ink); }
.page input::placeholder, .page textarea::placeholder { color: #a9a597; opacity: 1; }

/* ---------- buttons ---------- */
.page .btn,
.page button.btn {
  appearance: none;
  position: relative;
  isolation: isolate;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--f-display);
  font-size: 1.25rem;
  line-height: 1.2;
  padding: 12px 26px;
  border: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
  color: var(--ink);
  cursor: pointer;
  transition: transform .15s ease, color .15s;
}
.page .btn:hover { transform: translateY(-2px) rotate(-.5deg); box-shadow: none; }
.page .btn:active { transform: translateY(1px); }
.page .btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.page .btn:focus-visible { outline: 2px dashed var(--stamp); outline-offset: 4px; }

/* solid ink blot */
.btn-ink { color: var(--paper) !important; }
.btn-ink::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -2;
  background: var(--ink);
  border-radius: 18px 8px 20px 6px / 8px 18px 6px 20px;
  filter: url(#wobble-soft);
}
.btn-ink.hand::before { color: var(--ink); }

/* highlighter swipe */
.btn-marker::after {
  content: "";
  position: absolute;
  inset: 18% 4% 12%;
  z-index: -2;
  background: var(--marker);
  transform: skewX(-8deg);
  border-radius: 3px;
  transition: inset .2s;
}
.btn-marker:hover::after { inset: 8% 0 6%; }

.btn-block { width: 100%; }
.btn-small { font-size: 1rem !important; padding: 6px 14px !important; }
.btn-danger { color: var(--stamp) !important; }

/* ---------- "or" divider with scribble ---------- */
.or {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--ink-soft);
  font-family: var(--f-display);
  margin: 26px 0;
}
.or::before, .or::after {
  content: "";
  flex: 1;
  height: 10px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='10'%3E%3Cpath d='M0 5 Q5 0 10 5 T20 5 T30 5 T40 5' fill='none' stroke='%235b6f94' stroke-width='1.6'/%3E%3C/svg%3E") repeat-x center;
}

.join { display: flex; gap: 14px; align-items: flex-end; }
.join input { flex: 1; min-width: 0; letter-spacing: 6px; text-transform: uppercase; }

/* ---------- how to play ---------- */
.howto {
  list-style: none;
  counter-reset: step;
  padding: 0;
  margin: 36px 0 0;
}
.howto li {
  counter-increment: step;
  position: relative;
  padding-right: 46px;
  line-height: var(--line);
  font-size: 1.1rem;
  margin: 0 0 6px;
}
.howto li::before {
  content: counter(step);
  position: absolute;
  right: 0;
  top: 0;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  font-family: var(--f-display);
  color: var(--stamp);
  border: 2px solid var(--stamp);
  border-radius: 50% 45% 55% 48%;
  transform: rotate(-8deg);
}

/* ---------- room header + rubber stamp ---------- */
.room-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 30px;
}
.room-head .logo { font-size: 2.2rem; text-decoration: none; background: none; }
.stamp {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 16px 4px;
  color: var(--stamp);
  border: 3px double var(--stamp);
  border-radius: 6px;
  transform: rotate(5deg);
  font-family: "Gochi Hand", var(--f-display);
  line-height: 1;
  opacity: .9;
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='60'%3E%3Cfilter id='g'%3E%3CfeTurbulence baseFrequency='.8' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1.6 1.35'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E");
          mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='60'%3E%3Cfilter id='g'%3E%3CfeTurbulence baseFrequency='.8' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1.6 1.35'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E");
}
.stamp small { font-family: var(--f-body); font-size: .75rem; letter-spacing: 2px; }
.stamp b { font-size: 2rem; letter-spacing: 6px; direction: ltr; font-weight: 400; }

/* ---------- players = sticky notes ---------- */
.players {
  list-style: none;
  padding: 6px 0 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  gap: 18px 14px;
}
.players li {
  --r: -2deg;
  position: relative;
  min-height: 86px;
  padding: 22px 10px 10px;
  margin: 0;
  display: grid;
  place-items: center;
  text-align: center;
  font-family: var(--f-display);
  font-size: 1.2rem;
  color: #3a3524;
  background: var(--note-1);
  box-shadow: 0 10px 12px -8px rgba(0,0,0,.35), inset 0 -12px 18px -14px rgba(0,0,0,.18);
  transform: rotate(var(--r));
  animation: stick .35s cubic-bezier(.3,1.6,.5,1) both;
  word-break: break-word;
}
.players li::before { /* bit of tape on each note */
  content: "";
  position: absolute;
  top: -9px;
  left: 50%;
  width: 54px;
  height: 18px;
  margin-left: -27px;
  background: var(--tape);
  transform: rotate(calc(var(--r) * -2));
  clip-path: polygon(4% 0, 96% 6%, 100% 60%, 94% 100%, 3% 94%, 0 40%);
}
.players li:nth-child(5n+2) { background: var(--note-2); --r: 2.5deg; }
.players li:nth-child(5n+3) { background: var(--note-3); --r: -1deg; }
.players li:nth-child(5n+4) { background: var(--note-4); --r: 3deg; }
.players li:nth-child(5n+5) { background: var(--note-5); --r: -3deg; }
.players li.me { outline: 2px dashed var(--ink); outline-offset: 4px; }
.players li.off { opacity: .45; filter: grayscale(.8); }
.players .crown {
  position: absolute;
  top: 4px;
  right: 6px;
  font-size: .95rem;
  color: var(--stamp);
  font-family: var(--f-body);
}
@keyframes stick {
  from { transform: rotate(var(--r)) translateY(-14px) scale(1.06); opacity: 0; }
  to { transform: rotate(var(--r)); opacity: 1; }
}

/* ---------- the question you received: folded note ---------- */
.folded {
  position: relative;
  padding: 26px 24px 24px;
  background: #fffdf5;
  color: var(--ink);
  font-size: 1.5rem;
  line-height: 1.5;
  font-family: var(--f-display);
  box-shadow: 0 14px 22px -14px rgba(0,0,0,.4);
  transform: rotate(1deg);
  clip-path: polygon(0 0, calc(100% - 26px) 0, 100% 26px, 100% 100%, 0 100%);
}
.folded::after { /* dog-ear */
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 26px;
  height: 26px;
  background: linear-gradient(225deg, transparent 50%, #e6dfc9 50%);
}

.status {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink-soft);
  font-size: 1.05rem;
  line-height: var(--line);
}
.tally { font-family: "Gochi Hand", var(--f-display); letter-spacing: 3px; color: var(--ink); direction: ltr; }

/* ---------- results: notes on a phone cord ---------- */
.chain { position: relative; padding: 0; margin: 0; list-style: none; }
.chain li {
  position: relative;
  margin: 0 0 54px;
  padding: 18px 20px 16px;
  background: #fffdf5;
  box-shadow: 0 12px 20px -12px rgba(0,0,0,.4);
  transform: rotate(var(--r, -1deg));
  animation: drop .5s cubic-bezier(.2,1.4,.4,1) both;
}
.chain li::before { display: none; }
.chain li:nth-child(even) { --r: 1.2deg; margin-right: 22px; }
.chain li:not(:last-child)::after { /* curly cord to the next note */
  content: "";
  position: absolute;
  bottom: -52px;
  right: 50%;
  width: 22px;
  height: 52px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='52'%3E%3Cpath d='M11 0 C 22 5, 0 9, 11 13 S 22 22, 11 26 S 0 35, 11 39 S 22 48, 11 52' fill='none' stroke='%231f3a6e' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E") center / contain no-repeat;
}
.chain .who {
  font-family: var(--f-display);
  color: var(--stamp);
  font-size: 1.05rem;
  margin: 0 0 6px;
}
.chain .q { font-size: 1.3rem; color: var(--ink); margin: 0 0 8px; line-height: 1.5; }
.chain .a {
  font-size: 1.2rem;
  margin: 0;
  padding-top: 8px;
  border-top: 1.5px dashed #d8d0b8;
  line-height: 1.5;
}
.chain .a b { font-family: var(--f-display); font-weight: 400; }
@keyframes drop {
  from { transform: rotate(var(--r, -1deg)) translateY(-24px) scale(.96); opacity: 0; }
  to { transform: rotate(var(--r, -1deg)); opacity: 1; }
}

.actions { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) rotate(-1deg);
  background: var(--note-1);
  color: #3a3524;
  font-family: var(--f-display);
  padding: 10px 22px;
  box-shadow: 0 10px 18px -8px rgba(0,0,0,.5);
  z-index: 20;
  max-width: calc(100vw - 32px);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

@media (max-width: 560px) {
  :root { --line: 32px; }
  .page {
    padding: 44px 50px 48px 22px;
    transform: none;
    background:
      linear-gradient(to left, transparent 37px, var(--margin) 37px, var(--margin) 39px, transparent 39px),
      repeating-linear-gradient(to bottom, transparent 0 calc(var(--line) - 1px), var(--rule) calc(var(--line) - 1px) var(--line)),
      var(--paper);
  }
  .page::before { display: none; }
  .tape { width: 80px; }
  .players { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
  .join { flex-direction: column; align-items: stretch; }
}

button.stamp { box-shadow: none; background: none; }
button.stamp:hover { transform: rotate(3deg) scale(1.04); box-shadow: none; }

/* ---------- lobby: mode picker as index cards ---------- */
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.page .mode-card {
  position: relative;
  display: block;
  text-align: right;
  padding: 16px 16px 14px;
  background: #fffdf5;
  border: 0;
  border-top: 3px solid var(--margin);
  border-radius: 2px;
  box-shadow: 0 10px 16px -10px rgba(0,0,0,.35);
  color: var(--graphite);
  cursor: pointer;
  transform: rotate(-1deg);
  transition: transform .2s, box-shadow .2s;
}
.page .mode-card:nth-child(2) { transform: rotate(1.2deg); }
.page .mode-card b {
  display: block;
  font-family: var(--f-display);
  font-weight: 400;
  font-size: 1.4rem;
  color: var(--ink);
  margin-bottom: 4px;
}
.page .mode-card span { font-size: 1rem; line-height: 1.55; display: block; }
.page .mode-card:hover { transform: rotate(0) translateY(-3px); box-shadow: 0 14px 20px -10px rgba(0,0,0,.4); }
.page .mode-card.on::after { /* circled in red pen */
  content: "";
  position: absolute;
  inset: -8px -10px;
  border: 2.5px solid var(--stamp);
  border-radius: 48% 52% 46% 54% / 55% 45% 55% 45%;
  filter: url(#wobble);
  pointer-events: none;
}
.page .mode-card:disabled { cursor: default; opacity: 1; }
.page .mode-card:disabled:not(.on) { opacity: .55; }

/* ---------- circle: the table ---------- */
.circle-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.circle-head h2 { margin: 0; }

.table {
  position: relative;
  width: min(440px, 100%);
  aspect-ratio: 1;
  margin: 10px auto 0;
}
.ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  color: var(--ink-soft);
}

.table-center {
  position: absolute;
  inset: 36%;
  display: grid;
  place-items: center;
  text-align: center;
  font-family: var(--f-display);
  color: var(--ink);
  font-size: .95rem;
  line-height: 1.45;
}
.ring .arrows { color: var(--stamp); }

.seats { list-style: none; margin: 0; padding: 0; }
.seats li {
  position: absolute;
  left: calc(50% + var(--x) * 40%);
  top: calc(50% + var(--y) * 40%);
  width: 92px;
  min-height: 58px;
  margin: -29px 0 0 -46px;
  padding: 8px 6px;
  display: grid;
  place-items: center;
  text-align: center;
  font-family: var(--f-display);
  font-size: 1rem;
  line-height: 1.2;
  color: #3a3524;
  background: var(--note-1);
  box-shadow: 0 8px 10px -7px rgba(0,0,0,.4);
  transform: rotate(var(--r, -2deg));
  transition: transform .3s, box-shadow .3s;
  word-break: break-word;
}
.seats li::before { display: none; }
.seats li:nth-child(5n+2) { background: var(--note-2); --r: 2deg; }
.seats li:nth-child(5n+3) { background: var(--note-3); --r: -1deg; }
.seats li:nth-child(5n+4) { background: var(--note-4); --r: 3deg; }
.seats li:nth-child(5n+5) { background: var(--note-5); --r: -3deg; }
.seats li.off { opacity: .45; filter: grayscale(.8); }
.seats li.me { outline: 2px dashed var(--ink); outline-offset: 3px; }
.seats li.cur, .seats li.tgt { transform: rotate(0) scale(1.12); z-index: 2; box-shadow: 0 14px 18px -8px rgba(0,0,0,.45); }
.seats li .role {
  position: absolute;
  top: -22px;
  left: 50%;
  transform: translateX(-50%) rotate(-3deg);
  white-space: nowrap;
  font-size: .85rem;
  padding: 0 8px;
  color: var(--paper);
  background: var(--ink);
  border-radius: 10px 4px 10px 4px;
}
.seats li.tgt .role { background: var(--stamp); }

/* ---------- the reverse card ---------- */
.page .reverse-card {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  padding: 14px 18px;
  border: 0;
  border-radius: 14px;
  color: #fff;
  background:
    radial-gradient(ellipse 60% 75% at 18% 50%, rgba(255,255,255,.18), transparent 70%),
    var(--stamp);
  box-shadow: 0 0 0 5px #fff, 0 0 0 7px var(--stamp), 0 16px 24px -10px rgba(0,0,0,.5);
  font-family: var(--f-display);
  font-size: 1.3rem;
  text-align: right;
  cursor: pointer;
  transform: rotate(-2deg);
  animation: deal .6s cubic-bezier(.2,1.5,.4,1) both, wiggle 2.8s 1s ease-in-out infinite;
}
.page .reverse-card svg { width: 54px; height: 54px; flex: none; }
.page .reverse-card small { display: block; font-family: var(--f-body); font-size: .95rem; opacity: .9; }
.page .reverse-card:hover { transform: rotate(0) scale(1.03); }
@keyframes deal { from { transform: translateY(40px) rotate(12deg); opacity: 0; } to { transform: rotate(-2deg); opacity: 1; } }
@keyframes wiggle { 0%, 88%, 100% { rotate: 0deg; } 92% { rotate: -2deg; } 96% { rotate: 2deg; } }

.chain.mini li { margin-bottom: 38px; padding: 12px 16px; }
.chain.mini li:not(:last-child)::after { bottom: -36px; height: 36px; }
.chain.mini .q { font-size: 1.1rem; }
.chain.mini .a { font-size: 1.05rem; }
.chain .flip {
  display: inline-block;
  margin-inline-start: 8px;
  padding: 0 8px;
  font-size: .85rem;
  color: #fff;
  background: var(--stamp);
  border-radius: 8px 3px 8px 3px;
  transform: rotate(-3deg);
}

@media (max-width: 560px) {
  .modes { grid-template-columns: 1fr; }
  .seats li { width: 76px; min-height: 50px; margin: -25px 0 0 -38px; font-size: .9rem; }
}
