/* 06_scratch-reveal — 架空の催し「ヨツユ横丁 夜の市」のひとことみくじ。藍の夜、提灯の灯り、生成りの券 */
:root {
  --night: #0f1830;
  --night-deep: #090f20;
  --paper: #f6ecd4;
  --paper-deep: #eadcb8;
  --ink: #1f1a14;
  --ink-soft: #5a4e3c;
  --light: #f4e9d0;
  --light-soft: #cfc4a8;
  --lamp: #f2a23c;
  --red: #a82c1b;
  --line: rgba(31, 26, 20, .22);
  --brush: "Yuji Syuku", "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", "Noto Serif JP", serif;
  --gothic: "BIZ UDPGothic", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", "Noto Sans JP", sans-serif;
  --pad: clamp(20px, 5vw, 88px);
}

*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  display: flex; flex-direction: column;
  background: var(--night);
  color: var(--light);
  font-family: var(--gothic);
  font-size: 15px;
  line-height: 1.9;
  letter-spacing: .05em;
  -webkit-font-smoothing: antialiased;
  line-break: strict;
  overflow-wrap: anywhere;
}
.ph { display: inline-block; }
/* こすれるとき・こすれないときで替える文言（.night に is-scratch が付くのは、PixiJS の用意ができたとき） */
.only-scratch { display: none; }
.night.is-scratch .only-scratch { display: inline; }
.night.is-scratch .only-plain { display: none; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

/* ---------- 夜の横丁 ---------- */
.night {
  position: relative;
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
  align-items: center;
  gap: clamp(28px, 5vw, 100px);
  padding: clamp(64px, 11vh, 120px) var(--pad) clamp(28px, 5vh, 64px);
  overflow: hidden;
  overflow: clip;   /* hidden だと、フォーカスの移動などで中身が送られてしまうことがある */
  background:
    radial-gradient(60% 50% at 78% 46%, rgba(242, 162, 60, .2) 0%, rgba(242, 162, 60, 0) 70%),
    radial-gradient(50% 40% at 10% 0%, rgba(242, 162, 60, .12) 0%, rgba(242, 162, 60, 0) 70%),
    linear-gradient(180deg, var(--night-deep) 0%, var(--night) 46%, #17223f 100%);
}

/* 提灯の列 */
.lanterns {
  position: absolute; left: -2%; right: -2%; top: 0; height: clamp(44px, 8vh, 80px);
  display: flex; justify-content: space-around; align-items: flex-start;
  border-top: 2px solid rgba(244, 233, 208, .4);
  pointer-events: none;
}
.lanterns span {
  position: relative;
  width: clamp(20px, 2.2vw, 30px); height: clamp(28px, 3.1vw, 42px);
  margin-top: clamp(8px, 1.6vh, 16px);
  border-radius: 46% / 38%;
  background: linear-gradient(180deg, #f7c169 0%, var(--lamp) 60%, #d97d24 100%);
  box-shadow: 0 0 28px 6px rgba(242, 162, 60, .34);
}
.lanterns span:nth-child(even) { margin-top: clamp(14px, 3vh, 30px); }
.lanterns span::before { content: ""; position: absolute; left: 50%; top: calc(-1 * clamp(14px, 3vh, 30px)); width: 1px; height: clamp(14px, 3vh, 30px); background: rgba(244, 233, 208, .4); }
.lanterns span::after { content: ""; position: absolute; left: 22%; right: 22%; top: -3px; bottom: -3px; border: solid #2a1c10; border-width: 4px 0; border-radius: 2px; }

.night__head { position: relative; z-index: 1; min-width: 0; }
.night__place { margin: 0 0 clamp(10px, 2vh, 20px); font-size: 13px; font-weight: 700; letter-spacing: .3em; line-height: 1.6; color: var(--lamp); }
.night__title {
  margin: 0;
  font-family: var(--brush); font-weight: 400;
  font-size: clamp(44px, min(6.6vw, 13vh), 104px);
  line-height: 1.2; letter-spacing: .06em;
}
.night__lead { margin: clamp(14px, 2.6vh, 28px) 0 0; font-size: clamp(15px, 1.2vw, 17px); line-height: 2; }
.night__notes { list-style: none; margin: clamp(14px, 2.6vh, 28px) 0 0; padding: clamp(12px, 2vh, 18px) 0 0; border-top: 1px solid rgba(244, 233, 208, .28); font-size: 13.5px; line-height: 1.9; color: var(--light-soft); }
.night__notes li { position: relative; padding-left: 1.2em; }
.night__notes li::before { content: ""; position: absolute; left: 0; top: .82em; width: 6px; height: 6px; border-radius: 50%; background: var(--lamp); }

/* ---------- 券 ---------- */
.ticket {
  position: relative; z-index: 1;
  justify-self: center;
  width: min(100%, 580px, max(300px, (100vh - 250px) * 1.55));
  padding: clamp(14px, 2.4vh, 26px) clamp(16px, 2.4vw, 30px) clamp(14px, 2.4vh, 24px);
  color: var(--ink);
  background:
    radial-gradient(circle at 0 50%, var(--night) 0 9px, transparent 10px) left / 20px 28px repeat-y,
    radial-gradient(circle at 100% 50%, var(--night) 0 9px, transparent 10px) right / 20px 28px repeat-y,
    var(--paper);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .45);
}
.ticket__head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 0 4px 8px; border-bottom: 2px solid var(--ink); }
.ticket__title { margin: 0; font-family: var(--brush); font-weight: 400; font-size: clamp(19px, 1.7vw, 24px); letter-spacing: .16em; line-height: 1.5; }
.ticket__no { margin: 0; font-size: 12px; letter-spacing: .12em; line-height: 1.5; color: var(--ink-soft); font-variant-numeric: tabular-nums; white-space: nowrap; }

.scratch {
  position: relative;
  margin-top: clamp(10px, 1.8vh, 16px);
  aspect-ratio: 2 / 1;
  overflow: hidden;
  border: 1px solid var(--ink);
  background: #f7efd9;
  touch-action: auto;
  -webkit-user-select: none; user-select: none;
  cursor: default;
}
/* なぞりを受けるのは、こすれるあいだ（PixiJS の用意ができていて、まだ開いていない）だけ。
   開いたあと・こすれないときは、面の上を縦になぞってもページを送れる */
.scratch.is-live:not(.is-open) { touch-action: none; cursor: crosshair; }
.scratch__canvas { position: absolute; inset: 0; z-index: 3; display: none; }
.scratch.is-live .scratch__canvas { display: block; }
.scratch__canvas canvas { display: block; width: 100%; height: 100%; }

/* 絵が描けないときの表示（文字の面と、金色のおおい） */
.scratch__face { position: absolute; inset: 0; z-index: 1; display: grid; align-content: center; justify-items: center; gap: 2px; padding: 8px 16px; text-align: center; }
.scratch__face p { margin: 0; }
.scratch__word { font-family: var(--brush); font-size: clamp(30px, 5vw, 52px); line-height: 1.3; letter-spacing: .1em; }
.scratch__line { font-size: clamp(12.5px, 1.2vw, 15px); line-height: 1.7; color: var(--ink-soft); }
.scratch__stamp { margin-top: 6px !important; padding: 1px 12px 2px; border: 2px solid var(--red); color: var(--red); font-weight: 700; font-size: 12.5px; letter-spacing: .2em; line-height: 1.6; }
.scratch__cover {
  position: absolute; inset: 0; z-index: 2;
  display: grid; place-items: center;
  background:
    repeating-linear-gradient(135deg, rgba(255, 255, 255, .16) 0 2px, transparent 2px 9px),
    linear-gradient(120deg, #b9994f 0%, #ead9a2 38%, #c7aa62 62%, #a98a45 100%);
  color: #2b220f;
  font-weight: 700; font-size: 14px; letter-spacing: .14em;
  transition: opacity .5s ease;
}
.scratch.is-live .scratch__cover, .scratch.is-live .scratch__face { display: none; }
.scratch.is-open .scratch__cover { opacity: 0; pointer-events: none; }

.ticket__actions { margin: clamp(10px, 1.8vh, 16px) 0 0; display: flex; flex-wrap: wrap; gap: 10px; }
.btn {
  appearance: none;
  flex: 1 1 140px;
  min-height: 46px;
  padding: 8px 20px 9px;
  border: 2px solid var(--ink);
  border-radius: 4px;
  background: transparent;
  color: var(--ink);
  font: 700 15px/1.4 var(--gothic);
  letter-spacing: .14em;
  cursor: pointer;
  transition: background .2s, color .2s;
}
.btn:hover { background: rgba(31, 26, 20, .08); }
.btn--main { background: var(--ink); color: var(--paper); }
.btn--main:hover { background: #3a2f22; }
.btn:focus-visible { outline: 3px solid #0b57c4; outline-offset: 3px; }
.btn[aria-disabled="true"] { border-color: #6f6350; background: transparent; color: #6f6350; cursor: default; }

.result {
  margin-top: clamp(10px, 1.8vh, 16px);
  padding: 8px 14px 10px;
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 0 16px; align-items: baseline;
  background: var(--paper-deep);
  border-left: 4px solid var(--red);
}
.result[hidden] { display: none; }
.result p { margin: 0; }
.result__label { grid-column: 1 / -1; font-size: 11.5px; font-weight: 700; letter-spacing: .24em; line-height: 1.6; color: var(--red); }
.result__word { font-family: var(--brush); font-size: 22px; letter-spacing: .12em; line-height: 1.5; white-space: nowrap; }
.result__line { font-size: 14px; line-height: 1.7; }
.result__use { grid-column: 1 / -1; font-size: 12.5px; line-height: 1.7; color: var(--ink-soft); }
details.result { display: block; }
.result--plain summary { cursor: pointer; font-weight: 700; letter-spacing: .14em; }

.ticket__foot { margin: clamp(8px, 1.6vh, 14px) 0 0; padding: 8px 4px 0; border-top: 1px dashed var(--line); font-size: 12px; line-height: 1.7; color: var(--ink-soft); }

/* ---------- フッター ---------- */
.foot {
  padding: 14px var(--pad) 76px;   /* 左下の案内バーの分をあける */
  background: var(--night-deep);
  color: var(--light-soft);
  font-size: 12px; letter-spacing: .06em; line-height: 1.7;
}
.foot p { margin: 0; }

/* ---------- 幅が狭いとき ---------- */
@media (max-width: 860px) {
  .night { grid-template-columns: 1fr; align-items: start; gap: 22px; padding-top: clamp(64px, 9vh, 88px); }
  .night__title { font-size: clamp(40px, 11.5vw, 72px); }
  .night__lead { margin-top: 10px; font-size: 14.5px; line-height: 1.9; }
  .night__notes { display: none; }          /* 同じ内容を、券の下に出す */
  .ticket { width: min(100%, 560px); }
}
@media (min-width: 861px) and (min-height: 481px) {
  .ticket__foot--notes { display: none; }
}

/* ---------- 高さが低いとき ---------- */
@media (min-width: 861px) and (max-height: 720px) {
  .night { padding-top: 74px; padding-bottom: 18px; }
  .night__notes { font-size: 13px; line-height: 1.8; }
  .btn { min-height: 42px; }
}
@media (max-height: 480px) and (orientation: landscape) {
  .night { grid-template-columns: minmax(0, 4fr) minmax(0, 6fr); align-items: center; gap: 22px; padding: 40px var(--pad) 12px; }
  .lanterns { height: 34px; }
  .lanterns span { width: 14px; height: 20px; margin-top: 6px; }
  .lanterns span:nth-child(even) { margin-top: 10px; }
  .lanterns span::before { top: -10px; height: 10px; }
  .night__place { font-size: 11.5px; margin-bottom: 4px; }
  .night__title { font-size: clamp(32px, 11vh, 46px); }
  .night__lead { margin-top: 6px; font-size: 13px; line-height: 1.7; }
  .night__notes { display: none; }
  .ticket { width: min(100%, max(300px, (100vh - 176px) * 2)); padding: 8px 22px 8px; }
  .ticket__head { padding-bottom: 3px; }
  .ticket__title { font-size: 16px; }
  .scratch { margin-top: 6px; }
  .ticket__actions { margin-top: 6px; }
  .btn { min-height: 38px; padding: 5px 14px 6px; font-size: 14px; }
  .ticket__foot:not(.ticket__foot--notes) { display: none; }
  .ticket__foot--notes { display: block; margin-top: 6px; padding-top: 4px; }
  .result { margin-top: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  .scratch__cover, .btn { transition: none; }
}
