/* 見た目の決まりは DESIGN.md（会場の掲示物と同じ「黒板の黒地・下に溜まる暗い赤・赤い筆文字のロゴ・白い太い文字」）。
   並びと文言は Figma「怪談イベント関連依頼」の 360 幅の画面どおり。PC では中央の列を広げる。 */
:root {
  color-scheme: dark; /* スクロールバーなどを暗い側に。端末の自動の暗色化で色を書き換えさせない */
  --ground: #151313; /* 黒板の黒 */
  --surface-rgb: 33, 29, 28; /* 入力のカードの面（#211d1c。透かして使うので成分で持つ） */
  --field: #0f0e0e; /* 入力欄の中 */
  --play-face: #0c0b0b; /* 再生のボタンの面（入力欄の中よりさらに一段暗い。地と同じざらつきと下の赤い影を重ねる） */
  --chalk-rgb: 241, 236, 228; /* 本文（チョークの白 #f1ece4）。枠線は同じ白を透かして使うので成分で持つ */
  --chalk: rgb(var(--chalk-rgb));
  --chalk-muted: #ada59e; /* 補足・問い合わせ先 */
  --line: rgba(var(--chalk-rgb), 0.16); /* 枠線 */
  --blood-rgb: 110, 14, 17; /* 下に溜まる暗い赤（#6e0e11。透かして使うので成分で持つ） */
  --red: #c8161d; /* ボタン（ロゴの赤） */
  --red-pressed: #a51117;
  --red-text: #ff6464; /* 暗い地に置く赤い文字（題の【】・カーソル）。ざらつき込みの地の平均で 4.8 前後（DESIGN.md の実測） */
  --error: #ff7366; /* 失敗の文字（暗い地で 6:1 以上） */
  --disabled-bg: #3a3434;
  --disabled-fg: #9b938c;

  --font-display: "Dela Gothic One", "Zen Kaku Gothic New", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
  --font-body: "Zen Kaku Gothic New", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
  --font-mono: "JetBrains Mono", "Zen Kaku Gothic New", Menlo, Consolas, monospace;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

  /* 黒板の質感（細かいざらつきと、消し跡のような大きなむら）。絵ではなく地の質感だけ。
     filter の範囲を瓦と同じ大きさにする（既定の -10%〜120% のままだと、瓦の継ぎ目に直線が出る） */
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='g' x='0' y='0' width='1' height='1'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .1 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E");
  --dust: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='640' height='640'%3E%3Cfilter id='d' x='0' y='0' width='1' height='1'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.006' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .09 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23d)'/%3E%3C/svg%3E");
  /* デザイナーの背景素材の差し替え口。素材を置いたら url(bg.jpg) にする（無ければ質感と色だけ） */
  --bg-photo: none;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background-color: var(--ground);
  color: var(--chalk);
  font-family: var(--font-body);
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}

/* 地は画面に貼り付ける（iPhone は background-attachment: fixed を無視するので、固定した疑似要素に描く） */
body::before {
  content: "";
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: -1;
  background-color: var(--ground);
  background-image:
    linear-gradient(180deg, rgba(0, 0, 0, 0.3) 0%, rgba(0, 0, 0, 0) 26%),
    linear-gradient(180deg, rgba(var(--blood-rgb), 0) 40%, rgba(var(--blood-rgb), 0.36) 70%, rgba(var(--blood-rgb), 0.85) 100%),
    var(--dust),
    var(--grain),
    var(--bg-photo);
  background-repeat: no-repeat, no-repeat, repeat, repeat, no-repeat;
  background-size: auto, auto, 640px 640px, 220px 220px, cover;
  background-position: center;
}

[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---- ロゴ（Figma の画像 1200×630 を 267×67 の枠で切り抜く。位置もそのまま） ---- */
/* ロゴを置く列が 267px より狭い画面（入力は幅 299px 未満・視聴は 315px 未満。折りたたみのスマホ）では、枠ごと縦横の比を保って縮める（中の画像は枠に対する割合で置いているので、切り抜きは変わらない） */
.logo {
  position: relative;
  flex: none;
  width: min(267px, 100%);
  height: auto;
  aspect-ratio: 267 / 67;
  margin: 0;
  overflow: hidden;
}

.logo img {
  position: absolute;
  top: -32.11%;
  left: -21.88%;
  width: 138.89%;
  height: 288.99%;
  max-width: none;
}

/* 会場の掲示物と同じく、一番下に白い KAK（飾り。読み上げない） */
.kak {
  display: block;
  flex: none;
  width: 72px;
  height: auto;
  margin: 48px auto 0;
  opacity: 0.9;
}

/* ---- 認証（黒板の上に、貼り出した紙のようなカードを 1 枚） ---- */
/* 背の低い画面（横向きのスマホ・文字の拡大）でもカードの上下に届くよう、はみ出したらスクロールする。
   縦の中央寄せは、最初と最後の子の margin:auto で行う（justify-content:center だと、はみ出した上の方に届かない） */
.auth {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 32px 16px;
}

.auth > :first-child {
  margin-top: auto;
}

.auth > :last-child {
  margin-bottom: auto;
}

.auth-card {
  display: flex;
  flex: none;
  flex-direction: column;
  align-items: center;
  width: 320px;
  max-width: 100%;
  margin-top: 28px;
  padding: 28px 18px 24px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: rgba(var(--surface-rgb), 0.94);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.5);
}

