/* 工程4 の仮の見た目（ux が作り込む）。--top、--clock、--bottom は render/scene.js も読むので px の値だけを書く */
:root {
  --top: 52px; --clock: 96px; --bottom: 84px; --duel: 0px;
  --room: #0c0b0e; --brass: #b48a45; --paper: #e9dfc6; --ink: #22303c; --warn: #e5b52e; --glow: #ff4a1f; --safe: #59e08a;
}
@media (max-height: 700px) { :root { --clock: 80px; --bottom: 76px; } }
@media (max-height: 500px) { :root { --top: 48px; --clock: 64px; --bottom: 60px; } }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none; background: var(--room); color: #f1ead9; }
body { font-family: system-ui, -apple-system, "Hiragino Sans", "Yu Gothic", sans-serif; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

#stage { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

button { font-family: inherit; font-size: 15px; font-weight: 700; line-height: 1.2; min-height: 48px; padding: 0 16px; color: #f1ead9; background: #23211f; border: 1px solid #6c5a38; border-radius: 6px; cursor: pointer; touch-action: manipulation; }
button:focus-visible { outline: 3px solid var(--warn); outline-offset: 2px; }
button.primary { width: 100%; min-height: 56px; font-size: 18px; color: #16130c; background: var(--warn); border-color: #8a6a12; }

#topbar { position: fixed; top: 0; left: 50%; transform: translateX(-50%); width: min(100%, 560px); height: var(--top); display: flex; align-items: center; gap: 8px; padding: 0 8px; z-index: 5; }
#topbar .spacer { flex: 1; }
#stage-label { font-weight: 800; font-size: 16px; }
#topbar button { min-height: 44px; height: 44px; font-size: 13px; padding: 0 10px; }
#topbar .book { width: 48px; padding: 0; display: grid; place-items: center; color: var(--ink); background: var(--paper); }

/* 部屋の四隅の暗がり（操作は通す） */
#vignette { position: fixed; inset: 0; pointer-events: none; z-index: 1; background: radial-gradient(ellipse 80% 64% at 46% 46%, transparent 55%, rgba(0, 0, 0, .62) 100%); }

#status { position: fixed; top: calc(var(--top) + var(--duel) + var(--clock));left: 0; right: 0; z-index: 2; pointer-events: none; text-align: center; padding: 0 16px; }
body.manual-open #status, body.manual-open #countdown { visibility: hidden; }
#status #misses-left, #status #note { display: table; margin: 0 auto 2px; padding: 1px 10px; border-radius: 3px; background: rgba(10, 9, 11, .8); text-shadow: 0 1px 3px #000; }
#status #note:empty { display: none; }
#status p { margin: 0; }
#misses-left { font-size: 13px; color: #ffc9a0; }
#note { font-size: 13px; line-height: 1.5; margin: 2px auto 0; max-width: 520px; text-shadow: 0 1px 4px #000; }
:lang(ja) #note { word-break: auto-phrase; } /* 日本語は文節で折り返す（使えないブラウザは今までどおり） */
#countdown { position: fixed; inset: 0; margin: 0; display: grid; place-items: center; font: 800 120px/1 ui-monospace, monospace; color: rgba(255, 74, 31, .75); pointer-events: none; z-index: 3; }

#bottombar { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: min(100%, 560px); height: var(--bottom); display: flex; align-items: center; justify-content: center; padding: 0 64px; z-index: 5; pointer-events: none; }
#bottombar > * { pointer-events: auto; }
#btn-back { width: 100%; min-height: 56px; }
#faces { display: flex; align-items: center; gap: 10px; margin: 0; font-size: 14px; color: #a99f8c; }
#faces i { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--brass); }
#faces[data-face="front"] i:first-of-type, #faces[data-face="back"] i:last-of-type { background: var(--brass); }
#faces[data-face="front"] .front, #faces[data-face="back"] .back { color: #f1ead9; font-weight: 700; }

/* 説明書: ホチキス留めの紙の仕様書。生成りの紙、油じみ、角の折れ、青灰の線画、赤鉛筆 */
#manual { position: fixed; top: calc(var(--top) + var(--duel) + var(--clock) + 4px); bottom: var(--bottom); left: 50%; transform: translateX(-50%); width: min(94%, 520px); z-index: 6; display: flex; flex-direction: column; justify-content: flex-end; touch-action: pan-y; animation: paper-in .18s ease-out; }
.paper { position: relative; display: flex; flex-direction: column; height: 100%; max-height: 600px; min-height: 0; color: var(--ink); border-radius: 3px; padding: 0 14px 8px; box-shadow: 0 12px 34px rgba(0, 0, 0, .65), 5px 5px 0 -1px #bfb398, 9px 9px 0 -3px #9d927a; font-family: ui-serif, "Hiragino Mincho ProN", "Yu Mincho", serif; font-size: 15px; line-height: 1.45;
  background: radial-gradient(ellipse 90px 62px at 92% 78%, rgba(150, 110, 50, .2), transparent 70%), radial-gradient(ellipse 140px 90px at 6% 18%, rgba(160, 120, 60, .14), transparent 70%), repeating-linear-gradient(0deg, rgba(90, 70, 40, .035) 0 1px, transparent 1px 3px), repeating-linear-gradient(90deg, rgba(255, 255, 255, .05) 0 2px, transparent 2px 5px), var(--paper); }
.paper::before, .paper::after { content: ""; position: absolute; top: 5px; width: 22px; height: 3px; border-radius: 2px; background: linear-gradient(#e8ecef, #6e757c); box-shadow: 0 1px 2px rgba(0, 0, 0, .5); transform: rotate(-32deg); }
.paper::before { left: 6px; }
.paper::after { right: auto; left: 34px; opacity: 0; }
/* 位置合わせの transform を壊さないように、translate で動かす */
@keyframes paper-in { from { translate: 0 14px; opacity: 0; } }
.paper .band { margin: 0 -14px 4px; padding: 3px 34px; text-align: center; font: 700 12px/1.4 system-ui, sans-serif; letter-spacing: .06em; border-bottom: 1px dashed rgba(34, 48, 60, .35); }
.paper.running .band { background: #b4332a; color: #fff; border: 0; font-size: 14px; }
.paper .sheet { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.paper header { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; border-bottom: 2px solid var(--ink); }
.paper h1 { margin: 0; font-size: 20px; line-height: 1.35; }
.paper p { margin: 0; }
.paper .serial { font: 11px ui-monospace, monospace; color: #8a3b30; white-space: nowrap; }
.paper .figure { flex: 1 1 96px; min-height: 80px; max-height: 190px; display: flex; border: 1px solid rgba(34, 48, 60, .3); background: rgba(255, 255, 255, .34); padding: 3px; }
.paper .figure svg { display: block; width: 100%; height: 100%; }
.paper .legend { display: flex; flex-wrap: wrap; justify-content: center; column-gap: 12px; font: 700 12px/1.35 system-ui, -apple-system, "Hiragino Sans", "Yu Gothic", sans-serif; }
.paper .legend span { white-space: nowrap; }
.paper .ref { color: #a22b22; font-weight: 700; }
/* 版で替わった行の下に残す、直前の版の文 */
.paper .rules .was { display: block; font-size: 11px; font-weight: 400; line-height: 1.3; color: #5b5348; }
.paper .rules .was s { text-decoration-color: rgba(180, 51, 42, .8); }
.paper .rules .was .ref { font-weight: 400; }
#where { display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 1px; min-width: 0; overflow: hidden; }
#edition-tag { font: 700 10px/1.35 system-ui, sans-serif; color: #f1ead9; border: 1px solid #c9645a; border-radius: 2px; padding: 0 4px; white-space: nowrap; transform: rotate(-2deg); }
.paper .rules { list-style: none; margin: 2px 0; padding: 0; }
.paper .rules li { padding: 2px 0 2px 11px; border-left: 3px solid rgba(180, 51, 42, .55); margin-bottom: 3px; }
.paper .example { display: flex; align-items: center; gap: 8px; border: 2px solid rgba(180, 51, 42, .75); border-radius: 12px 10px 14px 9px; padding: 3px 8px; font-size: 13px; line-height: 1.35; }
.paper .example svg { flex: none; width: 108px; height: 30px; }
.paper .strip { border-style: dashed; border-width: 1px; }
.paper .tip { font-size: 13px; font-weight: 700; text-align: center; }
/* 結果から読み返す時: 事実の印と、終わった爆弾の仕掛けの写し */
.paper .tags { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-start; font: 800 11px/1.5 system-ui, -apple-system, "Hiragino Sans", sans-serif; }
.paper .tags .tag { padding: 0 5px; border-radius: 2px; white-space: nowrap; }
.paper .tags .open { color: #fff; background: #b4332a; }
.paper .tags .missed { color: #8f241c; background: #fff; border: 1px solid #b4332a; }
.paper .tags .done { color: #1f5c38; border: 1px solid #1f7a43; }
.paper .tabs button .tags { margin-top: 2px; }
.paper.report .tabs button { display: flex; flex-wrap: wrap; align-items: center; align-content: center; column-gap: 4px; }
.paper.report .tabs button .tags { flex: 0 0 100%; }
.paper .views { display: flex; gap: 4px; }
.paper .views button { flex: 1; min-height: 32px; padding: 0 6px; font-size: 12px; font-weight: 700; color: var(--ink); background: transparent; border: 1px solid #8d7d58; }
.paper .views button[aria-pressed="true"] { color: #f6f1e6; background: var(--ink); border-color: var(--ink); }
.paper .figure.mine { position: relative; flex: 1 1 118px; min-height: 118px; max-height: 290px; padding: 0; background: #15110f; }
.paper .figure.mine canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.paper .figure.mine .under { position: absolute; left: 0; right: 0; bottom: 0; padding: 2px 6px; text-align: center; font: 700 12px/1.4 system-ui, sans-serif; color: #f6f1e6; background: rgba(20, 15, 12, .82); }
.paper.report .stamps { flex-wrap: wrap; justify-content: flex-end; align-items: center; }
@media (max-height: 700px) { .paper.report { font-size: 13px; line-height: 1.28; } .paper.report .views button { min-height: 30px; } .paper.report header .serial { display: none; } }
.paper .band #manual-index { position: absolute; right: 4px; top: 2px; min-height: 28px; padding: 0 10px; font-size: 12px; color: var(--ink); background: #d9ceb0; border: 1px solid #8d7d58; }
.paper .band:has(#manual-index) { min-height: 32px; display: flex; align-items: center; justify-content: center; padding-left: 34px; padding-right: 82px; text-align: center; }
.paper .tabs { list-style: none; margin: 4px 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.paper .tabs button { width: 100%; height: 100%; min-height: 38px; padding: 0 8px; font-size: 13px; line-height: 1.15; color: var(--ink); background: #f3dc86; border: 0; border-radius: 2px; box-shadow: 1px 2px 4px rgba(0, 0, 0, .25); text-align: left; }
.paper footer { flex: none; padding-top: 3px; }
.paper .dots { display: flex; justify-content: center; gap: 5px; height: 8px; margin: 0 0 5px; }
.paper .dots i { width: 6px; height: 6px; border-radius: 50%; border: 1px solid var(--ink); }
.paper .dots i.on { background: var(--ink); }
/* 仕掛けの記号の帯: 記号は「その仕掛けの説明へ飛ぶ印」だけ。1色の線画を四角い札に入れる。背の高い画面は2段まで全部見せる */
.paper svg.sym { display: block; width: 28px; height: 28px; }
.paper .syms-wrap { position: relative; margin: 0 -6px 5px; }
.paper .syms { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px 1px; }
.paper .syms button { flex: 0 0 calc((100% - 6px) / 7); min-width: 44px; min-height: 44px; height: 44px; padding: 0; display: grid; place-items: center; color: var(--ink); background: rgba(255, 255, 255, .42); border: 1px solid #8d7d58; border-radius: 3px; }
.paper .syms button[aria-current] { color: #f6f1e6; background: var(--ink); border-color: var(--ink); box-shadow: inset 0 0 0 2px var(--warn); }
.paper .syms button:focus-visible { outline-offset: -3px; }
/* 背の低い画面: 1段を横に送る。続きのある側の端に山形を出す */
@media (max-height: 700px) {
  .paper .syms { position: relative; flex-wrap: nowrap; justify-content: safe center; overflow-x: auto; overscroll-behavior-x: contain; touch-action: pan-x; scrollbar-width: none; }
  .paper .syms::-webkit-scrollbar { display: none; }
  .paper .syms button { flex: 0 0 46px; }
  .paper .syms-wrap::before, .paper .syms-wrap::after { position: absolute; top: 0; bottom: 0; width: 17px; display: none; place-items: center; font: 800 22px/1 system-ui, sans-serif; color: #f6f1e6; background: rgba(34, 48, 60, .82); pointer-events: none; z-index: 1; }
  .paper .syms-wrap::before { content: "‹"; left: 0; border-radius: 0 6px 6px 0; }
  .paper .syms-wrap::after { content: "›"; right: 0; border-radius: 6px 0 0 6px; }
  .paper .syms-wrap.more-left::before, .paper .syms-wrap.more-right::after { display: grid; }
}
.paper header .head-sym { flex: none; align-self: center; }
.paper header .head-sym svg.sym { width: 24px; height: 24px; }
.paper header h1 { margin-right: auto; }
/* 記号の帯の分だけ紙が低くなる: 図は低くできるようにする */
.paper .sheet > .figure { min-height: 62px; }
/* 複数ページの仕掛け: ページの種類、決まりの図、例の手順 */
.paper .part { display: flex; align-items: center; gap: 8px; font: 700 13px/1.5 system-ui, -apple-system, "Hiragino Sans", "Yu Gothic", sans-serif; }
.paper .part b { padding: 0 7px; border: 1.5px solid var(--ink); border-radius: 2px; font-size: 12px; white-space: nowrap; }
.paper .part b.except { color: #fff; background: var(--ink); }
.paper .part i { margin-left: auto; font-style: normal; font-variant-numeric: tabular-nums; color: #5b5348; white-space: nowrap; }
.paper .intro { padding: 2px 2px 0; }
.paper .sheet.multi { font-size: 15px; line-height: 1.38; }
/* 背の低い画面: 記号の帯の分を図と行間で詰める */
@media (max-height: 700px) and (orientation: portrait) {
  .paper .dots { height: 6px; margin-bottom: 2px; }
  .paper .sheet.multi { line-height: 1.3; }
  .paper .sheet.multi header .serial { display: none; }
  /* 起きる事を2行並べる妨害のページ */
  .paper .sheet.multi .rules li { margin-bottom: 2px; }
  /* 対戦の準備は下に残り時間とランプの行が増える */
  #manual.is-duel .paper .band:has(#manual-index) { min-height: 28px; }
  #manual.is-duel .paper .band #manual-index { min-height: 24px; top: 1px; }
  #manual.is-duel .paper .duel-ready { margin-bottom: 2px; }
  #manual.is-duel .paper .sheet.multi { gap: 2px; line-height: 1.2; }
  #manual.is-duel .paper .sheet.multi > .figure { flex-basis: 44px; min-height: 40px; }
  #manual.is-duel .paper .sheet.multi .part { line-height: 1.3; }
  #manual.is-duel .paper .sheet.multi .cases { min-height: 80px; gap: 3px; }
  #manual.is-duel .paper .sheet.multi .cases figure { padding: 2px 3px 1px; }
  #manual.is-duel .paper .sheet.multi .cases figcaption { line-height: 1.15; }
  #manual.is-duel .paper .sheet.multi .rules { margin: 0; }
  #manual.is-duel .paper .sheet.multi .rules li { padding: 0 0 0 9px; margin-bottom: 1px; }
  #manual.is-duel .paper .sheet.multi .steps li { padding: 0; }
  #manual.is-duel .paper .tabs.many button { min-height: 30px; }
  #manual.is-duel .paper .tabs.many { gap: 2px; margin: 1px 0; }
}
.paper .cases { flex: 1 1 96px; min-height: 90px; max-height: 270px; display: flex; flex-wrap: wrap; justify-content: center; align-content: stretch; gap: 5px; }
.paper .cases figure { flex: 1 1 40%; min-width: 0; min-height: 0; margin: 0; display: flex; flex-direction: column; padding: 4px 3px 2px; border: 1px solid rgba(34, 48, 60, .3); background: rgba(255, 255, 255, .34); }
.paper .cases.n3 figure { flex-basis: 30%; }
.paper .cases figure.wide { flex-basis: 100%; }
.paper .cases figure svg { flex: 1 1 0; min-height: 0; width: 100%; }
.paper .cases figcaption { flex: none; text-align: center; font: 700 13px/1.3 system-ui, -apple-system, "Hiragino Sans", "Yu Gothic", sans-serif; }
.paper .cases figure.dont { border-style: dashed; }
.paper .case-title { font-weight: 700; text-align: center; }
.paper .steps { margin: 0; padding: 0 0 0 1.6em; list-style: decimal; }
.paper .steps li { padding: 1px 0; }
.paper .steps li::marker { font-weight: 800; }
.paper .tabs button { display: flex; flex-wrap: wrap; align-items: center; column-gap: 6px; }
.paper .tabs button svg.sym { width: 24px; height: 24px; flex: none; }
.paper .tabs button > span:not(.tags) { flex: 1; min-width: 0; }
/* 横向きのスマホ: 複数ページの仕掛けは左右に分けず、縦に並べて図を低くする */
@media (max-height: 500px) {
  .paper .sheet.multi { display: flex; }
  .paper .sheet.multi .steps li { padding: 0; }
  .paper .sheet.multi > .figure { flex: 1 1 60px; height: auto; min-height: 56px; }
  .paper .sheet.multi .cases { min-height: 72px; flex-basis: 72px; }
  .paper .tabs.many { gap: 3px; margin: 2px 0; }
  .paper .tabs.many button { min-height: 35px; }
}
@media (min-height: 701px) and (max-height: 840px) { .paper .tabs.many { gap: 3px; margin: 2px 0; } .paper .tabs.many button { min-height: 35px; } }
/* 記号の帯の分だけ紙が低くなるので、背の低い画面の長い目次は札を詰める */
@media (max-height: 700px) and (orientation: portrait) {
  .paper .tabs.many { gap: 3px; margin: 2px 0; }
  .paper .tabs.many button { min-height: 31px; padding: 0 5px; column-gap: 4px; font-size: 12px; }
  .paper .tabs.many button svg.sym { width: 20px; height: 20px; }
  .paper.report .tabs.many button .tags { margin: 0; font-size: 10px; line-height: 1.25; }
  .paper .example svg { width: 86px; }
}
.paper .actions { display: flex; gap: 8px; }
.paper button { font-family: system-ui, -apple-system, "Hiragino Sans", "Yu Gothic", sans-serif; }
.paper .actions button { min-height: 50px; color: var(--ink); background: #d9ceb0; border: 1px solid #8d7d58; }
.paper .actions button:disabled { opacity: .35; }
.paper .actions #manual-prev, .paper .actions #manual-next { flex: none; width: 52px; padding: 0; font-size: 26px; }
.paper .actions #manual-close { flex: 1; width: auto; font-size: 17px; }
.paper .actions button.primary { color: #16130c; background: var(--warn); border-color: #8a6a12; }
@media (max-height: 700px) { .paper { font-size: 14px; line-height: 1.34; } .paper h1 { font-size: 17px; } .paper .figure { flex-basis: 80px; min-height: 66px; } .paper .rules li { padding-top: 0; padding-bottom: 0; margin-bottom: 3px; } .paper .example { font-size: 12px; } .paper .example svg { width: 92px; height: 25px; } .paper .actions button { min-height: 48px; } }
/* 横向きのスマホ: 説明書は絵と決まりを左右に、時計の箱は左上、下の帯の中身は右の列 */
@media (max-height: 500px) {
  #manual { top: 4px; bottom: 4px; z-index: 9; width: min(96%, 760px); }
  .paper .sheet { display: grid; grid-template-columns: 44% 1fr; grid-auto-rows: min-content; align-content: start; column-gap: 10px; }
  .paper .sheet > * { grid-column: 2; }
  .paper .sheet > header, .paper .sheet > .tabs { grid-column: 1 / -1; }
  .paper .sheet > .figure { grid-column: 1; grid-row: 2 / span 4; height: 190px; max-height: 100%; }
  .paper .tabs { grid-template-columns: 1fr 1fr 1fr; }
}
@media (max-height: 500px) and (orientation: landscape) {
  #status { right: auto; width: min(30%, 250px); padding: 0 6px; }
  #status #note { font-size: 12px; }
  #bottombar { left: auto; right: 8px; transform: none; top: var(--top); bottom: auto; width: 150px; height: calc(100% - var(--top) - 76px); padding: 0; }
}

/* 下の帯の高さは空ける（右下の感想のボタンが札のボタンに重ならない） */
#result { position: fixed; left: 50%; bottom: var(--bottom); transform: translateX(-50%); width: min(94%, 520px); max-height: calc(100% - var(--top) - var(--duel) - var(--clock) - var(--bottom) - 8px); display: flex; flex-direction: column; justify-content: flex-end; z-index: 6; animation: paper-in .22s ease-out; }
.card { background: linear-gradient(#28221c, #161310); border: 2px solid var(--brass); border-radius: 8px; padding: 10px 14px 6px; text-align: center; box-shadow: 0 10px 30px rgba(0, 0, 0, .6); min-height: 0; overflow-y: auto; }
.card h2 { margin: 0; font-size: 28px; letter-spacing: .08em; }
.card p { margin: 3px 0; }
.card .brand { font-size: 12px; color: #cdb98c; letter-spacing: .04em; }
.card .label { font-size: 12px; margin: 0; }
.card .sub { font-size: 13px; }
.card .big { font: 800 50px/1.05 ui-monospace, Menlo, monospace; margin: 0; color: var(--safe); text-shadow: 0 0 14px rgba(89, 224, 138, .5); }
.card .count { font: 800 40px/1.1 ui-monospace, Menlo, monospace; margin: 0; }
.card .cause { font-size: 16px; font-weight: 700; }
.card .all { color: var(--warn); font-weight: 800; }
.card.lost h2 { color: var(--glow); }
.card.won h2 { color: var(--safe); }
.card .primary { margin-top: 4px; min-height: 52px; }
.card .main { display: flex; gap: 6px; align-items: stretch; }
.card .main .primary { flex: 1; min-width: 0; }
.card .main .read { flex: none; margin-top: 4px; min-width: 88px; padding: 0 12px; font-size: 14px; font-weight: 700; color: #16130c; background: #e9dfc6; border-color: #b9a981; }
/* 結果の板から説明書を読み返す間は、板を隠して紙だけにする */
body.manual-open.result-open #result { visibility: hidden; }
.card .row { display: flex; gap: 6px; margin-top: 6px; }
.card .row button { flex: 1; padding: 0 4px; font-size: 13px; }
.card .note { font-size: 12px; min-height: 0; margin: 2px 0; overflow-wrap: anywhere; -webkit-user-select: text; user-select: text; }
.card .note:empty { display: none; }
/* 1人用の結果の札: 低くして下に寄せ、見出しと時間を1行に並べる（対戦の札は変えない） */
@media (min-height: 501px), (orientation: portrait) { #result:has(.card.solo) { bottom: 64px; } }
@media (max-height: 500px) and (orientation: landscape) { #result .card.solo h2 { font-size: 21px; } #result .card.solo .big { font-size: 32px; } #result .card.solo .row button { min-height: 42px; } }
.card.solo { padding: 6px 10px 4px; }
.card.solo p { margin: 1px 0; }
.card.solo .head { display: flex; align-items: center; justify-content: center; gap: 18px; }
.card.solo .figure-of { display: flex; flex-direction: column; align-items: center; margin: 0; }
.card.solo .label { line-height: 1.2; }
.card.solo h2 { font-size: 27px; }
.card.solo .big { font-size: 36px; }
.card.solo .count { font-size: 28px; }
.card.solo .cause { font-size: 15px; }
.card.solo .compare { font-weight: 700; font-variant-numeric: tabular-nums; }
.card.solo .compare.better { color: var(--safe); }
.card.solo .all { font-size: 14px; }
.card.solo .endless-open { color: #cdb98c; }
.card.solo .primary { margin-top: 3px; min-height: 46px; font-size: 17px; }
.card.solo .row { margin-top: 5px; }
.card.solo .row button { min-height: 44px; }
.tubes { display: inline-flex; gap: 4px; vertical-align: middle; }
.tubes i { width: 9px; height: 18px; border-radius: 5px 5px 2px 2px; background: #3a322c; border-bottom: 3px solid var(--brass); }
.tubes i.ok { background: #ffa03a; box-shadow: 0 0 8px #ff7a1f; }

#topbar #btn-stages, #topbar #btn-sound { width: 44px; padding: 0; display: grid; place-items: center; }
#btn-sound[aria-pressed="false"] .off, #btn-sound[aria-pressed="true"] .on { display: none; }

/* 面の選択: 下から出る工具の引き出し */
#stages { position: fixed; inset: var(--top) 0 0 0; z-index: 7; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; background: rgba(6, 5, 7, .55); }
.drawer { width: min(100%, 560px); max-height: 100%; overflow-y: auto; padding: 8px 12px 12px; background: linear-gradient(#2c2620, #17130f); border-top: 3px solid var(--brass); border-radius: 10px 10px 0 0; animation: paper-in .18s ease-out; touch-action: pan-y; }
.drawer .band { margin: -8px -12px 6px; padding: 4px; text-align: center; font-weight: 700; font-size: 13px; background: #b4332a; }
.drawer header { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.drawer h1 { margin: 0; font-size: 18px; }
.drawer .hint { margin: 4px 0 8px; font-size: 12px; color: #bcae92; }
.drawer ul { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.drawer li button { width: 100%; height: 76px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 4px; background: linear-gradient(#4a4036, #2b251f); border: 1px solid #8a744a; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .12), 0 3px 0 #0b0907; }
.drawer li button:disabled { opacity: .45; cursor: default; }
.drawer li button.current { border: 2px solid var(--warn); }
.drawer li .best { font: 700 15px ui-monospace, Menlo, monospace; display: grid; place-items: center; min-height: 18px; }
.drawer li button.cleared .best { color: var(--safe); }
.drawer li .mark { display: flex; align-items: center; gap: 3px; min-height: 14px; font-size: 11px; color: var(--warn); }
.drawer li button:disabled .mark { color: #cfc4ab; }
/* 終わりのない爆弾の入口（12面の札の下の横長の札） */
.drawer .endless { width: 100%; min-height: 56px; margin-top: 10px; display: flex; align-items: center; justify-content: center; gap: 12px; padding: 6px 10px; text-align: left; background: linear-gradient(#4a2620, #2a1411); border: 1px solid #d8734a; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .12), 0 3px 0 #0b0907; }
.drawer .endless .loop { flex: none; display: grid; place-items: center; width: 30px; font-size: 28px; line-height: 1; color: var(--warn); }
.drawer .endless .words { display: flex; flex-direction: column; gap: 2px; }
.drawer .endless .words span { font-size: 12px; font-weight: 400; color: #f3d9c4; }
.drawer .endless.current { border: 2px solid var(--warn); }
.drawer .endless:disabled { opacity: .55; cursor: default; background: linear-gradient(#332b26, #1f1a16); border-color: #8a744a; }
body.stages-open #result, body.stages-open #manual { visibility: hidden; }
body.result-open #faces, body.result-open #btn-back, body.result-open #breath, body.result-open #status { visibility: hidden; }
@media (max-height: 700px) { .drawer li button { height: 64px; } }
@media (max-height: 500px) { .drawer ul { grid-template-columns: repeat(6, 1fr); } }
/* 狭い画面では右下の感想のボタンの分だけ下を空け、面の札に重ねない */
@media (max-width: 639px) { .drawer { padding-bottom: calc(66px + env(safe-area-inset-bottom, 0px)); } }
/* 背の低い画面の改訂のページは「旧:」の行の分だけ図を低くして、例まで紙に入れる */
@media (max-height: 700px) { .paper .sheet:has(.rules.revised) .figure { flex-basis: 56px; min-height: 52px; } .paper .rules .was { font-size: 10.5px; line-height: 1.22; } }
/* 版（13面より先と毎日の爆弾）: 版の判、改訂の判、替わった行の太い縦線。替わらない行と例は弱くして、印を目立たせる */
.paper .stamps { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 2px 5px; margin-left: auto; min-width: 0; }
.paper .stamps .edition { font: 700 11px/1.3 system-ui, sans-serif; color: #8a3b30; border: 1.5px solid #8a3b30; border-radius: 2px; padding: 0 4px; white-space: nowrap; }
.paper b.revised { display: inline-block; flex: none; font: 800 12px/1.35 system-ui, sans-serif; letter-spacing: .06em; color: #fff; background: #b4332a; border-radius: 2px; padding: 0 5px; rotate: -4deg; white-space: nowrap; }
.paper .rules.revised li { border-left: 6px solid transparent; padding-left: 8px; }
.paper .rules.revised li.changed { border-left-color: #b4332a; background: rgba(180, 51, 42, .14); font-weight: 700; }
.paper .example.quiet { border-color: rgba(34, 48, 60, .35); border-width: 1px; }
.paper .tabs button:has(.revised) { display: flex; align-items: center; justify-content: space-between; gap: 4px; }
/* 読み返す時の目次: 印と「改訂」の判は名前の下の1行に並べる（13個の札が送らずに収まる） */
.paper.report .tabs button .tags { flex: 0 0 auto; margin-left: 30px; }
.paper.report .tabs button { justify-content: flex-start; row-gap: 0; }
.paper.report .tabs button b.revised { font-size: 11px; }
.paper.report .tabs button > span:not(.tags) { flex: 0 1 calc(100% - 30px); }
.paper.report .tabs.many { gap: 4px; margin: 2px 0; }
@media (min-height: 701px) { .paper.report .tabs.many button { padding-top: 3px; padding-bottom: 3px; } }
@media (max-height: 700px) and (orientation: portrait) { .paper.report .tabs.many { gap: 2px; margin: 1px 0; } }
.paper.report .tabs.many button .tags { line-height: 1.25; margin-top: 0; }
/* 幅の狭い画面: 「未解除」と「ミス n」が並ぶと名前の下げ幅の分だけ右にはみ出すので、札の左端から使い、足りなければ折り返す */
@media (max-width: 420px) and (orientation: portrait) { .paper.report .tabs button .tags { flex: 0 1 auto; max-width: 100%; margin-left: 0; column-gap: 3px; } }
/* 背の低い画面の版の爆弾: 「未解除」「ミス n」「改訂」の3つが付く札は詰めて1行に並べる。3行になると目次の最後が紙から落ちる */
@media (max-width: 420px) and (max-height: 700px) and (orientation: portrait) {
  .paper.report .tabs.many button:has(.missed):has(.revised) { padding: 0 2px; column-gap: 2px; }
  .paper.report .tabs.many button:has(.missed):has(.revised) .tags { column-gap: 2px; font-size: 9.5px; letter-spacing: -.01em; }
  .paper.report .tabs.many button:has(.missed):has(.revised) .tag { padding: 0 2px; }
  .paper.report .tabs.many button:has(.missed):has(.revised) b.revised { font-size: 9.5px; letter-spacing: 0; padding: 0 2px; }
}
/* 背の低い画面の読み返し（切り替えの分だけ低い）: 2段になる図は、言葉を図の横に置いて図の高さを残す */
@media (max-height: 700px) and (orientation: portrait) {
  .paper.report .cases.n4, .paper.report .cases.n2:has(.wide) { min-height: 96px; gap: 3px; }
  .paper.report .cases.n4 figure, .paper.report .cases.n2 figure.wide { flex-direction: row; align-items: center; gap: 3px; padding: 1px 3px; }
  .paper.report .cases.n4 figure svg { flex: 1 1 0; width: 0; height: 100%; }
  .paper.report .cases.n2 figure.wide svg { flex: 1 1 0; width: 0; height: 44px; }
  .paper.report .cases.n4 figcaption { flex: 0 0 40%; line-height: 1.15; }
  .paper.report .cases.n2 figure.wide figcaption { flex: 0 0 38%; line-height: 1.15; }
}
.paper .band .edition-line { display: block; color: #8a2b20; font-size: 13px; }
.paper.ready .edition-line { padding: 0 0 6px; font-weight: 800; color: #8a2b20; }
/* 今日の爆弾の入口と結果 */
.drawer .endless.daily { background: linear-gradient(#203a44, #122229); border-color: #6fb3c4; margin-top: 8px; }
.drawer .endless .loop.day { width: 52px; font: 800 17px ui-monospace, Menlo, monospace; }
.drawer .endless .words small { margin-left: 8px; font-size: 11px; font-weight: 400; color: #bcdce4; }
.drawer .endless .words span.done { color: var(--safe); font-weight: 700; }
.drawer .endless .words span.streak, .card.solo .daily-mark .streak { color: #ffd98a; font-weight: 700; }
.card.solo .daily-title { font-size: 15px; font-weight: 800; color: #bfe3ec; letter-spacing: .04em; }
.card.solo .daily-mark { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 2px 8px; font-size: 12px; }
.card.solo .daily-mark b { color: #16130c; background: var(--warn); border-radius: 2px; padding: 0 7px; }
.card.solo .daily-mark.practice b { color: var(--ink); background: #cfd8dc; }
.paper.ready { height: auto; }
.paper.ready h1 { font-size: 19px; padding: 8px 0; }
.paper.ready footer { padding-top: 10px; }
.paper.ready .endless-line { padding: 4px 0 0; font-size: 13px; border-top: 1px dashed rgba(34, 48, 60, .35); }
.paper.ready .actions button#manual-read { flex: none; font-size: 14px; padding: 0 12px; }

/* くらくら: 自分の目の中の出来事（赤紫の暗がり、ぼけ、残像、汗）。時計の箱と下の帯にはかけない */
#ghost { position: fixed; left: 0; width: 100%; z-index: 1; pointer-events: none; filter: blur(2px) saturate(1.3);
  -webkit-mask-image: radial-gradient(ellipse 62% 52% at 50% 50%, transparent 45%, #000 100%), linear-gradient(transparent, #000 60px, #000 calc(100% - 30px), transparent);
  mask-image: radial-gradient(ellipse 62% 52% at 50% 50%, transparent 45%, #000 100%), linear-gradient(transparent, #000 60px, #000 calc(100% - 30px), transparent);
  -webkit-mask-composite: source-in; mask-composite: intersect; }
#dizzy { position: fixed; left: 0; right: 0; top: calc(var(--top) + var(--duel) + var(--clock)); bottom: var(--bottom); z-index: 1; pointer-events: none; opacity: 0; overflow: hidden; transition: opacity .12s; -webkit-mask-image: linear-gradient(transparent, #000 56px, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(transparent, #000 56px, #000 calc(100% - 28px), transparent); }
#dizzy[data-level="1"] { background: radial-gradient(ellipse 75% 60% at 50% 50%, transparent 55%, rgba(106, 31, 77, .62) 100%); }
#dizzy[data-level="2"] { background: radial-gradient(ellipse 68% 54% at 50% 50%, transparent 48%, rgba(106, 31, 77, .78) 88%, rgba(40, 6, 30, .9) 100%); }
#dizzy[data-level="3"] { background: radial-gradient(ellipse 62% 50% at 50% 50%, transparent 42%, rgba(116, 31, 82, .88) 80%, rgba(30, 3, 22, .96) 100%); }
/* 横に広い画面では左右の端から暗くする（上下だけの帯に見えないように） */
@media (orientation: landscape) {
  #dizzy[data-level="1"] { background: radial-gradient(ellipse 52% 90% at 50% 50%, transparent 50%, rgba(106, 31, 77, .62) 100%); }
  #dizzy[data-level="2"] { background: radial-gradient(ellipse 48% 84% at 50% 50%, transparent 46%, rgba(106, 31, 77, .78) 88%, rgba(40, 6, 30, .9) 100%); }
  #dizzy[data-level="3"] { background: radial-gradient(ellipse 44% 78% at 50% 50%, transparent 42%, rgba(116, 31, 82, .88) 82%, rgba(30, 3, 22, .96) 100%); }
}
.sweat { position: absolute; top: -20px; width: 9px; height: 15px; border-radius: 50% 50% 50% 50% / 62% 62% 38% 38%; background: linear-gradient(135deg, #fff, rgba(150, 200, 235, .55)); animation: sweat 4.2s ease-in infinite; }
.sweat.s1 { left: 4%; }
.sweat.s2 { right: 6%; animation-delay: 1.5s; }
.sweat.s3 { left: 11%; animation-delay: 2.8s; }
#dizzy[data-level="1"] .s2, #dizzy[data-level="1"] .s3, #dizzy[data-level="2"] .s3 { display: none; }
@keyframes sweat { 0% { translate: 0 0; opacity: 0; } 12% { opacity: .9; } 55% { translate: 3px 28vh; } 100% { translate: 0 70vh; opacity: 0; } }
#drop { position: fixed; z-index: 4; top: -30px; right: 22%; width: 18px; height: 28px; pointer-events: none; border-radius: 50% 50% 50% 50% / 64% 64% 36% 36%; background: linear-gradient(135deg, #fff 10%, rgba(140, 195, 235, .65)); animation: drop 2.2s cubic-bezier(.5, 0, .8, .6) forwards; }
@keyframes drop { 0% { translate: 0 0; } 35% { translate: 2px 18vh; } 100% { translate: 0 110vh; } }

/* 妨害: 部屋で起きること */
#siren { position: fixed; inset: 0; z-index: 2; pointer-events: none; box-shadow: inset 0 0 50px 12px rgba(230, 40, 20, .65); animation: siren .96s ease-in-out infinite; }
@keyframes siren { 50% { opacity: .3; } }
#badge { position: fixed; z-index: 4; top: calc(var(--top) + var(--duel) + var(--clock) + 50px); left: 50%; transform: translateX(-50%); margin: 0; padding: 6px 22px; font-size: 22px; font-weight: 900; letter-spacing: .2em; white-space: nowrap; pointer-events: none; color: #16130c; background: repeating-linear-gradient(135deg, var(--warn) 0 12px, #f3cb52 12px 24px); border: 2px solid #16130c; box-shadow: 0 4px 14px rgba(0, 0, 0, .6); animation: stamp .18s ease-out; }
@keyframes stamp { from { scale: 1.5; opacity: 0; } }
#steady { position: fixed; z-index: 4; width: 92px; height: 92px; margin: -46px 0 0 -46px; border-radius: 50%; pointer-events: none; background: conic-gradient(var(--warn) var(--k, 0deg), rgba(255, 255, 255, .18) 0); -webkit-mask-image: radial-gradient(circle, transparent 55%, #000 57%); mask-image: radial-gradient(circle, transparent 55%, #000 57%); }

/* ミス: 理由の文のすぐ下に赤い数字が出て、下へ落ちる。文の流れの中に置き、上へは動かさないので、文の行数が増えても重ならない */
#status #lost { display: table; margin: 4px auto 0; font: 900 34px/1.15 ui-monospace, Menlo, monospace; color: #ff3b26; text-shadow: 0 0 10px rgba(255, 40, 20, .8), 0 2px 3px #000; transform-origin: 50% 0; animation: lost 1.8s ease-in forwards; }
@keyframes lost { 0% { scale: 1.45; opacity: 0; } 12% { scale: 1; opacity: 1; } 60% { translate: 0 14px; opacity: 1; } 100% { translate: 0 110px; opacity: 0; } }
/* 解けた時の光（ランプから時計へ） */
#beam { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 4; pointer-events: none; overflow: hidden; }
#beam .trail, #beam .head { filter: drop-shadow(0 0 8px #3dff8b) drop-shadow(0 0 16px #22d96a); }

/* 深呼吸の輪（左下）。文は輪の上の吹き出し */
#breath { position: absolute; left: 0; top: 50%; translate: 0 -50%; width: 66px; height: 76px; padding: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; background: none; border: 0; touch-action: none; }
#breath .dial { position: relative; width: 56px; height: 56px; flex: none; }
#breath svg { width: 100%; height: 100%; rotate: -90deg; }
#breath circle { fill: rgba(12, 10, 12, .7); stroke-width: 7; }
#breath .track { stroke: #4d4650; }
#breath .fill { fill: none; stroke: #e7a8d2; stroke-dasharray: 289; stroke-dashoffset: 289; }
#breath .core { position: absolute; inset: 7px; border-radius: 50%; background: #5a5260; transform: scale(.34); }
#breath .lv { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 3px; }
#breath .lv i { width: 7px; height: 7px; border-radius: 50%; border: 1px solid #fff; opacity: .5; }
#breath .lv i.on { background: #fff; opacity: 1; }
#breath .state { font-size: 10px; line-height: 1.2; margin-top: 3px; white-space: nowrap; color: #a99f8c; }
#breath .say { position: absolute; bottom: calc(100% + 4px); left: 6px; padding: 5px 10px; white-space: nowrap; font-size: 14px; font-weight: 800; color: #fff; background: #6a1f4d; border: 1px solid #e7a8d2; border-radius: 6px; pointer-events: none; }
#breath .say:empty { display: none; }
/* くらくらが 0 の間は小さく薄く置き、来たら大きく光らせる */
#breath[data-mode="calm"] { opacity: .42; }
#breath[data-mode="calm"] .dial { scale: .74; }
#breath[data-mode="calm"] .state { margin-top: -3px; }
#breath:not([data-mode="calm"]) .dial { scale: 1.08; }
#breath:not([data-mode="calm"]) .core { background: radial-gradient(circle, #f0b6dc, #8c2f68); }
#breath:not([data-mode="calm"]) .state { color: #ffd3ee; font-weight: 700; }
#breath:not([data-mode="calm"]) .dial { border-radius: 50%; box-shadow: 0 0 16px 3px rgba(231, 120, 200, .55); }
#breath.beat .dial { scale: 1.1; }
#breath.arrive .dial { animation: arrive .5s ease-out; }
@keyframes arrive { 30% { scale: 1.35; } 60% { scale: .92; } }
#breath[data-mode="now"] .core { background: #fff; }
#breath[data-mode="now"] .dial { box-shadow: 0 0 24px 10px #fff; }
#breath[data-mode="now"] .say { background: #fff; color: #4a0f35; font-size: 17px; }
#breath[data-mode="fail"] .dial, #breath[data-mode="over"] .dial { animation: cough .12s linear infinite; }
#breath[data-mode="ok"] .say { background: #175c37; border-color: var(--safe); }
@keyframes cough { 25% { translate: -3px 0; } 75% { translate: 3px 0; } }

.panel { position: fixed; top: var(--top); left: 0; right: 0; bottom: 0; z-index: 8; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 8px; padding: 24px; text-align: center; background: var(--room); }
.panel h1 { font-size: 19px; margin: 0; }
.panel p { margin: 0 0 8px; max-width: 34em; line-height: 1.6; }
.panel button { max-width: 320px; }
.no-3d #stage, .no-3d #status, .no-3d #bottombar, .no-3d #manual, .no-3d #result, .no-3d #countdown, .no-3d #btn-manual, .no-3d #where { display: none; }

#loading { position: fixed; inset: 0; z-index: 4; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; }
#loading .blink { margin: 0; padding: 12px 28px; font: 800 44px/1 ui-monospace, monospace; color: var(--glow); background: #161012; border-radius: 8px; animation: blink 1s steps(2, start) infinite; }
#loading .late { visibility: hidden; font-size: 13px; animation: late 0s linear 2s forwards; }
@keyframes blink { to { opacity: .55; } }
@keyframes late { to { visibility: visible; } }

#boot-error { z-index: 20; top: 0; }

.fx { position: fixed; inset: 0; pointer-events: none; z-index: 3; }
.fx-miss { box-shadow: inset 0 0 90px 30px rgba(230, 30, 20, .75); }
.fx-boom { background: #fff1dc; animation: boom .42s ease-out forwards; }
@keyframes boom { 0%, 55% { opacity: 1; } 100% { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  #loading .blink, #breath .dial, #badge, #manual, #result, .drawer, .sweat { animation: none !important; }
  .sweat { display: none; }
  #breath.beat .dial { scale: 1; }
  #siren { animation-duration: 2s; }
  #status #lost { animation: lost-still 1.8s linear forwards; }
}
@keyframes lost-still { 0%, 75% { opacity: 1; } 100% { opacity: 0; } }
/* メニューの「揺れを弱める」: 上の端末の設定の時と同じ見せ方 */
html.calm #loading .blink, html.calm #breath .dial, html.calm #badge, html.calm #manual, html.calm #result, html.calm .drawer, html.calm .sweat, html.calm .sheet-card.enter, html.calm .sheet-card .spin, html.calm .sheet-card .blink, html.calm #duel.bump { animation: none !important; }
html.calm .sweat { display: none; }
html.calm #breath.beat .dial { scale: 1; }
html.calm #siren { animation-duration: 2s; }
html.calm #status #lost { animation: lost-still 1.8s linear forwards; }
html.calm #finger { animation-timing-function: steps(2, end) !important; }
.drawer .calm { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; min-height: 44px; margin-top: 6px; padding: 3px 12px; text-align: left; }
.drawer .calm .words { display: flex; flex-direction: column; line-height: 1.3; }
.drawer .calm .words span { font-size: 11px; color: #cdb98c; }
.drawer .calm .state { flex: none; min-width: 52px; padding: 2px 8px; text-align: center; font-weight: 800; border: 1px solid #9a8458; border-radius: 12px; }
.drawer .calm[aria-checked="true"] .state { color: #16130c; background: var(--warn); border-color: var(--warn); }
@media (max-height: 700px) { .drawer li button { height: 56px; gap: 0; } .drawer li button:disabled .mark { display: none; } .drawer ul { gap: 6px; } .drawer .hint { margin: 2px 0 6px; } .drawer .endless { min-height: 50px; margin-top: 7px; padding-top: 3px; padding-bottom: 3px; } .drawer .endless.daily { margin-top: 6px; } .drawer .calm { margin-top: 6px; } }
.no-3d #breath, .no-3d #btn-stages { display: none; }
@media (max-height: 500px) and (orientation: landscape) { #breath { left: 50%; top: auto; bottom: -72px; translate: -50% 0; } #breath .say { left: auto; right: 0; } #badge { top: calc(var(--top) + 8px); } #result { width: min(52%, 440px); left: auto; right: 64px; transform: none; bottom: 4px; max-height: calc(100% - var(--top) - 8px); } .card .big { font-size: 38px; } .card .count { font-size: 28px; } .card h2 { font-size: 21px; } .card p { margin: 1px 0; } .card .primary { min-height: 46px; } .card .row button { min-height: 42px; } }
/* 指の影: 最初の操作に迷っている時に1回だけ、動きの型を見せる */
#finger { position: fixed; z-index: 4; width: 44px; height: 62px; margin: -12px 0 0 -22px; pointer-events: none; border-radius: 22px 22px 18px 18px; background: radial-gradient(ellipse 14px 18px at 50% 26%, rgba(255, 244, 225, .75), transparent 70%), rgba(240, 225, 200, .38); border: 2px solid rgba(255, 244, 225, .75); rotate: -18deg; box-shadow: 0 8px 18px rgba(0, 0, 0, .55); }
#finger[data-move="tap"] { animation: finger-tap 1.8s ease-in-out forwards; }
#finger[data-move="swipe"] { animation: finger-swipe 2s ease-in-out forwards; }
@keyframes finger-tap { 0% { translate: 30px 60px; opacity: 0; } 30% { translate: 0 0; opacity: 1; scale: 1; } 45% { scale: .82; box-shadow: 0 0 0 14px rgba(229, 181, 46, .45); } 60% { scale: 1; box-shadow: 0 0 0 28px rgba(229, 181, 46, 0); } 85% { opacity: 1; } 100% { opacity: 0; } }
@keyframes finger-swipe { 0% { translate: -110px 0; opacity: 0; } 20% { translate: -110px 0; opacity: 1; } 80% { translate: 110px -8px; opacity: 1; } 100% { translate: 120px -8px; opacity: 0; } }
@media (prefers-reduced-motion: reduce) { #finger { animation-timing-function: steps(2, end) !important; } }

/* 対戦。--duel は相手の帯の高さ（render/scene.js も読むので px の値だけ） */
html.versus { --duel: 34px; }
@media (max-height: 500px) { html.versus { --duel: 28px; } }
html.versus #topbar #btn-stages { display: none; }
#topbar #btn-lang { white-space: nowrap; }
#topbar #btn-duel { width: 44px; padding: 0; display: grid; place-items: center; }
html.versus #topbar #btn-duel { border-color: var(--warn); color: var(--warn); }
#stage-label { white-space: nowrap; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
/* 細い画面（360px）: すき間と言語ボタンを詰め、面の番号を切らない */
@media (max-width: 400px) {
  #topbar { gap: 4px; padding: 0 6px; }
  #stage-label { flex: none; font-size: 15px; }
  #topbar #btn-lang { padding: 0 6px; font-size: 12px; }
}
.no-3d #btn-duel, .no-3d #duel, .no-3d #versus { display: none; }

#duel { position: fixed; z-index: 5; top: var(--top); left: 50%; transform: translateX(-50%); width: min(100% - 8px, 552px); height: var(--duel); display: flex; align-items: center; gap: 8px; padding: 0 10px; font-size: 13px; background: linear-gradient(#332b23, #1c1713); border: 1px solid #8a744a; border-radius: 4px; white-space: nowrap; overflow: hidden; }
#duel .who { flex: none; color: #cdb98c; }
#duel .say { flex: 1; min-width: 0; text-align: right; overflow: hidden; text-overflow: ellipsis; font-weight: 700; }
#duel .lamps { flex: none; display: flex; gap: 3px; }
#duel .lamps i { width: 10px; height: 10px; border-radius: 50%; background: #3a322c; border: 1px solid #9a8458; }
#duel .lamps i.on { background: var(--safe); border-color: #d8ffe6; box-shadow: 0 0 7px var(--safe); }
#duel .misses { flex: none; display: flex; }
#duel .tubes i { width: 7px; height: 15px; }
#duel[data-tone="good"] { border-color: var(--safe); }
#duel[data-tone="good"] .say { color: var(--safe); }
#duel[data-tone="warn"] .say { color: var(--warn); }
#duel[data-tone="flash"] { color: #16130c; background: var(--warn); border-color: #fff; box-shadow: 0 0 22px 6px rgba(229, 181, 46, .7); }
#duel[data-tone="flash"] .who { color: #16130c; }
#duel.bump { animation: arrive .45s ease-out; }
#duel.bump { animation-name: duel-bump; }
@keyframes duel-bump { 35% { scale: 1.04 1.18; filter: brightness(1.6); } }

#linkbar { position: fixed; z-index: 10; left: 50%; bottom: calc(var(--bottom) + 6px); transform: translateX(-50%); width: min(94%, 460px); padding: 10px 12px; text-align: center; background: #3c1712; border: 2px solid #ff7a5c; border-radius: 8px; box-shadow: 0 8px 24px rgba(0, 0, 0, .6); }
#linkbar.high { top: calc(var(--top) + var(--duel) + 4px); bottom: auto; }
#linkbar p { margin: 0 0 8px; font-weight: 700; font-size: 14px; line-height: 1.5; }
#linkbar div { display: flex; gap: 8px; justify-content: center; }
#linkbar button { flex: 1; max-width: 200px; min-height: 44px; font-size: 14px; }

#versus { position: fixed; inset: var(--top) 0 0 0; z-index: 7; display: flex; flex-direction: column; align-items: center; overflow-y: auto; padding: 10px 12px 76px; background: rgba(6, 5, 7, .78); touch-action: pan-y; }
.sheet-card { width: min(100%, 440px); margin: auto 0; display: flex; flex-direction: column; gap: 8px; padding: 14px 14px 14px; text-align: center; background: linear-gradient(#2c2620, #17130f); border: 2px solid var(--brass); border-radius: 10px; box-shadow: 0 12px 34px rgba(0, 0, 0, .65); }
.sheet-card.enter { animation: paper-in .18s ease-out; }
.sheet-card > * { flex: none; }
.sheet-card h1 { margin: 0; font-size: 21px; }
.sheet-card p { margin: 0; line-height: 1.5; font-size: 14px; }
.sheet-card .label { font-size: 12px; color: #bcae92; }
.sheet-card .small { font-size: 12px; color: #bcae92; }
.sheet-card .band { margin: -14px -14px 0; padding: 4px; font-weight: 700; font-size: 13px; background: #b4332a; border-radius: 8px 8px 0 0; }
.sheet-card form { display: flex; flex-direction: column; gap: 4px; margin: 4px 0; padding: 10px 0 0; border-top: 1px dashed #6c5a38; }
.sheet-card label { font-size: 13px; color: #cdb98c; }
.sheet-card .join { display: flex; gap: 8px; }
.sheet-card input { flex: 1; min-width: 0; height: 52px; padding: 0 8px; text-align: center; text-transform: uppercase; font: 800 26px ui-monospace, Menlo, monospace; letter-spacing: .3em; color: var(--ink); background: var(--paper); border: 2px solid #8d7d58; border-radius: 6px; -webkit-user-select: text; user-select: text; }
.sheet-card input:focus-visible { outline: 3px solid var(--warn); outline-offset: 2px; }
.sheet-card .bad, .sheet-card .note { font-size: 13px; color: #ffc9a0; overflow-wrap: anywhere; -webkit-user-select: text; user-select: text; }
.sheet-card .bad:empty, .sheet-card .note:empty { display: none; }
.sheet-card .code { align-self: center; padding: 6px 10px 6px 20px; font: 800 44px/1.1 ui-monospace, Menlo, monospace; letter-spacing: .22em; color: var(--ink); background: linear-gradient(#e8d7a4, #c3a866); border: 2px solid #7d6430; border-radius: 6px; box-shadow: inset 0 2px 0 rgba(255, 255, 255, .5), 0 3px 0 #0b0907; -webkit-user-select: text; user-select: text; }
.sheet-card .link { font: 12px ui-monospace, Menlo, monospace; color: #cdb98c; overflow-wrap: anywhere; -webkit-user-select: text; user-select: text; }
.sheet-card button:disabled { opacity: .45; cursor: default; }
.sheet-card .pair { display: flex; gap: 8px; }
.sheet-card .pair button { flex: 1; }
.sheet-card .spin { font: 800 34px ui-monospace, monospace; color: var(--glow); animation: blink 1s steps(2, start) infinite; }
.sheet-card .blink { font-weight: 700; color: var(--warn); animation: blink 1.4s ease-in-out infinite alternate; }
.levels { display: flex; gap: 6px; }
.levels button { flex: 1; min-width: 0; min-height: 56px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 4px 2px; }
.levels button span { font-size: 11px; font-weight: 400; color: #cdb98c; }
.levels button[aria-pressed="true"] { color: #16130c; background: var(--warn); border-color: #fff3c4; }
.levels button[aria-pressed="true"] span { color: #16130c; }
.seats { display: flex; justify-content: center; gap: 28px; }
.seat { display: flex; flex-direction: column; align-items: center; gap: 4px; color: #8c8375; }
.seat i { position: relative; width: 52px; height: 46px; border-radius: 6px; background: #1b2423; border: 2px solid #3c4644; }
.seat i::before { content: ""; position: absolute; left: 14px; right: 14px; top: -7px; height: 6px; border: 2px solid #5d5442; border-bottom: 0; border-radius: 4px 4px 0 0; }
.seat i::after { content: ""; position: absolute; left: 10px; right: 10px; top: 10px; height: 11px; border-radius: 2px; background: #2a1613; }
.seat.lit { color: #f1ead9; font-weight: 700; }
.seat.lit i { background: #24423f; border-color: var(--brass); box-shadow: 0 0 18px rgba(255, 190, 90, .45); }
.seat.lit i::after { background: var(--glow); box-shadow: 0 0 9px var(--glow); }
@media (max-height: 700px) { .sheet-card { gap: 6px; padding-top: 10px; padding-bottom: 10px; } .sheet-card .band { margin-top: -10px; } .sheet-card .code { font-size: 34px; } .sheet-card p { font-size: 13px; } .seat i { height: 32px; } .seat i::after { top: 7px; height: 8px; } }

/* 開幕の説明書の「友だちと対戦」と、対戦の準備の行。
   操作の行はいつも紙のいちばん下に置き（ページ、言語、入口の有無で位置が変わらない）、入口はその上に置く */
.paper .invite { display: block; width: 100%; min-height: 34px; margin: 0 0 8px; font-size: 13px; color: var(--ink); background: transparent; border: 1px dashed #8d7d58; }
/* 背の低い画面では、入口を紙の上の帯の右端に置いて、中身の高さを減らさない。下のボタンの位置は変わらない */
@media (max-height: 700px) {
  .paper .tabs button { min-height: 36px; }
  .paper.ready .invite { min-height: 34px; font-size: 12px; }
  .paper:not(.ready) .invite { position: absolute; top: 0; right: 0; width: auto; max-width: 96px; height: 30px; min-height: 30px; margin: 0; padding: 0 6px; font-size: 11px; line-height: 1.1; background: var(--paper); }
  .paper:not(.ready):has(.invite) .band { min-height: 30px; line-height: 22px; text-align: left; padding-left: 62px; }
}
.paper .duel-ready { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 2px 10px; margin: 0 0 4px; font: 700 13px system-ui, sans-serif; }
.paper .duel-ready #duel-left { font-variant-numeric: tabular-nums; color: #8a2b20; }
.paper .duel-ready .lamp { display: flex; align-items: center; gap: 4px; }
.paper .duel-ready .lamp::before { content: ""; width: 11px; height: 11px; border-radius: 50%; border: 2px solid var(--ink); }
.paper .duel-ready .lamp.on::before { background: #1f9d57; box-shadow: 0 0 7px #1f9d57; }
.paper .actions button#btn-ready { flex: 1; font-size: 16px; }
.paper .actions button#btn-ready:disabled { opacity: .65; }

/* 対戦の結果（S6） */
.card.duel h2 { font-size: 34px; }
.card .sides { display: flex; gap: 8px; margin: 6px 0; }
.card .side { flex: 1; min-width: 0; padding: 4px; background: rgba(255, 255, 255, .05); border: 1px solid #55472d; border-radius: 6px; font-size: 12px; }
.card .side.won { border: 2px solid var(--safe); }
.card .side p { margin: 1px 0; }
.card .side .who { color: #cdb98c; font-weight: 700; }
.card .side .state { font-weight: 800; font-size: 14px; }
.card .side .time { font: 800 24px/1.15 ui-monospace, Menlo, monospace; }
.card .levels button { min-height: 46px; }
.card .primary:disabled { opacity: .6; }
.card #duel-status:empty { display: none; }
.card.waiting h2 { font-size: 24px; }
@media (max-height: 700px) { .card.duel h2 { font-size: 26px; } .card.duel .brand { display: none; } .card .side .time { font-size: 19px; } .card .levels button { min-height: 42px; } .card.duel .primary { min-height: 46px; } .card.duel .row button { min-height: 42px; } }
body.versus-open #status, body.versus-open #countdown, body.versus-open #duel, body.versus-open #manual, body.versus-open #result, body.versus-open #bottombar { visibility: hidden; }
@media (max-height: 500px) and (orientation: landscape) { #duel { left: auto; right: 4px; transform: none; width: min(52%, 440px); } #manual { z-index: 9; } html.versus #manual { top: calc(var(--top) + var(--duel) + 2px); } #result .card.duel .sides p { margin: 0; } }
@media (prefers-reduced-motion: reduce) { .sheet-card.enter,.sheet-card .spin, .sheet-card .blink, #duel.bump { animation: none !important; } }
