@import url("https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=DM+Sans:opsz,wght@9..40,400;9..40,500;9..40,600;9..40,700&family=Playfair+Display:ital,wght@0,600;0,700;1,600&display=swap");

:root {
  color-scheme: dark;
  --ink: #12131d;
  --ink-soft: #1a1c29;
  --ink-raised: #222433;
  --line: rgba(244, 238, 223, 0.14);
  --line-strong: rgba(244, 238, 223, 0.24);
  --paper: #f4eedf;
  --paper-muted: #bdb9b3;
  --paper-faint: #8c8e97;
  --coral: #f07c60;
  --coral-light: #ffad8e;
  --yellow: #f0bd5a;
  --green: #8ec7ac;
  --shadow: 0 24px 65px rgba(0, 0, 0, 0.3);
  font-family: "DM Sans", system-ui, sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html, body, #root { min-height: 100%; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--paper);
  background:
    radial-gradient(circle at 87% -10%, rgba(240, 124, 96, 0.16), transparent 30rem),
    radial-gradient(circle at 5% 90%, rgba(142, 199, 172, 0.07), transparent 34rem),
    var(--ink);
}

button, input { font: inherit; }

button { border: 0; }

button, label[for] { -webkit-tap-highlight-color: transparent; }

button:not(:disabled), label[for] { cursor: pointer; }

button:disabled { cursor: not-allowed; opacity: 0.42; }

button:focus-visible, input:focus-visible, label[for]:focus-within {
  outline: 2px solid var(--coral-light);
  outline-offset: 3px;
}

