/* Lost in Translation: airmail. Kraft paper, red-and-blue airmail stripes,
   perforated stamps, green postmarks and handwritten captions. */

@font-face {
  font-family: "Alfa Slab One";
  src: url("/alfa-slab-one.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Patrick Hand";
  src: url("/patrick-hand.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --kraft: #ecdcc2;
  --kraft-deep: #d9bf98;
  --paper: #fffaf0;
  --ink: #1e1b2e;
  --ink-soft: #5a4e3c;
  --rule: #d8c4a2;
  --red: #d7263d;
  --blue: #1f4e9c;
  --green: #2e7d5b;
  --yellow: #f2b705;

  --display: "Alfa Slab One", "Rockwell", "Roboto Slab", Georgia, serif;
  --hand: "Patrick Hand", "Segoe Print", "Bradley Hand", "Comic Sans MS", cursive;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --stripes: repeating-linear-gradient(-45deg, var(--red) 0 9px, var(--paper) 9px 15px, var(--blue) 15px 24px, var(--paper) 24px 30px);
  --radius: 12px;
  --behind: var(--kraft); /* what shows through a stamp's perforations */

  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(--kraft);
  color: var(--ink);
  font: 400 1rem/1.5 var(--font);
}

/* An airmail stripe band across the top of every page */
body::before {
  content: "";
  display: block;
  height: 10px;
  background: var(--stripes);
}

.masthead, main {
  width: min(36rem, 100% - 2rem);
  margin-inline: auto;
}
.masthead { display: flex; align-items: center; gap: 0.5rem; padding: 0.9rem 0 0.25rem; }

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--ink);
  text-decoration: none;
  font: 400 1.1rem/1 var(--display);
  letter-spacing: 0.01em;
}
.wordmark img { display: block; border-radius: 6px; }

.back {
  display: inline-grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  margin-left: -0.35rem;
  border-radius: 50%;
  color: var(--ink);
  flex: none;
}
.back:hover { background: rgb(30 27 46 / 0.08); }
.back:active { background: rgb(30 27 46 / 0.14); }
.chevron {
  width: 0.7rem;
  height: 0.7rem;
  border-left: 3px solid currentColor;
  border-bottom: 3px solid currentColor;
  border-radius: 2px;
  transform: translateX(2px) rotate(45deg);
}

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

h1, h2 { margin: 0; font-weight: 400; }
h2 { font: 400 1.05rem/1.25 var(--display); }
p { margin: 0; }

/* Headings are rubber-stamped: slab type in airmail blue, a red ink offset */
.print {
  font-family: var(--display);
  color: var(--blue);
  text-shadow: 0.05em 0.05em 0 rgb(215 38 61 / 0.55);
  font-size: clamp(2rem, 8.5vw, 2.8rem);
  line-height: 1.02;
  overflow-wrap: anywhere;
}
.print.giant { font-size: clamp(2.8rem, 15vw, 4.6rem); line-height: 0.95; }
.hero.mine .print { color: var(--red); text-shadow: 0.05em 0.05em 0 rgb(31 78 156 / 0.5); }

.intro { display: flex; flex-direction: column; gap: 0.7rem; }
.intro p { font-size: 1.05rem; color: var(--ink-soft); max-width: 31rem; }
.intro .tagline { font: 400 1.6rem/1.2 var(--hand); color: var(--ink); }
.hint, .note, .upnext { color: var(--ink-soft); font-size: 0.92rem; }
.center { text-align: center; }
.room-label { font: 400 1rem/1.3 var(--display); color: var(--ink-soft); overflow-wrap: anywhere; }

.handwriting { font-family: var(--hand); line-height: 1.3; overflow-wrap: anywhere; }
.handwriting.big { font-size: 1.65rem; }

/* Cards and postcards: paper with an airmail border */
.card, .postcard, .game {
  background: linear-gradient(var(--paper), var(--paper)) padding-box, var(--stripes) border-box;
  border: 6px solid transparent;
  border-radius: var(--radius);
  padding: 1.1rem;
  --behind: var(--paper);
}
.card { box-shadow: 0 2px 0 rgb(30 27 46 / 0.15); }

/* Postage stamps: perforated edges around drawings */
.stamp {
  display: block;
  padding: 9px;
  background:
    radial-gradient(circle at center, var(--behind) 3.2px, transparent 3.8px) -6px -6px / 12px 12px,
    #ffffff;
  position: relative;
}
.stamp::after {
  content: "";
  position: absolute;
  inset: 9px;
  border: 1.5px solid var(--ink);
  pointer-events: none;
}
.drawing { display: block; width: 100%; height: auto; aspect-ratio: 4 / 3; background: var(--paper); }

