/* 机、帯、盆、重ね。版のまわりは board.css（ux の A） */
* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
:root { --paper: #f1e8d3; --ink: #33271c; --shu: #c63e27; --light: #fff6df; --serif: "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif JP", Georgia, serif; }
html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
body { background: #4a3322; color: #f6efdd; font-family: -apple-system, system-ui, "Hiragino Kaku Gothic ProN", sans-serif; -webkit-tap-highlight-color: transparent; }
button, .button { font: inherit; font-size: 14px; min-height: 44px; padding: 6px 12px; border: 0; border-radius: 7px; background: linear-gradient(170deg, #fbf5e6, #e8dcc0); color: var(--ink); box-shadow: 0 2px 0 #9d8a66, 0 3px 6px #0005; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
button:focus-visible, .button:focus-visible { outline: 3px solid #ffd978; outline-offset: 2px; }
button:disabled { opacity: .55; cursor: default; }
button.dim { opacity: .45; }

#desk { position: relative; isolation: isolate; height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
  background: radial-gradient(120% 90% at 20% 10%, #ffe9c41f, transparent 55%), repeating-linear-gradient(92deg, #5a3d28 0 37px, #51351f 37px 40px, #5f4130 40px 96px); }
#deskCanvas { position: absolute; inset: 0; width: 100%; height: 100%; z-index: -1; pointer-events: none; }

.top { height: 48px; flex: none; display: flex; align-items: center; justify-content: flex-end; gap: 7px; padding: 0 10px 0 0; }
.widget-space { width: 62px; margin-right: auto; flex: none; }
.top-btn { min-height: 36px; height: 36px; padding: 0 10px; font-size: 12.5px; background: #2a1b10b8; color: var(--light); box-shadow: inset 0 0 0 1px #ffffff30; position: relative; }
.top-btn::after { content: ''; position: absolute; inset: -5px -2px; }
.top-btn svg { width: 20px; height: 20px; flex: none; }
.top-btn.icon { width: 40px; padding: 0; }
.prints-tag { display: none; min-height: 36px; height: 36px; padding: 0 9px; font: 12px var(--serif); background: var(--paper); transform: rotate(-1.5deg); }
/* 0枚の時は数を書いた薄い字だけ（紙の札にしない）。押した時の一言は出る */
.prints-tag.zero { background: none; box-shadow: none; color: #f3e6c8; opacity: .65; transform: none; padding: 0 3px; cursor: default; text-shadow: 0 1px 3px #000a; }

/* 干し紐 */
.rack { height: 76px; flex: none; display: flex; align-items: flex-start; padding: 7px 14px 0; overflow-x: auto; overflow-y: hidden; overscroll-behavior: contain; scrollbar-width: none;
  background: repeating-linear-gradient(118deg, #0000 0 2.5px, #6e5028b0 2.5px 4px, #fff2cc55 4px 5px, #0000 5px 6px) 0 7px / 100% 4px no-repeat local, linear-gradient(#ecd9aa, #a3814b) 0 7px / 100% 4px no-repeat local, linear-gradient(#26150880, #0000) 0 12px / 100% 4px no-repeat local; }
.rack::-webkit-scrollbar { display: none; }
.rack > button { background: none; box-shadow: none; padding: 0; min-height: 0; border-radius: 1px; }
/* 紙が増えたら幅を詰めて少しずつ重ねる（390 で12枚まで全部見える。1枚の見える幅は約29px） */
.hung { position: relative; flex: 0 1 56px; min-width: 24px; height: 65px; padding-top: 3px !important; transform: rotate(var(--tilt, 0deg)); transform-origin: 50% 0; align-items: flex-start !important; justify-content: flex-start !important; }
.hung:last-child { flex: 0 0 42px; }
.hung canvas { flex: none; width: 42px; height: 62px; box-shadow: -1px 0 3px #0006, 2px 4px 6px #0007; }
.pin { display: block; width: 10px; height: 20px; border-radius: 2px 2px 3px 3px; background: linear-gradient(90deg, #f0cf97 0, #c9985a 42%, #5d3d1c 43% 57%, #e2b978 58%, #8c6233 100%); box-shadow: 1px 3px 3px #0007; position: relative; flex: none; }
.pin::after { content: ''; position: absolute; left: -1px; right: -1px; top: 7px; height: 3px; background: linear-gradient(#e3e6e6, #77797b); border-radius: 2px; }
.hung .pin { position: absolute; top: -5px; left: 17px; }
.sway { animation: sway .9s ease-out; }
@keyframes sway { 20% { transform: rotate(9deg); } 45% { transform: rotate(-6deg); } 70% { transform: rotate(3deg); } 100% { transform: rotate(var(--tilt, 0deg)); } }
.rack > .rack-empty { flex: 1; display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; color: #f3e6c8; opacity: .85; margin: -5px 12px 0; height: 64px; }
.rack-empty span { font: 12px/1.6 var(--serif); padding-top: 24px; text-shadow: 0 1px 3px #000a; word-break: keep-all; overflow-wrap: anywhere; }
.rack-empty .pin { margin-top: 0; }
.ghost { position: fixed; z-index: 9; transform-origin: 0 0; box-shadow: 0 8px 18px #0008; pointer-events: none; }

.stage-area { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; }
.stage { position: relative; flex: none; width: min(80vw, 38vh); aspect-ratio: 100 / 148; background: #6f9c94; border-radius: 6px; }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 6px; }
#blockCanvas { box-shadow: 2px 3px 0 #5c8078, 4px 6px 0 #cfc4a6, 9px 13px 18px #0008; }
#paperCanvas { box-shadow: 0 1px 6px #0005; border-radius: 1px; }
#sketchCanvas, #markCanvas, #toolCanvas { pointer-events: none; }
/* 色を替える時の版ふき: ふく前の絵を左から消し、布が走る（約0.4秒。版の絵と面は変えない） */
.stage canvas.wipe-ghost { pointer-events: none; box-shadow: none; }
/* 布: しわのある手ぬぐい。端は不ぞろい */
.wipe-cloth { position: absolute; top: 3%; height: 94%; width: 22%; margin-left: -11%; pointer-events: none; transform: rotate(5deg); filter: drop-shadow(7px 5px 8px #0008);
  background: repeating-linear-gradient(72deg, #0000 0 17px, #7a604033 23px, #fffaf040 28px, #0000 36px), repeating-linear-gradient(0deg, #0000 0 3px, #8a735426 3px 4px), repeating-linear-gradient(90deg, #0000 0 3px, #8a735426 3px 4px), linear-gradient(90deg, #bfae8c, #efe4cb 60%, #cbb993);
  clip-path: polygon(18% 2%, 52% 0, 88% 4%, 100% 17%, 90% 31%, 99% 48%, 92% 66%, 100% 83%, 84% 98%, 55% 95%, 24% 100%, 4% 88%, 15% 72%, 0 55%, 12% 38%, 2% 21%); }
.board, .corner, .stage canvas { touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.board { position: absolute; inset: 0; cursor: crosshair; }
.corner { position: absolute; right: 0; bottom: 0; width: 72px; height: 72px; min-height: 0; padding: 0 6px 6px 0; flex-direction: column; align-items: flex-end; justify-content: flex-end; gap: 0; font-size: 11px; background: linear-gradient(135deg, transparent 38%, #fffaf0 40%, #e4d8bc); border-radius: 60% 0 0 0; box-shadow: -3px -3px 8px #0003; cursor: grab; }

.mirror-row { flex: none; height: 22px; display: flex; align-items: center; justify-content: center; padding: 0 6px; }
.mirror { min-height: 20px; height: 20px; padding: 0 8px; gap: 5px; font: 700 11px var(--serif); border-radius: 3px; white-space: nowrap; box-shadow: 0 1px 4px #0006; position: relative; }
.mirror::after { content: ''; position: absolute; inset: -8px -4px; }
.mirror em, .mirror i { font-style: normal; }
.mirror i { font-size: 14px; color: var(--shu); }
/* 版（緑の版に逆向きの白い字）→ 刷り（墨の紙に読める白い字） */
.mirror b { display: block; height: 16px; padding: 0 5px; border-radius: 2px; font: 800 12.5px/16px system-ui, sans-serif; letter-spacing: .5px; }
.mirror b.on-block { background: #6f9c94; color: #fff6df; box-shadow: 1px 1px 0 #cfc4a6; }
.mirror b.on-block span { display: inline-block; transform: scaleX(-1); }
.mirror b.on-paper { background: #231f20; color: #f0e6cf; }
.hint { flex: none; height: 28px; line-height: 28px; font: 600 13.5px/28px var(--serif); text-align: center; white-space: nowrap; overflow: hidden; padding: 0 6px; text-shadow: 0 1px 3px #000c; }
.hint.long { white-space: pre-line; line-height: 1.15; font-size: 11.5px; display: flex; align-items: center; justify-content: center; word-break: keep-all; overflow-wrap: anywhere; }
.hint.pop { animation: pop .4s; }
@keyframes pop { 40% { transform: scale(1.05); color: #ffe39b; } }

/* 道具の盆 */
.tray { height: 70px; flex: none; display: flex; align-items: stretch; justify-content: center; gap: 6px; padding: 4px 8px; margin: 0 6px; border-radius: 10px; background: linear-gradient(#2c1c1099, #3c281799); box-shadow: inset 0 2px 5px #0008, 0 1px 0 #ffffff1f; }
.tray .tool { flex: 1 1 0; min-width: 0; max-width: 104px; flex-direction: column; gap: 1px; padding: 2px 3px; font-size: 11.5px; line-height: 1.15; text-align: center; }
.tray .tool svg { width: 100%; max-width: 54px; height: 38px; flex: none; }
.tray .blade { max-width: 128px; }
.tray .blade svg { max-width: 84px; height: 40px; }
.tray .undo, .tray .wipe { max-width: 78px; margin-left: 6px; background: linear-gradient(170deg, #e7dcc2, #d3c29c); }
.tray .undo svg { height: 30px; }
.tray button[aria-pressed="true"] { background: linear-gradient(170deg, #fffdf4, #fff0c9); box-shadow: 0 0 0 3px var(--shu), 0 3px 9px #0007; transform: translateY(-1px); font-weight: 700; }
.tray-paper .sheet { font-size: 10px; max-width: 58px; word-break: keep-all; }
.tray-paper .sheet svg { height: 34px; }
.tray .place { flex: 1.9 1 0; max-width: 150px; margin-left: 5px; background: linear-gradient(170deg, #e25a3f, #b93620); color: #fff; font: 700 15px var(--serif); box-shadow: 0 3px 0 #7c2314, 0 4px 9px #0006; padding: 4px 6px; }
.tray .remove { max-width: 120px; font-size: 13px; }
.tray-rub { align-items: center; gap: 14px; }
.tray-rub .tool { flex: 0 0 auto; max-width: 160px; padding: 8px 14px; white-space: nowrap; }
.tray-note { font: 12px/1.5 var(--serif); color: #f3e6c8; max-width: 200px; }

/* 手順の切り替え */
.steps { height: 56px; flex: none; display: flex; align-items: center; justify-content: center; gap: 4px; padding: 0 8px; }
.steps button { flex: 1 1 0; max-width: 130px; height: 42px; min-height: 42px; padding: 0 4px; font: 700 14px var(--serif); position: relative; white-space: nowrap; }
.steps button[aria-pressed="true"] { background: linear-gradient(#cdb98d, #e8d9b2); box-shadow: inset 0 3px 7px #0006, 0 0 12px #ffdf8c88; transform: translateY(2px); }
.steps button[aria-pressed="true"]::after { content: ''; position: absolute; left: 22%; right: 22%; bottom: 5px; height: 3px; border-radius: 2px; background: var(--shu); }
.steps i { font-style: normal; font-size: 18px; color: #f3e1b6; flex: none; }
.steps button.next, .tray .place.next, .actions button.next { position: relative; box-shadow: 0 0 0 3px #ffd36a, 0 0 8px #ffc443; }
.steps button.next::before, .tray .place.next::before, .actions button.next::before { content: ''; position: absolute; inset: -2px; border-radius: inherit; pointer-events: none; box-shadow: 0 0 0 4px #ffd36a, 0 0 20px 5px #ffc443; opacity: 0; animation: glow 1.5s ease-in-out infinite; will-change: opacity; }
@keyframes glow { 50% { opacity: 1; } }

#desk.peeling .tray, #desk.peeling .hint, #desk.peeling .steps { opacity: .35; transition: opacity .2s; }
.lift { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; pointer-events: none; z-index: 5; }

/* めくりの案内。こする邪魔にならないよう、引く前の道は細い破線だけ */
#stage .pull-trail { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 2; pointer-events: none; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.pull-trail path { vector-effect: non-scaling-stroke; }
.pull-trail .under { stroke: #2a170a; stroke-width: 5; stroke-dasharray: 8 8; opacity: .55; }
.pull-trail .over { stroke: #fffaf0; stroke-width: 2.5; stroke-dasharray: 8 8; }
#stage #corner[hidden] ~ .pull-trail, body.board-lifting #stage .pull-trail { display: none; }
.lift-guide { position: fixed; z-index: 6; pointer-events: none; }
/* 目当ての輪: 手前は白い破線。ここまで来たら（離すとめくれる）黄色に塗って印を出す */
.lift-guide .goal { position: absolute; left: 50%; top: 50%; width: 58px; height: 58px; margin: -29px 0 0 -29px; border-radius: 50%; border: 3px dashed #fffaf0; box-shadow: 0 0 0 2px #2a170a80, inset 0 0 0 2px #2a170a80; }
.lift-guide.ready .goal { border: 4px solid #2a170a; background: #ffd36a; box-shadow: 0 0 0 4px #ffd36a, 0 3px 12px #000a; display: grid; place-items: center; }
.lift-guide.ready .goal::after { content: '✓'; font: 700 30px/1 system-ui, sans-serif; font-style: normal; color: #2a170a; }
/* 一言の札。下の帯は確定までの長さ */
.lift-guide p { position: absolute; left: 50%; top: 10px; transform: translateX(-50%); width: max-content; max-width: calc(100% - 12px); padding: 7px 14px 11px; border-radius: 8px; font: 700 14px/1.35 var(--serif); text-align: center; color: #fffaf0; background: #2a170ae6; box-shadow: 0 4px 12px #0009; }
.lift-guide p::after { content: ''; position: absolute; left: 10px; bottom: 4px; height: 4px; width: calc((100% - 20px) * var(--pulled, 0)); border-radius: 2px; background: #ffd36a; }
.lift-guide.ready p { color: #2a170a; background: #ffd36a; }
.lift-guide.ready p::after { background: #2a170a; }

/* 重ね */
.result { position: fixed; inset: 0; z-index: 10; background: radial-gradient(110% 80% at 30% 15%, #34241a, #140c07 75%); display: flex; flex-direction: column; align-items: center; justify-content: safe center; gap: 10px; padding: calc(52px + env(safe-area-inset-top, 0px)) 12px calc(14px + env(safe-area-inset-bottom, 0px)); overflow-y: auto; }
/* 縦のスマホは左右の余白を詰めて、版と刷りを大きく見せる */
#result { padding-left: 8px; padding-right: 8px; overflow-x: hidden; }
.close { width: 44px; height: 44px; padding: 0; font-size: 24px; line-height: 1; border-radius: 50%; flex: none; }
.result > .close { position: absolute; top: calc(6px + env(safe-area-inset-top, 0px)); right: 10px; }
.pair { display: flex; align-items: flex-end; justify-content: center; position: relative; margin-bottom: 8px; }
.pair figure { text-align: center; position: relative; }
.pair canvas { display: block; aspect-ratio: 100 / 148; height: auto; }
.pair figure.block canvas { width: min(44vw, 31vh, 340px); border-radius: 5px; box-shadow: 2px 3px 0 #5c8078, 4px 6px 0 #cfc4a6, 8px 12px 18px #000a; }
.pair figure.paper { z-index: 1; margin-bottom: 0; }
.pair figure.paper button { background: none; box-shadow: none; padding: 0; border-radius: 1px; min-height: 0; display: block; transform: rotate(1.2deg); }
.pair figure.paper canvas { width: min(50vw, 36vh, 390px); box-shadow: 3px 5px 5px #0008, 10px 20px 34px #000c; }
.pair .frame, .pair figure.paper button { position: relative; display: block; }
/* 対応の合図は2枚の外の枠だけを光らせる。版と紙の上に色を重ねない（汚れに見えないように） */
.pair .sweep { position: absolute; inset: -6px; border: 4px solid #ffd97a; border-radius: 7px; box-shadow: 0 0 18px 5px #ffc443cc; pointer-events: none; opacity: 0; }
.pair.glint .sweep { animation: show 2.2s ease-in-out; }
@keyframes show { 12%, 34% { opacity: 1; } 52% { opacity: .15; } 68%, 86% { opacity: 1; } }
/* 版の絵だけを裏返す（刷りと同じ向きになる）。紙と刷りは動かさない */
.pair figure.block .frame { cursor: pointer; perspective: 900px; }
#resultBlock { transition: transform .6s cubic-bezier(.45,.05,.25,1); }
.pair.flipped #resultBlock { transform: rotateY(180deg); }
.result.empty .pair figure.block .frame { cursor: default; }

.pair figcaption { position: relative; z-index: 1; display: inline-block; margin-top: 11px; padding: 2px 14px; font: 700 12.5px var(--serif); background: var(--paper); color: var(--ink); border-radius: 2px; box-shadow: 0 2px 4px #0007; }
/* 見出しの段に置いて、版と刷りの絵に重ねない。押せる物の厚み（下の影）を付ける */
.pair .flip-mark { align-self: flex-end; z-index: 2; margin: 0 -17px; width: 42px; height: 42px; min-height: 42px; padding: 0; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--shu); color: #fff; font-size: 22px; box-shadow: 0 3px 0 #7c2314, 0 4px 9px #000a; transform: translateY(11px); }
.pair .flip-mark:active { transform: translateY(13px); box-shadow: 0 1px 0 #7c2314, 0 2px 5px #000a; }
.pair.flipped .flip-mark { background: #fff6df; color: var(--shu); box-shadow: 0 0 0 3px var(--shu), 0 4px 9px #000a; }
.pair.glint .flip-mark { animation: nudge .55s ease-in-out 4; }
@keyframes nudge { 50% { scale: 1.2; } }
.result.empty .flip-mark, .result.empty .result-sub { visibility: hidden; }
.result-text { font: 700 15.5px/1.5 var(--serif); text-align: center; max-width: 34em; text-wrap: balance; }
.result-sub { font: 12.5px/1.5 var(--serif); color: #dccdac; text-align: center; max-width: 34em; }
.result-sub:empty { display: none; }
.actions { display: flex; flex-direction: column; align-items: center; gap: 9px; width: min(100%, 360px); flex: none; }
.actions .row { display: flex; gap: 10px; width: 100%; }
.actions .row button { flex: 1; }
.actions > button, .actions > .button { width: 100%; }
.actions .main { background: linear-gradient(170deg, #e25a3f, #b93620); color: #fff; font: 700 17px var(--serif); min-height: 50px; box-shadow: 0 3px 0 #7c2314, 0 4px 10px #0007; }
.actions button.quiet { background: none; box-shadow: none; color: #dccdac; text-decoration: underline; width: auto; font-size: 13px; }

.viewer { z-index: 12; gap: 8px; }
.viewer-count { position: absolute; top: calc(18px + env(safe-area-inset-top, 0px)); left: 0; right: 0; text-align: center; font: 13px var(--serif); }
.viewer .close { z-index: 1; }
.viewer-stage { display: flex; align-items: center; gap: 6px; flex: none; }
.viewer-stage canvas { width: min(calc(100vw - 116px), 36vh, 480px); aspect-ratio: 100 / 148; box-shadow: 4px 10px 26px #000c; }
.arrow { width: 44px; height: 64px; padding: 0; font-size: 28px; }

.image-view { z-index: 14; }
.saved { max-width: 80vw; max-height: 56vh; box-shadow: 3px 8px 24px #000b; -webkit-touch-callout: default !important; user-select: auto !important; -webkit-user-select: auto !important; }
.image-view p { font: 700 14px var(--serif); text-align: center; }
.image-view p.result-sub { font-weight: 400; }

/* 下絵の紙束 */
.drawer { position: fixed; inset: 0; z-index: 11; background: #100a06b8; display: flex; align-items: flex-end; justify-content: center; }
.drawer-sheet { width: min(560px, 100%); max-height: calc(100% - 52px); overflow-y: auto; overscroll-behavior: contain; padding: 10px 14px calc(16px + env(safe-area-inset-bottom, 0px)); border-radius: 16px 16px 0 0; background: linear-gradient(175deg, #8a6a47, #5b412a); box-shadow: 0 -6px 24px #000a; animation: rise .28s ease-out; }
@keyframes rise { from { transform: translateY(40%); opacity: .4; } }
.drawer header { display: flex; align-items: center; justify-content: space-between; }
.drawer h2 { font: 700 18px var(--serif); }
.drawer-sheet > p { font: 12.5px/1.5 var(--serif); margin: 2px 0 10px; color: #fbeed0; }
.designs-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.design { flex-direction: column; gap: 3px; padding: 5px 5px 6px; font: 11.5px/1.3 var(--serif); border-radius: 3px; text-align: center; justify-content: flex-start; }
.design canvas { width: 100%; max-width: 108px; aspect-ratio: 100 / 148; background: #f0e6cf; box-shadow: 0 1px 4px #0005; }
.design[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--shu), 0 4px 9px #0007; }
.ask { position: fixed; inset: 0; z-index: 16; background: #100a06b0; display: grid; place-items: center; padding: 20px; }
.ask-card { width: min(320px, 100%); padding: 20px 18px 18px; border-radius: 6px; background: var(--paper); color: var(--ink); box-shadow: 0 12px 34px #000b; display: flex; flex-direction: column; align-items: center; gap: 16px; }
.ask-card p { font: 700 15px/1.7 var(--serif); text-align: center; text-wrap: balance; white-space: pre-line; word-break: keep-all; overflow-wrap: anywhere; }

/* 縦に長いスマホの刷り上がり: 版を左上、刷りを右下に段違いで置き、上下の余白まで使って大きく見せる。
   2枚は上下に重ならない。見出しと ⇄ は、それぞれの横の空いた所に置く */
@media (orientation: portrait) and (min-height: 760px) and (max-width: 560px) {
  #result .pair { display: grid; grid-template-columns: 100%; row-gap: 14px; width: 100%; max-width: 440px; margin-bottom: 4px; }
  #result .pair figure.block { grid-area: 1 / 1; justify-self: start; margin-left: 6px; }
  #result .pair figure.paper { grid-area: 2 / 1; justify-self: end; margin-right: 8px; }
  #result .pair figure.block canvas { width: min(48vw, 21.6vh, 230px); }
  #result .pair figure.paper canvas { width: min(57vw, 25.6vh, 270px); }
  /* 一言が2つ出る時は少し小さくして、下のボタンまで一度に見せる */
  #result:has(#resultSub:not(:empty)) .pair { row-gap: 8px; }
  #result:has(#resultSub:not(:empty)) .pair figure.block canvas { width: min(48vw, 19.6vh, 230px); }
  #result:has(#resultSub:not(:empty)) .pair figure.paper canvas { width: min(57vw, 23.2vh, 270px); }
  #result .pair figcaption { position: absolute; margin: 0; white-space: nowrap; font-size: 14px; padding: 3px 18px; }
  #result .pair figure.block figcaption { left: calc(100% + 22px); bottom: 14px; }
  #result .pair figure.paper figcaption { right: calc(100% + 22px); top: 22px; }
  #result .pair .flip-mark { grid-area: 2 / 1; justify-self: start; align-self: center; margin: 0 0 0 52px; width: 54px; height: 54px; min-height: 54px; font-size: 28px; transform: none; }
  #result .pair .flip-mark:active { transform: translateY(2px); }
}
/* 低い画面（360×640 など）: 干し紐は上の帯の小札にする */
@media (max-height: 720px) and (max-width: 899px) {
  .top { height: 44px; gap: 5px; padding-right: 6px; } .rack { display: none; } .prints-tag { display: inline-flex; }
  .top-btn { padding: 0 8px; font-size: 12px; }
  .mirror-row { height: 19px; } .mirror { height: 18px; min-height: 18px; font-size: 10.5px; } .mirror b { height: 15px; line-height: 15px; font-size: 11.5px; }
  .hint { height: 23px; line-height: 23px; font-size: 12.5px; }
  .tray { height: 60px; padding: 3px 6px; } .tray .tool { font-size: 10.5px; } .tray .tool svg { height: 31px; } .tray .blade svg { height: 33px; } .tray .undo svg { height: 26px; }
  .tray-paper .sheet { font-size: 9.5px; } .tray-paper .sheet svg { height: 28px; }
  .steps { height: 48px; } .steps button { height: 38px; min-height: 38px; font-size: 13px; }
  .result { gap: 7px; } .result-text { font-size: 14px; } .actions { gap: 7px; } .actions .main { min-height: 46px; }
  .viewer-stage canvas { width: min(calc(100vw - 116px), 33vh); }
}
@media (max-width: 370px) { .top-btn svg { width: 17px; height: 17px; } #designsBtn svg { display: none; } }

/* PC: 左に道具、中央に版、右に刷った紙 */
@media (min-width: 900px) and (min-height: 560px) {
  #desk { display: grid; grid-template-columns: minmax(230px, 1fr) minmax(0, 560px) minmax(230px, 1fr); grid-template-rows: 52px minmax(0, 1fr) 26px 30px 64px; grid-template-areas: "top top top" "tray stage rack" "tray mirror rack" "tray hint rack" "tray steps rack"; }
  .top { grid-area: top; height: auto; padding-right: 18px; } .stage-area { grid-area: stage; } .mirror-row { grid-area: mirror; height: auto; } .hint { grid-area: hint; font-size: 15px; } .steps { grid-area: steps; height: auto; }
  .mirror { font-size: 12px; height: 22px; } .mirror b { height: 18px; line-height: 18px; font-size: 14px; }
  /* 紙が8枚を超えたら3列にして、12枚が下で切れないようにする */
  .rack:has(> :nth-child(9)) { grid-template-columns: repeat(3, minmax(0, 1fr)); width: min(300px, calc(100% - 20px)); margin-left: 10px; gap: 14px 8px; padding-left: 6px; padding-right: 6px; }
  .rack:has(> :nth-child(9)) .hung { width: 100%; max-width: 84px; height: auto; flex-direction: column; }
  .rack:has(> :nth-child(9)) .hung canvas { width: calc(100% - 6px); height: auto; aspect-ratio: 100 / 148; }
  .rack:has(> :nth-child(9)) .hung .pin { left: calc(50% - 5px); }
  .tray { grid-area: tray; align-self: center; justify-self: end; height: auto; width: 214px; flex-direction: column; align-items: center; gap: 12px; margin: 0 24px 0 0; padding: 18px 16px; }
  .tray .tool { flex: none; width: 100%; max-width: none; min-height: 72px; font-size: 13px; margin: 0; }
  .tray .tool svg { height: 44px; max-width: 80px; } .tray .blade svg { max-width: 110px; height: 50px; }
  .tray-ink, .tray-paper { display: grid; grid-template-columns: 1fr 1fr; }
  .tray-ink .wipe, .tray-paper .place { grid-column: 1 / -1; }
  .tray-paper .sheet { max-width: none; font-size: 11.5px; }
  .tray .place { flex: none; width: 100%; max-width: none; min-height: 58px; margin: 0; font-size: 17px; }
  .tray-rub .tool { min-height: 48px; } .tray-note { text-align: center; }
  .rack { grid-area: rack; align-self: center; justify-self: start; height: auto; max-height: 100%; width: 226px; margin-left: 20px; display: grid; grid-template-columns: 1fr 1fr; justify-items: center; gap: 18px 12px; padding: 12px 10px; overflow-y: auto; overflow-x: hidden; background: none; }
  .hung { width: 88px; height: 134px; background: linear-gradient(#0000 2px, #d9c08a 3px, #a5844f 5px, #0000 6px) !important; }
  .hung canvas { width: 82px; height: 121px; margin: 5px auto 0; }
  .hung .pin { left: 40px; top: -3px; }
  .rack > .rack-empty { grid-column: 1 / -1; width: 100%; height: auto; flex-wrap: wrap; justify-content: space-around; margin: 0; padding-top: 6px; }
  .rack-empty span { order: 3; width: 100%; padding-top: 12px; text-align: center; font-size: 13px; }
  .rack > .rack-empty { background: linear-gradient(#0000 6px, #d9c08a 7px, #a5844f 9px, #0000 10px) !important; }
  .pair figure.block canvas { width: min(34vw, 40vh, 340px); } .pair figure.paper canvas { width: min(38vw, 45vh, 390px); }
  .pair .flip-mark { width: 44px; height: 44px; margin: 0 4px 0 22px; }
  .pair figure.paper { margin-left: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  .sway, .hint.pop, .drawer-sheet { animation: none; }
  .steps button.next::before, .tray .place.next::before, .actions button.next::before { animation: none; }
  /* 裏返しは動かさず、絵だけ替えて戻す。ボタンの弾みも止める */
  #resultBlock { transition: none; }
  .pair.glint .flip-mark { animation: none; }
}
/* 低い縦の画面: 下絵は4列にして、白紙まで一度に見せる */
@media (max-height: 720px) and (max-width: 560px) {
  .drawer-sheet { max-height: calc(100% - 44px); padding-left: 10px; padding-right: 10px; }
  .drawer-sheet > p { margin-bottom: 8px; }
  .designs-grid { grid-template-columns: repeat(4, 1fr); gap: 8px; }
  .design { padding: 4px 4px 5px; font-size: 10.5px; }
}
/* 横向きのスマホ: 版を左に大きく、道具を右に */
@media (orientation: landscape) and (max-height: 559px) {
  #desk { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr); grid-template-rows: 44px 22px minmax(24px, auto) minmax(0, 1fr) 48px; grid-template-areas: "stage top" "stage mirror" "stage hint" "stage tray" "stage steps"; column-gap: 4px; }
  .top { grid-area: top; padding-right: 6px; } .widget-space { display: none; }
  /* 左上の「作った話と感想」の吹き出し（x 8〜38px）に版の角が重ならないよう、版を右へ寄せる */
  .stage-area { grid-area: stage; padding-left: 44px; }
  .drawer-sheet { width: min(640px, 100%); } .designs-grid { grid-template-columns: repeat(7, 1fr); gap: 7px; } .design { padding: 4px 3px 5px; font-size: 10px; }
.mirror-row { grid-area: mirror; height: auto; } .hint { grid-area: hint; }
  .tray { grid-area: tray; align-self: center; height: auto; max-height: 76px; min-height: 60px; } .steps { grid-area: steps; height: auto; } .rack { display: none; } .prints-tag { display: inline-flex; }
  .result { justify-content: safe center; padding-top: 8px; gap: 5px; }
  .pair figure.block canvas { width: min(24vw, 30vh); } .pair figure.paper canvas { width: min(27vw, 34vh); }
  .actions { flex-direction: row; width: min(100%, 640px); } .actions > button, .actions > .button { flex: 1; width: auto; } .actions .row { flex: 2; }
  .viewer-stage canvas { width: min(30vw, 36vh); } .saved { max-height: 50vh; }
}
