/* 紙と黒線。影とグラデーションは使わない。色は赤ペン（○×）と揺れの黄だけ。 */
:root {
  --ink: #18181a;
  --dim: #85827a;
  --paper: #f4f3ef;
  --sheet: #fbfaf7;
  --card: #fff;
  --soft: #d9d6cd;
  --red: #c8352a;
  --yel: #e9b500;
  --cw: 22px; /* 字の1マス。シールが貼れる行はぜんぶ同じ大きさ */
  /* 目隠しシールの形（.stk と同じ：白・黒線・右上の角がめくれる）。□・アイコン・OGP もこの形 */
  --hole: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 18'%3E%3Cpath d='M1 1H17L23 7V17H1Z' fill='%23fff'/%3E%3Cpath d='M17 1H1V17H23V7H17V1L23 7' fill='none' stroke='%2318181a' stroke-width='1.6' stroke-linejoin='round'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; height: 100%; background: var(--paper); touch-action: manipulation; }

body {
  color: var(--ink);
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Noto Sans CJK JP", "Yu Gothic", system-ui, sans-serif;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}

button { font-family: inherit; color: inherit; touch-action: manipulation; -webkit-touch-callout: none; }

#app {
  position: relative;
  height: var(--app-h, 100dvh);
  transform: translateY(var(--app-top, 0px));
  max-width: 440px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top);
  overflow: hidden;
}
@media (min-width: 520px) { #app { border-left: 1px solid var(--soft); border-right: 1px solid var(--soft); } }

/* --- 字の行（シールが吸い付く格子） --- */
.ln { margin: 0; white-space: nowrap; line-height: 1; }
.ln .c {
  display: inline-block; width: var(--cw); height: calc(var(--cw) * 1.3); line-height: calc(var(--cw) * 1.3);
  text-align: center; font-size: calc(var(--cw) * .86); vertical-align: top;
}
/* □ は目隠しシールと同じ形（角のめくれ）で描く。字の格子の1字のまま */
.ln .c.cmp { outline: 2px solid var(--ink); outline-offset: -2px; background: var(--card); }
.ln .c.cmp.ne { color: var(--red); outline-color: var(--red); }
.ln .c.cmp.yel { outline-color: var(--yel); background: #fff6d6; }
/* □ は目隠しシールと同じ形（角のめくれ）で描く。字の格子の1字のまま（下の字は「□」） */
.ln .c.hole, .ln .c.cmp.hole { color: transparent; background-image: var(--hole); background-position: center; background-size: 74% auto; background-repeat: no-repeat; }

/* --- 帯 --- */
.band { flex: 0 0 auto; padding: 6px 14px 8px; border-bottom: 1.5px solid var(--ink); }
.r { display: flex; align-items: center; gap: 10px; }
.title { font-weight: 700; }
.title .c { font-size: calc(var(--cw) * .95); }
.dots { display: flex; gap: 6px; margin-right: auto; }
.dots i { width: 11px; height: 11px; border-radius: 50%; border: 1.5px solid var(--ink); }
.dots i.on { background: var(--ink); }
.tools { display: flex; gap: 6px; }
.tool {
  font-size: 12px; height: 26px; padding: 0 8px; border: 1.5px solid var(--ink); border-radius: 3px;
  background: var(--card); cursor: pointer; position: relative;
}
.tool:active { transform: translateY(1px); }
.tool.snd { width: 28px; padding: 0; line-height: 1; }
.tool.snd.off::after { content: ""; position: absolute; left: 4px; right: 4px; top: 50%; border-top: 1.5px solid var(--ink); transform: rotate(-40deg); }
.rule { margin-top: 4px; }
.rule .c { font-size: calc(var(--cw) * .74); }

/* --- 本編 --- */
#main { flex: 1 1 auto; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; }
.play { padding: 12px 14px 8px; display: flex; flex-direction: column; gap: 10px; }
.paper {
  position: relative; background: var(--sheet); border: 1.5px solid var(--ink); padding: 10px 12px 14px;
  transition: transform .35s ease, opacity .35s ease;
}
.paper.out { transform: translateX(-110%) rotate(-4deg); opacity: 0; }
.paper.in0 { transform: translateX(30%); opacity: 0; transition: none; }
.head { margin-bottom: 8px; }
.head .c { font-size: calc(var(--cw) * .66); color: var(--dim); }
.text .ln { margin: 6px 0; }
.mark { position: absolute; right: 6px; top: 4px; width: 64px; height: 64px; pointer-events: none; }
.mark circle { fill: none; stroke: var(--red); stroke-width: 6; stroke-linecap: round; stroke-dasharray: 290; stroke-dashoffset: 290; transform: rotate(-80deg); transform-origin: 50% 50%; }
.mark.on circle { animation: draw .45s ease-out forwards; }
.mark.done circle { stroke-dashoffset: 0; }
@keyframes draw { to { stroke-dashoffset: 0; } }

.arow { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.ans { display: flex; align-items: center; gap: 10px; }
.genre .gl { font-size: 11px; color: var(--dim); margin-right: 6px; padding-right: 6px; border-right: 1px solid var(--soft); }
.genre .gt { display: inline-block; }
.genre { display: inline-flex; align-items: center; font-size: 14px; border: 1.5px solid var(--ink); border-radius: 3px; padding: 4px 8px; background: var(--card); white-space: nowrap; }
.genre.wob { animation: wob .5s; border-color: var(--yel); background: #fff6d6; }
.cells { position: relative; display: inline-flex; cursor: text; }
.boxes { display: inline-flex; gap: 4px; pointer-events: none; }
.boxes.wob { animation: wob .45s; }
.box { position: relative; width: 40px; height: 40px; border: 1.5px solid var(--ink); background: var(--card); display: inline-flex; align-items: center; justify-content: center; font-size: 22px; }
.box.eq { outline: 2px solid var(--ink); }
.box.ne { color: var(--red); border-color: var(--red); animation: wob .4s; }
.box.yel { border-color: var(--yel); background: #fff6d6; }
.box.blink { animation: blink .7s steps(1); }
.box.cur:empty::after { content: ""; position: absolute; left: 50%; top: 9px; bottom: 9px; border-left: 1.5px solid var(--dim); }
.cells.focus .box.cur { border-width: 2.5px; }
#in {
  position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; font-size: 16px; border: 0; padding: 0;
  -webkit-user-select: text; user-select: text;
}
.clr {
  height: 40px; padding: 0 9px; font-size: 13px; border: 1.5px solid var(--ink); border-radius: 3px; background: var(--card); cursor: pointer;
}
.clr:active { transform: translateY(1px); }
.xmark { position: absolute; left: 50%; top: 50%; width: 44px; height: 44px; margin: -22px 0 0 -22px; opacity: 0; pointer-events: none; transition: opacity .25s; }
.xmark path { fill: none; stroke: var(--red); stroke-width: 4.5; stroke-linecap: round; }
.xmark.on { opacity: 1; }
.genre.blink, .arow.blink .box { animation: blink .7s steps(1); }

.check {
  height: 48px; font-size: 16px; font-weight: 700; border: 2px solid var(--ink); border-radius: 4px; background: var(--card); cursor: pointer;
}
.check:active { transform: translateY(2px); }

@keyframes wob { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-4px); } 40% { transform: translateX(4px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(3px); } }
@keyframes blink { 0%, 50% { background: var(--soft); } 25%, 75% { background: var(--card); } }

/* --- シール --- */
.stk {
  position: absolute; left: 0; top: 0; z-index: 20; background: var(--card); border: 1.5px solid var(--ink);
  touch-action: none; cursor: grab; transform-origin: 50% 0;
  transition: transform .2s ease;
}
.stk .corner, .stki .corner {
  position: absolute; right: -1.5px; top: -1.5px; width: 9px; height: 9px; background: var(--paper);
  border-left: 1.5px solid var(--ink); border-bottom: 1.5px solid var(--ink);
}
.stk .corner::after, .stki .corner::after { content: ""; position: absolute; left: -1px; top: 0; width: 12px; border-top: 1.5px solid var(--ink); transform: rotate(45deg); transform-origin: 0 0; }
.stk.drag { cursor: grabbing; transition: none; opacity: .9; }
.ghost { position: absolute; z-index: 19; border: 2px dashed var(--ink); pointer-events: none; }
/* めくる：その場で上の辺へ巻き上がるだけ。ほかの字の上には動かない */
.stk.peel { transform: scaleY(.16); transform-origin: 50% 0; }
.stk.tug { animation: tug .35s; transform-origin: 50% 0; }
.stk.still { pointer-events: none; cursor: default; }
@keyframes tug { 50% { transform: scaleY(.7); } }

/* --- タイトル画面（遊びの土台だけ。仕掛けは教えない） --- */
.top { padding: 28px 22px 18px; display: flex; flex-direction: column; gap: 14px; }
.big { margin: 8px 0 0; font-size: 44px; letter-spacing: 6px; font-weight: 700; }
.base { margin: 0; font-size: 16px; line-height: 1.8; }
.hole { display: inline-block; width: 1.25em; height: .95em; vertical-align: -.1em; background: var(--hole) center / contain no-repeat; }
.stki { display: inline-block; position: relative; width: 3.4em; height: 1.35em; vertical-align: -.35em; margin: 0 .1em; background: var(--card); border: 1.5px solid var(--ink); }
.stki .corner { background: var(--sheet); }
.sample { background: var(--sheet); border: 1.5px solid var(--ink); padding: 12px 14px; display: flex; flex-direction: column; gap: 12px; }
.sl { margin: 0; font-size: 18px; letter-spacing: 2px; }
.srow { display: flex; align-items: center; gap: 6px; }
.srow .genre { margin-right: 4px; }
.sb { width: 34px; height: 34px; border: 1.5px solid var(--ink); background: var(--card); display: inline-flex; align-items: center; justify-content: center; font-size: 18px; }
.top .check { margin-top: 6px; }
.tfoot { font-size: 12px; text-align: center; color: var(--dim); }

/* --- 結果 --- */
.result { padding: 12px 14px 18px; display: flex; flex-direction: column; align-items: stretch; gap: 10px; }
.sheets { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mini { position: relative; background: var(--sheet); border: 1.5px solid var(--ink); padding: 6px 6px 8px; --cw: 11px; }
.mini .text .ln { margin: 3px 0; }
.mini .head { margin-bottom: 4px; }
.mini .ms { display: inline-block; background: var(--card); outline: 1px solid var(--ink); outline-offset: -1px; vertical-align: top; }
.mini .ms .c { color: transparent; }
.mini .mg { margin: 4px 0 0; display: inline-flex; align-items: center; border: 1px solid var(--ink); border-radius: 2px; padding: 1px 4px; background: var(--card); }
.mini .mg .gl { font-size: 8px; color: var(--dim); margin-right: 3px; }
.mini .mark { width: 32px; height: 32px; right: 2px; top: 2px; }
.btn {
  display: flex; align-items: center; justify-content: center; gap: 4px; height: 48px; font-size: 16px; font-weight: 700;
  border: 2px solid var(--ink); border-radius: 4px; background: var(--card); color: var(--ink); text-decoration: none; cursor: pointer;
}
.btn.x { background: var(--ink); color: #fff; }
.xlogo { width: 18px; height: 18px; }
.btn:active { transform: translateY(2px); }

#foot { padding: 6px 14px 16px; font-size: 12px; text-align: center; color: var(--dim); }

.toast {
  position: fixed; left: 50%; top: 40%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px;
  border-radius: 4px; font-size: 14px; z-index: 50; transition: opacity .5s;
}
.toast.out { opacity: 0; }
