/* まるこんカメラ。クリーム・きつね色・こげ茶。丸くて、少しゆがんだ手描きの線。 */
@font-face { font-family: "MaruYomogi"; src: url("fonts/yomogi-sub.woff2") format("woff2"); font-display: swap; }
:root {
  --cream: #fdf3de; --cream2: #fbe6c2; --fox: #fc761e; --fox2: #ffa257; --ink: #4e1d0c; --red: #d63a2c;
  --dock: 86px; --sab: env(safe-area-inset-bottom, 0px); --sat: env(safe-area-inset-top, 0px);
  --wob: 255px 18px 225px 18px / 18px 225px 18px 255px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--cream); color: var(--ink);
  font-family: "MaruYomogi", "Hiragino Maru Gothic ProN", "Yu Gothic", "Noto Sans JP", sans-serif; font-size: 16px; line-height: 1.5;
  overscroll-behavior: none; -webkit-user-select: none; user-select: none; touch-action: manipulation; }
[hidden] { display: none !important; }
button, input, a, label { font: inherit; color: inherit; }
button { cursor: pointer; }

#stage { position: fixed; inset: 0; overflow: hidden; touch-action: none;
  background: radial-gradient(120% 90% at 50% 35%, #fff8e8 0%, var(--cream) 55%, var(--cream2) 100%); }
#video, #bgimg, #freeze { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
#video.mirror, #freeze.mirror { transform: scaleX(-1); }
#gl { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

/* 吹き出し（頭の上に JS が置く） */
#bubble { position: absolute; left: 0; top: 0; max-width: min(230px, 62vw); padding: 9px 15px 10px; pointer-events: none;
  background: #fffaf0; border: 3px solid var(--ink); border-radius: 46% 54% 50% 50% / 58% 52% 48% 42%;
  font-size: 15.5px; line-height: 1.35; text-align: center; transform-origin: 50% 100%; will-change: transform; z-index: 2;
  filter: drop-shadow(0 3px 0 rgba(78, 29, 12, .25)); }
#bubble p { margin: 0; word-break: break-all; overflow-wrap: anywhere; }
#bubble i { position: absolute; left: var(--tail, 50%); bottom: -13px; width: 18px; height: 18px; margin-left: -9px; background: #fffaf0;
  border-right: 3px solid var(--ink); border-bottom: 3px solid var(--ink); border-radius: 0 0 9px 0; transform: rotate(48deg) skew(8deg, 8deg); }
#bubble.pop { animation: pop .34s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes pop { from { scale: .3; opacity: 0; } to { scale: 1; opacity: 1; } }

/* 上の列 */
#top { position: fixed; left: 0; right: 0; top: 0; z-index: 5; display: flex; gap: 8px; align-items: center;
  padding: calc(8px + var(--sat)) 10px 0; pointer-events: none; }
#top > * { pointer-events: auto; }
.grow { flex: 1; }
.pill { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 14px; background: var(--cream);
  border: 2.5px solid var(--ink); border-radius: var(--wob); box-shadow: 0 3px 0 var(--ink); font-size: 14px; white-space: nowrap;
  transition: transform .08s, box-shadow .08s; cursor: pointer; }
.pill b { display: inline-block; min-width: 24px; padding: 0 6px; text-align: center; background: var(--fox); color: #fff; border-radius: 12px; font-size: 13px; }
.pill:active, .chip:active, .big:active, .dockbtn:active { transform: translateY(3px) rotate(-1.5deg); box-shadow: 0 0 0 var(--ink); }

#loading { position: fixed; left: 50%; top: 42%; transform: translate(-50%, -50%); z-index: 3; padding: 12px 18px; background: var(--cream);
  border: 2.5px solid var(--ink); border-radius: var(--wob); font-size: 15px; white-space: nowrap; animation: sway 1.6s ease-in-out infinite; }
@keyframes sway { 0%, 100% { rotate: -1.5deg; } 50% { rotate: 1.5deg; } }

/* 下の列 */
#dock { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; height: calc(var(--dock) + var(--sab)); padding: 6px 6px calc(6px + var(--sab)) 0;
  display: grid; grid-template-columns: minmax(0, 1fr) 84px; align-items: center; justify-items: center;
  background: linear-gradient(to top, rgba(253, 243, 222, .96) 55%, rgba(253, 243, 222, 0)); }
/* 道具は横に流せる列（右はしが切れて見えるので、まだあると分かる）。シャッターは親指の所に固定 */
#tabs { display: flex; gap: 6px; width: 100%; overflow-x: auto; padding: 4px 14px 8px 8px; scrollbar-width: none; scroll-snap-type: x proximity;
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 22px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 22px), transparent); }
#tabs::-webkit-scrollbar { display: none; }
#tabs .dockbtn { flex: 0 0 66px; scroll-snap-align: start; }
.dockbtn { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; width: 100%; max-width: 78px; height: 62px;
  background: var(--cream); border: 2.5px solid var(--ink); border-radius: var(--wob); box-shadow: 0 3px 0 var(--ink); font-size: 11.5px;
  white-space: nowrap; transition: transform .08s, box-shadow .08s; padding: 0; }
