/* えのバトン：クレパスと紙。色面・紙目は pastel.js が実行時に作り、CSS変数で渡す。 */

:root {
  --ink: #3b3430;
  --ink-soft: #7a6a5a;
  --red: #d8483a;
  --blue: #3f61b8;
  --bar-h: 54px;
  --font: "Hiragino Maru Gothic ProN", "Hiragino Maru Gothic Pro", "BIZ UDPGothic", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100dvh;
  background:
    linear-gradient(180deg, #c9e3f1 0, #e4f0ec 120px, #f7efdc 260px);
  overflow-x: hidden;
}

body::after {
  content: "";
  position: fixed;
  left: -4%;
  right: -4%;
  bottom: -18px;
  height: 56px;
  background: var(--sw-leaf) center / 100% 100% no-repeat;
  opacity: .55;
  pointer-events: none;
  z-index: -1;
}

button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
input { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.crayon-btn {
  border: 0;
  min-height: 48px;
  padding: 10px 26px;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: .04em;
  background: var(--sw-sun) center / 100% 100% no-repeat;
  transition: transform .12s ease;
}
.crayon-btn:active { transform: scale(.95) rotate(-1deg); }
.crayon-btn.big { font-size: 22px; padding: 14px 36px; min-height: 58px; }
.crayon-btn:disabled { filter: grayscale(.8); opacity: .6; }

.chip {
  border: 0;
  height: 38px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--sw-cream) center / 100% 100% no-repeat;
  font-size: 14px;
  font-weight: 700;
}

.msg { min-height: 1.4em; margin: 4px 0; font-weight: 800; color: var(--red); text-align: center; }
.msg.pop { animation: pop .35s ease; }
.shake { animation: shake .4s ease; }

@keyframes pop { 0% { transform: scale(.7); opacity: 0; } 60% { transform: scale(1.08); } 100% { transform: none; opacity: 1; } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-8px); } 40% { transform: translateX(7px); } 60% { transform: translateX(-5px); } 80% { transform: translateX(3px); } }
@keyframes bob { 0%, 100% { transform: translateY(0) rotate(-1deg); } 50% { transform: translateY(-5px) rotate(-.4deg); } }
@keyframes wiggle { 0%, 100% { transform: rotate(-24deg) translateX(0); } 50% { transform: rotate(-12deg) translateX(6px); } }
@keyframes draw { from { stroke-dashoffset: 320; } to { stroke-dashoffset: 0; } }

