/* ═══════════════════════════════════════════════
   RAI — 呼べば、落ちる。
   真夜中の群青 × 稲妻の白金
   ═══════════════════════════════════════════════ */

:root {
  --sky:     #06070f;   /* ほぼ黒に近い群青 */
  --fg:      #e9e6da;   /* 稲光に晒された紙のような白 */
  --fg-dim:  #8d92a8;   /* 遠雷の灰青 */
  --plat:    #e6d79c;   /* 白金（アクセント） */
  --line:    rgba(233, 230, 218, 0.15);

  --font-display: "Shippori Mincho B1", serif;
  --font-latin:   "Cormorant Garamond", serif;
  --font-body:    "Zen Kaku Gothic New", sans-serif;
  --font-mono:    "IBM Plex Mono", monospace;

  --ease-out:  cubic-bezier(0.16, 1, 0.3, 1);
  --ease-soft: cubic-bezier(0.45, 0, 0.15, 1);

  --pad: clamp(20px, 4vw, 48px);
  --load: 0;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

body {
  background: var(--sky);
  color: var(--fg);
  font-family: var(--font-body);
  font-weight: 300;
  letter-spacing: 0.06em;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
body.has-cursor, body.has-cursor a, body.has-cursor button { cursor: none; }

::selection { background: var(--plat); color: var(--sky); }

.mono {
  font-family: var(--font-mono);
  font-weight: 400;
  font-size: 11px;
  letter-spacing: 0.22em;
  color: var(--fg-dim);
}

/* ═══════════ キャンバス ═══════════ */
.storm-canvas {
  position: fixed; inset: 0;
  width: 100vw; height: 100vh;
  z-index: 0;
  touch-action: none;
}

.grain {
  position: fixed; inset: -60%;
  z-index: 3; pointer-events: none;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='240' height='240' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
  animation: grain 0.9s steps(4) infinite;
}
@keyframes grain {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-3%, 2%); }
  50% { transform: translate(2%, -3%); }
  75% { transform: translate(-2%, -2%); }
  100% { transform: translate(3%, 3%); }
}

/* ═══════════ ローダー ═══════════ */
.loader {
  position: fixed; inset: 0; z-index: 100;
  background: var(--sky);
  display: grid; place-items: center;
  overflow: hidden;
  transition: opacity 0.9s var(--ease-soft) 0.25s, visibility 0s 1.2s;
}
body.is-loaded .loader { opacity: 0; visibility: hidden; }

/* 雲間のほのかな稲光 */
.loader__ink {
  position: absolute; left: 50%; top: 50%;
  width: 46vmax; height: 46vmax;
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(var(--load));
  background: radial-gradient(circle,
    rgba(180, 198, 255, 0.14) 0%,
    rgba(150, 168, 235, 0.06) 42%,
    rgba(120, 140, 220, 0.02) 68%,
    transparent 78%);
  filter: blur(6px);
}
.loader__center { position: relative; text-align: center; }
.loader__kanji {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(64px, 11vw, 130px);
  color: var(--fg);
  text-shadow: 0 0 60px rgba(160, 180, 255, 0.25);
}
.loader__count {
  margin-top: 10px;
  font-family: var(--font-latin);
  font-weight: 300; font-size: 20px; letter-spacing: 0.3em;
  color: var(--plat);
}
.loader__count small { font-size: 12px; }

/* ═══════════ カーソル（避雷針） ═══════════ */
.cursor { position: fixed; top: 0; left: 0; z-index: 90; pointer-events: none; will-change: transform; }
.cursor__tip {
  position: absolute; top: -3px; left: -3px;
  width: 6px; height: 6px; border-radius: 50%;
  background: #f2e6bc;
  box-shadow: 0 0 8px rgba(242, 230, 188, 0.7);
  transition: transform 0.25s var(--ease-out);
}
.cursor__ring {
  position: absolute; top: -16px; left: -16px;
  width: 32px; height: 32px; border-radius: 50%;
  border: 1px solid rgba(233, 230, 218, 0.35);
  transition: transform 0.3s var(--ease-out), border-color 0.3s;
}
.cursor.is-down .cursor__tip { transform: scale(1.8); }
.cursor.is-down .cursor__ring { transform: scale(0.7); border-color: var(--fg); }
.cursor.is-charge .cursor__ring { transform: scale(2.1); border-color: var(--plat); }
.cursor.is-hover .cursor__ring { transform: scale(1.5); border-color: var(--plat); }