.dockbtn:nth-child(even) { border-radius: 18px 225px 18px 255px / 255px 18px 225px 18px; }
.dockbtn svg { width: 27px; height: 27px; fill: none; stroke: var(--ink); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.dockbtn svg .fill { fill: var(--fox); }
.dockbtn.on { background: var(--fox2); }
#btnShot { width: 74px; height: 74px; border-radius: 50%; background: var(--cream); border: 3.5px solid var(--ink); box-shadow: 0 4px 0 var(--ink);
  display: grid; place-items: center; padding: 0; transition: transform .08s, box-shadow .08s; }
#btnShot i { width: 54px; height: 54px; border-radius: 47% 53% 50% 50% / 52% 48% 52% 48%; background: var(--fox); border: 3px solid var(--ink); }
#btnShot:active { transform: translateY(4px) scale(.96); box-shadow: 0 0 0 var(--ink); }
#btnShot:disabled { opacity: .5; }

/* 下から出る板 */
.sheet { position: fixed; left: 8px; right: 8px; bottom: calc(var(--dock) + var(--sab) + 4px); z-index: 5; padding: 8px 10px 10px;
  max-height: calc(100vh - var(--dock) - var(--sab) - 70px); max-height: calc(100dvh - var(--dock) - var(--sab) - 70px); overflow-y: auto; background: rgba(253, 243, 222, .97);
  border: 2.5px solid var(--ink); border-radius: 22px 26px 20px 28px / 26px 20px 28px 22px; box-shadow: 0 4px 0 var(--ink);
  animation: rise .22s cubic-bezier(.3, 1.4, .5, 1); }
@keyframes rise { from { translate: 0 30px; opacity: 0; } to { translate: 0 0; opacity: 1; } }
.sheethead { display: flex; align-items: center; gap: 8px; min-height: 40px; margin-bottom: 2px; }
.sheet h2, .card h2 { margin: 0; font-size: 17px; }
.wearrow { display: flex; align-items: center; gap: 6px; height: 46px; }
.wearrow > b { flex: 0 0 62px; font-size: 13px; font-weight: normal; text-align: center; background: var(--cream2); border-radius: 12px; padding: 3px 0; }
.wearrow > div { display: flex; gap: 7px; overflow-x: auto; padding: 4px 2px 7px; scrollbar-width: none; flex: 1; }
.wearrow > div::-webkit-scrollbar { display: none; }
.chip { flex: 0 0 auto; min-height: 36px; padding: 0 12px; background: #fffaf0; border: 2.2px solid var(--ink); border-radius: var(--wob);
  box-shadow: 0 2.5px 0 var(--ink); font-size: 13.5px; white-space: nowrap; transition: transform .08s, box-shadow .08s, background .15s; }