/* 非同期の入口と、自分の絵から伸びるリレー。紙を横に渡す配置。 */
.lease-note { margin: 0; padding: 4px 10px; position: absolute; top: var(--bar-h); width: 100%; text-align: center; font-size: 11px; color: var(--ink-soft); pointer-events: none; }
#homeBtn { flex: 0 0 34px; font-size: 26px; padding: 0; justify-content: center; }
#people { font-size: 12px; white-space: nowrap; }
#lobby .logo { margin-top: 10px; font-size: clamp(54px, 13vw, 88px); }
#lobby #lobbyArt { max-width: 420px; max-height: 110px; object-fit: contain; }
#lobby { padding-bottom: 55px; }
.shelf-section { width: min(900px, 96vw); margin: 12px auto 0; }
.shelf-section h2 { font-size: 18px; text-align: left; padding-left: 12px; }
.shelf-pages { display: flex; justify-content: center; align-items: center; gap: 16px; }
.relay-shelf { display: flex; gap: 18px; overflow-x: auto; padding: 8px 14px 20px; scroll-snap-type: x proximity; }
.shelf-relay { flex: 0 0 150px; min-width: 0; border: 0; padding: 8px; background: #fffaf0; box-shadow: 2px 4px 0 #63503520; transform: rotate(-1deg); display: flex; flex-direction: column; gap: 6px; scroll-snap-align: start; }
.shelf-relay:nth-child(even) { transform: rotate(1deg); }
.shelf-relay img { width: 100%; aspect-ratio: 1; object-fit: contain; }
.shelf-relay span { font-size: 14px; font-weight: bold; }
.shelf-relay small { color: #715d49; font-size: 12px; }
#watch { width: min(960px, 100%); margin: 20px auto 0; text-align: center; padding: 0 14px; }
.watch-title { font-size: 19px; font-weight: bold; display: flex; align-items: center; justify-content: center; gap: 16px; flex-wrap: wrap; }
.watch-title > span { font-size: 24px; color: #ae4b35; padding: 6px 14px; background: var(--sw-tag) center / 100% 100% no-repeat; }
.watch-strip { width: 100%; display: grid; grid-template-columns: minmax(0,1fr) minmax(90px,.6fr) minmax(0,1fr); align-items: center; border: 0; background: none; margin: 20px 0; padding: 12px 8px; }
.watch-paper { display: flex; flex-direction: column; background: #fffaf1; padding: 12px; gap: 8px; transform: rotate(-2deg); box-shadow: 3px 5px 0 #654a2b20; min-width: 0; }
.watch-paper > img { width: 100%; aspect-ratio: 1; object-fit: contain; }
.watch-paper small { color: var(--ink-soft); font-size: 13px; }
.watch-paper b { font-size: 21px; }
.watch-paper.next { transform: rotate(3deg); }
.watch-paper.waiting { aspect-ratio: 1; justify-content: center; align-items: center; gap: 20px; background: #f4ebd8; border: 2px dashed #bdac88; box-shadow: none; }
.waiting-crayon { width: 12px; height: 60px; background: var(--sw-leaf) center / 100% 100%; transform: rotate(25deg); border-radius: 3px; }
.watch-connection { min-width: 0; display: flex; align-items: center; flex-direction: column; gap: 10px; }
.watch-arrow { font-size: 70px; line-height: 1; color: #c9684e; }
.watch-answer { display: flex; flex-direction: column; gap: 6px; align-items: center; font-size: 20px; font-weight: bold; overflow-wrap: anywhere; }
.watch-answer .mark { width: 45px; height: 45px; }
.watch-answer .mark path { animation: none; }
.watch-wait { font-size: 12px; line-height: 1.8; max-width: 90px; color: var(--ink-soft); }
.watch-once { color: var(--ink-soft); font-size: 12px; line-height: 1.8; }
.other-relay { display: block; margin: 20px auto 0; background-image: var(--sw-sky); }
#pauseDraw { margin: 2px auto; }
@media(max-width: 600px) {
  #watch { padding: 0 8px; margin-top: 10px; }
  .watch-title { font-size: 16px; gap: 5px; }
  .watch-title > span { font-size: 20px; }
  .watch-strip { grid-template-columns: minmax(0,1fr) 72px minmax(0,1fr); padding: 8px 4px; margin: 12px 0 18px; }
  .watch-paper { padding: 6px; gap: 5px; }
  .watch-paper small { font-size: 10px; }
  .watch-paper b { font-size: 16px; }
  .watch-arrow { font-size: 48px; }
  .watch-answer { font-size: 14px; }
  .watch-answer .mark { width: 32px; height: 32px; }
  .watch-wait { font-size: 10px; padding: 0 5px; }
  .watch-once { max-width: 280px; margin: 10px auto; }
  .shelf-relay { flex-basis: 128px; }
  #people { display: none; }
}

/* ---------------------------------------------------------------- ヘッダー */

#bar {
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--bar-h);
  padding: 6px max(10px, env(safe-area-inset-right)) 6px max(10px, env(safe-area-inset-left));
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 20;
}
.room-chip span { font-size: 11px; color: var(--ink-soft); }
.room-chip b { letter-spacing: .12em; }
body.offline .room-chip { filter: grayscale(1); animation: pop 1.2s ease infinite alternate; }
.sample-tag {
  padding: 3px 10px;
  font-weight: 900;
  font-size: 13px;
  color: #fff;
  background: var(--sw-rose) center / 100% 100% no-repeat;
  transform: rotate(-4deg);
}
.people { display: flex; align-items: center; gap: 2px; min-width: 0; overflow: hidden; }
.pp { width: 30px; height: 30px; flex: 0 0 auto; }
.pp-me { filter: drop-shadow(0 0 0 #3b3430) drop-shadow(0 2px 0 rgba(0,0,0,.25)); transform: translateY(-2px); }
.pp-empty { border-radius: 50%; border: 2px dashed rgba(59, 52, 48, .22); width: 22px; height: 22px; margin: 4px; }
.pp-view { font-size: 12px; color: var(--ink-soft); margin-left: 4px; white-space: nowrap; }
.bar-gap { flex: 1; }
.emaki-icon {
  width: 22px; height: 16px;
  background:
    linear-gradient(90deg, #d9573f 0 3px, transparent 3px 7px, #4d9d4a 7px 10px, transparent 10px 14px, #3f6fc0 14px 17px, transparent 17px) center / 100% 100%;
  border-radius: 3px;
  opacity: .8;
}
.mute-btn span { width: 22px; height: 22px; display: block; position: relative; }
.mute-btn span::before { content: ""; position: absolute; left: 2px; top: 7px; width: 7px; height: 8px; background: var(--ink); border-radius: 2px; }
.mute-btn span::after { content: ""; position: absolute; left: 8px; top: 2px; border: 9px solid transparent; border-left: 0; border-right-color: var(--ink); border-right-width: 9px; }
.mute-btn.muted { opacity: .5; }
.mute-btn.muted span { background: linear-gradient(45deg, transparent 45%, var(--red) 45% 58%, transparent 58%); }
.me-chip { border: 0; background: none; padding: 0; width: 44px; height: 44px; }
.me-chip img { width: 44px; height: 44px; display: block; }
.me-chip.viewer img { filter: grayscale(.8); }

#stage { padding-top: var(--bar-h); min-height: 100dvh; }
body[data-stage="lobby"] #stage { padding-top: 0; }

/* ---------------------------------------------------------------- ロビー */

#lobby {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 16px;
  padding: clamp(16px, 5vh, 40px) 16px 50px;
}
.logo { margin: 0; font-size: clamp(54px, 15vw, 104px); font-weight: 900; letter-spacing: .02em; line-height: 1; }
.logo span { display: inline-block; text-shadow: 2px 2px 0 rgba(255,255,255,.7), 4px 5px 0 rgba(59,52,48,.12); }
.logo span:nth-child(1) { color: #e2583f; transform: rotate(-6deg); }
.logo span:nth-child(2) { color: #e9a62f; transform: translateY(6px) rotate(4deg); }
.logo span:nth-child(3) { color: #4d9d4a; transform: rotate(-3deg); }
.logo span:nth-child(4) { color: #3f6fc0; transform: translateY(-4px) rotate(5deg); }
.logo span:nth-child(5) { color: #9466c0; transform: rotate(-4deg); }
#lobbyArt { width: min(760px, 96vw); height: auto; }
.lobby-start { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; width: min(680px, 100%); }
.entry-choice { display: grid; grid-template-columns: 42px minmax(0, 1fr); gap: 14px; align-items: center; min-height: 122px; padding: 22px; text-align: left; letter-spacing: 0; }
.entry-join { background-image: var(--sw-sky); }
.entry-choice[aria-expanded="true"] { outline: 2px dashed #507f9c; outline-offset: 3px; }
.entry-copy { display: flex; flex-direction: column; gap: 8px; }
.entry-copy strong { font-size: clamp(20px, 2.7vw, 24px); line-height: 1.3; white-space: nowrap; }
.entry-copy small { font-size: 14px; font-weight: 600; line-height: 1.4; }
.entry-icon { position: relative; display: grid; place-items: center; width: 40px; height: 48px; font-size: 32px; font-weight: 700; background: #fffaf0; box-shadow: 2px 3px 0 #63503526; transform: rotate(5deg); color: #476f8e; }
.entry-chain { transform: rotate(-6deg); box-shadow: -7px -5px 0 #fff8e0, -8px -6px 0 #63503526, 2px 3px 0 #63503526; }
.entry-paper { color: #956a22; }
.entry-choice:focus-visible, .demo-entry:focus-visible { outline: 3px solid #3f61b8; outline-offset: 4px; }
#lobbyMsg:empty { display: none; }
.join-panel { width: min(680px, 100%); padding: 18px 8px 4px; border-top: 2px dashed #b9b09a; outline: none; scroll-margin-top: 16px; }
.join-panel .shelf-section { width: 100%; margin-top: 16px; }
.join-panel h2 { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 0 8px; padding-left: 4px; }
.relay-status { font-size: 15px; line-height: 1.7; margin: 12px 4px; color: var(--ink-soft); }
.relay-status:empty { display: none; }
.join-form { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.join-form label { font-size: 16px; font-weight: 800; }
.join-code-row { display: flex; gap: 8px; width: 100%; align-items: center; }
.join-code-row .crayon-btn { flex: 0 0 auto; padding: 10px 16px; }
.join-form input {
  width: min(12em, 100%);
  min-width: 0;
  font-size: 20px;
  letter-spacing: .18em;
  text-transform: uppercase;
  text-align: center;
  border: 0;
  border-bottom: 3px dashed var(--ink-soft);
  background: transparent;
  padding: 6px;
}
.demo-entry { border: 0; background: none; min-height: 44px; padding: 10px 16px; color: var(--ink-soft); font-size: 16px; font-weight: 700; text-decoration: underline dotted; }
#lobby .relay-footnote { margin-top: 0; }
@media(max-width: 600px) {
  .lobby-start { grid-template-columns: minmax(0, 1fr); max-width: 400px; gap: 12px; }
  .entry-choice { min-height: 104px; padding: 18px 24px; }
  #lobby #lobbyArt { max-height: 82px; }
}

/* ---------------------------------------------------------------- えらぶ */

#pick { padding: 10px 0 70px; }
.lanes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 26px 30px;
  padding: 18px 28px;
  max-width: 1240px;
  margin: 0 auto;
}
.lanes[data-count="1"] { grid-template-columns: minmax(0, 520px); justify-content: center; }
.lanes[data-count="2"] { grid-template-columns: repeat(2, minmax(0, 480px)); justify-content: center; }

.lane-card { position: relative; display: flex; flex-direction: column; gap: 6px; }
.lc-trail {
  height: 60px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding-left: 6px;
  background: linear-gradient(transparent 46%, var(--lane) 46% 54%, transparent 54%);
  background-size: 100% 100%;
  opacity: .95;
}
.lc-trail:empty { background: linear-gradient(transparent 46%, color-mix(in srgb, var(--lane) 40%, transparent) 46% 54%, transparent 54%); }
.lc-old { position: relative; width: 52px; height: 52px; background: #fffaf0; box-shadow: 0 2px 4px rgba(60, 40, 20, .25); }
.lc-old:nth-child(odd) { transform: rotate(-5deg); }
.lc-old:nth-child(even) { transform: rotate(4deg) translateY(3px); }
.lc-old img { width: 100%; height: 100%; display: block; }
.lc-old .mark { position: absolute; right: -10px; top: -10px; width: 26px; height: 26px; }

.lc-tip {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border: 0;
  padding: 0;
  background: #fffaf0;
  box-shadow: 0 6px 14px rgba(70, 50, 25, .22), 0 1px 2px rgba(70, 50, 25, .3);
  transform: rotate(-1deg);
  transition: transform .2s ease, box-shadow .2s ease, filter .2s ease;
}
.lc-tip::before {
  content: "";
  position: absolute;
  top: -12px;
  left: 50%;
  width: 26px;
  height: 34px;
  margin-left: -13px;
  background: var(--lane);
  border-radius: 6px 6px 3px 3px;
  box-shadow: inset 0 -8px 0 rgba(0,0,0,.18);
  z-index: 2;
}
.lc-img { width: 100%; height: 100%; display: block; object-fit: cover; }
.lc-seed { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; gap: 6px; }
.lc-seed small { font-size: 14px; color: var(--ink-soft); font-weight: 700; }
.lc-seed span { font-size: clamp(34px, 7vw, 52px); font-weight: 900; }
.lc-state { position: absolute; inset: 0; pointer-events: none; }
.lc-verb {
  position: absolute;
  right: -8px;
  bottom: 14px;
  padding: 10px 22px;
  font-size: 22px;
  font-weight: 900;
  background: var(--sw-sun) center / 100% 100% no-repeat;
  transform: rotate(-4deg);
}
.lc-by { position: absolute; left: 10px; top: 10px; width: 46px; height: 46px; }
.lc-holder { position: absolute; left: 50%; top: 50%; width: 96px; height: 96px; margin: -48px 0 0 -48px; filter: drop-shadow(0 3px 0 rgba(0,0,0,.2)); }
.lc-wait { position: absolute; left: 0; right: 0; top: calc(50% + 52px); text-align: center; font-weight: 800; color: var(--ink-soft); }
.pencil {
  position: absolute;
  left: calc(50% + 30px);
  top: calc(50% + 20px);
  width: 46px;
  height: 11px;
  border-radius: 2px 6px 6px 2px;
  background: linear-gradient(90deg, #3b3430 0 8px, #f2c444 8px);
  animation: wiggle .9s ease-in-out infinite;
}
.pencil.guess { background: linear-gradient(90deg, #3b3430 0 8px, #9fcfeb 8px); animation-duration: 1.6s; }
.ek-reading .pencil { position: absolute; left: 30px; top: 18px; width: 30px; height: 8px; }

.lane-card.can .lc-tip { animation: bob 3.2s ease-in-out infinite; cursor: pointer; }
.lane-card.can:nth-child(2) .lc-tip { animation-delay: -.8s; }
.lane-card.can:nth-child(3) .lc-tip { animation-delay: -1.6s; }
.lane-card.can:nth-child(4) .lc-tip { animation-delay: -2.4s; }
.lane-card.can .lc-tip:hover { box-shadow: 0 12px 22px rgba(70, 50, 25, .28); }
.lane-card.resume .lc-verb { background-image: var(--sw-leaf); }
.lane-card.why-held .lc-img, .lane-card.why-own .lc-img, .lane-card.why-viewer .lc-img { filter: saturate(.5) brightness(1.04) blur(.6px); opacity: .7; }
.lane-card.why-busy .lc-tip { opacity: .6; }

.lc-foot { display: flex; align-items: flex-end; gap: 8px; padding: 2px 6px; font-weight: 800; color: var(--ink-soft); }
.lc-stack {
  width: 30px;
  height: calc(var(--n, 1) * 3px + 3px);
  background: repeating-linear-gradient(180deg, #fffaf0 0 2px, #cdbb98 2px 3px);
  box-shadow: 0 1px 2px rgba(0,0,0,.25);
}
.lc-count { font-size: 16px; }
.pick-note { text-align: center; font-weight: 800; color: var(--ink-soft); min-height: 1.4em; }
.pick-note.waiting::after { content: ""; display: inline-block; width: 1.4em; text-align: left; animation: dots 1.4s steps(4) infinite; }
@keyframes dots { 0% { content: ""; } 25% { content: "・"; } 50% { content: "・・"; } 75% { content: "・・・"; } }

/* ---------------------------------------------------------------- よむ */

.g-wrap {
  height: calc(100dvh - var(--bar-h));
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4px 12px 10px;
  gap: 4px;
}
.g-author { display: flex; align-items: center; gap: 6px; font-weight: 800; align-self: center; }
.g-author img { width: 36px; height: 36px; }
.g-pic {
  flex: 0 1 auto;
  width: min(94vw, calc(100dvh - var(--bar-h) - 260px));
  min-width: 220px;
  aspect-ratio: 1;
  background: #fffaf0;
  box-shadow: 0 8px 18px rgba(70, 50, 25, .25);
  transform: rotate(-.6deg);
  position: relative;
}
.g-pic img { width: 100%; height: 100%; display: block; object-fit: contain; }
.g-tag, .g-reveal {
  position: relative;
  width: min(560px, 94vw);
  margin-top: 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  background: var(--sw-tag) center / 100% 100% no-repeat;
  transform: rotate(.8deg);
}
.g-tag::before, .g-reveal::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -26px;
  width: 3px;
  height: 34px;
  background: #8b6b4a;
  border-radius: 2px;
}
.g-tag::after, .g-reveal::after {
  content: "";
  position: absolute;
  left: calc(50% - 6px);
  top: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #f7efdc;
  box-shadow: inset 0 1px 2px rgba(0,0,0,.35);
}
.g-tag { flex-wrap: wrap; gap: 6px 10px; }
.g-hint { flex-basis: 100%; display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 18px; font-weight: 800; }
.g-hint b { display: inline-grid; place-items: center; width: 44px; height: 44px; border: 3px solid var(--blue); border-radius: 45% 53% 46% 51%; color: var(--blue); font-size: 30px; line-height: 1; transform: rotate(-5deg); }
.g-q { font-size: 20px; font-weight: 900; white-space: nowrap; }
#gInput, #wInput {
  flex: 1;
  min-width: 0;
  border: 0;
  border-bottom: 3px dashed #8b6b4a;
  background: transparent;
  font-size: 26px;
  font-weight: 800;
  padding: 4px 6px;
  outline: none;
}
#gInput:focus, #wInput:focus { border-bottom-style: solid; }
.g-reveal { flex-wrap: wrap; justify-content: center; gap: 4px 18px; padding: 16px 18px; }
.g-yours { position: relative; font-size: 26px; font-weight: 800; padding: 0 10px; }
.g-yours .mark { position: absolute; left: 50%; top: 50%; width: 2.6em; height: 2.6em; margin: -1.3em 0 0 -1.3em; }
.g-reveal.is-ng .g-yours { color: var(--ink-soft); }
.g-true { font-size: 34px; font-weight: 900; animation: pop .5s .35s both; }
.g-reveal.is-ok .g-true { display: none; }
.g-reveal .crayon-btn { flex-basis: 100%; max-width: 320px; background-image: var(--sw-leaf); }
.leave { border: 0; background: none; color: var(--ink-soft); font-weight: 700; text-decoration: underline dotted; margin-top: auto; padding: 8px; }

.mark { overflow: visible; }
.mark path { fill: none; stroke-width: 9; stroke-linecap: round; stroke-dasharray: 320; animation: draw .5s ease-out both; }
.mark-o path { stroke: var(--red); }
.mark-x path { stroke: var(--blue); }
.mark-x path + path { animation-delay: .2s; }

.tail {
  display: inline-block;
  color: var(--red);
  border: 3px solid currentColor;
  border-radius: 50%;
  padding: 0 .1em;
  margin: 0 .04em;
  line-height: 1.15;
  font-weight: 900;
}
.hidden-word { color: var(--ink-soft); letter-spacing: .1em; }

/* ---------------------------------------------------------------- きめる */

.w-wrap {
  max-width: 640px;
  margin: 0 auto;
  min-height: calc(100dvh - var(--bar-h));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 24px 16px 20px;
}
.w-prev { display: flex; align-items: center; gap: 12px; font-size: 22px; font-weight: 800; opacity: .9; }
.w-prev img { width: 84px; height: 84px; background: #fffaf0; box-shadow: 0 3px 8px rgba(70, 50, 25, .25); transform: rotate(-3deg); }
.w-prev .mark { width: 34px; height: 34px; }
.w-row { display: flex; align-items: center; gap: 12px; width: min(560px, 100%); }
.w-stamp {
  flex: 0 0 auto;
  width: 96px;
  height: 96px;
  display: grid;
  place-items: center;
  font-size: 54px;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 2px 0 rgba(0,0,0,.2);
  background: var(--sw-stamp) center / 100% 100% no-repeat;
  border-radius: 50%;
  transform: rotate(-6deg);
  filter: grayscale(.55);
  opacity: .8;
  transition: filter .2s, transform .2s, opacity .2s;
}
.w-stamp.ok { filter: none; opacity: 1; transform: rotate(-6deg) scale(1.08); }
#wInput { font-size: 34px; border-bottom: 4px solid var(--ink); }
#wGo { background-image: var(--sw-cream); }
#wGo.ready { background-image: var(--sw-leaf); animation: bob 2.6s ease-in-out infinite; }

/* ---------------------------------------------------------------- かく */

.d-wrap {
  display: grid;
  grid-template-columns: auto 230px;
  gap: 18px;
  justify-content: center;
  align-items: start;
  padding: 8px 16px 16px;
}
#board {
  position: relative;
  width: min(calc(100dvh - var(--bar-h) - 28px), calc(100vw - 300px));
  min-width: 280px;
  aspect-ratio: 1;
  box-shadow: 0 10px 22px rgba(70, 50, 25, .25), 0 1px 2px rgba(70, 50, 25, .3);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
#board canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#board .b-live { touch-action: none; cursor: crosshair; }
#board.erasing .b-live { cursor: cell; }
.d-tools { display: flex; flex-direction: column; gap: 12px; }
.d-colors { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px 6px; }
.stick {
  height: 52px;
  border: 0;
  background:
    linear-gradient(180deg, transparent 52%, rgba(255,255,255,.5) 52% 74%, transparent 74%),
    var(--c);
  clip-path: polygon(30% 0, 70% 0, 100% 26%, 100% 100%, 0 100%, 0 26%);
  transition: transform .12s ease;
  box-shadow: inset 0 0 0 2px rgba(0,0,0,.08);
}
.stick.on { transform: translateY(-8px); }
.d-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.d-sizes { display: flex; gap: 4px; }
.size, .tool {
  width: 46px;
  height: 46px;
  border: 0;
  display: grid;
  place-items: center;
  background: var(--sw-cream) center / 100% 100% no-repeat;
  font-size: 22px;
  font-weight: 900;
}
.size span { width: var(--s); height: var(--s); border-radius: 50%; background: var(--c, var(--ink)); }
.size.on, .tool.on { background-image: var(--sw-sky); }
.tool:disabled { opacity: .3; }
.tool-eraser::before { content: ""; width: 26px; height: 14px; border-radius: 3px; background: linear-gradient(90deg, #f2a3b4 0 60%, #6a8fd0 60%); transform: rotate(-30deg); }
.tool-clear::before { content: "✕"; font-size: 20px; }
.tool-clear.armed { background-image: var(--sw-rose); animation: shake .4s ease; }
.secret {
  border: 0;
  align-self: flex-start;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 8px 18px 10px 14px;
  background: var(--sw-tag) center / 100% 100% no-repeat;
  transform: rotate(-2deg);
}
.secret small { font-size: 11px; color: var(--ink-soft); font-weight: 800; }
.secret span { font-size: 22px; font-weight: 900; }
.send { background-image: var(--sw-leaf); }

.fly {
  position: fixed;
  left: 50%;
  top: 50%;
  width: 220px;
  height: 220px;
  margin: -110px 0 0 -110px;
  box-shadow: 0 0 0 6px var(--lane), 0 10px 20px rgba(0,0,0,.25);
  z-index: 50;
  pointer-events: none;
  animation: fly .85s ease-in forwards;
}
@keyframes fly {
  0% { transform: none; opacity: 1; }
  100% { transform: translate(38vw, -42vh) rotate(24deg) scale(.25); opacity: 0; }
}

/* ---------------------------------------------------------------- えまき */

.emaki {
  --ek-h: 236px;
  --pic: calc(var(--ek-h) * .62);
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  grid-template-rows: auto auto auto 1fr;
  grid-template-columns: minmax(0, 1fr);
  background: linear-gradient(180deg, #d9ecf4, #f7efdc 160px);
}
body.emaki-open { overflow: hidden; background: none; }
body.emaki-open #stage, body.emaki-open #bar { visibility: hidden; }
body.emaki-open #leaseNote { visibility: hidden; }
body.emaki-open #stage * { animation-play-state: paused !important; }
.ek-link .mark path { animation: none; }
.ek-head { display: flex; align-items: center; gap: 8px; padding: 8px 12px 0; }
.emaki > * { min-width: 0; min-height: 0; }
.ek-tabs { display: flex; gap: 6px; flex: 1; min-width: 0; overflow-x: auto; }
.ek-tabs button {
  border: 0;
  height: 40px;
  min-width: 70px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--sw-cream) center / 100% 100% no-repeat;
  opacity: .65;
}
.ek-tabs button[aria-selected="true"] { opacity: 1; transform: translateY(-2px); }
.ek-thread { width: 22px; height: 6px; border-radius: 3px; background: var(--lane); }
.ek-close { flex: 0 0 44px; width: 44px; height: 44px; border: 0; background: var(--sw-cream) center / 100% 100% no-repeat; position: relative; }
.ek-close::before { content: "✕"; font-size: 20px; font-weight: 900; }
.ek-map { width: calc(100% - 24px); margin: 8px 12px 0; display: block; cursor: pointer; touch-action: manipulation; }
.ek-samples { display: flex; gap: 6px; overflow-x: auto; padding: 8px 12px 6px; scrollbar-width: none; }
.ek-samples button { position: relative; flex: 0 0 auto; width: 52px; height: 52px; padding: 0; border: 0; background: #fffaf0; box-shadow: 0 2px 4px rgba(60, 40, 20, .22); }
.ek-samples img { width: 100%; height: 100%; display: block; }
.ek-samples span { position: absolute; right: 2px; bottom: 0; font-size: 10px; font-weight: 800; color: var(--ink-soft); background: rgba(255, 250, 240, .85); padding: 0 2px; }
.ek-list { overflow-y: auto; overscroll-behavior: contain; position: relative; padding-bottom: 80px; }
.ek-spacer { position: relative; max-width: 780px; margin: 0 auto; }
.ek-item { position: absolute; left: 0; right: 0; }
.ek-curve { position: absolute; left: 0; top: -50%; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.ek-curve path { fill: none; stroke: var(--lane); stroke-width: 6; stroke-linecap: round; vector-effect: non-scaling-stroke; opacity: .75; }
.ek-mine-link .ek-curve path { stroke: var(--me); stroke-width: 10; opacity: 1; }
.ek-pic {
  z-index: 1;
  position: absolute;
  top: calc(50% - var(--pic) / 2);
  width: var(--pic);
  height: var(--pic);
  padding: 0;
  border: 0;
  background: #fffaf0;
  box-shadow: 0 4px 10px rgba(70, 50, 25, .22);
}
.ek-l .ek-pic { left: calc(30% - var(--pic) / 2); transform: rotate(-2deg); }
.ek-r .ek-pic { left: calc(70% - var(--pic) / 2); transform: rotate(2deg); }
.ek-pic img { width: 100%; height: 100%; display: block; }
.ek-wait { background: repeating-linear-gradient(45deg, #f3e8d2 0 10px, #efe2c8 10px 20px); }
.ek-mine .ek-pic { box-shadow: 0 0 0 5px var(--me), 0 4px 10px rgba(70, 50, 25, .22); }
.ek-cap {
  z-index: 1;
  position: absolute;
  top: calc(50% - var(--pic) / 2 + 4px);
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-width: calc(50% - var(--pic) / 2 + 10%);
  font-weight: 800;
}
.ek-l .ek-cap { left: calc(30% + var(--pic) / 2 + 14px); align-items: flex-start; }
.ek-r .ek-cap { right: calc(30% + var(--pic) / 2 + 14px); align-items: flex-end; text-align: right; }
.ek-cap img { width: 30px; height: 30px; }
.ek-name { font-size: 12px; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.ek-word { font-size: 24px; font-weight: 900; }
.ek-no { font-size: 11px; color: var(--ink-soft); }
.ek-link {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px 4px 6px;
  background: var(--sw-tag) center / 100% 100% no-repeat;
  font-weight: 800;
  z-index: 2;
  white-space: nowrap;
}
.ek-link img { width: 26px; height: 26px; }
.ek-link .mark { width: 26px; height: 26px; }
.ek-link.is-ng .ek-guess { color: var(--ink-soft); }
.ek-mine-link .ek-link { box-shadow: 0 0 0 3px var(--me); }
.ek-reading { position: absolute; z-index: 2; top: calc(50% + var(--pic) / 2 - 30px); width: 40px; height: 40px; }
.ek-l .ek-reading { left: calc(30% + var(--pic) / 2 - 20px); }
.ek-r .ek-reading { left: calc(70% + var(--pic) / 2 - 20px); }
.ek-reading img { width: 40px; height: 40px; }
.ek-free { display: grid; place-items: center; }
.ek-star, .ek-free .ek-star {
  display: inline-block;
  width: 22px;
  height: 22px;
  background: #e9b52f;
  clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
}
.ek-left { position: absolute; bottom: 6px; display: flex; gap: 6px; font-size: 12px; opacity: .75; }
.ek-l .ek-left { left: calc(30% + var(--pic) / 2 + 14px); }
.ek-r .ek-left { right: calc(30% + var(--pic) / 2 + 14px); }
.ek-left span { display: flex; align-items: center; gap: 2px; text-decoration: line-through dotted; }
.ek-left img { width: 20px; height: 20px; }
.ek-seedcard {
  position: absolute;
  left: calc(30% - 90px);
  top: calc(50% - 40px);
  width: 180px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px;
  background: var(--sw-cream) center / 100% 100% no-repeat;
}
.ek-seedcard small { color: var(--ink-soft); font-weight: 800; }
.ek-seedcard .ek-word { font-size: 28px; }
.ek-flag {
  display: inline-block;
  width: 16px;
  height: 18px;
  background: linear-gradient(90deg, var(--ink) 0 2px, transparent 2px), linear-gradient(var(--red), var(--red)) 2px 1px / 12px 9px no-repeat;
}
.ek-jump {
  width: max-content;
  max-width: calc(100% - 16px);
  white-space: nowrap;
  position: fixed;
  left: 50%;
  bottom: max(12px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  z-index: 41;
}
.ek-jump button {
  border: 0;
  height: 46px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 900;
  background: var(--sw-sun) center / 100% 100% no-repeat;
}
.ek-jump button[data-j="start"] { background-image: var(--sw-cream); }
.ek-jump button[data-j="mine"] { background-image: var(--sw-sky); }
.ek-jump .ek-none { animation: shake .4s ease; }
.ek-me { width: 26px; height: 26px; }
.ek-zoom { position: fixed; inset: 0; z-index: 45; display: grid; place-items: center; background: rgba(40, 32, 25, .72); }
.ek-zoom img { width: min(92vw, 88dvh); height: auto; aspect-ratio: 1; background: #fffaf0; box-shadow: 0 10px 30px rgba(0,0,0,.4); }

/* ---------------------------------------------------------------- プロフィール・交代・通知 */

.profile {
  border: 0;
  padding: 0;
  background: transparent;
  max-width: min(440px, 94vw);
}
.profile::backdrop { background: rgba(40, 32, 25, .45); }
.pf {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 22px 18px 18px;
  background: var(--paper, #f7efdc);
  box-shadow: 0 12px 30px rgba(0,0,0,.3);
}
.pf-avatar { width: 108px; height: 108px; }
.pf-name { display: flex; align-items: center; gap: 10px; font-weight: 800; }
.pf-name input { font-size: 20px; width: 9em; border: 0; border-bottom: 3px solid var(--ink); background: transparent; padding: 4px; }
.pf-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; }
.pf-row button { width: 44px; height: 44px; padding: 0; border: 0; background: none; opacity: .65; }
.pf-row button.on { opacity: 1; transform: scale(1.12); }
.pf-row img { width: 44px; height: 44px; }
.pf-ids { display: flex; flex-direction: column; align-items: center; gap: 6px; padding-top: 6px; border-top: 2px dashed rgba(59,52,48,.2); width: 100%; }
.pf-sub { font-size: 12px; color: var(--ink-soft); font-weight: 800; }
#pfIds { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.pf-id img { width: 26px; height: 26px; }

.curtain { position: fixed; inset: 0; z-index: 55; display: grid; place-items: center; background: var(--paper, #f7efdc); }
.curtain-in { display: flex; flex-direction: column; align-items: center; gap: 18px; padding: 20px; }
.curtain-title { font-size: 30px; font-weight: 900; margin: 0; }
.curtain-ids { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; }
.cu-id { border: 0; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 14px; min-width: 110px; background: var(--sw-cream) center / 100% 100% no-repeat; font-weight: 800; }
.cu-id img { width: 72px; height: 72px; }
.cu-plus { font-size: 48px; line-height: 72px; }
.cu-stay { opacity: .7; }
.cu-stay img { width: 48px; height: 48px; }

.toasts { position: fixed; top: calc(var(--bar-h) + 6px); left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; z-index: 60; pointer-events: none; }
.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  font-weight: 800;
  background: var(--sw-cream) center / 100% 100% no-repeat;
  animation: pop .3s ease;
  transition: opacity .35s, transform .35s;
  white-space: nowrap;
}
.toast.out { opacity: 0; transform: translateY(-8px); }
.toast img { width: 30px; height: 30px; }
.toast .mark { width: 28px; height: 28px; }
.t-word { font-size: 18px; }
.t-paper { width: 18px; height: 22px; background: #fffaf0; box-shadow: 0 1px 3px rgba(0,0,0,.3); transform: rotate(-8deg); }

.longest-share{margin:18px auto 0;display:block}
#longestRelayShare{width:min(94vw,760px);max-height:94dvh;overflow:auto;box-sizing:border-box;border:1px solid #ddceb1;border-radius:16px;background:#fbf4e4;padding:18px;color:#4d4138}
#longestRelayShare::backdrop{background:#453b2caa}
#longestRelayShare header{display:flex;justify-content:space-between;align-items:center;gap:12px}
#longestRelayShare h2{font-size:20px;margin:0}
#longestRelayShare .album-image{display:block;max-width:100%;max-height:56dvh;width:auto;height:auto;margin:12px auto;object-fit:contain}
#longestRelayShare .album-pages,#longestRelayShare .album-actions{display:flex;gap:12px;align-items:center;justify-content:center;flex-wrap:wrap;margin:14px 0}
#longestRelayShare input{width:72px;font:inherit;padding:6px;text-align:center;background:#fffdf5;border:1px solid #b9a17c;border-radius:6px}
#longestRelayShare .album-help,#longestRelayShare .album-status{font-size:14px;line-height:1.65}
#longestRelayShare a{text-decoration:none;color:inherit;display:inline-block}
#longestRelayShare [hidden]{display:none!important}
@media(max-width:480px){#longestRelayShare{padding:12px}#longestRelayShare h2{font-size:17px}#longestRelayShare .album-actions{gap:8px}#longestRelayShare .album-actions .crayon-btn{font-size:16px;padding:10px 12px}}

/* ---------------------------------------------------------------- スマホ */

@media (max-width: 760px) {
  :root { --bar-h: 50px; }
  #bar { gap: 4px; }
  .pp { width: 24px; height: 24px; }
  .pp-empty { width: 14px; height: 14px; margin: 3px; }
  .room-chip span { display: none; }
  .chip { padding: 0 8px; }

  .lanes, .lanes[data-count="1"], .lanes[data-count="2"] {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    gap: 16px;
    padding: 10px 8vw 16px;
    scrollbar-width: none;
  }
  .lane-card { flex: 0 0 84vw; scroll-snap-align: center; }
  .lanes[data-count="1"] .lane-card { margin: 0 auto; }
  .lc-trail { height: 50px; }
  .lc-old { width: 42px; height: 42px; }

  .g-pic { width: min(96vw, calc(100dvh - var(--bar-h) - 250px)); }
  .g-q { font-size: 17px; }
  .g-tag .crayon-btn { padding: 8px 14px; font-size: 16px; }

  .d-wrap { grid-template-columns: 1fr; gap: 8px; padding: 4px 6px 10px; justify-items: center; }
  #board { width: min(calc(100vw - 12px), calc(100dvh - var(--bar-h) - 236px)); min-width: 240px; }
  .d-tools { width: 100%; max-width: 520px; gap: 8px; position: relative; }
  .d-colors { display: flex; overflow-x: auto; gap: 4px; padding-top: 8px; scrollbar-width: none; order: 1; }
  .stick { flex: 0 0 34px; height: 44px; }
  .d-row { order: 2; justify-content: space-between; }
  .size, .tool { width: 42px; height: 42px; }
  .secret { order: 0; flex-direction: row; align-items: baseline; gap: 8px; align-self: center; padding: 4px 14px 6px; }
  .secret span { font-size: 17px; }
  .send { order: 3; }
  #dErr { order: 4; }

  .w-stamp { width: 78px; height: 78px; font-size: 44px; }
  #wInput { font-size: 28px; }

  .emaki { --ek-h: 196px; --pic: calc(var(--ek-h) * .6); }
  .ek-word { font-size: 19px; }
  .ek-link { font-size: 13px; }
  .ek-jump button { padding: 0 12px; height: 42px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
}

.relay-footnote{font-size:12px;line-height:1.7;color:#756452;max-width:90%;margin:30px auto 14px}.relay-footnote a{color:inherit}.share-actions{display:flex;justify-content:center;gap:12px;flex-wrap:wrap;margin:16px}.share-actions a{text-decoration:none;display:inline-flex;align-items:center;color:inherit}#shareRelay{width:min(92vw,700px);border:0;background:#fbf4e4;border-radius:12px;padding:20px}#shareRelay::backdrop{background:#453b2caa}#shareRelay img{width:100%;margin-top:15px}#shareRelay a{display:inline-block;text-decoration:none;color:inherit}#shareRelay p{font-size:14px}.ek-report{position:absolute;bottom:24px;left:50%;transform:translateX(-50%);z-index:2;background:#fff8e8}
