/* Per-screen layout. Desktop first (design screens 01–06, A1–A3), with the
   mobile designs (M1–M8) as the narrow-viewport branch at the bottom. */

/* ===================== Toast ===================== */

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--surface);
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 3px var(--ink);
  border-radius: var(--r-md);
  padding: 12px 20px;
  font-family: var(--font-mono);
  font-size: 14px;
  z-index: 60;
  animation: jwrise .18s ease-out;
  max-width: min(520px, calc(100vw - 32px));
  text-align: center;
}

/* ===================== 01 Join ===================== */

.join__body {
  flex: 1;
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 64px;
  padding: 56px 64px;
  align-items: center;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}
.join__pitch { display: flex; flex-direction: column; gap: 28px; }
.join__headline {
  font-size: clamp(44px, 6.4vw, 92px);
  line-height: .92;
  font-weight: 800;
  letter-spacing: -0.04em;
}
.join__hl {
  background: var(--purple);
  padding: 0 12px;
  border: 3px solid var(--ink);
  display: inline-block;
  transform: rotate(-2deg);
}
.join__sub {
  font-size: 21px;
  line-height: 1.4;
  max-width: 520px;
  color: var(--ink-700);
  text-wrap: pretty;
}
.join__teasers { display: flex; gap: 20px; margin-top: 12px; }
.join__teaser {
  width: 170px; height: 128px;
  position: relative;
  border: 2px solid var(--ink);
  box-shadow: var(--sh-3);
  overflow: hidden;
  flex-shrink: 0;
}
.join__teaserText {
  position: absolute;
  left: 6px; right: 6px;
  font-family: var(--font-meme);
  color: #fff;
  text-align: center;
  font-size: 17px;
  text-shadow: var(--meme-outline-2);
}

.join__card { max-width: 480px; width: 100%; justify-self: end; }
.join__identity { display: flex; align-items: flex-end; gap: 14px; }
.join__myAvatar {
  width: 56px; height: 56px;
  box-shadow: var(--sh-1);
  font-size: 16px;
}
.join__avatars { display: grid; grid-template-columns: repeat(8, 1fr); gap: 8px; }
.join__avatarOpt {
  height: 46px;
  border-radius: var(--r-md);
  border: 2px solid var(--ink);
  display: grid; place-items: center;
  font-weight: 800; font-size: 12px;
  cursor: pointer;
  color: var(--ink);
  transition: transform .15s, box-shadow .15s;
  padding: 0;
}
.join__avatarOpt.is-on { transform: rotate(-6deg) translateY(-3px); box-shadow: var(--sh-1); }
.join__avatarOpt:focus-visible { outline: 3px solid var(--link); outline-offset: 2px; }

.join__codeWrap { position: relative; cursor: text; }
.join__codeInput {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  opacity: 0;
  border: 0; padding: 0;
  font-size: 16px;      /* keeps iOS from zooming on focus */
  letter-spacing: 1em;
}
.join__code { display: flex; gap: 8px; pointer-events: none; }
.join__codeCell {
  flex: 1; height: 60px;
  border: 2px solid var(--ink);
  border-radius: 10px;
  display: grid; place-items: center;
  font-family: var(--font-mono);
  font-size: 28px; font-weight: 500;
  background: var(--paper);
  text-transform: uppercase;
}
.join__codeInput:focus + .join__code .join__codeCell.is-next {
  box-shadow: var(--sh-1);
  background: var(--surface);
}
.join__or {
  display: flex; align-items: center; gap: 12px;
  font-family: var(--font-mono); font-size: 13px; color: var(--ink-500);
}
.join__rule { flex: 1; height: 2px; background: var(--rule); }

/* ===================== 02 Lobby ===================== */

.lobby__leave {
  background: none; border: 0; cursor: pointer;
  font-size: 14px; color: var(--ink); padding: 8px;
}
.lobby__leave:hover { text-decoration: underline; }

.lobby__body {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 400px;
  gap: 48px;
  padding: 48px 64px;
  max-width: 1400px; width: 100%; margin: 0 auto;
}
.lobby__main { display: flex; flex-direction: column; gap: 32px; min-width: 0; }
.lobby__codeRow { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; }
.lobby__code {
  font-family: var(--font-mono);
  font-size: clamp(48px, 7vw, 96px);
  font-weight: 500;
  letter-spacing: .04em;
  line-height: 1;
}
.lobby__playersHead { display: flex; align-items: baseline; justify-content: space-between; }
.lobby__playersTitle { font-size: 26px; font-weight: 800; }
.lobby__grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

