:root {
  --bg: #031412;
  --ink: #D8FFE9;
  --soft: #A9D9C2;
  --muted: #8FBFA8;
  --phosphor: #7CFFB2;
  --on-phosphor: #03211B;
  --panel: rgba(3, 20, 18, 0.86);
  --line: rgba(124, 255, 178, 0.45);
  --line-soft: rgba(124, 255, 178, 0.25);
  --hilite: rgba(124, 255, 178, 0.12);
  --cat-camera: #FFB020;
  --cat-play: #13B5C9;
  --cat-3d: #C2338A;
  --cat-prep: #9AA3B5;
  --cat-watch: #9BE15D;
  --font: 'DotGothic16', 'MS Gothic', 'Osaka-Mono', monospace;
  --mono: 'Space Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
  --gutter: 40px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--phosphor); }
a:hover { color: #C2FFDB; }

:focus-visible { outline: 2px solid var(--phosphor); outline-offset: 2px; }

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}
#scene.is-dragging { cursor: grabbing; }
#scene.is-hovering { cursor: pointer; }

/* ---- HUD ---- */

.hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  transition: opacity 0.35s;
}
/* ダイブ中は HUD を消して、レーンだけを見せる */
.is-diving .hud { opacity: 0; }
.is-diving .hud > * { pointer-events: none; }
.hud > * { pointer-events: auto; }
.hud > .leader, .hud > .reticle { pointer-events: none; }

.brand { position: absolute; left: var(--gutter); top: 36px; }
.brand__code {
  margin: 0 0 6px;
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.16em;
  color: var(--phosphor);
}
.brand__title { margin: 0; font-weight: 400; font-size: 38px; line-height: 1.15; }

.status {
  position: absolute;
  right: var(--gutter);
  top: 40px;
  margin: 0;
  text-align: right;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.7;
  color: var(--muted);
}
.status__dot { color: var(--phosphor); }