/* 子の間に 16px（flex の gap は古い Safari〔14.1 未満〕で効かないため margin で付ける）。
   .auth-error の margin: 0 に負けないよう :not() で強める */
.auth-card > :not(:first-child) {
  margin-top: 16px;
}

.auth-lead {
  margin: 0;
  color: var(--chalk);
  font-size: 17px;
  font-weight: 700;
  line-height: 1.6;
  letter-spacing: 0.04em;
  text-align: center;
}

.auth-input {
  width: 240px;
  max-width: 100%;
  height: 52px;
  padding: 12px 14px;
  border: 1px solid rgba(var(--chalk-rgb), 0.38);
  border-radius: 4px;
  background: var(--field);
  color: var(--chalk);
  caret-color: var(--red-text);
  font-family: var(--font-mono);
  font-size: 18px; /* 16px 未満だと iPhone が入力時に拡大する */
  font-weight: 600;
  line-height: 26px;
  letter-spacing: 0.08em;
  text-align: center;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color 150ms var(--ease-out);
}

.auth-input::placeholder {
  color: #8a827b;
  opacity: 1;
}

.auth-input:focus {
  border-color: var(--chalk);
}

.auth-input:focus-visible {
  outline: 2px solid var(--chalk);
  outline-offset: 2px;
}

/* 案内の 2 行目（24 字）が、360 幅の画面ではカードの幅に 1 行で収まる大きさ（320 幅の端末では折り返す）。
   Figma の 9px は暗い地では読めないので上げる */
.auth-error {
  margin: 0;
  color: var(--error);
  font-size: 11.5px;
  font-weight: 700;
  line-height: 1.6;
  text-align: center;
}

.auth-button {
  width: 100%;
  height: 52px;
  padding: 0 16px;
  border: 0;
  border-radius: 4px;
  background: var(--red);
  color: #fff;
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 400;
  line-height: 1;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: background-color 150ms var(--ease-out), transform 100ms var(--ease-out);
}

/* 重ねたときの姿は、マウスで重ねられる端末だけ（タッチ端末は押した後も :hover が残り、押した色のままになる） */
@media (hover: hover) {
  .auth-button:not(:disabled):hover {
    background: var(--red-pressed);
  }
}

.auth-button:not(:disabled):active {
  transform: translateY(1px);
}

.auth-button:disabled {
  background: var(--disabled-bg);
  color: var(--disabled-fg);
  cursor: default;
}

.auth-button:focus-visible {
  outline: 2px solid var(--chalk);
  outline-offset: 3px;
}

/* ---- 視聴・公開前・終了後 ---- */
.page {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 24px 40px;
}

.lead {
  margin: 24px 0 0;
  color: var(--chalk);
  font-size: 15px;
  font-weight: 500;
  line-height: 1.7;
  letter-spacing: 0.04em;
  text-align: center;
}

.lead.notice {
  margin-top: 32px;
  font-size: 16px;
  font-weight: 700;
}

.part {
  width: 100%;
  margin-top: 36px;
}

.part + .part {
  margin-top: 40px;
}

.part-title {
  margin: 0 0 14px;
  color: var(--chalk);
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 400;
  line-height: 1.45;
  letter-spacing: 0.02em;
  text-align: center;
}

.part-label {
  color: var(--red-text);
}

/* 広い画面（PC・タブレット）では動画の枠が大きくなるので、題と案内も一段大きくする */
@media (min-width: 600px) {
  .lead {
    font-size: 16px;
  }

  .part-title {
    font-size: 24px;
  }
}

/* 動画の枠は、黒板に貼った写真のように少しだけ浮かせる（斜め下の影） */
.player {
  position: relative;
  width: 100%;
  aspect-ratio: 303.424 / 182;
  border: 1px solid var(--line);
  background: #000;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.6);
}