.lobby__player {
  background: var(--surface);
  border: 2px solid var(--ink);
  border-radius: var(--r-xl);
  padding: 18px;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  position: relative;
  min-height: 142px;
  justify-content: center;
}
.lobby__playerName { font-weight: 600; font-size: 18px; text-align: center; }
.lobby__hostBadge {
  position: absolute; top: -10px; right: -8px;
  background: var(--ink); color: var(--purple);
  font-family: var(--font-mono); font-size: 11px;
  padding: 3px 8px; border-radius: 6px;
  transform: rotate(6deg);
}
.lobby__slot {
  border: 2px dashed var(--ink-400);
  border-radius: var(--r-xl);
  display: grid; place-items: center;
  font-family: var(--font-mono); font-size: 13px; color: var(--ink-500);
  min-height: 142px;
  background: none;
  padding: 12px;
  text-align: center;
}
.lobby__slot--action { cursor: pointer; color: var(--ink); font-weight: 600; }
.lobby__slot--action:hover { background: var(--surface); border-color: var(--ink); }

.lobby__settings { max-width: 400px; }
.lobby__settingsTitle { font-size: 24px; font-weight: 800; }
.lobby__readonly {
  height: 48px; border: 2px solid var(--rule); border-radius: var(--r-md);
  display: flex; align-items: center; padding: 0 14px;
  font-size: 17px; color: var(--ink-600);
}
.lobby__select { position: relative; }
.lobby__select select {
  width: 100%; height: 48px;
  border: 2px solid var(--ink); border-radius: var(--r-md);
  background: var(--surface); color: var(--ink);
  padding: 0 38px 0 14px; font-size: 17px;
  appearance: none; cursor: pointer;
}
.lobby__select select:disabled { color: var(--ink-600); cursor: default; }
.lobby__caret { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); pointer-events: none; }
.lobby__waitHost {
  text-align: center; font-size: 14px; color: var(--ink-600);
  border: 2px dashed var(--ink-400); border-radius: var(--r-md); padding: 18px;
}
.lobby__hint { font-size: 12px; color: var(--ink-500); text-align: center; }
.lobby__waiting {
  display: flex; flex-direction: column; gap: 4px;
  padding: 14px 18px; margin-bottom: 16px; background: var(--surface);
}

/* ===================== 03 Create ===================== */

.create__round { flex-shrink: 0; }
.create__timer { display: flex; align-items: center; gap: 12px; }
.create__timerText { font-size: 15px; }

.create__body {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 420px;
  gap: 48px;
  padding: 40px 56px 24px;
  min-height: 0;
  max-width: 1500px; width: 100%; margin: 0 auto;
}
.create__stage {
  display: flex; align-items: center; justify-content: center;
  min-width: 0; min-height: 0;
}
.create__stage .meme { width: min(100%, 680px); }
.create__panel {
  display: flex; flex-direction: column; gap: 20px; justify-content: center;
  min-width: 0;
}
.create__title { font-size: 34px; font-weight: 800; letter-spacing: -0.02em; line-height: 1; }
.create__note { font-size: 16px; color: var(--ink-600); margin-top: -8px; }
.create__capLabel { display: flex; align-items: center; gap: 8px; }
.create__capNum {
  width: 26px; height: 26px; border-radius: 7px;
  border: 2px solid var(--ink);
  display: grid; place-items: center;
  font-weight: 800; font-size: 14px; color: var(--ink);
  flex-shrink: 0;
}
.create__actions { display: flex; gap: 12px; margin-top: 8px; }
.create__swap { flex: 1; font-size: 16px; white-space: nowrap; padding: 0 14px; }
.create__lock { flex: 1.4; }

.create__foot {
  height: 72px; flex-shrink: 0;
  border-top: 2px solid var(--ink);
  display: flex; align-items: center; gap: 16px;
  padding: 0 56px;
  background: var(--surface);
}
.create__dots { display: flex; gap: 8px; }

/* ===================== 04 Vote ===================== */

.vote__progress { display: flex; align-items: center; gap: 10px; }
.vote__count { font-size: 14px; margin-right: 10px; white-space: nowrap; }
.vote__dots { display: flex; gap: 6px; align-items: center; }
.vote__dot { width: 28px; height: 6px; border-radius: 3px; background: var(--dark-700); }
.vote__dot.is-done { background: var(--purple); }
.vote__dot.is-now { background: var(--paper); }
.vote__timer { font-size: 15px; }

.vote__body {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 32px;
  padding: 40px;
  min-height: 0;
}
.vote__body .meme { width: min(100%, 600px); }
.vote__prompt { font-size: 28px; font-weight: 800; }
.vote__ratings { display: flex; gap: 18px; flex-wrap: wrap; justify-content: center; }
.vote__sticker {
  width: 132px; height: 72px;
  color: var(--ink);
  border: 3px solid var(--paper);
  border-radius: var(--r-xl);
  font-weight: 800; font-size: 22px;
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
}
.vote__sticker:hover:not(:disabled) { transform: translateY(-4px); }
.vote__sticker.is-on {
  transform: rotate(-4deg) translateY(-8px) scale(1.08);
  box-shadow: 6px 6px 0 var(--pink);
}
.vote__sticker:disabled:not(.is-on) { opacity: .4; cursor: default; }
.vote__sticker:focus-visible { outline: 3px solid var(--purple); outline-offset: 3px; }
.vote__hint { font-size: 13px; color: var(--ink-400); }
.vote__empty { font-size: 22px; font-weight: 600; }

