/* 転成チャット。白い紙に、転成先と書く欄と時計だけ（2026-11-14、3minutes の style.css から作った）。色は spaces のウェブ版から取った */
:root {
  --paper: #fff;
  --ink: #1d2328;
  --ink2: rgba(29, 35, 40, .62);
  --ink3: rgba(29, 35, 40, .48);
  --line: rgba(29, 35, 40, .12);
  --part: rgba(29, 35, 40, .05);
  --blue: #026881;   /* ブルスコブルー。カーソルと時計の線 */
  --on-blue: #fff;
  --red: #b3261e;
  --ui: system-ui, -apple-system, "Hiragino Sans", "Noto Sans JP", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #1C1C1F; --ink: #e8ecef; --ink2: rgba(232, 236, 239, .66); --ink3: rgba(232, 236, 239, .5);
    --line: rgba(232, 236, 239, .14); --part: rgba(232, 236, 239, .07);
    --blue: #7CC6D8; --on-blue: #0B161C; --red: #ff8a80;
    color-scheme: dark;
  }
  :root:not([data-theme="light"]) .atomo-ring { --atomo-glow: 106 168 255; }
}
:root[data-theme="dark"] {
  --paper: #1C1C1F; --ink: #e8ecef; --ink2: rgba(232, 236, 239, .66); --ink3: rgba(232, 236, 239, .5);
  --line: rgba(232, 236, 239, .14); --part: rgba(232, 236, 239, .07);
  --blue: #7CC6D8; --on-blue: #0B161C; --red: #ff8a80;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--paper); color: var(--ink); }
body {
  font-family: var(--ui); font-size: 16px; line-height: 1.6; -webkit-font-smoothing: antialiased;
  /* 1行40字の本文（字間0.04em）が入る幅にする */
  max-width: calc(40 * 1.04em + 32px); margin: 0 auto; padding: 0 16px;
  min-height: 100dvh; display: flex; flex-direction: column;
}
a { color: inherit; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px 0 24px; }
.brand { white-space: nowrap; display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 500; }
.brand img { display: block; }
.brand .name { display: flex; flex-direction: column; line-height: 1.2; }
.brand .title { font-size: 18px; letter-spacing: .06em; }
.brand .sub { font-size: 11px; font-weight: 400; color: var(--ink3); letter-spacing: .08em; }
.me { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink2); min-width: 0; }
.me img { width: 24px; height: 24px; border-radius: 50%; }
.me .h { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

main { flex: 1; }
.lead { margin: 24px 0 28px; font-size: 17px; line-height: 1.8; letter-spacing: .04em; }

.primary {
  display: block; width: 100%; padding: 14px; border: none; border-radius: 999px;
  background: var(--blue); color: var(--on-blue); font-weight: 500; letter-spacing: .06em;
}
.primary:disabled { opacity: .4; }
.ghost { display: inline-block; white-space: nowrap; padding: 8px 14px; border: 1px solid var(--line); border-radius: 6px; background: transparent; color: var(--ink); text-decoration: none; }
.ghost.strong { border-color: var(--blue); color: var(--blue); }
.ghost:disabled { opacity: .4; }
.atomo { white-space: nowrap; display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border: 1px solid var(--line); border-radius: 6px; background: transparent; color: var(--ink); }
.row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.note { margin: 10px 0 0; font-size: 13px; color: var(--ink2); }
.status { margin: 8px 0 0; font-size: 14px; min-height: 1.4em; }
.status.bad { color: var(--red); }
.label { margin: 0 0 6px; font-size: 12px; color: var(--ink3); letter-spacing: .06em; }

.titlebox { display: block; margin-bottom: 14px; }
.titlebox input { width: 100%; padding: 12px 14px; font: inherit; font-size: 17px; letter-spacing: .04em; color: var(--ink); background: var(--part); border: 1.5px solid transparent; border-radius: 12px; outline: none; }
.titlebox input:focus { border-color: var(--line); }
.room-title { margin: 0 0 10px; font-size: 20px; font-weight: 500; letter-spacing: .04em; line-height: 1.5; overflow-wrap: anywhere; }
.guest { margin-top: 14px; display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--ink2); }
.guest input { flex: 1; min-width: 0; padding: 8px 10px; font: inherit; color: var(--ink); background: var(--part); border: 1px solid var(--line); border-radius: 6px; }