/* 稲妻の色に合わせて針先が変わる */
body[data-bolt="plat"] .cursor__tip     { background: #f2e6bc; box-shadow: 0 0 8px rgba(242, 230, 188, 0.7); }
body[data-bolt="blue"] .cursor__tip     { background: #cfe4ff; box-shadow: 0 0 8px rgba(140, 180, 255, 0.8); }
body[data-bolt="murasaki"] .cursor__tip { background: #d3b3ff; box-shadow: 0 0 8px rgba(180, 130, 255, 0.8); }

/* ═══════════ ヘッダー ═══════════ */
.site-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: clamp(16px, 2.6vw, 26px) var(--pad);
  pointer-events: none;
}
.site-header a, .site-header button { pointer-events: auto; }

.brand { display: inline-flex; align-items: center; gap: 12px; color: var(--plat); }
.brand__mark { width: 30px; height: 30px; filter: drop-shadow(0 0 10px rgba(230, 215, 156, 0.3)); }
.brand__name {
  font-family: var(--font-latin);
  font-weight: 500; font-size: 18px; letter-spacing: 0.42em;
  color: var(--fg);
}

.header__right { display: flex; align-items: center; gap: clamp(14px, 2.5vw, 28px); }
.counter span { color: var(--plat); }
.share {
  pointer-events: auto;
  color: var(--fg); text-decoration: none;
  border: 1px solid var(--line); border-radius: 999px;
  padding: 8px 18px;
  background: rgba(10, 12, 24, 0.6);
  transition: border-color 0.3s, background 0.3s, color 0.3s;
}
.share:hover { border-color: var(--plat); color: var(--plat); background: rgba(230, 215, 156, 0.07); }

/* 言語スイッチャー */
.lang {
  pointer-events: auto;
  display: flex; align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
  background: rgba(10, 12, 24, 0.6);
}
.lang button {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  color: var(--fg-dim);
  background: transparent;
  border: 0;
  border-radius: 999px;
  min-width: 30px;
  padding: 5px 8px;
  cursor: pointer;
  transition: color 0.25s, background 0.25s;
}
.lang button:hover { color: var(--fg); }
.lang button.is-on { color: #0a0d1c; background: var(--plat); }

/* 韓国語・中国語のフォント差し替え（選択時にJSがロード） */
body[data-lang="ko"] {
  --font-display: "Noto Serif KR", serif;
  --font-body: "Noto Sans KR", sans-serif;
}
body[data-lang="zh"] {
  --font-display: "Noto Serif SC", serif;
  --font-body: "Noto Sans SC", sans-serif;
}
body[data-lang="en"] .intro__title {
  font-size: clamp(40px, 7.4vw, 100px);
  letter-spacing: 0.01em;
}

/* ═══════════ タイトル ═══════════ */
.stage { position: relative; z-index: 2; height: 100svh; pointer-events: none; }

.intro {
  position: absolute;
  left: var(--pad); top: 50%;
  transform: translateY(-56%);
  transition: opacity 1.2s var(--ease-soft), transform 1.2s var(--ease-soft), filter 1.2s var(--ease-soft);
}
body.is-played .intro {
  opacity: 0;
  transform: translateY(-56%) scale(0.985);
  filter: blur(4px);
}

.intro__eyebrow { margin-bottom: clamp(14px, 2.4vw, 26px); }

.intro__title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(52px, 9.5vw, 132px);
  line-height: 1.22;
  letter-spacing: 0.05em;
  color: var(--fg);
  text-shadow: 0 0 90px rgba(150, 170, 255, 0.18);
}
.intro__line { display: block; overflow: hidden; }
.intro__line--indent { padding-left: clamp(28px, 7vw, 130px); }
.intro__line-inner {
  display: inline-block;
  transform: translateY(115%) rotate(1.2deg);
  transition: transform 1.3s var(--ease-out);
}
body.is-loaded .intro__line:nth-child(1) .intro__line-inner { transition-delay: 0.45s; transform: none; }
body.is-loaded .intro__line:nth-child(2) .intro__line-inner { transition-delay: 0.62s; transform: none; }

.intro__hint {
  display: flex; flex-wrap: wrap; gap: 10px;
  margin-top: clamp(22px, 3.4vw, 38px);
  opacity: 0; transform: translateY(20px);
  transition: opacity 1s var(--ease-out) 1s, transform 1s var(--ease-out) 1s;
}
body.is-loaded .intro__hint { opacity: 1; transform: none; }

.hint-chip {
  font-size: 12px; letter-spacing: 0.12em;
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 16px;
  background: rgba(9, 11, 22, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

/* ═══════════ 操作ドック ═══════════ */
.dock {
  position: fixed;
  left: 50%; bottom: clamp(18px, 3.4vh, 34px);
  transform: translateX(-50%);
  z-index: 60;
  display: flex; align-items: stretch;
  gap: clamp(10px, 1.6vw, 22px);
  padding: 12px clamp(14px, 2vw, 24px);
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(9, 11, 22, 0.72);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
  opacity: 0; translate: 0 24px;
  transition: opacity 1s var(--ease-out) 1.2s, translate 1s var(--ease-out) 1.2s;
}
body.is-loaded .dock { opacity: 1; translate: 0 0; }

.dock__group { display: flex; align-items: center; gap: 6px; }
.dock__label {
  margin-right: 6px; font-size: 10px;
  writing-mode: vertical-rl;
  letter-spacing: 0.28em;
}
.dock__rule { width: 1px; background: var(--line); margin: 4px 0; }

.dock button {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 14px;
  letter-spacing: 0.1em;
  color: var(--fg-dim);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 9px 14px;
  display: inline-flex; align-items: center; gap: 7px;
  white-space: nowrap;
  transition: color 0.25s, background 0.25s, border-color 0.25s, transform 0.2s var(--ease-out);
}
.dock button:hover { color: var(--fg); transform: translateY(-1px); }
.dock button.is-on {
  color: var(--fg);
  background: rgba(233, 230, 218, 0.07);
  border-color: rgba(233, 230, 218, 0.35);
}
.dock button:active { transform: scale(0.94); }

/* 非日本語時のみ、漢字の横に小さな訳語サブラベルを併記 */
.dock button small {
  font-family: var(--font-mono);
  font-size: 8.5px;
  font-weight: 400;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-dim);
  opacity: 0.75;
}
.dock button small:empty { display: none; }
body[data-lang="ja"] .dock small { display: none; }
.dock button.is-disabled {
  opacity: 0.35;
  pointer-events: none;
}

/* 稲妻の色見本 */
.swatch {
  width: 12px; height: 12px; border-radius: 50%;
  border: 1px solid rgba(233, 230, 218, 0.25);
}
.swatch--plat     { background: #f2e6bc; box-shadow: 0 0 6px rgba(242, 230, 188, 0.6); }
.swatch--blue     { background: #cfe4ff; box-shadow: 0 0 6px rgba(140, 180, 255, 0.6); }
.swatch--murasaki { background: #c9a6ff; box-shadow: 0 0 6px rgba(180, 130, 255, 0.6); }

/* ═══════════ フッター ═══════════ */
.site-footer {
  position: fixed;
  left: 50%; transform: translateX(-50%);
  bottom: clamp(140px, 19vh, 175px);
  z-index: 40;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1s var(--ease-out) 1.5s;
}
body.is-loaded .site-footer { opacity: 1; }
.site-footer p { font-size: 10px; color: rgba(141, 146, 168, 0.85); }

/* ═══════════ 落款 ═══════════ */
.rakkan {
  position: fixed;
  right: var(--pad); bottom: clamp(20px, 3.4vh, 36px);
  z-index: 40;
  width: 44px; height: 44px;
  display: grid; place-items: center;
  background: linear-gradient(160deg, #ecdfab, #c3ac66);
  color: #10121f;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 24px;
  border-radius: 6px;
  box-shadow: 0 4px 18px rgba(230, 215, 156, 0.25);
  opacity: 0;
  transition: opacity 1s var(--ease-out) 1.7s;
}
body.is-loaded .rakkan { opacity: 0.92; }

/* ═══════════ レスポンシブ ═══════════ */
.pc-only { display: inline-flex; }

@media (max-width: 860px) {
  .pc-only { display: none; }
  .counter { display: none; }
  .intro { right: var(--pad); }
  .intro__title { font-size: clamp(46px, 13vw, 76px); }
  body[data-lang="en"] .intro__title { font-size: clamp(30px, 10.5vw, 58px); }
  .dock button small { font-size: 8px; }

  .dock {
    left: 12px; right: 12px;
    transform: none;
    flex-wrap: wrap;
    justify-content: center;
    row-gap: 6px;
    border-radius: 16px;
  }
  .dock__rule { display: none; }
  .dock__label { display: none; }
  .dock button { padding: 9px 12px; font-size: 13px; }

  .site-footer { display: none; }
  .rakkan { bottom: auto; top: 76px; width: 38px; height: 38px; font-size: 20px; }
}

/* ═══════════ 動きを減らす設定 ═══════════ */
@media (prefers-reduced-motion: reduce) {
  .grain { animation: none; }
  .intro__line-inner, .intro__hint, .dock, .site-footer, .rakkan { transition: none; opacity: 1; transform: none; translate: 0 0; }
}

/* ═══════════ ハブ（SHIZEN）へ戻る ═══════════ */
.hub-link {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  padding-right: 14px;
  margin-right: 2px;
  border-right: 1px solid var(--line);
  transition: color 0.3s;
}
.hub-link:hover { color: inherit; }
@media (max-width: 860px) {
  .hub-link { font-size: 9.5px; letter-spacing: 0.14em; padding-right: 10px; }
}