/* Postmarks: who sent each postcard */
.postmark {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  align-self: flex-end;
  margin-top: 0.7rem;
  padding: 0.25rem 0.75rem 0.25rem 0.3rem;
  border: 2px solid var(--green);
  border-radius: 999px;
  color: var(--green);
  font: 400 0.82rem/1 var(--display);
  transform: rotate(-3deg);
  opacity: 0.92;
}
.postmark .avatar { border-color: var(--green); }

/* Home page demo */
.demo { display: flex; flex-direction: column; align-items: center; gap: 0; padding: 0.25rem 0 0.5rem; }
.postcard.mini { width: min(22rem, 94%); padding: 0.5rem 0.8rem; font-size: 1.2rem; text-align: center; }
.postcard.mini:first-child { transform: rotate(-2deg); }
.postcard.mini:last-child { transform: rotate(1.5deg); background: linear-gradient(#fff3c4, #fff3c4) padding-box, var(--stripes) border-box; }
.mini-stamp { width: 11rem; margin: -0.3rem 0; transform: rotate(3deg); z-index: 1; box-shadow: 0 3px 8px rgb(30 27 46 / 0.2); }

/* Forms */
.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, .label { 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"], input[type="time"], select, textarea {
  width: 100%;
  font: inherit;
  font-size: 1rem;
  color: var(--ink);
  background: #ffffff;
  border: 2px solid var(--ink);
  border-radius: 8px;
  padding: 0.7rem 0.8rem;
}
textarea { resize: vertical; font-family: var(--hand); font-size: 1.35rem; line-height: 1.3; }
::placeholder { color: #a39780; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; box-shadow: 0 0 0 4px rgb(31 78 156 / 0.35); }

.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; }

.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: var(--red); font-weight: 700; }

.check { display: flex; gap: 0.6rem; align-items: center; font-weight: 700; cursor: pointer; }
.check input { accent-color: var(--blue); width: 1.15rem; height: 1.15rem; margin: 0; flex: none; }
.hours-text { font-weight: 500; color: var(--ink-soft); }
.quiet .ghost { padding: 0; }
.hours input[type="time"] { width: auto; flex: 1; min-width: 7rem; }
.hours label { font-weight: 600; font-size: 0.92rem; }

/* Buttons */
button, .button {
  font: 700 1rem/1.2 var(--font);
  color: var(--ink);
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 10px;
  padding: 0.75rem 1.15rem;
  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: var(--paper);
  font: 400 1.15rem/1.2 var(--display);
  letter-spacing: 0.02em;
  padding: 0.95rem 1.2rem;
  box-shadow: 4px 4px 0 var(--red);
}
.primary:active:not(:disabled) { transform: translate(4px, 4px); }
a.button.primary { width: auto; align-self: stretch; }
.danger { background: var(--red); color: var(--paper); 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;
}
a.ghost { display: inline-block; }
.ghost.delete { color: var(--red); margin-top: 0.5rem; }
button:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; }
button:focus-visible, .button:focus-visible, a:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }

/* Choices (turn order) */
.choices .choice {
  display: flex;
  gap: 0.7rem;
  align-items: center;
  padding: 0.65rem 0.85rem;
  border: 2px solid var(--rule);
  border-radius: 10px;
  cursor: pointer;
  font-weight: 500;
  background: #ffffff;
}
.choices .choice + .choice { margin-top: 0.45rem; }
.choices .choice:has(input:checked) { border-color: var(--blue); background: #e9eff9; }
.choices input { accent-color: var(--blue); margin: 0; width: 1.1rem; height: 1.1rem; flex: none; }
.choice:has(input:focus-visible) { outline: 3px solid var(--blue); outline-offset: 2px; }

/* Avatars: pixel art as tiny stamps */
.avatar {
  --size: 2.6rem;
  width: var(--size);
  height: var(--size);
  flex: none;
  display: inline-block;
  border: 2px solid var(--ink);
  border-radius: 6px;
  overflow: hidden;
  background: #ffffff;
}
.avatar.big { --size: 4rem; border-width: 3px; }
.avatar.small { --size: 1.6rem; border-width: 1.5px; border-radius: 4px; }
.avatar.empty { background: transparent; border: 2px dashed rgb(30 27 46 / 0.35); }
.px {
  display: block;
  width: 100%;
  height: 100%;
  background-image: url("/avatars.png");
  background-size: 500% 500%;
  image-rendering: crisp-edges;
  image-rendering: pixelated;
}

.picker { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0.55rem; }
.pick { position: relative; cursor: pointer; display: block; }
.pick input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.pick .avatar { width: 100%; height: auto; aspect-ratio: 1; display: block; transition: transform 0.12s, box-shadow 0.12s; }
.pick:hover .avatar { transform: translateY(-2px); }
.pick:has(input:checked) .avatar { transform: translateY(-3px) rotate(-4deg); box-shadow: 3px 3px 0 var(--red), 0 0 0 3px var(--blue); }
.pick:has(input:focus-visible) .avatar { outline: 3px solid var(--blue); outline-offset: 2px; }
.pick:has(input:disabled) { cursor: not-allowed; }
.pick:has(input:disabled) .avatar { opacity: 0.3; filter: grayscale(1); }

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

/* People */
.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: 10px; }
.players li.current { background: rgb(242 183 5 / 0.35); }
.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(--red); background: var(--red); color: var(--paper); margin-left: auto; }
.ghost.remove { margin-left: auto; padding: 0.2rem 0; font-size: 0.85rem; color: var(--red); align-self: center; }
.players li .tag.hot + .ghost.remove { margin-left: 0.5rem; }
.players li.kick-choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
  align-items: start;
  margin: -0.1rem 0 0.4rem;
  padding: 0.75rem;
  border: 2px dashed rgb(30 27 46 / 0.4);
}
.kick-option { display: flex; flex-direction: column; gap: 0.35rem; }
.kick-option button { width: 100%; padding: 0.6rem 0.8rem; font-size: 0.92rem; }
.kick-option .hint { font-size: 0.8rem; }