/* 時計。数字と、減っていく1本の線 */
.clock { padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.clock-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
/* 退出と閉じる。細い線の小さな丸い札。閉じるは開いた人にだけ出し、一度目で赤く変わり、二度目で閉じる（2026-11-13、依頼） */
.acts { display: flex; gap: 8px; padding-top: 10px; }
.pill { padding: 5px 14px; border: 1px solid var(--line); border-radius: 999px; background: transparent; color: var(--ink2); font-size: 13px; letter-spacing: .06em; line-height: 1.4; transition: color .15s, border-color .15s, background .15s; }
.pill:hover { color: var(--ink); border-color: var(--ink3); }
.pill.warn:hover { color: var(--red); border-color: var(--red); }
.pill.warn.armed, .pill.warn.armed:hover { color: var(--paper); background: var(--red); border-color: var(--red); }
.time { margin: 0; font-size: 44px; font-weight: 300; line-height: 1.1; font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.count { margin: -6px 0 10px; font-size: 13px; color: var(--ink3); font-variant-numeric: tabular-nums; }
.state { margin: 4px 0 10px; font-size: 13px; color: var(--ink2); }
.bar { height: 2px; background: var(--line); border-radius: 1px; overflow: hidden; }
.bar span { display: block; height: 100%; width: 100%; background: var(--blue); transform-origin: left; }
.waiting .bar span { background: var(--ink3); }
.people { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; color: var(--ink2); }
.people li { display: flex; align-items: center; gap: 6px; }
.people img, .people .face { width: 20px; height: 20px; border-radius: 50%; background: var(--part); }

.tell { margin-top: 16px; padding: 14px; border: 1px solid var(--line); border-radius: 10px; }
.tell-text { margin: 0; font: inherit; font-size: 14px; white-space: pre-wrap; word-break: break-word; color: var(--ink2); }

/* 発言。spaces の本文と同じ組み方（字間0.04em・行間1.8倍・1行40字まで） */
.log { list-style: none; margin: 0; padding: 8px 0 0; }
.log li { padding: 10px 0; }
.log .who { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink3); }
.log .who img { width: 16px; height: 16px; border-radius: 50%; }
.log .text, .page {
  font-family: var(--ui); font-size: 17px; letter-spacing: .04em; line-height: 1.8;
  max-width: calc(40 * 1.04em); white-space: pre-wrap; overflow-wrap: anywhere; line-break: strict;
}
.log .text { margin: 2px 0 0; }

/* 書く欄。押した瞬間に書く状態に入る。標準のカーソルは透かし、caret.js が描く */
.composer { position: sticky; bottom: 0; padding: 10px 0 12px; background: var(--paper); }
.card { position: relative; padding: 10px 14px; border-radius: 14px; background: var(--part); border: 1.5px solid transparent; cursor: text; }
.card.on { border-color: var(--line); }
.page { min-height: 1.8em; max-height: 9em; overflow-y: auto; outline: none; color: var(--ink); caret-color: transparent; }
.page:empty::before { content: attr(data-ph); color: var(--ink3); }
.caret { position: absolute; width: 2px; border-radius: 1px; background: var(--blue); pointer-events: none; display: none; }
.hint { margin: 6px 2px 0; font-size: 12px; color: var(--ink3); }
.joinbox { padding: 16px 0; }

.closed .lead { margin-top: 40px; }

.sheet { border: 1px solid var(--line); border-radius: 10px; background: var(--paper); color: var(--ink); padding: 24px; width: min(420px, calc(100vw - 32px)); }
.sheet::backdrop { background: rgba(0, 0, 0, .3); }
.sheet-title { margin: 0; font-weight: 500; }
.sheet input { width: 100%; margin-top: 14px; padding: 10px 12px; font: inherit; color: inherit; background: var(--part); border: 1px solid var(--line); border-radius: 6px; }

.site { padding: 32px 0 20px; }
.fine { margin: 0; font-size: 12px; color: var(--ink3); }

@media (max-width: 420px) {
  .me .h { display: none; }
  .time { font-size: 38px; }
}
@media (prefers-reduced-motion: reduce) {
  .bar span { transition: none; }
}

/* 入口。白い画面に「転成先を選べ」だけが浮かび、転成先が4つ並ぶ（2026-11-14） */
.call { margin: 48px 0 32px; font-size: 26px; font-weight: 300; letter-spacing: .24em; text-align: center; opacity: 0; transition: opacity 1.2s ease; }
.call.on { opacity: 1; }
.worlds { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.world {
  width: 100%; min-height: 108px; padding: 16px; display: flex; flex-direction: column; align-items: flex-start; gap: 6px;
  text-align: left; border: 1px solid var(--line); border-radius: 14px; background: transparent;
  transition: border-color .2s, background .2s;
}
.world:hover, .world:focus-visible { border-color: var(--blue); background: var(--part); outline: none; }
.world .k { font-size: 11px; letter-spacing: .12em; color: var(--ink3); }
.world .n { font-size: 18px; letter-spacing: .06em; line-height: 1.5; }
.world .c { margin-top: auto; font-size: 12px; color: var(--blue); font-variant-numeric: tabular-nums; }
.row.center { justify-content: center; }
.rule { margin-top: 28px; text-align: center; line-height: 1.8; }

/* 部屋。転成先の名前と、自分の役 */
.kind { margin: 0; font-size: 11px; letter-spacing: .12em; color: var(--ink3); }
.you { margin: -4px 0 14px; font-size: 15px; letter-spacing: .06em; color: var(--blue); }
.log .who .role { color: var(--ink); font-weight: 500; margin-right: 4px; }
.people .role { color: var(--ink); }
.people .h { color: var(--ink3); font-size: 12px; }

/* 転成と帰還の幕。画面ぜんぶを白で覆い、一文だけ出す */
.veil { position: fixed; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: center; padding: 24px; background: var(--paper); opacity: 0; transition: opacity .6s ease; }
.veil.on { opacity: 1; }
.veil-text { margin: 0; font-size: 22px; font-weight: 300; letter-spacing: .16em; line-height: 1.8; text-align: center; }

@media (max-width: 420px) {
  .worlds { grid-template-columns: minmax(0, 1fr); }
  .world { min-height: 0; }
  .call { font-size: 22px; }
}
@media (prefers-reduced-motion: reduce) {
  .call, .veil { transition: none; }
}

/* 役の名前はウィキペディアへのリンク。ふだんは字のまま、指を置くと下線が出る（2026-11-14、依頼） */
a.role, a.role-link { text-decoration: none; }
a.role:hover, a.role-link:hover, a.role:focus-visible, a.role-link:focus-visible { text-decoration: underline; text-underline-offset: 3px; }
a.role-link { color: var(--blue); text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 4px; }

/* ===== RPG の画面（2026-11-14、依頼） =====
   夜空の地に、二重の白い枠の窓を置く。文字はドット絵の DotGothic16。明るい画面と暗い画面で同じ色にする
   上の色はそのまま残し、ここで上書きする */
html:root:not([data-theme="none"]) {
  --paper: #0d1030;
  --win: #060920;
  --ink: #f4f1e6;
  --ink2: rgba(244, 241, 230, .74);
  --ink3: rgba(244, 241, 230, .52);
  --line: rgba(244, 241, 230, .28);
  --part: rgba(244, 241, 230, .07);
  --blue: #ffd75e;     /* 金。カーソル・役の名前・時計の線 */
  --on-blue: #1a1400;
  --red: #ff7a6e;
  --frame: #f4f1e6;
  --ui: "DotGothic16", system-ui, "Hiragino Sans", sans-serif;
  color-scheme: dark;
}
html, body { background: var(--paper); }
html {
  /* 星。動かない小さな点を散らす */
  background-image:
    radial-gradient(1px 1px at 12% 18%, rgba(255,255,255,.7), transparent 60%),
    radial-gradient(1px 1px at 78% 9%, rgba(255,255,255,.6), transparent 60%),
    radial-gradient(1.5px 1.5px at 40% 30%, rgba(255,255,255,.5), transparent 60%),
    radial-gradient(1px 1px at 88% 44%, rgba(255,255,255,.55), transparent 60%),
    radial-gradient(1px 1px at 6% 62%, rgba(255,255,255,.5), transparent 60%),
    radial-gradient(1.5px 1.5px at 64% 72%, rgba(255,255,255,.45), transparent 60%),
    radial-gradient(1px 1px at 26% 88%, rgba(255,255,255,.5), transparent 60%),
    radial-gradient(1px 1px at 92% 92%, rgba(255,255,255,.55), transparent 60%),
    linear-gradient(#0a0c26, #141a44);
  background-attachment: fixed;
}
body { background: transparent; letter-spacing: .04em; }

/* 窓。二重の白い枠と、黒に近い紺の地 */
.worlds, .clock, .tell, .log, .card, .joinbox, .closed .lead, .sheet, .veil-text, .call {
  background: var(--win);
  border: 5px double var(--frame);
  border-radius: 10px;
  color: var(--ink);
}
.call { display: inline-block; padding: 10px 28px; margin: 40px auto 24px; font-size: 24px; font-weight: 400; letter-spacing: .3em; }
.door { text-align: center; }
.door > * { text-align: left; }
.door > .call { text-align: center; }

/* 転成先はコマンドの一覧。指を置くと左に ▶ が出る */
.worlds { padding: 14px 10px; gap: 2px 8px; }
.world {
  min-height: 0; padding: 10px 12px 10px 30px; border: none; border-radius: 4px; background: transparent; position: relative;
}
.world:hover, .world:focus-visible { background: transparent; }
.world::before { content: "▶"; position: absolute; left: 8px; top: 12px; font-size: 13px; color: var(--blue); opacity: 0; }
.world:hover::before, .world:focus-visible::before { opacity: 1; animation: blink .8s steps(2, start) infinite; }
.world .k { font-size: 11px; color: var(--ink3); }
.world .n { font-size: 18px; }
.world .c { margin-top: 2px; color: var(--blue); }
@keyframes blink { to { visibility: hidden; } }

.ghost, .pill, .atomo, .music {
  background: var(--win); color: var(--ink); border: 2px solid var(--frame); border-radius: 6px; font-family: var(--ui);
}
.ghost.strong { border-color: var(--blue); color: var(--blue); }
.primary { border-radius: 6px; border: 2px solid var(--frame); background: var(--blue); color: var(--on-blue); font-family: var(--ui); }
.music { min-width: 36px; padding: 6px 10px; font-size: 15px; line-height: 1; }
.music.off { color: var(--ink3); border-color: var(--line); }
.me { gap: 10px; }
.brand .title { letter-spacing: .12em; }
.guest input, .sheet input { background: var(--part); color: var(--ink); border: 2px solid var(--line); font-family: var(--ui); }
.rule { color: var(--ink3); }

/* 部屋 */
.kind { color: var(--ink3); }
.room-title { font-weight: 400; }
.you { color: var(--ink); }
a.role-link { color: var(--blue); text-decoration-color: rgba(255, 215, 94, .4); }
.clock { padding: 14px 16px; margin-bottom: 14px; }
.time { font-weight: 400; }
.tell { margin: 0 0 14px; }
.log { padding: 6px 16px; min-height: 80px; }
.log:empty::before { content: "……"; display: block; padding: 12px 0; color: var(--ink3); }
.log li + li { border-top: 1px dashed rgba(244, 241, 230, .12); }
.log .who .role { color: var(--blue); font-weight: 400; }
.people .role { color: var(--blue); }
.composer { background: transparent; }
.card { border-width: 5px; }
.card.on { border-color: var(--blue); }
.page:empty::before { content: "▶ " attr(data-ph); }
.joinbox { padding: 16px; }
.closed .lead { padding: 16px 20px; }

/* 幕。転成のときは一度白く光り、夜空に戻ってから文の窓が出る */
.veil { background: var(--paper); align-items: flex-end; padding-bottom: 18vh; }
.veil.flash { animation: flash .9s ease-out; }
@keyframes flash { 0% { background: #fff; } 100% { background: var(--paper); } }
.veil-text { min-width: min(560px, 100%); padding: 20px 24px; font-size: 20px; letter-spacing: .1em; text-align: left; min-height: 3.6em; position: relative; }
.veil-text::after { content: "▼"; position: absolute; right: 14px; bottom: 8px; font-size: 12px; color: var(--blue); animation: blink .8s steps(2, start) infinite; }

@media (prefers-reduced-motion: reduce) {
  .veil.flash, .world:hover::before, .veil-text::after { animation: none; }
}

/* 舞台。アイコンが並び、話した人の上にフキダシが出る（2026-11-14、依頼。Clubhouse の部屋のように） */
.stage {
  list-style: none; margin: 0 0 14px; padding: 18px 12px 14px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(116px, 1fr)); gap: 18px 10px;
  background: var(--win); border: 5px double var(--frame); border-radius: 10px; min-height: 180px;
}
.stage:empty::before { content: "……"; grid-column: 1 / -1; align-self: center; text-align: center; color: var(--ink3); }
.stage li { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; padding-top: 4px; min-width: 0; text-align: center; }
.stage .icon {
  width: 64px; height: 64px; border-radius: 50%; overflow: hidden; display: grid; place-items: center;
  background: var(--part); border: 3px solid var(--frame); font-size: 28px; color: var(--ink);
  transition: transform .15s, border-color .15s, box-shadow .15s;
}
.stage .icon img { width: 100%; height: 100%; object-fit: cover; image-rendering: pixelated; }
.stage li.me .icon { border-color: var(--blue); }
.stage li.talking .icon { transform: translateY(-3px); box-shadow: 0 0 0 4px rgba(255, 215, 94, .35); }
.stage .role { font-size: 14px; color: var(--blue); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stage .h { font-size: 11px; color: var(--ink3); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* フキダシ。アイコンの上に浮かび、しばらくすると消える */
.bubble {
  position: absolute; bottom: calc(100% - 2px); left: 50%; transform: translateX(-50%);
  width: max-content; max-width: min(240px, 80vw); margin: 0; padding: 8px 12px; z-index: 2;
  background: var(--ink); color: var(--win); border-radius: 10px;
  font-size: 15px; line-height: 1.6; letter-spacing: .04em; text-align: left; white-space: pre-wrap; overflow-wrap: anywhere;
  opacity: 0; visibility: hidden; transition: opacity .4s, visibility .4s;
}
.bubble::after { content: ""; position: absolute; top: 100%; left: 50%; margin-left: -7px; border: 7px solid transparent; border-top-color: var(--ink); }
.bubble.on { opacity: 1; visibility: visible; }
.bubble.pop { animation: pop .25s ease-out; }
@keyframes pop { from { transform: translateX(-50%) scale(.6); } to { transform: translateX(-50%) scale(1); } }
/* フキダシが上に出るので、舞台の上に余白を取る */
.stage { padding-top: 96px; }
@media (prefers-reduced-motion: reduce) { .bubble.pop { animation: none; } }
/* フキダシは自分の列の幅に収める。隣の人のフキダシと重ならないように */
.bubble { width: max-content; max-width: calc(100% + 6px); font-size: 14px; padding: 6px 9px; }
.stage { padding-top: 132px; }

/* 入ってはじめて分かる一文と、口調の手がかり（2026-11-14、全員同じ役に替えた） */
.reveal { margin: -6px 0 4px; font-size: 15px; color: var(--blue); letter-spacing: .06em; }
.hint-line { margin: 0 0 14px; font-size: 13px; color: var(--ink2); line-height: 1.7; }
.stage .h { font-size: 13px; color: var(--ink); }

/* ===== 部屋を軽くする（2026-11-14、UX 検査）=====
   窓の枠は書く欄と幕にだけ残す。上は細い帯1本、舞台は枠なしで夜空にじかに立たせる */
body.in-room .site { display: none; }
body.in-room .top { padding: 12px 0 10px; }
.roombar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 0; margin: 0; border: none; background: none; }
.roombar .where { display: flex; align-items: baseline; gap: 8px; min-width: 0; flex-wrap: wrap; }
.roombar .kind { font-size: 11px; }
.roombar .room-title { margin: 0; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.roombar .count { margin: 0; font-size: 12px; color: var(--ink3); }
.roombar .acts { padding: 0; flex: none; align-items: center; }
.clock-pill { font-size: 18px; font-variant-numeric: tabular-nums; color: var(--blue); padding: 2px 8px; letter-spacing: .04em; }
.waiting .clock-pill { color: var(--ink3); }
.room > .bar { margin: 8px 0 6px; }
.room > .state { margin: 0 0 4px; font-size: 12px; color: var(--ink3); min-height: 1.2em; }
.you { margin: 2px 0 0; font-size: 14px; color: var(--ink2); }
.hint-line { margin: 2px 0 0; font-size: 12px; color: var(--ink3); }

/* 舞台。枠を外し、画面の残りを使う */
.stage {
  background: none; border: none; border-radius: 0; margin: 0; padding: 120px 0 120px;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 26px 8px; min-height: 50vh;
}
.stage .icon { width: 72px; height: 72px; border: none; border-radius: 0; background: none; }
.stage .icon svg { width: 100%; height: 100%; display: block; image-rendering: pixelated; }
.stage li.me .icon { filter: drop-shadow(0 0 6px rgba(255, 215, 94, .55)); }
.stage li.talking .icon { box-shadow: none; transform: translateY(-4px); }
.stage li.me .h { color: var(--blue); }

/* 書く欄は画面の下に貼りつける */
.composer { position: fixed; left: 0; right: 0; bottom: 0; padding: 10px 16px calc(12px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--paper) 30%); z-index: 3; }
.composer .card { max-width: calc(40 * 1.04em); margin: 0 auto; }

.sheet .tell-text { margin: 12px 0 0; }
.row.spread { justify-content: space-between; margin-top: 18px; }

/* 書く欄の ▶ は欄の左の外に置く。中に置くと、自前のカーソルと重なる（指摘） */
.page:empty::before { content: attr(data-ph); }
.composer .card { padding-left: 34px; }
.composer .card::before { content: "▶"; position: absolute; left: 13px; top: 50%; transform: translateY(-50%); font-size: 12px; color: var(--blue); pointer-events: none; }
/* 空の欄では、案内の字をカーソルの右に置く。カーソルは字の頭に立つので、ずらさないと重なる（指摘） */
.page:empty::before { display: inline-block; margin-left: 8px; }
/* 名札。人物の名前を大きく、ハンドルを小さく（指摘） */
.stage .role { font-size: 14px; color: var(--ink); }
.stage li.me .role { color: var(--blue); }
.stage .h { font-size: 11px; color: var(--ink3); }
.stage li.me .h { color: var(--ink3); }