/* ===================== 05 Results ===================== */

.results__next {
  background: none; border: 0; cursor: pointer;
  font-size: 14px; color: var(--ink); padding: 8px;
}
.results__next:hover { text-decoration: underline; }

.results__body {
  flex: 1;
  display: grid; grid-template-columns: 1fr 1fr; gap: 64px;
  padding: 48px 64px;
  max-width: 1500px; width: 100%; margin: 0 auto;
  min-height: 0;
}
.results__bestCol { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.results__bestCol .meme { width: min(100%, 520px); }
.results__noBest {
  width: min(100%, 520px); aspect-ratio: 4 / 3;
  border: 3px dashed var(--ink-400); border-radius: 4px;
  display: grid; place-items: center;
  font-size: 18px; color: var(--ink-500);
}
.results__byline { display: flex; align-items: center; gap: 12px; margin-top: 8px; flex-wrap: wrap; }
.results__by { font-size: 22px; font-weight: 600; }
.results__avg { background: var(--pink); transform: rotate(-3deg); }

.results__boardCol { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.results__boardTitle { font-size: 34px; font-weight: 800; letter-spacing: -0.02em; margin-bottom: 8px; }
.results__row {
  display: flex; align-items: center; gap: 16px;
  background: var(--surface);
  border: 2px solid var(--ink);
  border-radius: var(--r-lg);
  padding: 12px 18px;
  /* `backwards`, not `both`: a fill held after the end would pin transform and
     override the hover rotation below. */
  animation: jwrise .22s ease-out backwards;
  transition: transform .18s ease-out;
}
.results__row:hover { transform: rotate(-2deg); }
.results__row.is-lead { background: var(--purple); }
.results__row.is-lead:hover { transform: rotate(-2deg); }
.results__rank { font-size: 20px; width: 28px; flex-shrink: 0; }
.results__name { flex: 1; font-size: 20px; font-weight: 600; min-width: 0; }
.results__delta {
  font-size: 14px; background: var(--purple);
  border: 2px solid var(--ink); border-radius: var(--r-pill);
  padding: 3px 10px; flex-shrink: 0;
}
.results__row.is-lead .results__delta { background: var(--surface); }
.results__pts {
  font-size: 22px; font-weight: 500; width: 72px; text-align: right; flex-shrink: 0;
}

/* ===================== 06 Final ===================== */

.final__meta, .final__room { font-size: 14px; }
.final__stage {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: var(--purple-deep);
  min-height: 0;
}
.final__glow {
  position: absolute; inset: 0;
  background: radial-gradient(circle at 50% 56%,
    rgba(255,253,248,.75) 0, rgba(255,253,248,.25) 18%, rgba(255,253,248,0) 40%);
  pointer-events: none;
}
.final__tadaa {
  position: absolute; top: 18px; left: 0; right: 0;
  text-align: center;
  font-family: var(--font-meme);
  font-size: clamp(64px, 10vw, 128px);
  line-height: 1; letter-spacing: .03em;
  color: var(--surface);
  -webkit-text-stroke: 4px var(--ink);
  text-shadow: 8px 8px 0 var(--ink);
  transform: rotate(-4deg);
  pointer-events: none;
}
.final__winner {
  position: absolute; top: 180px; left: 0; right: 0;
  display: flex; flex-direction: column; align-items: center;
}
.final__winnerAvatarWrap { position: relative; animation: jwpop .3s ease-out both; }
.final__winnerAvatar {
  width: 200px; height: 200px; border-radius: 50%;
  border: 6px solid var(--ink);
  box-shadow: 0 0 0 8px var(--surface), 12px 12px 0 8px var(--ink);
  display: grid; place-items: center;
  font-weight: 800; font-size: 50px; color: var(--ink);
}
.final__badge {
  position: absolute; top: -6px; right: -30px;
  background: var(--amber); color: var(--ink);
  border: 3px solid var(--ink); border-radius: var(--r-pill);
  padding: 6px 14px;
  font-family: var(--font-meme); font-size: 26px;
  transform: rotate(14deg);
  box-shadow: var(--sh-2);
}
.final__nameplate { margin-top: -18px; position: relative; }
.final__score {
  margin-top: 18px;
  background: var(--surface); color: var(--ink);
  border: 3px solid var(--ink); border-radius: var(--r-pill);
  padding: 6px 18px;
  font-family: var(--font-mono); font-size: 18px; font-weight: 500;
  box-shadow: var(--sh-2);
  text-align: center;
}

.final__podium {
  position: absolute; top: 250px;
  width: 240px;
  background: var(--surface); color: var(--ink);
  border: 3px solid var(--ink); border-radius: var(--r-2xl);
  box-shadow: var(--sh-5);
  padding: 20px;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.final__podium--left { left: 120px; transform: rotate(-7deg); }
.final__podium--right { right: 120px; transform: rotate(6deg); }
.final__podiumRank {
  position: absolute; top: -22px;
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--ink); color: var(--surface);
  border: 3px solid var(--surface);
  display: grid; place-items: center;
  font-family: var(--font-meme); font-size: 26px;
}
.final__podium--left .final__podiumRank { left: -18px; }
.final__podium--right .final__podiumRank { right: -18px; }
.final__podiumAvatar {
  width: 92px; height: 92px; border-radius: 50%;
  border: 3px solid var(--ink);
  display: grid; place-items: center;
  font-weight: 800; font-size: 24px;
}
.final__podiumName { font-size: 24px; font-weight: 800; }
.final__podiumPts { font-size: 16px; }

.final__foot {
  height: 96px; flex-shrink: 0;
  background: var(--ink);
  display: flex; align-items: center; justify-content: center; gap: 16px;
  flex-wrap: wrap;
  padding: 0 24px;
  position: relative; z-index: 2;
}

/* ---- gallery overlay ---- */

.gallery {
  position: fixed; inset: 0;
  background: rgba(22,19,26,.82);
  display: grid; place-items: center;
  padding: 32px; z-index: 50;
  overflow: auto;
}
.gallery__inner {
  background: var(--paper);
  border: 3px solid var(--ink);
  box-shadow: var(--sh-6);
  border-radius: var(--r-2xl);
  padding: 28px;
  width: min(1100px, 100%);
  color: var(--ink);
}
.gallery__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.gallery__title { font-size: 28px; font-weight: 800; }
.gallery__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 20px; }
.gallery__item { display: flex; flex-direction: column; gap: 8px; }
.gallery__cap {
  display: flex; align-items: center; gap: 10px;
  font-size: 15px; font-weight: 600;
}
.gallery__cap .mono { font-size: 13px; color: var(--ink-600); }

/* ===================== A1 Admin login ===================== */

.alogin { display: grid; place-items: center; position: relative; }
.alogin__mark {
  position: absolute; left: 48px; top: 28px;
  display: flex; align-items: center; gap: 6px;
  color: var(--paper);
}
.alogin__studio { font-size: 13px; margin-left: 10px; color: var(--ink-400); }
.alogin__card {
  width: min(440px, calc(100vw - 48px));
  background: var(--paper);
  border-radius: var(--r-2xl);
  padding: 40px;
  display: flex; flex-direction: column; gap: 20px;
  box-shadow: var(--sh-6);
  box-shadow: 10px 10px 0 var(--purple);
  color: var(--ink);
}
.alogin__title { font-size: 38px; font-weight: 800; letter-spacing: -0.02em; line-height: 1; }
.alogin__sub { font-size: 16px; color: var(--ink-600); margin-top: -8px; }
.alogin__forgot { font-size: 13px; text-align: center; }
.alogin__back {
  background: none; border: 0; cursor: pointer;
  font-size: 13px; color: var(--ink-600); padding: 4px;
}
.alogin__back:hover { text-decoration: underline; }

/* ===================== A2 Library ===================== */

.library { flex-direction: row; }
.library__side {
  width: 240px; flex-shrink: 0;
  background: var(--ink); color: var(--paper);
  padding: 28px 20px;
  display: flex; flex-direction: column; gap: 6px;
}
.library__sideMark { margin-bottom: 28px; }
.library__nav {
  padding: 12px 14px; border-radius: 10px;
  font-size: 16px; text-align: left;
  background: none; border: 0; color: inherit; cursor: pointer;
  font-family: inherit;
}
.library__nav:hover { background: var(--dark-700); }
.library__nav.is-on { background: var(--purple); color: var(--ink); font-weight: 600; }
.library__signout, .library__toGame {
  background: none; border: 0; cursor: pointer; text-align: left;
  font-size: 12px; color: var(--ink-400); padding: 6px 14px;
}
.library__signout:hover, .library__toGame:hover { color: var(--paper); }

.library__main {
  flex: 1;
  padding: 36px 44px;
  display: flex; flex-direction: column; gap: 24px;
  min-width: 0;
  overflow: auto;
}
.library__head { display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.library__titleRow { display: flex; align-items: baseline; gap: 14px; }
.library__title { font-size: 40px; font-weight: 800; letter-spacing: -0.02em; }
.library__count { font-size: 15px; color: var(--ink-600); }
.library__tools { display: flex; gap: 12px; }
.library__search { width: 260px; height: 48px; font-size: 16px; border-radius: var(--r-md); }
.library__new { box-shadow: var(--sh-1); }

.library__filters { display: flex; gap: 10px; flex-wrap: wrap; }
.library__chip {
  height: 38px; padding: 0 16px;
  border: 2px solid var(--ink); border-radius: var(--r-pill);
  display: flex; align-items: center;
  font-weight: 600; font-size: 15px;
  cursor: pointer;
  background: var(--surface); color: var(--ink);
  font-family: inherit;
}
.library__chip.is-on { background: var(--ink); color: var(--purple); }

.library__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 20px;
  align-content: start;
}
.library__card {
  background: var(--surface);
  border: 2px solid var(--ink);
  border-radius: var(--r-lg);
  overflow: hidden;
  cursor: pointer;
  padding: 0;
  text-align: left;
  font-family: inherit;
  transition: box-shadow .12s, transform .12s;
  display: flex; flex-direction: column;
}
.library__card:hover { box-shadow: var(--sh-3); transform: translate(-1px, -1px); }
.library__card:focus-visible { outline: 3px solid var(--link); outline-offset: 2px; }
.library__thumb { height: 150px; position: relative; overflow: hidden; border-bottom: 2px solid var(--ink); }
.library__img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.library__meta { padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; }
.library__metaTop { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.library__name { font-weight: 600; font-size: 17px; }
.library__status {
  font-size: 11px; padding: 2px 8px; border-radius: 6px;
  border: 1.5px solid var(--ink);
  flex-shrink: 0;
}
.library__stats { font-size: 12px; color: var(--ink-600); }
.library__empty {
  display: flex; flex-direction: column; gap: 8px;
  padding: 48px; text-align: center;
  border: 2px dashed var(--ink-400); border-radius: var(--r-xl);
}

/* ===================== A3 Editor ===================== */

.editor__bar {
  height: 72px; flex-shrink: 0;
  background: var(--ink); color: var(--paper);
  display: flex; align-items: center; gap: 20px;
  padding: 0 28px;
}
.editor__back {
  background: none; border: 0; color: inherit; cursor: pointer;
  font-size: 14px; padding: 8px;
}
.editor__back:hover { text-decoration: underline; }
.editor__divider { width: 2px; height: 28px; background: var(--dark-700); }
.editor__name {
  background: none; border: 0; color: inherit;
  font-size: 22px; font-weight: 800; font-family: inherit;
  padding: 6px 8px; border-radius: 6px;
  min-width: 0; width: 220px;
}
.editor__name:hover { background: var(--dark-700); }
.editor__name:focus { background: var(--dark-700); outline: 2px solid var(--purple); }
.editor__status {
  font-size: 12px; padding: 3px 9px; border-radius: 6px;
  background: var(--dark-700);
  white-space: nowrap;
}
.editor__publish { box-shadow: none; border-color: var(--purple); }

.editor__body {
  flex: 1;
  display: grid;
  grid-template-columns: 260px 1fr 300px;
  min-height: 0;
}
.editor__rail {
  padding: 24px;
  display: flex; flex-direction: column; gap: 22px;
  background: var(--surface);
  overflow: auto;
}
.editor__rail--left { border-right: 2px solid var(--ink); }
.editor__rail--right { border-left: 2px solid var(--ink); }

.editor__drop {
  height: 96px;
  border: 2px dashed var(--ink);
  border-radius: var(--r-md);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  background: var(--paper);
  cursor: pointer;
}
.editor__drop:hover,
.editor__drop.is-over { background: var(--rule); }
.editor__drop.is-over { border-style: solid; }
.editor__dropNote { font-size: 11px; color: var(--ink-600); }

.editor__countOpt { font-weight: 800; font-size: 20px; }
.editor__boxList { display: flex; flex-direction: column; gap: 8px; }
.editor__boxItem {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border: 2px solid var(--rule); border-radius: 10px;
  cursor: pointer; background: var(--surface);
  font-family: inherit; text-align: left;
}
.editor__boxItem.is-on { border-color: var(--ink); }
.editor__boxNum {
  width: 26px; height: 26px; border-radius: 7px;
  border: 2px solid var(--ink);
  display: grid; place-items: center;
  font-weight: 800; font-size: 13px; color: var(--ink);
  flex-shrink: 0;
}
.editor__boxHint { font-size: 15px; font-weight: 600; }

.editor__canvas {
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  min-width: 0; min-height: 0;
  background:
    repeating-linear-gradient(0deg, transparent 0 23px, var(--rule) 23px 24px),
    repeating-linear-gradient(90deg, transparent 0 23px, var(--rule) 23px 24px);
}
.editor__imageWrap { width: min(100%, 640px); }
.editor__image {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  border: 3px solid var(--ink);
  box-shadow: var(--sh-5);
  user-select: none;
  touch-action: none;
  overflow: hidden;
  container-type: size;
}
.editor__img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.editor__imgPlaceholder {
  position: absolute; inset: 0;
  display: grid; place-items: center;
}
.editor__imgPlaceholder span {
  font-size: 13px; color: var(--ink-500);
  background: var(--paper); padding: 4px 8px;
}
.editor__box {
  position: absolute;
  border-radius: 6px;
  cursor: grab;
  display: grid; place-items: center;
}
.editor__box:active { cursor: grabbing; }
.editor__box:focus-visible { outline: 3px solid var(--link); outline-offset: 2px; }
.editor__boxLabel {
  font-family: var(--font-meme);
  color: #fff; font-size: 4.2cqw;
  text-shadow: var(--meme-outline-2);
  pointer-events: none;
  text-align: center;
  padding: 0 4px;
  overflow: hidden;
}
.editor__boxBadge {
  position: absolute; top: -14px; left: -14px;
  width: 28px; height: 28px; border-radius: var(--r-sm);
  border: 2px solid var(--ink);
  display: grid; place-items: center;
  font-weight: 800; font-size: 14px; color: var(--ink);
  pointer-events: none;
}
.editor__handle {
  position: absolute; right: -7px; bottom: -7px;
  width: 14px; height: 14px;
  background: var(--surface);
  border: 2px solid var(--ink);
  cursor: nwse-resize;
}

.editor__selHead { display: flex; align-items: center; gap: 10px; }
.editor__selTitle { font-size: 22px; font-weight: 800; }
.editor__hintInput { height: 46px; font-size: 16px; border-radius: 10px; }
.editor__fonts { display: flex; gap: 6px; }
.editor__font {
  flex: 1; height: 40px;
  border: 2px solid var(--ink); border-radius: 10px;
  display: grid; place-items: center;
  background: var(--surface); color: var(--ink);
  cursor: pointer; font-family: inherit;
  font-weight: 800; font-size: 15px;
}
.editor__font--impact { font-family: var(--font-meme); font-size: 16px; font-weight: 400; }
.editor__font--mono { font-family: var(--font-mono); font-size: 14px; font-weight: 400; }
.editor__font.is-on { background: var(--ink); color: var(--paper); }
.editor__swatches { display: flex; gap: 8px; }
.editor__swatch {
  width: 34px; height: 34px; border-radius: 50%;
  border: 2px solid var(--ink);
  cursor: pointer; padding: 0;
}
.editor__swatch.is-on {
  border-width: 3px;
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--ink);
}
.editor__coords { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.editor__coord {
  border: 2px solid var(--ink); border-radius: 10px;
  padding: 6px 10px;
  display: flex; align-items: center; gap: 6px;
  font-family: var(--font-mono); font-size: 14px;
}
.editor__coordLabel { color: var(--ink-500); }
.editor__coordInput {
  flex: 1; min-width: 0;
  border: 0; background: none; text-align: right;
  font-family: inherit; font-size: 14px; color: var(--ink);
  padding: 0; outline: none;
  appearance: textfield;
}
.editor__coordInput::-webkit-outer-spin-button,
.editor__coordInput::-webkit-inner-spin-button { appearance: none; }
.editor__coordPct { color: var(--ink-500); }
.editor__maxChars { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.editor__maxInput {
  width: 72px;
  font-size: 15px;
  border: 2px solid var(--ink); border-radius: var(--r-sm);
  padding: 4px 10px; text-align: center;
  background: var(--surface); color: var(--ink);
}
.editor__footNote { font-size: 12px; color: var(--ink-600); line-height: 1.5; }

.previewOverlay {
  position: fixed; inset: 0;
  background: rgba(22,19,26,.82);
  display: grid; place-items: center;
  padding: 32px; z-index: 55; overflow: auto;
}
.previewOverlay__inner {
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: var(--r-2xl);
  padding: 28px;
  display: flex; flex-direction: column; gap: 18px;
  max-width: 100%;
}
.previewOverlay__head { display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.previewOverlay__title { font-size: 26px; font-weight: 800; }
.previewOverlay__note { font-size: 12px; color: var(--ink-600); }
.previewOverlay .meme { max-width: 100%; }

/* =========================================================================
   MOBILE — design screens M1–M8
   ========================================================================= */

@media (max-width: 900px) {
  .topbar { height: 64px; padding: 0 20px; gap: 10px; }
  .mark__jw { font-size: 18px; padding: 1px 8px; }
  .mark__name { font-size: 20px; }

  /* M1 Join */
  .join__body {
    grid-template-columns: 1fr;
    gap: 24px;
    padding: 20px 22px 28px;
  }
  .join__pitch { gap: 16px; }
  .join__sub { font-size: 17px; }
  .join__teasers { display: none; }
  .join__card {
    max-width: none; justify-self: stretch;
    padding: 22px; gap: 16px; box-shadow: var(--sh-3);
  }
  .join__avatars { grid-template-columns: repeat(4, 1fr); }
  .join__codeCell { height: 52px; font-size: 22px; }
  .join__myAvatar { width: 48px; height: 48px; font-size: 14px; }

  /* M2 Lobby */
  .lobby__body { grid-template-columns: 1fr; gap: 20px; padding: 16px 22px 28px; }
  .lobby__main { gap: 18px; }
  .lobby__codeRow {
    flex-direction: column; align-items: stretch; gap: 12px;
    background: var(--ink); color: var(--paper);
    border-radius: var(--r-xl); padding: 18px 20px;
  }
  .lobby__codeRow .eyebrow { color: var(--ink-400); font-size: 12px; }
  .lobby__code { font-size: 44px; color: var(--purple); }
  .lobby__copy { background: var(--purple); border-color: var(--purple); box-shadow: none; }
  .lobby__grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .lobby__player {
    flex-direction: row; justify-content: flex-start;
    padding: 10px; gap: 10px; min-height: 0;
    border-radius: var(--r-md);
  }
  .lobby__player .avatar { width: 36px !important; height: 36px !important; font-size: 11px !important; }
  .lobby__playerName { font-size: 16px; text-align: left; }
  .lobby__hostBadge { top: -8px; right: -4px; font-size: 10px; }
  .lobby__slot { min-height: 60px; font-size: 12px; border-radius: var(--r-md); }
  .lobby__settings {
    max-width: none; padding: 20px; gap: 16px; box-shadow: var(--sh-3);
  }

  /* M3 Create */
  .create__body {
    grid-template-columns: 1fr;
    gap: 16px;
    padding: 16px 22px 20px;
  }
  .create__stage .meme { width: 100%; }
  .create__panel { gap: 12px; justify-content: flex-start; }
  .create__title { font-size: 24px; }
  .create__note { font-size: 14px; }
  .create__actions { gap: 10px; }
  .create__swap { flex: 0 0 76px; font-size: 12px; font-family: var(--font-mono); padding: 0 8px; }
  .create__foot { height: 60px; padding: 0 22px; gap: 10px; }
  .create__dots .avatar { width: 28px !important; height: 28px !important; font-size: 9px !important; }
  .create__timerText { font-size: 16px; }
  .create__timer .timerRing { display: none; }  /* ring gives way to the digits */

  /* M4 Vote */
  .vote__body { gap: 24px; padding: 20px 22px 32px; }
  .vote__prompt { font-size: 24px; }
  .vote__ratings {
    display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px;
    width: 100%;
  }
  .vote__sticker {
    width: auto; height: 64px;
    font-size: 13px; padding: 0;
    border-width: 2px; border-radius: var(--r-md);
  }
  .vote__sticker.is-on { box-shadow: 3px 3px 0 var(--pink); }
  .vote__progress .vote__count { margin-right: 0; }
  .vote__dots { display: none; }  /* dots give way to the counter */

  /* M5 Results — the design's mobile header drops the wordmark, so the round
     pill and the next-round countdown both fit on one line. */
  .results .topbar { padding: 0 16px; gap: 8px; }
  .results .mark { display: none; }
  .results .pill { font-size: 12px; padding: 4px 10px; }
  .results__next { font-size: 12px; padding: 4px 0; text-align: right; }

  .results__body { grid-template-columns: 1fr; gap: 20px; padding: 16px 22px 28px; overflow: auto; }
  .results__bestCol .meme, .results__noBest { width: 100%; }
  .results__boardTitle { font-size: 24px; margin-bottom: 0; }
  .results__row { padding: 8px 12px; gap: 10px; border-radius: var(--r-md); }
  .results__rank { font-size: 15px; width: 16px; }
  .results__row .avatar { width: 32px !important; height: 32px !important; font-size: 10px !important; }
  .results__name { font-size: 16px; }
  .results__delta { font-size: 12px; padding: 1px 7px; border-width: 1.5px; }
  .results__pts { font-size: 16px; width: 52px; }
  .results__by { font-size: 18px; }

  /* M8 Final — one column as in the design: TADAA, the winner, then the two
     runner-up cards side by side. In flow rather than absolute so nothing
     overlaps, and positioned so it all paints above the sunburst and glow. */
  .final__stage {
    display: flex; flex-wrap: wrap; justify-content: center; align-content: flex-start;
    gap: 14px;
    padding: 12px 22px 24px;
  }
  .final__tadaa {
    position: relative; top: auto; flex-basis: 100%;
    font-size: clamp(52px, 17vw, 76px); -webkit-text-stroke-width: 3px; text-shadow: 5px 5px 0 var(--ink);
  }
  .final__winner { position: relative; top: auto; flex-basis: 100%; order: 1; }
  .final__winnerAvatar {
    width: 150px; height: 150px;
    border-width: 5px; font-size: 38px;
    box-shadow: 0 0 0 6px var(--surface), 8px 8px 0 6px var(--ink);
  }
  .final__badge { font-size: 20px; padding: 4px 11px; right: -24px; }
  .final__nameplate { margin-top: -14px; transform: scale(.66); }
  .final__score { font-size: 14px; padding: 4px 14px; margin-top: 4px; }
  .final__podium {
    position: relative;   /* anchors the rank badge; static let it escape to the corner */
    top: auto; left: auto; right: auto;   /* drop the desktop offsets */
    order: 2;
    width: auto; flex: 1 1 0; min-width: 0;
    margin-top: 20px;
    transform: none;
    padding: 12px; gap: 6px;
    border-radius: var(--r-xl); box-shadow: var(--sh-3);
  }
  .final__podiumRank {
    width: 34px; height: 34px; font-size: 17px;
    top: -14px; left: -10px; right: auto;
  }
  .final__podium--right .final__podiumRank { left: -10px; right: auto; }
  .final__podiumAvatar { width: 56px; height: 56px; font-size: 15px; border-width: 2px; }
  .final__podiumName { font-size: 17px; }
  .final__podiumPts { font-size: 13px; }
  .final__foot { height: auto; padding: 16px 22px; gap: 10px; }
  .final__foot .btn { flex: 1; min-width: 130px; height: 52px; font-size: 16px; }
  .final__meta { display: none; }

  /* M6 Admin library */
  .library { flex-direction: column; }
  .library__side {
    width: auto;
    flex-direction: row; align-items: center; gap: 4px;
    padding: 12px 16px;
    overflow-x: auto;
  }
  .library__sideMark { margin-bottom: 0; margin-right: 10px; flex-shrink: 0; }
  .library__nav { padding: 8px 12px; font-size: 14px; white-space: nowrap; flex-shrink: 0; }
  .library__signout { display: none; }
  .library__toGame { flex-shrink: 0; white-space: nowrap; }
  .library__main { padding: 16px 22px 28px; gap: 16px; }
  .library__title { font-size: 28px; }
  .library__head { flex-direction: column; align-items: stretch; gap: 12px; }
  .library__tools { gap: 8px; }
  .library__search { flex: 1; width: auto; }
  .library__filters {
    flex-wrap: nowrap; overflow-x: auto;
    margin: 0 -22px; padding: 0 22px 4px;
  }
  .library__chip { flex-shrink: 0; height: 34px; padding: 0 12px; font-size: 14px; }
  .library__grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .library__thumb { height: 96px; }
  .library__meta { padding: 8px 10px; gap: 4px; }
  .library__name { font-size: 14px; }
  .library__stats { font-size: 11px; }
  .library__status { font-size: 10px; padding: 1px 6px; }

  /* M7 Admin editor */
  .editor__bar {
    height: auto; flex-wrap: wrap; gap: 10px;
    padding: 10px 22px;
  }
  .editor__divider { display: none; }
  .editor__name { font-size: 18px; width: 140px; }
  .editor__body {
    grid-template-columns: 1fr;
    grid-template-areas: 'canvas' 'right' 'left';
    overflow: auto;
  }
  .editor__canvas { grid-area: canvas; padding: 16px 22px; background: none; }
  .editor__rail--right { grid-area: right; border-left: 0; border-top: 2px solid var(--ink); }
  .editor__rail--left { grid-area: left; border-right: 0; border-top: 2px solid var(--ink); }
  .editor__rail { padding: 18px 22px; gap: 16px; }
  .editor__selTitle { font-size: 18px; }
  .editor__coords { grid-template-columns: repeat(4, 1fr); gap: 6px; }
  .editor__coord { padding: 6px 8px; font-size: 12px; }
  .editor__coordInput { font-size: 12px; }
}

/* Tighter still: single-column grids on small phones. */
@media (max-width: 420px) {
  .lobby__grid { grid-template-columns: 1fr; }
  .library__grid { grid-template-columns: 1fr; }
  .vote__sticker { font-size: 11px; }
  .join__body, .lobby__body, .create__body, .results__body { padding-left: 16px; padding-right: 16px; }
}

/* Connection lost: a bar along the top until the socket is back. */
.netbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 60;
  background: var(--pink); color: var(--ink);
  border-bottom: 2px solid var(--ink);
  font-family: var(--font-mono); font-size: 14px;
  text-align: center; padding: 8px 16px;
}