.hidden { display: none !important; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.app-shell { min-height: 100vh; }

.topbar {
  position: relative;
  z-index: 10;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  height: 78px;
  padding: 0 clamp(1.35rem, 4vw, 4.5rem);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  gap: 0.72rem;
  color: var(--paper);
  font-family: "DM Mono", monospace;
  font-size: 0.73rem;
  font-weight: 500;
  letter-spacing: 0.075em;
  text-decoration: none;
  text-transform: uppercase;
}

.brand-mark {
  display: grid;
  grid-template-columns: repeat(2, 6px);
  gap: 2px;
  width: 14px;
  height: 14px;
  transform: rotate(45deg);
}

.brand-mark i {
  display: block;
  background: var(--coral);
  border-radius: 1px;
}

.brand-mark i:nth-child(2), .brand-mark i:nth-child(3) { background: var(--paper); }

.room-status, .presence-title {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.48rem;
  color: var(--paper-muted);
  font-family: "DM Mono", monospace;
  font-size: 0.65rem;
  letter-spacing: 0.065em;
  text-transform: uppercase;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(142, 199, 172, 0.11), 0 0 12px rgba(142, 199, 172, 0.5);
}

.top-actions { display: flex; justify-content: flex-end; align-items: center; gap: 0.85rem; }

.sound-button, .avatar {
  display: grid;
  place-items: center;
  color: var(--paper);
  background: transparent;
}

.sound-button {
  width: 30px;
  height: 30px;
  font-family: "DM Mono", monospace;
  font-size: 1.35rem;
  line-height: 1;
  transition: color 160ms ease, transform 160ms ease;
}

.sound-button:hover { color: var(--coral-light); transform: rotate(-15deg); }

.avatar {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  font-family: "DM Mono", monospace;
  font-size: 0.73rem;
  transition: border-color 160ms ease, background 160ms ease;
}

.avatar:hover { border-color: var(--paper); background: rgba(244, 238, 223, 0.1); }

main { min-height: calc(100vh - 78px); }

.eyebrow {
  margin: 0;
  color: var(--coral-light);
  font-family: "DM Mono", monospace;
  font-size: 0.65rem;
  font-weight: 500;
  letter-spacing: 0.145em;
  line-height: 1.4;
  text-transform: uppercase;
}

/* Welcome */
.welcome-screen {
  position: relative;
  display: grid;
  grid-template-columns: minmax(280px, 0.95fr) minmax(380px, 1.08fr) minmax(175px, 0.38fr);
  min-height: calc(100vh - 78px);
  overflow: hidden;
  isolation: isolate;
}

.welcome-screen::before {
  position: absolute;
  z-index: -2;
  inset: 0;
  content: "";
  opacity: 0.21;
  background-image: linear-gradient(rgba(244, 238, 223, 0.075) 1px, transparent 1px), linear-gradient(90deg, rgba(244, 238, 223, 0.075) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(90deg, black, transparent 70%);
}

.hero-copy {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  padding: clamp(3.3rem, 8vh, 7.4rem) clamp(1.5rem, 5.8vw, 7.1rem) 6.5rem;
}

.hero-copy h1 {
  max-width: 630px;
  margin: 1.15rem 0 1.28rem;
  color: var(--paper);
  font-family: "Playfair Display", Georgia, serif;
  font-size: clamp(3.05rem, 5.45vw, 6.6rem);
  font-weight: 600;
  letter-spacing: -0.055em;
  line-height: 0.94;
}

.hero-copy h1 em { color: var(--coral-light); font-weight: 600; }

.lede {
  max-width: 390px;
  margin: 0;
  color: var(--paper-muted);
  font-size: clamp(0.96rem, 1.25vw, 1.1rem);
  line-height: 1.65;
}

.hero-actions { display: flex; flex-wrap: wrap; gap: 0.7rem; margin-top: 2rem; }

.landing-presets-block {
  width: 100%;
  margin-top: 1.6rem;
}

.preset-eyebrow {
  display: block;
  margin-bottom: 0.65rem;
  color: var(--paper-faint);
  font-family: "DM Mono", monospace;
  font-size: 0.63rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.landing-presets-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
  max-width: 440px;
}

.landing-preset-btn {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.45rem 0.65rem;
  background: rgba(244, 238, 223, 0.04);
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--paper);
  text-align: left;
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.landing-preset-btn:hover {
  background: rgba(240, 124, 96, 0.12);
  border-color: var(--coral-light);
  transform: translateY(-2px);
}

.landing-preset-btn img {
  width: 40px;
  height: 40px;
  border-radius: 3px;
  object-fit: cover;
  flex-shrink: 0;
}

.landing-preset-btn span {
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.presets-container {
  margin-top: 1.5rem;
}

.preset-cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.58rem;
}

.preset-card-item {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 0.45rem;
  background: rgba(244, 238, 223, 0.035);
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--paper-muted);
  text-align: left;
  transition: border-color 160ms ease, color 160ms ease, background 160ms ease, transform 160ms ease;
}

.preset-card-item:hover {
  color: var(--paper);
  background: rgba(240, 124, 96, 0.1);
  border-color: var(--coral-light);
  transform: translateY(-2px);
}

.preset-card-item.selected {
  color: var(--paper);
  background: rgba(240, 124, 96, 0.18);
  border-color: var(--coral);
  box-shadow: 0 0 0 1px var(--coral);
}

.preset-card-item img {
  width: 100%;
  aspect-ratio: 16/9;
  border-radius: 2px;
  object-fit: cover;
  margin-bottom: 0.4rem;
}

.preset-card-item span {
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 47px;
  gap: 0.72rem;
  padding: 0.7rem 1.1rem;
  border: 1px solid transparent;
  border-radius: 2px;
  font-size: 0.84rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  text-decoration: none;
  transition: transform 160ms ease, box-shadow 160ms ease, color 160ms ease, background 160ms ease, border-color 160ms ease;
}

.button span { font-size: 1.05rem; line-height: 1; }

.button-primary {
  color: #22161a;
  background: var(--coral);
  box-shadow: 5px 5px 0 rgba(245, 238, 222, 0.18);
}

.button-primary:hover:not(:disabled) { background: var(--coral-light); transform: translate(-2px, -2px); box-shadow: 7px 7px 0 rgba(245, 238, 222, 0.21); }
.button-primary:active:not(:disabled) { transform: translate(1px, 1px); box-shadow: 3px 3px 0 rgba(245, 238, 222, 0.18); }

.button-quiet {
  color: var(--paper);
  background: rgba(244, 238, 223, 0.04);
  border-color: var(--line-strong);
}

.button-quiet:hover { background: rgba(244, 238, 223, 0.11); border-color: var(--paper-muted); }

.tiny-note {
  margin: 1.3rem 0 0;
  color: var(--paper-faint);
  font-family: "DM Mono", monospace;
  font-size: 0.62rem;
  letter-spacing: 0.02em;
}

.hero-art {
  position: relative;
  min-height: 560px;
  overflow: hidden;
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  background: #db785f;
}

.hero-art::before {
  position: absolute;
  inset: 0;
  content: "";
  opacity: 0.37;
  background-image: radial-gradient(rgba(36, 23, 31, 0.6) 0.6px, transparent 0.8px);
  background-size: 4px 4px;
  mix-blend-mode: multiply;
}

.sun {
  position: absolute;
  top: 12%;
  left: 50%;
  width: min(35vw, 390px);
  aspect-ratio: 1;
  border-radius: 50%;
  transform: translateX(-50%);
  background: #f2b45c;
  box-shadow: 0 0 0 1px rgba(255, 239, 187, 0.3), 0 0 95px rgba(240, 189, 90, 0.25);
}

.horizon {
  position: absolute;
  z-index: 1;
  right: -6%;
  bottom: 15%;
  left: -6%;
  height: 26%;
  transform: skewY(-6deg);
  background: #313047;
  box-shadow: 0 -1px rgba(18, 19, 29, 0.3), 0 36px 0 #202131;
}

.puzzle-silhouette {
  position: absolute;
  z-index: 2;
  width: clamp(118px, 15vw, 230px);
  aspect-ratio: 1;
  filter: drop-shadow(13px 16px 0 rgba(27, 25, 39, 0.2));
  transform: rotate(var(--angle, 0deg));
  background: var(--piece, #f3e8cf);
  clip-path: polygon(0 0, 39% 0, 42% 11%, 50% 17%, 59% 15%, 64% 7%, 63% 0, 100% 0, 100% 40%, 89% 42%, 83% 50%, 85% 60%, 94% 64%, 100% 63%, 100% 100%, 61% 100%, 60% 89%, 51% 84%, 42% 86%, 37% 95%, 38% 100%, 0 100%, 0 62%, 11% 60%, 16% 51%, 14% 41%, 5% 37%, 0 38%);
}

.p1 { --angle: -9deg; --piece: #2d3148; top: 19%; left: 10%; }
.p2 { --angle: 10deg; --piece: #f5e9ce; right: 7%; bottom: 8%; }
.p3 { --angle: 19deg; --piece: #e6a552; width: clamp(86px, 11vw, 160px); top: 48%; left: 16%; }
.p4 { --angle: -5deg; --piece: #b95755; width: clamp(78px, 9vw, 133px); top: 9%; right: 12%; }

.hand-note {
  position: absolute;
  z-index: 3;
  right: 8%;
  bottom: 7%;
  color: #ffe9c1;
  font-family: "Playfair Display", Georgia, serif;
  font-size: clamp(1.05rem, 1.5vw, 1.5rem);
  font-style: italic;
  transform: rotate(-7deg);
}

.hand-note span { display: inline-block; margin-left: 0.2rem; font-family: "DM Sans", sans-serif; }

.how-it-works {
  align-self: center;
  padding: 0 clamp(1.5rem, 3.6vw, 4rem);
}

.side-rule { display: block; width: 34px; height: 1px; margin-bottom: 1.25rem; background: var(--coral); }

.how-it-works ol { display: grid; gap: 1.08rem; padding: 0; margin: 1.5rem 0 0; list-style: none; }

.how-it-works li { display: grid; gap: 0.25rem; color: var(--paper-muted); font-size: 0.82rem; }

.how-it-works li span { color: var(--paper-faint); font-family: "DM Mono", monospace; font-size: 0.6rem; letter-spacing: 0.1em; }

.room-join {
  position: absolute;
  bottom: 1.65rem;
  left: clamp(1.5rem, 5.8vw, 7.1rem);
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 35px;
  color: var(--paper-faint);
  font-family: "DM Mono", monospace;
  font-size: 0.61rem;
}

.room-join input {
  width: 102px;
  min-height: 32px;
  padding: 0.35rem 0.35rem 0.3rem 0.55rem;
  color: var(--paper);
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line-strong);
  border-radius: 0;
  font-family: "DM Mono", monospace;
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  transition: border-color 160ms ease;
}

.room-join input::placeholder { color: #656875; text-transform: none; }
.room-join input:focus { border-bottom-color: var(--coral-light); outline: none; }

.room-join button {
  display: grid;
  place-items: center;
  width: 29px;
  height: 29px;
  color: var(--ink);
  background: var(--paper);
  border-radius: 50%;
  font-size: 1rem;
  transition: background 160ms ease, transform 160ms ease;
}

.room-join button:hover { background: var(--coral-light); transform: translateX(2px); }

.site-credit {
  position: absolute;
  right: clamp(1.5rem, 3.5vw, 4.5rem);
  bottom: 1.75rem;
  color: var(--paper-faint);
  font-family: "DM Mono", monospace;
  font-size: 0.58rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.site-credit span { color: var(--yellow); }

/* Lobby */
.lobby-screen {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 0.28fr);
  min-height: calc(100vh - 78px);
}

.lobby-panel { padding: clamp(2.8rem, 7vh, 6.5rem) clamp(1.5rem, 8vw, 10rem) 3rem; }

.lobby-heading { max-width: 530px; }
.lobby-heading h2, .complete-card h2, .name-modal h2 {
  margin: 0.55rem 0 0;
  color: var(--paper);
  font-family: "Playfair Display", Georgia, serif;
  font-size: clamp(2.3rem, 3.6vw, 4.15rem);
  font-weight: 600;
  letter-spacing: -0.045em;
  line-height: 1;
}

.lobby-heading > p:last-child { margin: 0.86rem 0 0; color: var(--paper-muted); line-height: 1.6; }

.image-picker { margin-top: 2.45rem; }

.image-drop {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 174px;
  padding: 1.3rem;
  overflow: hidden;
  color: var(--paper);
  border: 1px dashed rgba(244, 238, 223, 0.36);
  background: linear-gradient(135deg, rgba(240, 124, 96, 0.08), rgba(244, 238, 223, 0.015));
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.image-drop::after {
  position: absolute;
  inset: 10px;
  content: "";
  border: 1px solid rgba(244, 238, 223, 0.05);
  pointer-events: none;
}

.image-drop:hover { background: rgba(240, 124, 96, 0.12); border-color: var(--coral-light); transform: translateY(-2px); }
.image-drop strong { margin-top: 0.35rem; font-size: 0.94rem; }
.image-drop small { margin-top: 0.36rem; color: var(--paper-faint); font-size: 0.73rem; }

.upload-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  color: var(--coral-light);
  border: 1px solid currentColor;
  border-radius: 50%;
  font-family: "DM Mono", monospace;
  font-size: 1.05rem;
}

.image-picked {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1rem;
  align-items: center;
  min-height: 174px;
  padding: 0.9rem;
  border: 1px solid var(--line-strong);
  background: rgba(244, 238, 223, 0.035);
}

.image-picked img { display: block; width: 100%; max-height: 154px; object-fit: cover; }

.image-picked button, .invite-box button, .room-chip button, .tool-button, .game-footer button, #change-image {
  color: var(--paper-muted);
  background: transparent;
  font-family: "DM Mono", monospace;
  font-size: 0.65rem;
  letter-spacing: 0.04em;
  transition: color 160ms ease, background 160ms ease;
}

.image-picked button { align-self: end; padding: 0.5rem; }
.image-picked button:hover, .invite-box button:hover, .room-chip button:hover, .game-footer button:hover { color: var(--coral-light); }

.difficulty-block { margin-top: 2rem; }

.difficulty-block > div:first-child { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: 0.68rem; }
.difficulty-block label { color: var(--paper); font-size: 0.87rem; font-weight: 700; }
.difficulty-block > div:first-child span { color: var(--paper-faint); font-family: "DM Mono", monospace; font-size: 0.63rem; }

.difficulty-options { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.58rem; }

.difficulty {
  min-height: 72px;
  padding: 0.7rem;
  text-align: left;
  color: var(--paper-muted);
  background: rgba(244, 238, 223, 0.035);
  border: 1px solid var(--line);
  transition: border-color 160ms ease, color 160ms ease, background 160ms ease, transform 160ms ease;
}

.difficulty b { display: block; font-size: clamp(0.68rem, 1vw, 0.82rem); font-weight: 600; line-height: 1.15; }
.difficulty small { display: block; margin-top: 0.34rem; color: var(--paper-faint); font-family: "DM Mono", monospace; font-size: 0.57rem; }
.difficulty:hover { color: var(--paper); border-color: rgba(244, 238, 223, 0.42); transform: translateY(-2px); }
.difficulty.selected { color: #321d1d; background: var(--coral-light); border-color: var(--coral-light); box-shadow: 3px 3px 0 rgba(240, 124, 96, 0.32); }
.difficulty.selected small { color: rgba(50, 29, 29, 0.66); }

.piece-style-block { margin-top: 1.5rem; }
.setting-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: 0.68rem; }
.setting-heading label { color: var(--paper); font-size: 0.87rem; font-weight: 700; }
.setting-heading span { color: var(--paper-faint); font-family: "DM Mono", monospace; font-size: 0.63rem; }
.piece-style-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.58rem; }
.piece-style {
  display: flex;
  align-items: center;
  gap: 0.68rem;
  min-height: 67px;
  padding: 0.58rem 0.65rem;
  color: var(--paper-muted);
  text-align: left;
  background: rgba(244, 238, 223, 0.035);
  border: 1px solid var(--line);
  transition: border-color 160ms ease, color 160ms ease, background 160ms ease, transform 160ms ease;
}
.piece-style:hover { color: var(--paper); border-color: rgba(244, 238, 223, 0.42); transform: translateY(-2px); }
.piece-style.selected { color: #321d1d; background: rgba(142, 199, 172, 0.96); border-color: var(--green); box-shadow: 3px 3px 0 rgba(142, 199, 172, 0.22); }
.piece-style b { display: block; font-size: clamp(0.68rem, 1vw, 0.82rem); font-weight: 600; line-height: 1.15; }
.piece-style small { display: block; margin-top: 0.28rem; color: var(--paper-faint); font-family: "DM Mono", monospace; font-size: 0.57rem; }
.piece-style.selected small { color: rgba(50, 29, 29, 0.66); }
.piece-style-preview {
  position: relative;
  display: block;
  flex: 0 0 31px;
  width: 31px;
  height: 31px;
  color: currentColor;
  background: currentColor;
  opacity: .9;
}
.piece-style-preview::before, .piece-style-preview::after { position: absolute; content: ""; background: inherit; }
.organic-preview { border-radius: 7px 10px 8px 11px; clip-path: polygon(0 0, 45% 0, 53% 8%, 62% 7%, 69% 0, 100% 0, 100% 39%, 91% 45%, 92% 55%, 100% 62%, 100% 100%, 57% 100%, 53% 91%, 40% 91%, 35% 100%, 0 100%, 0 60%, 8% 54%, 8% 43%, 0 37%); }
.classic-preview { clip-path: polygon(0 0, 39% 0, 40% 14%, 50% 20%, 60% 14%, 61% 0, 100% 0, 100% 38%, 86% 39%, 80% 50%, 86% 61%, 100% 62%, 100% 100%, 61% 100%, 60% 86%, 50% 80%, 40% 86%, 39% 100%, 0 100%, 0 62%, 14% 61%, 20% 50%, 14% 39%, 0 38%); }
.smooth-preview { border-radius: 10px; clip-path: polygon(0 0, 100% 0, 100% 37%, 89% 43%, 88% 56%, 100% 62%, 100% 100%, 63% 100%, 56% 89%, 43% 88%, 37% 100%, 0 100%, 0 63%, 11% 56%, 12% 43%, 0 37%); }

.lobby-bottom { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 1.15rem; align-items: end; margin-top: 2.3rem; }

.invite-box {
  display: grid;
  grid-template-columns: auto minmax(80px, 1fr) auto;
  gap: 0.6rem;
  align-items: center;
  min-height: 47px;
  padding: 0 0.73rem;
  border-bottom: 1px solid var(--line-strong);
}

.invite-box > span { color: var(--paper-faint); font-family: "DM Mono", monospace; font-size: 0.6rem; }
.invite-box code { overflow: hidden; color: var(--paper-muted); font-family: "DM Mono", monospace; font-size: 0.63rem; text-overflow: ellipsis; white-space: nowrap; }
.invite-box button { padding: 0.45rem; color: var(--coral-light); text-transform: uppercase; }

.start-button { min-width: 150px; }

.lobby-side {
  padding: clamp(2.8rem, 7vh, 6.5rem) clamp(1.35rem, 3vw, 3.6rem) 3rem;
  border-left: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.09);
}

.presence-title { justify-content: flex-start; }
.people-list { display: grid; gap: 0.55rem; min-height: 42px; margin: 1.25rem 0; }

/* Javascript may render any person entries in the list. */
.people-list > * {
  display: flex;
  align-items: center;
  gap: 0.52rem;
  min-height: 38px;
  padding: 0.55rem 0.6rem;
  color: var(--paper-muted);
  background: rgba(244, 238, 223, 0.04);
  border: 1px solid rgba(244, 238, 223, 0.07);
  font-size: 0.75rem;
}

.person-dot {
  display: inline-grid;
  flex: 0 0 23px;
  place-items: center;
  width: 23px;
  height: 23px;
  color: #171824;
  border-radius: 50%;
  font-family: "DM Mono", monospace;
  font-size: 0.6rem;
  font-weight: 500;
}

.person > small { margin-left: auto; color: var(--paper-faint); font-family: "DM Mono", monospace; font-size: 0.54rem; text-transform: uppercase; }
.person span small { color: var(--paper-faint); font-size: 0.62rem; }

.lobby-side > p { max-width: 215px; margin: 2rem 0 0; color: var(--paper-faint); font-size: 0.75rem; line-height: 1.65; }

/* Puzzle table */
.game-screen {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: calc(100vh - 78px);
  min-height: 500px;
}

.game-toolbar {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(180px, 1.35fr) minmax(150px, 1fr);
  align-items: center;
  gap: 1rem;
  min-height: 68px;
  padding: 0.7rem clamp(1rem, 3vw, 3.5rem);
  border-bottom: 1px solid var(--line);
  background: rgba(18, 19, 29, 0.86);
}

.room-chip { display: flex; align-items: center; gap: 0.55rem; }
.room-chip > span:nth-child(2) { color: var(--paper-muted); font-family: "DM Mono", monospace; font-size: 0.66rem; letter-spacing: 0.075em; }
.room-chip button { padding: 0.32rem; color: var(--paper-faint); font-size: 0.84rem; }

.game-progress { display: grid; grid-template-columns: auto minmax(70px, 1fr); gap: 0.6rem; align-items: center; }
.game-progress > span { color: var(--paper-faint); font-family: "DM Mono", monospace; font-size: 0.6rem; text-align: right; white-space: nowrap; }
.game-progress > div { height: 4px; overflow: hidden; background: rgba(244, 238, 223, 0.12); border-radius: 10px; }
.game-progress i { display: block; width: 0; height: 100%; background: var(--coral); border-radius: inherit; transition: width 360ms ease; }

.game-tools { display: flex; justify-content: flex-end; gap: 0.45rem; }

.tool-button {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 32px;
  padding: 0.35rem 0.55rem;
  color: var(--paper-muted);
  border: 1px solid transparent;
  border-radius: 2px;
}

.tool-button:hover { color: var(--paper); background: rgba(244, 238, 223, 0.06); border-color: var(--line); }
.tool-button.active { color: var(--paper); background: rgba(240, 124, 96, 0.16); border-color: rgba(240, 124, 96, 0.42); }
.tool-button > span { color: var(--coral-light); font-size: 0.95rem; }
kbd { padding: 0.08rem 0.25rem; color: var(--paper-faint); background: rgba(244, 238, 223, 0.08); border: 1px solid rgba(244, 238, 223, 0.12); border-radius: 2px; font-family: "DM Mono", monospace; font-size: 0.55rem; }

.canvas-wrap {
  position: relative;
  min-height: 0;
  overflow: hidden;
  background:
    linear-gradient(rgba(244, 238, 223, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(244, 238, 223, 0.035) 1px, transparent 1px),
    radial-gradient(ellipse at 50% 50%, #252738 0%, #181a27 73%);
  background-size: 32px 32px, 32px 32px, 100% 100%;
}

.canvas-wrap::before {
  position: absolute;
  z-index: 0;
  inset: clamp(1.2rem, 4vw, 4rem);
  content: "";
  pointer-events: none;
  border: 1px dashed rgba(244, 238, 223, 0.11);
  border-radius: 3px;
}

#puzzle-canvas {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
}

#puzzle-canvas:active { cursor: grabbing; }
#puzzle-canvas.dragging { cursor: grabbing; }

.canvas-guide {
  position: absolute;
  z-index: 2;
  bottom: 1rem;
  left: 50%;
  max-width: calc(100% - 2rem);
  padding: 0.45rem 0.72rem;
  color: rgba(244, 238, 223, 0.64);
  background: rgba(18, 19, 29, 0.68);
  border: 1px solid rgba(244, 238, 223, 0.1);
  border-radius: 100px;
  backdrop-filter: blur(8px);
  font-family: "DM Mono", monospace;
  font-size: clamp(0.56rem, 1.5vw, 0.65rem);
  letter-spacing: 0.02em;
  text-align: center;
  transform: translateX(-50%);
  pointer-events: none;
  transition: opacity 280ms ease, transform 280ms ease;
}

.preview-card {
  position: absolute;
  z-index: 4;
  top: clamp(0.85rem, 2vw, 1.5rem);
  right: clamp(0.85rem, 2vw, 1.5rem);
  width: clamp(112px, 16vw, 205px);
  padding: 0.38rem;
  background: var(--paper);
  box-shadow: 8px 9px 0 rgba(0, 0, 0, 0.22), 0 13px 30px rgba(0, 0, 0, 0.35);
  transform: rotate(1.4deg);
  animation: card-in 180ms ease-out;
}

.preview-card img { display: block; width: 100%; aspect-ratio: 1.45; object-fit: cover; }
.preview-card.pinned { outline: 2px solid rgba(245, 185, 78, 0.72); outline-offset: 3px; }

#pin-preview {
  position: absolute;
  top: -11px;
  left: 50%;
  display: grid;
  place-items: center;
  width: 23px;
  height: 23px;
  padding: 0;
  color: #49272b;
  background: var(--coral-light);
  border: 1px solid rgba(61, 31, 35, 0.3);
  border-radius: 50%;
  box-shadow: 1px 2px 2px rgba(0, 0, 0, 0.28);
  font-size: 0.9rem;
  transform: translateX(-50%);
  transition: transform 160ms ease, background 160ms ease;
}

#pin-preview:hover { background: var(--yellow); transform: translateX(-50%) rotate(14deg); }

.complete-card {
  position: absolute;
  z-index: 5;
  top: 50%;
  left: 50%;
  width: min(420px, calc(100% - 2rem));
  padding: clamp(1.6rem, 5vw, 2.7rem);
  text-align: center;
  background: #f4eedf;
  box-shadow: 14px 16px 0 rgba(0, 0, 0, 0.18), var(--shadow);
  color: #201c27;
  transform: translate(-50%, -50%) rotate(-1.3deg);
  animation: card-in 260ms cubic-bezier(.2,.8,.2,1);
}

.complete-card > span { display: block; color: var(--coral); font-size: 1.5rem; }
.complete-card h2 { margin-top: 0.35rem; color: #201c27; font-size: clamp(2rem, 4vw, 3.2rem); }
.complete-card p { margin: 0.8rem auto 1.4rem; color: #625c62; font-size: 0.88rem; line-height: 1.55; }
.complete-card .button { min-width: 150px; }

.game-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  padding: 0.5rem clamp(1rem, 3vw, 3.5rem);
  color: var(--paper-faint);
  border-top: 1px solid var(--line);
  background: #151622;
  font-family: "DM Mono", monospace;
  font-size: 0.6rem;
  letter-spacing: 0.025em;
}

.game-footer b { color: var(--green); font-weight: 500; }
.game-footer button { padding: 0.3rem; text-transform: uppercase; }

/* Dialogs and transient feedback */
.modal-backdrop {
  position: fixed;
  z-index: 30;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(9, 10, 16, 0.72);
  backdrop-filter: blur(10px);
}

.name-modal {
  position: relative;
  width: min(430px, 100%);
  padding: clamp(1.7rem, 5vw, 2.8rem);
  background: #f4eedf;
  color: #1c1923;
  box-shadow: 12px 14px 0 rgba(240, 124, 96, 0.65), var(--shadow);
  animation: dialog-in 220ms cubic-bezier(.2,.8,.2,1);
}

.name-modal .eyebrow { color: #b55747; }
.name-modal h2 { color: #1c1923; font-size: clamp(2.1rem, 6vw, 3.3rem); }
.name-modal input {
  width: 100%;
  min-height: 49px;
  margin: 1.4rem 0 0.9rem;
  padding: 0 0.82rem;
  color: #1c1923;
  background: transparent;
  border: 1px solid #b8af9f;
  border-radius: 0;
  font-size: 0.95rem;
}

.name-modal input::placeholder { color: #978e87; }
.name-modal .button { width: 100%; }

.modal-close {
  position: absolute;
  top: 0.7rem;
  right: 0.7rem;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  color: #625c62;
  background: transparent;
  border-radius: 50%;
  font-size: 1.35rem;
  line-height: 1;
  transition: background 160ms ease, color 160ms ease;
}

.modal-close:hover { color: #1c1923; background: rgba(32, 28, 39, 0.08); }

.toast {
  position: fixed;
  z-index: 50;
  bottom: 1.3rem;
  left: 50%;
  max-width: calc(100vw - 2rem);
  padding: 0.7rem 0.92rem;
  color: var(--paper);
  background: #2a2c3c;
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow);
  font-size: 0.78rem;
  transform: translateX(-50%);
}

@keyframes card-in {
  from { opacity: 0; transform: rotate(1.4deg) translateY(-9px); }
  to { opacity: 1; transform: rotate(1.4deg) translateY(0); }
}

@keyframes dialog-in {
  from { opacity: 0; transform: translateY(10px) rotate(1deg) scale(0.98); }
  to { opacity: 1; transform: translateY(0) rotate(0) scale(1); }
}

@media (max-width: 1050px) {
  .welcome-screen { grid-template-columns: minmax(0, 1fr) minmax(350px, 0.86fr); }
  .how-it-works { display: none; }
  .hero-copy { padding-right: clamp(2rem, 5vw, 4rem); }
  .lobby-panel { padding-right: clamp(1.5rem, 5vw, 4rem); padding-left: clamp(1.5rem, 5vw, 4rem); }
  .difficulty-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .topbar { grid-template-columns: 1fr auto; height: 65px; padding: 0 1.15rem; }
  .topbar .room-status { display: none; }
  main { min-height: calc(100vh - 65px); }
  .welcome-screen { display: flex; flex-direction: column; min-height: calc(100vh - 65px); }
  .hero-copy { order: 1; justify-content: flex-start; padding: 3.2rem 1.35rem 2.35rem; }
  .hero-copy h1 { font-size: clamp(3rem, 13vw, 4.35rem); }
  .hero-art { order: 2; min-height: 295px; border: 0; border-top: 1px solid var(--line); }
  .sun { width: min(64vw, 275px); top: 8%; }
  .horizon { bottom: 10%; height: 33%; }
  .p1 { left: 14%; top: 21%; }
  .p2 { right: 12%; bottom: 4%; }
  .p3 { left: 30%; top: 44%; }
  .p4 { right: 15%; top: 6%; }
  .hand-note { right: 13%; bottom: 7%; }
  .room-join { position: relative; order: 3; bottom: auto; left: auto; flex-wrap: wrap; padding: 1.15rem 1.35rem; border-top: 1px solid var(--line); }
  .site-credit { display: none; }
  .lobby-screen { display: block; min-height: calc(100vh - 65px); }
  .lobby-panel { padding: 2.7rem 1.35rem 2rem; }
  .lobby-side { padding: 1.35rem; border-top: 1px solid var(--line); border-left: 0; }
  .lobby-side > p { margin-top: 1rem; }
  .lobby-bottom { grid-template-columns: 1fr; }
  .start-button { width: 100%; }
  .game-screen { height: calc(100vh - 65px); min-height: 430px; }
  .game-toolbar { grid-template-columns: auto 1fr; gap: 0.55rem; min-height: 62px; padding: 0.55rem 0.75rem; }
  .game-progress { order: 3; grid-column: 1 / -1; grid-template-columns: auto 1fr; }
  .game-progress > span { text-align: left; }
  .game-tools { justify-content: flex-end; }
  .tool-button { min-height: 28px; padding: 0.28rem 0.4rem; }
  .tool-button kbd, .tool-button#scatter-button { display: none; }
  .canvas-guide { bottom: 0.65rem; }
  .game-footer { padding: 0.45rem 0.7rem; font-size: 0.53rem; }
  .game-footer span:nth-child(2) { display: none; }
}

@media (max-width: 430px) {
  .brand { font-size: 0.62rem; }
  .sound-button { display: none; }
  .hero-actions { display: grid; width: 100%; grid-template-columns: 1fr; }
  .hero-actions .button { width: 100%; }
  .difficulty-block > div:first-child { align-items: flex-start; flex-direction: column; gap: 0.3rem; }
  .image-picked { grid-template-columns: 1fr; }
  .image-picked button { justify-self: start; }
  .game-toolbar { grid-template-columns: 1fr auto; }
  .tool-button { font-size: 0; }
  .tool-button > span { font-size: 1rem; }
  .tool-button#scatter-button { display: inline-flex; font-size: 0; }
  .tool-button#scatter-button::before { content: "↝"; color: var(--coral-light); font-size: 1rem; }
  .tool-button#scatter-button { color: transparent; }
  .preview-card { width: 100px; }
  .game-footer { min-height: 42px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