.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: 10px; padding: 0.6rem 0.75rem; background: rgb(255 250 240 / 0.6); }
.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 */
.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(--paper);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.pill .dot { width: 0.6rem; height: 0.6rem; border-radius: 50%; background: var(--red); animation: pulse 1.6s ease-in-out infinite; }
.pill.wait { align-self: stretch; justify-content: center; }
.pill.on { background: #dcefe5; }
.pill.paused { background: #e3e9f6; }
@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.8rem; border: 2px solid var(--ink); border-radius: 999px; background: var(--paper); overflow: hidden; }
.bar span { display: block; height: 100%; min-width: 0.5rem; background: var(--stripes); 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; }

/* What arrived in the mail */
.arrived { display: flex; flex-direction: column; gap: 0.6rem; }
.arrived-label, .card-label { font: 400 0.85rem/1.2 var(--display); color: var(--ink-soft); letter-spacing: 0.02em; }
.postcard.arrived { transform: rotate(-0.6deg); }

/* The drawing pad */
.pad-wrap { display: flex; flex-direction: column; gap: 0.7rem; }
.big-stamp { box-shadow: 0 3px 10px rgb(30 27 46 / 0.18); }
.pad { touch-action: none; cursor: crosshair; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.palette { display: grid; grid-template-columns: repeat(9, 1fr); gap: 0.4rem; }
.swatch {
  aspect-ratio: 1;
  width: 100%;
  min-width: 0;
  padding: 0;
  border-radius: 50%;
  border: 2px solid var(--ink);
  background: var(--swatch);
  box-shadow: none;
}
.swatch.eraser { background: #ffffff; position: relative; }
/* A little pink-and-white eraser, tilted like it's mid-rub */
.swatch.eraser::before {
  content: "";
  position: absolute;
  left: 18%;
  top: 33%;
  width: 64%;
  height: 34%;
  border: 1.5px solid var(--ink);
  border-radius: 2px;
  background: linear-gradient(90deg, #e86fa6 0 42%, var(--ink) 42% calc(42% + 1.5px), #ffffff calc(42% + 1.5px));
  transform: rotate(-35deg);
}
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--paper), 0 0 0 5px var(--blue); transform: none; }
.toolrow { display: flex; justify-content: space-between; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.sizes { display: flex; gap: 0.4rem; }
.size { width: 2.7rem; height: 2.7rem; padding: 0; display: grid; place-items: center; box-shadow: none; border-radius: 10px; }
.size .dot { display: block; border-radius: 50%; background: var(--ink); }
.size[aria-pressed="true"] { background: #e3e9f6; border-color: var(--blue); }
.tool { padding: 0.55rem 0.9rem; box-shadow: 2px 2px 0 var(--ink); font-size: 0.92rem; }
.ink { display: flex; align-items: center; gap: 0.6rem; font-size: 0.85rem; font-weight: 600; color: var(--ink-soft); }
.ink-bar { flex: 1; height: 0.5rem; border-radius: 999px; background: rgb(30 27 46 / 0.12); overflow: hidden; }
.ink-bar span { display: block; height: 100%; background: var(--blue); }
.ink.low .ink-bar span { background: var(--red); }

/* Ending heads-up */
.ending {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  padding: 0.75rem 0.95rem;
  border: 2px solid var(--ink);
  border-radius: 10px;
  background: #fff3c4;
  font-weight: 700;
  line-height: 1.35;
}
.ending.last { background: var(--yellow); box-shadow: 3px 3px 0 var(--ink); }

/* The reveal: a trail of postcards */
.postcards { list-style: none; margin: 0; padding: 0.25rem 0; display: flex; flex-direction: column; gap: 1rem; }
.postcards .postcard { display: flex; flex-direction: column; }
.postcards .postcard:nth-child(odd) { transform: rotate(-0.7deg); }
.postcards .postcard:nth-child(even) { transform: rotate(0.6deg); }
.postcards .postcard.first { background: linear-gradient(#fff3c4, #fff3c4) padding-box, var(--stripes) border-box; --behind: #fff3c4; }
.reveal { opacity: 0; animation: arrive 0.8s cubic-bezier(0.2, 0.9, 0.3, 1.15) forwards; }
.revealed .reveal { animation: none; opacity: 1; }
@keyframes arrive {
  from { opacity: 0; translate: 0 2.5rem; scale: 0.94; }
  to { opacity: 1; translate: 0 0; scale: 1; }
}

/* Room codes: a dashed "cut here" slip inside the invite card */
.code-card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 1rem;
  padding: 0.9rem 1rem;
  border: 2px dashed var(--ink);
  border-radius: 10px;
  background: #fff3c4;
}
.code-card .label { flex-basis: 100%; font-size: 0.85rem; color: var(--ink-soft); }
.code {
  font: 400 clamp(2rem, 10vw, 2.5rem)/1 var(--display);
  letter-spacing: 0.06em;
  color: var(--red);
  user-select: all;
  -webkit-user-select: all;
}
.code-card button { margin-left: auto; }

.join-row { display: flex; gap: 0.6rem; }
.join-row input { flex: 1; min-width: 0; text-transform: uppercase; letter-spacing: 0.04em; }
.join-row input::placeholder { text-transform: none; letter-spacing: 0; }

.steps { margin: 0; padding-left: 1.4rem; display: flex; flex-direction: column; gap: 0.55rem; }
.steps li { padding-left: 0.25rem; }
.steps li::marker { font-family: var(--display); color: var(--red); }

/* Your games */
.section-label { font: 400 0.85rem/1.2 var(--display); color: var(--ink-soft); }
.game {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  color: var(--ink);
  text-decoration: none;
  box-shadow: 0 3px 0 rgb(30 27 46 / 0.2);
  transition: transform 0.08s;
}
.game:active { transform: translateY(2px); }
.game.mine { background: linear-gradient(#fff3c4, #fff3c4) padding-box, var(--stripes) border-box; --behind: #fff3c4; }
.game-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.4rem 0.6rem; }
.game-title { flex: 1 1 9rem; min-width: 0; font: 400 1.15rem/1.25 var(--display); overflow-wrap: break-word; }
.game-status { color: var(--ink-soft); font-size: 0.92rem; font-weight: 500; }
.game-status.hot { color: var(--red); font-weight: 800; font-size: 1rem; }
.game .pill { padding: 0.2rem 0.6rem; font-size: 0.8rem; flex: 0 1 auto; max-width: 100%; }

.notify:empty { display: none; }
.notify { display: flex; flex-direction: column; gap: 0.4rem; }
.notify .inline .pill, .notify .inline .ghost, .idea .inline .ghost { align-self: center; }
.tip { --behind: var(--paper); }

.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: var(--paper);
  padding: 0.7rem 1.1rem;
  border-radius: 10px;
  font-weight: 600;
  box-shadow: 3px 3px 0 var(--red);
  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, .players li.kick-choices { grid-template-columns: 1fr; }
  .palette { grid-template-columns: repeat(5, 1fr); }
}

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