.chip.on { background: var(--fox); color: #fff; animation: boing .3s; }
.chip.strong { background: var(--fox2); }
.chip.locked { opacity: .55; border-style: dashed; box-shadow: none; }
.chip.new { animation: boing .5s 3; }
@keyframes boing { 0% { scale: 1; } 40% { scale: 1.14 .9; } 70% { scale: .95 1.06; } 100% { scale: 1; } }
.wrap { display: flex; flex-wrap: wrap; gap: 8px; padding: 4px 0; }
.wrap .chip { min-height: 44px; padding: 0 15px; font-size: 15px; }
.toggle { display: flex; align-items: center; gap: 10px; min-height: 46px; font-size: 15px; }
.toggle input { width: 26px; height: 26px; accent-color: var(--fox); }
.small { font-size: 12.5px; margin: 6px 0; opacity: .9; }
.warn { color: var(--red); }

/* はじめの札・重ねて出す札 */
.card { background: var(--cream); border: 3px solid var(--ink); border-radius: 26px 30px 24px 32px / 30px 24px 32px 26px; box-shadow: 0 5px 0 var(--ink); padding: 16px 18px; }
#start { position: fixed; left: 50%; bottom: calc(var(--sab) + 18px); transform: translateX(-50%); z-index: 8; width: min(92vw, 380px); text-align: center; }
#start { max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px); overflow-y: auto; }
#start h1 { margin: 0 0 2px; font-size: 22px; }
#start p { margin: 4px 0 10px; }
.big { display: flex; align-items: center; justify-content: center; width: 100%; min-height: 52px; margin: 8px 0; padding: 0 16px; background: var(--fox); color: #fff;
  border: 2.5px solid var(--ink); border-radius: var(--wob); box-shadow: 0 4px 0 var(--ink); font-size: 17px; text-decoration: none; cursor: pointer;
  transition: transform .08s, box-shadow .08s; }
.big.sub { background: #fffaf0; color: var(--ink); }
.big.danger { background: #fffaf0; color: var(--red); border-color: var(--red); box-shadow: 0 4px 0 var(--red); font-size: 13.5px; padding: 0 8px; white-space: nowrap; }
.row { display: flex; gap: 10px; align-items: center; }
.row > * { flex: 1; }
.modal { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 14px; background: rgba(78, 29, 12, .45); overflow-y: auto; }
.modal .card { width: min(100%, 420px); max-height: calc(100vh - 28px); max-height: calc(100dvh - 28px); overflow-y: auto; animation: rise .22s cubic-bezier(.3, 1.4, .5, 1); -webkit-user-select: text; user-select: text; }
.modal p { margin: 6px 0; font-size: 14.5px; }
.modal h3 { margin: 12px 0 4px; font-size: 14.5px; }
#shotImg { display: block; max-width: 100%; max-height: 46dvh; margin: 8px auto; border: 2.5px solid var(--ink); border-radius: 12px; background: #fff; -webkit-touch-callout: default; }
#formWord input { flex: 2.2; min-width: 0; min-height: 52px; padding: 0 12px; background: #fff; border: 2.5px solid var(--ink); border-radius: 14px; font-size: 16px; -webkit-user-select: text; user-select: text; }
.list { list-style: none; margin: 4px 0; padding: 0; max-height: 32dvh; overflow-y: auto; }
.list li { display: flex; align-items: center; gap: 8px; padding: 6px 2px; border-bottom: 2px dashed rgba(78, 29, 12, .25); font-size: 14px; }
.list li span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.list li small { display: block; opacity: .75; font-size: 12px; }
.list li .chip { min-height: 40px; }
.list .empty { opacity: .7; border: 0; }

#toast { position: fixed; left: 50%; top: calc(62px + var(--sat)); transform: translateX(-50%); z-index: 30; max-width: 88vw; padding: 9px 16px; background: var(--ink); color: #fff8e8;
  border-radius: 20px; font-size: 14px; text-align: center; animation: rise .25s; pointer-events: none; }

/* 横長・PC: 板は右に寄せ、まるこんの場所をあける */
.sheet { max-height: 47vh; max-height: 47dvh; }   /* 縦長: まるこんの場所を残す。main.js の homePose と合わせる */
@media (min-width: 760px), (orientation: landscape) and (min-width: 560px) {
  .sheet { left: auto; right: 12px; width: min(400px, 48vw); max-height: calc(100vh - var(--dock) - 80px); max-height: calc(100dvh - var(--dock) - var(--sab) - 80px); }
  #dock { left: auto; right: 12px; width: min(400px, 48vw); background: none; padding-left: 0; }
  #start { left: auto; right: 12px; transform: none; bottom: calc(var(--sab) + 12px); width: min(400px, 48vw); }
}
@media (max-height: 520px) {
  #start { padding: 8px 14px; } #start .big { min-height: 44px; margin: 5px 0; } #start h1 { font-size: 18px; } #start p { margin: 2px 0 4px; }
  :root { --dock: 74px; }
  .dockbtn { height: 54px; }
  #btnShot { width: 62px; height: 62px; } #btnShot i { width: 44px; height: 44px; }
  .wearrow { height: 44px; }
  .pill { min-height: 40px; }
}
@media (max-width: 420px) { .pill { padding: 0 11px; font-size: 13px; } #top { gap: 6px; padding-left: 8px; padding-right: 8px; } }
@media (max-width: 359px) { .dockbtn { font-size: 10px; } .pill { padding: 0 8px; font-size: 12px; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
.saying { padding: 8px 12px; background: #fffaf0; border: 2.2px solid var(--ink); border-radius: var(--wob); }
#btnLater { margin: 2px 0 6px; min-height: 40px; }

/* スライダー（うごかす・ひかり） */
.slider { display: grid; grid-template-columns: 68px minmax(0, 1fr) 84px; align-items: center; gap: 6px; height: 44px; font-size: 13px; }
.slider span { text-align: center; background: var(--cream2); border-radius: 12px; padding: 3px 0; }
.slider b { font-weight: normal; font-size: 12px; text-align: right; white-space: nowrap; }
.slider input { width: 100%; height: 36px; margin: 0; accent-color: var(--fox); touch-action: pan-y; }
/* かくれる */
#hideView { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 1; }
#edgeUI { position: absolute; inset: 0; pointer-events: none; z-index: 3; }
.handle { position: absolute; left: 0; top: 0; width: 46px; height: 46px; border-radius: 50%; padding: 0; pointer-events: auto; touch-action: none;
  background: #fffaf0; border: 2.5px solid #1e78d2; color: #1e78d2; font-size: 22px; line-height: 1; box-shadow: 0 2px 0 rgba(30, 120, 210, .6); }
.handle.turn { width: 38px; height: 38px; font-size: 15px; }
.handle.sel { background: #dcedff; }
.toolrow { display: flex; align-items: center; gap: 7px; min-height: 46px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding: 2px 2px 5px; }
.toolrow::-webkit-scrollbar { display: none; }
.toolrow > b { flex: 0 0 52px; font-size: 13px; font-weight: normal; text-align: center; background: var(--cream2); border-radius: 12px; padding: 3px 0; }
.chip:disabled { opacity: .45; box-shadow: none; }
.chip.dot { width: 44px; padding: 0; display: grid; place-items: center; }
.chip.dot i { width: var(--d); height: var(--d); border-radius: 50%; background: var(--ink); }
.chip.dot.on i { background: #fff; }
#sheetHide .small { min-height: 2.6em; margin: 2px 0 0; }