/* aspect-ratio が効かない古い Safari（15 未満）は、上の余白で同じ比率にする（数字は上の aspect-ratio と同じ） */
@supports not (aspect-ratio: 1) {
  .player {
    height: 0;
    padding-top: calc(100% * 182 / 303.424);
  }

  .player video {
    position: absolute;
    top: 0;
    left: 0;
  }
}

.player video {
  display: block;
  width: 100%;
  height: 100%;
  background: #000;
  object-fit: contain;
}

/* 押す前の「再生」。黒い面に白い極太の文字と、ロゴの赤の太い下線 */
.player .play {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  border: 0;
  background-color: var(--play-face);
  background-image: linear-gradient(180deg, rgba(var(--blood-rgb), 0) 55%, rgba(var(--blood-rgb), 0.45) 100%), var(--grain);
  background-size: auto, 220px 220px;
  color: var(--chalk);
  font-family: var(--font-display);
  font-size: 34px;
  font-weight: 400;
  letter-spacing: 0.12em;
  text-decoration: underline;
  text-decoration-color: var(--red);
  text-decoration-thickness: 5px;
  text-underline-offset: 12px;
  cursor: pointer;
  transition: letter-spacing 200ms var(--ease-out), text-decoration-color 150ms var(--ease-out);
}

@media (hover: hover) {
  .player .play:hover {
    letter-spacing: 0.18em;
    text-decoration-color: var(--red-text);
  }
}

.player .play:focus-visible {
  outline: 2px solid var(--chalk);
  outline-offset: -6px;
}

/* 動画の上端に出す（下の操作バーの再生ボタン・シークを隠さない）。押し操作は下に通す */
.player-error {
  pointer-events: none;
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  margin: 0;
  padding: 8px 10px;
  background: rgba(var(--blood-rgb), 0.94);
  color: var(--chalk);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.6;
  text-align: center;
}

.contact {
  margin: 40px 0 0;
  color: var(--chalk-muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.6;
  text-align: center;
}

.contact a {
  color: var(--chalk);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.contact a:focus-visible {
  outline: 2px solid var(--chalk);
  outline-offset: 2px;
}

/* 公開前・終了後の画面だけ、グッズのおばけが右下の隅からのぞく（飾り。押し操作は下に通す） */
.ghost {
  pointer-events: none;
  position: fixed;
  right: 12px;
  bottom: 0;
  width: 120px;
  height: auto;
  transform: translateY(24%);
}

/* 背の低い画面（横向きのスマホ）では、文字に重なるので出さない */
@media (max-height: 480px) {
  .ghost {
    display: none;
  }
}

/* ---- 動き: 会場の明かりが落ちるように黒から浮かび上がり、ロゴが判子のように一度だけ押される ---- */
.page:not([hidden]),
.auth:not([hidden]) {
  animation: lights-down 600ms var(--ease-out) both;
}

.logo {
  animation: stamp 520ms var(--ease-out) 180ms both;
}

.ghost {
  animation: peek 900ms var(--ease-out) 900ms both;
}

@keyframes lights-down {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes stamp {
  from {
    opacity: 0;
    transform: scale(1.12) rotate(-2deg);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes peek {
  from {
    transform: translateY(100%);
  }

  to {
    transform: translateY(24%);
  }
}

/* 「動きを減らす」設定では止める（.unsupported の遅れて出す仕組みは止めない） */
@media (prefers-reduced-motion: reduce) {
  .page:not([hidden]),
  .auth:not([hidden]),
  .logo,
  .ghost {
    animation: none;
  }

  .player .play,
  .auth-button,
  .auth-input {
    transition: none;
  }
}

/* JS が動かなかったときだけ見えるよう、6 秒おいてから出す（JS が動けば、その前に app.js が隠す）。
   必要な機能が無いと分かったときは、app.js が now を付けてすぐ出す */
.unsupported {
  margin: 0;
  padding: 24px 16px;
  color: var(--chalk);
  font-size: 14px;
  line-height: 1.6;
  text-align: center;
  visibility: hidden;
  -webkit-animation: unsupported-reveal 0s linear 6s forwards;
  animation: unsupported-reveal 0s linear 6s forwards;
}

.unsupported.now {
  visibility: visible;
  -webkit-animation: none;
  animation: none;
}

@-webkit-keyframes unsupported-reveal {
  to {
    visibility: visible;
  }
}

@keyframes unsupported-reveal {
  to {
    visibility: visible;
  }
}

/* 画面の切り替えで案内の文へ移したフォーカスは、枠を出さない（読み上げのため） */
.lead:focus,
.auth-lead:focus {
  outline: none;
}

.noscript {
  padding: 24px;
  color: var(--chalk);
  text-align: center;
}