.panel, .card, .menu {
  background: var(--panel);
  border: 1px solid var(--line);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

/* 選んでいるネタ */
.card {
  position: absolute;
  left: var(--gutter);
  top: 150px;
  width: 320px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.card__head { display: flex; justify-content: space-between; align-items: center; }
.card__id { font-family: var(--mono); font-size: 13px; letter-spacing: 0.1em; color: var(--phosphor); }
.card__name { margin: 0; font-size: 52px; line-height: 1.05; }
.card__title { margin: 0; font-weight: 400; font-size: 20px; }
.card__desc { margin: 0; font-size: 14px; line-height: 1.6; color: var(--soft); }
.card__spec {
  margin: 0;
  padding: 10px 0;
  border-top: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}
.card__spec div { display: flex; gap: 1.5em; }
.card__spec dt { flex-shrink: 0; font-family: var(--font); }
.card__spec dd { margin: 0; }
.card__actions { display: flex; gap: 10px; }
.card__dive {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  background: var(--phosphor);
  color: var(--on-phosphor);
  font-size: 17px;
  text-decoration: none;
}
.card__dive:hover { color: var(--on-phosphor); background: #A8FFCB; }
.card__dive[aria-disabled="true"] {
  background: transparent;
  border: 1px dashed var(--cat-prep);
  color: var(--muted);
  pointer-events: none;
}
.card__menu {
  display: none;
  min-height: 48px;
  padding: 0 14px;
  background: transparent;
  border: 1px solid var(--phosphor);
  color: var(--ink);
  font: inherit;
  font-size: 15px;
}

.chip {
  padding: 2px 8px;
  font-family: var(--mono);
  font-size: 12px;
  color: #1B1F3B;
  background: var(--cat-camera);
}
.chip[data-category="play"] { background: var(--cat-play); color: #06262B; }
.chip[data-category="3d"] { background: var(--cat-3d); color: #FFFFFF; }
.chip[data-category="prep"] { background: var(--cat-prep); color: #121826; }
.chip[data-category="watch"] { background: var(--cat-watch); color: #10240A; }

/* お品書き */
.menu {
  position: absolute;
  right: var(--gutter);
  top: 150px;
  width: 300px;
  padding: 16px;
}
.menu__head { display: flex; align-items: baseline; gap: 10px; padding: 0 4px 8px; }
.menu__head h2 { margin: 0; font-weight: 400; font-size: 22px; flex: 1; }
.menu__en { font-family: var(--mono); font-size: 11px; letter-spacing: 0.12em; color: var(--muted); }
.menu__close {
  display: none;
  width: 44px;
  height: 44px;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 22px;
}
.menu__list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.menu__list a, .menu__list .is-prep {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 0 10px;
  color: var(--ink);
  text-decoration: none;
}
.menu__list a:hover { background: rgba(124, 255, 178, 0.06); color: var(--ink); }
.menu__list [aria-current="true"] { background: var(--hilite); }
.menu__list a::after { content: '→'; margin-left: auto; color: var(--phosphor); }
.menu__list .is-prep { color: var(--muted); }
.menu__name { font-size: 17px; width: 5em; flex-shrink: 0; }
.menu__title { font-size: 13px; color: var(--soft); }
.is-prep .menu__title { color: var(--muted); }

.dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--cat-camera);
}
[data-category="play"] > .dot { background: var(--cat-play); }
[data-category="3d"] > .dot { background: var(--cat-3d); }
[data-category="watch"] > .dot { background: var(--cat-watch); }
[data-category="prep"] > .dot { background: transparent; border: 2px dashed var(--cat-prep); }

/* 皿の色の凡例 */
.legend {
  position: absolute;
  left: var(--gutter);
  bottom: 36px;
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  gap: 16px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}
.legend::before { content: '皿の色＝ページの種類'; font-family: var(--font); }
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.legend li::before { content: ''; width: 10px; height: 10px; border-radius: 50%; background: var(--cat-camera); }
.legend li[data-category="play"]::before { background: var(--cat-play); }
.legend li[data-category="3d"]::before { background: var(--cat-3d); }
.legend li[data-category="watch"]::before { background: var(--cat-watch); }
.legend li[data-category="prep"]::before { background: var(--cat-prep); }

.hint {
  position: absolute;
  right: var(--gutter);
  bottom: 36px;
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

/* 選んだネタを囲む照準。位置と大きさは JS が毎フレーム決める */
.reticle {
  --c: var(--phosphor);
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  opacity: 0;
  transition: opacity 0.2s;
  background:
    linear-gradient(var(--c), var(--c)) left top / 24px 2.5px,
    linear-gradient(var(--c), var(--c)) left top / 2.5px 24px,
    linear-gradient(var(--c), var(--c)) right top / 24px 2.5px,
    linear-gradient(var(--c), var(--c)) right top / 2.5px 24px,
    linear-gradient(var(--c), var(--c)) left bottom / 24px 2.5px,
    linear-gradient(var(--c), var(--c)) left bottom / 2.5px 24px,
    linear-gradient(var(--c), var(--c)) right bottom / 24px 2.5px,
    linear-gradient(var(--c), var(--c)) right bottom / 2.5px 24px;
  background-repeat: no-repeat;
}
.reticle.is-on { opacity: 1; }
.reticle span {
  position: absolute;
  left: calc(100% + 8px);
  top: -4px;
  white-space: nowrap;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.1em;
  color: var(--phosphor);
}

.leader { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.leader line { stroke: var(--phosphor); stroke-width: 1; opacity: 0; transition: opacity 0.2s; }
.leader.is-on line { opacity: 0.8; }

/* ダイブするときに画面を覆う */
.veil {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--phosphor);
  color: var(--on-phosphor);
  font-family: var(--mono);
  font-size: 14px;
  letter-spacing: 0.2em;
  opacity: 0;
  pointer-events: none;
}

/* ---- スマホ ---- */
@media (max-width: 1024px) {
  :root { --gutter: 16px; }

  .brand { top: calc(16px + env(safe-area-inset-top)); }
  .brand__code { font-size: 11px; margin-bottom: 4px; }
  .brand__title { font-size: 26px; }
  .status { top: calc(20px + env(safe-area-inset-top)); font-size: 11px; }

  .card {
    left: 0;
    right: 0;
    top: auto;
    bottom: 0;
    width: auto;
    padding: 16px 20px calc(20px + env(safe-area-inset-bottom));
    gap: 8px;
    border-width: 1px 0 0;
  }
  .card__name { font-size: 34px; display: inline; }
  .card__title { font-size: 17px; }
  .card__spec { display: none; }
  .card__menu { display: inline-flex; align-items: center; }

  .menu {
    position: fixed;
    inset: 0;
    width: auto;
    padding: calc(16px + env(safe-area-inset-top)) 16px 16px;
    border: 0;
    display: none;
    overflow-y: auto;
  }
  .menu.is-open { display: block; z-index: 10; }
  .menu__close { display: block; }

  .legend { display: none; }
  /* 下から出るカードのすぐ上に置く。--sheet-h は JS がカードの高さを入れる */
  .hint {
    left: 0;
    right: 0;
    bottom: calc(var(--sheet-h, 220px) + 12px);
    text-align: center;
    font-size: 12px;
  }
  .leader { display: none; }
}

/* ---- スマホ（縦長）: レーンを指で回して、手前のネタをタップでダイブ ---- */

.hud-menu, .holo-caption, .tap-hint, .edge-label, .dots { display: none; }

.is-phone .card,
.is-phone .status,
.is-phone .legend { display: none; }

.is-phone .brand__title { font-size: 18px; }

.is-phone .hud-menu {
  position: absolute;
  right: 16px;
  top: calc(20px + env(safe-area-inset-top));
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: rgba(3, 20, 18, 0.7);
  border: 1px solid rgba(124, 255, 178, 0.6);
  color: var(--ink);
}
.hud-menu path { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

/* ホログラムの見出し */
.is-phone .holo-caption {
  position: absolute;
  left: 16px;
  right: 16px;
  top: calc(84px + env(safe-area-inset-top));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  text-align: center;
  pointer-events: none;
}
.holo-caption p { margin: 0; }
.holo-caption__head { display: flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: 11px; letter-spacing: 0.12em; color: var(--phosphor); }
.holo-caption .chip { font-size: 11px; padding: 1px 7px; letter-spacing: 0; }
.holo-caption__name { font-size: 34px; line-height: 1.15; text-shadow: 0 0 12px rgba(124, 255, 178, 0.35); }
.holo-caption__title { font-size: 14px; color: var(--soft); }

/* 手前の皿の下に出す。位置は JS が毎フレーム決める */
.is-phone .tap-hint {
  position: absolute;
  left: 0;
  top: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 18px;
  color: var(--phosphor);
  white-space: nowrap;
  pointer-events: none;
}
.tap-hint span { font-family: var(--mono); font-size: 10px; letter-spacing: 0.2em; color: var(--muted); }

.is-phone .edge-label {
  position: absolute;
  bottom: calc(92px + env(safe-area-inset-bottom));
  display: block;
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  pointer-events: none;
}
.edge-label--left { left: 12px; }
.edge-label--right { right: 12px; }

.is-phone .dots {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(60px + env(safe-area-inset-bottom));
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  pointer-events: none;
}
.dots li { width: 8px; height: 8px; border-radius: 50%; background: var(--cat-camera); opacity: 0.6; }
.dots li[data-category="play"] { background: var(--cat-play); }
.dots li[data-category="3d"] { background: var(--cat-3d); }
.dots li[data-category="watch"] { background: var(--cat-watch); }
.dots li[data-category="prep"] { background: transparent; border: 1.5px dashed var(--cat-prep); }
.dots li.is-on { width: 12px; height: 12px; opacity: 1; box-shadow: 0 0 0 3px rgba(124, 255, 178, 0.5); }

.is-phone .hint { bottom: calc(26px + env(safe-area-inset-bottom)); }
.is-phone .reticle span { left: 0; top: -20px; }

/* 横長のタブレットでは、下のカードを横に伸ばしすぎない */
@media (min-width: 640px) and (max-width: 1024px) {
  .card {
    left: 50%;
    right: auto;
    width: min(560px, 100%);
    transform: translateX(-50%);
    border-width: 1px 1px 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .reticle, .leader line { transition: none; }
}
