:root {
  --ink: #1a1714;
  --paper: #f3efe7;
  --gold: #c8a24a;
  --muted: rgba(243, 239, 231, 0.6);
}

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

html, body {
  height: 100%;
  background: #0c0a09;
  color: var(--paper);
  font-family: "Noto Serif JP", "Cormorant Garamond", serif;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ---------- file:// 直開き時の案内 ---------- */
#protocolWarning {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(80% 70% at 50% 0%, rgba(200, 162, 74, 0.16), transparent 60%),
    linear-gradient(160deg, #14110e 0%, #0c0a09 100%);
}

.warning-card {
  width: min(680px, 100%);
  padding: 42px;
  border: 1px solid rgba(200, 162, 74, 0.35);
  background: rgba(12, 10, 9, 0.78);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
  text-align: center;
}

.warning-card h2 {
  font-weight: 400;
  font-size: clamp(24px, 5vw, 38px);
  line-height: 1.55;
  letter-spacing: 0.08em;
}

.warning-card p {
  margin: 22px auto 0;
  max-width: 520px;
  color: rgba(243, 239, 231, 0.8);
  font-size: 15px;
  line-height: 2;
  font-weight: 300;
}

.warning-card code {
  color: var(--gold);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.command-box {
  margin: 26px auto 0;
  padding: 18px 20px;
  max-width: 520px;
  background: rgba(0, 0, 0, 0.32);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--gold);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.8;
  text-align: left;
  overflow-x: auto;
}

.warning-link {
  display: inline-block;
  margin-top: 28px;
  padding: 14px 28px;
  color: #14110e;
  background: var(--gold);
  border: 1px solid var(--gold);
  text-decoration: none;
  letter-spacing: 0.08em;
  transition: all 0.3s ease;
}

.warning-link:hover {
  background: transparent;
  color: var(--gold);
}

/* ---------- エントランス ---------- */
#entrance {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.entrance-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(120% 80% at 50% 0%, rgba(200, 162, 74, 0.18), transparent 60%),
    radial-gradient(100% 100% at 50% 120%, rgba(31, 91, 115, 0.25), transparent 60%),
    linear-gradient(160deg, #14110e 0%, #0c0a09 45%, #0a0d0f 100%);
  z-index: -1;
}
.entrance-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255,255,255,0.04) 1px, transparent 1px);
  background-size: 3px 3px;
  opacity: 0.5;
}

.entrance-inner {
  text-align: center;
  max-width: 680px;
  padding: 40px 28px;
  animation: rise 1.2s cubic-bezier(.2,.7,.2,1) both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: translateY(0); }
}

.eyebrow {
  font-family: "Cormorant Garamond", serif;
  letter-spacing: 0.5em;
  text-transform: uppercase;
  font-size: 13px;
  color: var(--gold);
  margin-bottom: 18px;
  padding-left: 0.5em;
}

.title {
  font-family: "Cormorant Garamond", serif;
  font-weight: 500;
  font-size: clamp(48px, 11vw, 104px);
  line-height: 0.95;
  letter-spacing: 0.02em;
}
.title span {
  font-style: italic;
  color: var(--gold);
}

.ja-title {
  margin-top: 22px;
  font-size: clamp(14px, 3.6vw, 18px);
  letter-spacing: 0.28em;
  font-weight: 300;
  color: var(--muted);
}

.lead {
  margin: 30px auto 0;
  max-width: 520px;
  font-size: clamp(14px, 3.6vw, 16px);
  line-height: 2.1;
  font-weight: 300;
  color: rgba(243, 239, 231, 0.82);
}

#enterBtn {
  margin-top: 40px;
  padding: 16px 46px;
  background: transparent;
  border: 1px solid var(--gold);
  color: var(--paper);
  font-family: "Noto Serif JP", serif;
  font-size: 15px;
  letter-spacing: 0.25em;
  cursor: pointer;
  transition: all 0.4s ease;
  position: relative;
  overflow: hidden;
}
#enterBtn::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--gold);
  transform: translateY(101%);
  transition: transform 0.4s cubic-bezier(.2,.7,.2,1);
  z-index: -1;
}
#enterBtn:hover { color: #14110e; border-color: var(--gold); }
#enterBtn:hover::before { transform: translateY(0); }

.controls-hint {
  margin-top: 44px;
  display: flex;
  gap: 28px;
  justify-content: center;
  flex-wrap: wrap;
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.controls-hint b { color: var(--gold); font-weight: 500; margin-right: 6px; }

/* ---------- ローダー ---------- */
#loader {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  background: #0c0a09;
  letter-spacing: 0.2em;
  font-weight: 300;
  font-size: 14px;
  color: var(--muted);
}
.loader-ring {
  width: 54px; height: 54px;
  border: 1px solid rgba(255,255,255,0.12);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#loadPct { color: var(--gold); }

/* ---------- 3D canvas ---------- */
#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}
#scene:active { cursor: grabbing; }

/* ---------- HUD ---------- */
/* z-index は touch-controls(12) より前面に。pointer-events:none なのでボタン以外のタップは視点エリアへ通る */
#hud { position: fixed; inset: 0; z-index: 13; pointer-events: none; }

.room-label {
  position: absolute;
  top: 26px; left: 50%;
  transform: translateX(-50%);
  font-family: "Cormorant Garamond", serif;
  font-size: 18px;
  letter-spacing: 0.18em;
  color: rgba(243,239,231,0.85);
  background: rgba(12,10,9,0.45);
  padding: 8px 22px;
  border: 1px solid rgba(200,162,74,0.3);
  border-radius: 2px;
  backdrop-filter: blur(6px);
  white-space: nowrap;
  transition: opacity 0.5s;
}

.hud-btn {
  position: absolute;
  top: 22px;
  width: 44px; height: 44px;
  border: 1px solid rgba(200,162,74,0.4);
  background: rgba(12,10,9,0.5);
  color: var(--paper);
  font-size: 18px;
  cursor: pointer;
  pointer-events: auto;
  backdrop-filter: blur(6px);
  transition: all 0.3s;
}
.hud-btn:hover { background: var(--gold); color: #14110e; }
#mapBtn { right: 76px; }
#exitBtn { right: 22px; }

.crosshair {
  position: absolute;
  top: 50%; left: 50%;
  width: 8px; height: 8px;
  margin: -4px 0 0 -4px;
  border: 1px solid rgba(255,255,255,0.5);
  border-radius: 50%;
  transition: all 0.2s;
}
.crosshair.active {
  width: 22px; height: 22px;
  margin: -11px 0 0 -11px;
  border-color: var(--gold);
}

/* ---------- モバイル FPS 操作 ---------- */
#touch-controls {
  position: fixed;
  inset: 0;
  z-index: 12;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

/* 右半分：視点操作エリア（ドラッグで見回す） */
#lookZone {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 60%;
  pointer-events: auto;
}

/* 左：移動ジョイスティック */
#joystick {
  position: absolute;
  left: max(28px, env(safe-area-inset-left));
  bottom: max(28px, env(safe-area-inset-bottom));
  width: 132px; height: 132px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 50%, rgba(20,17,14,0.42), rgba(20,17,14,0.18));
  border: 1px solid rgba(200,162,74,0.35);
  backdrop-filter: blur(4px);
  pointer-events: auto;
  touch-action: none;
}
#joystick::before {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: rgba(200,162,74,0.5);
}
#stick {
  position: absolute;
  left: 50%; top: 50%;
  width: 58px; height: 58px;
  margin: -29px 0 0 -29px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, rgba(200,162,74,0.9), rgba(150,118,48,0.75));
  border: 1px solid rgba(255,255,255,0.25);
  box-shadow: 0 6px 18px rgba(0,0,0,0.45);
  transition: transform 0.04s linear;
}

/* ---------- 横画面案内 ---------- */
#rotateHint {
  position: fixed;
  inset: 0;
  z-index: 55;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10,8,7,0.94);
  backdrop-filter: blur(6px);
  text-align: center;
}
.rotate-inner { padding: 30px; }
.rotate-icon {
  font-size: 56px;
  color: var(--gold);
  line-height: 1;
  display: inline-block;
  animation: rotateTilt 1.8s ease-in-out infinite;
}
@keyframes rotateTilt {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(90deg); }
}
.rotate-inner p {
  margin-top: 24px;
  font-size: 16px;
  line-height: 2;
  letter-spacing: 0.12em;
  color: rgba(243,239,231,0.85);
}

/* ---------- 作品詳細パネル ---------- */
#artPanel {
  position: fixed;
  top: 0; right: 0;
  width: min(420px, 100%);
  height: 100%;
  z-index: 20;
  background: rgba(16, 13, 11, 0.92);
  backdrop-filter: blur(16px);
  border-left: 1px solid rgba(200,162,74,0.25);
  padding: 64px 36px 40px;
  overflow-y: auto;
  animation: slideIn 0.5s cubic-bezier(.2,.7,.2,1) both;
}
@keyframes slideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }

.panel-close {
  position: absolute;
  top: 20px; right: 22px;
  width: 40px; height: 40px;
  border: 1px solid rgba(255,255,255,0.2);
  background: transparent;
  color: var(--paper);
  font-size: 18px;
  cursor: pointer;
  transition: all 0.3s;
}
.panel-close:hover { border-color: var(--gold); color: var(--gold); }

.panel-img {
  width: 100%;
  background: #0c0a09;
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 20px 50px rgba(0,0,0,0.5);
}
.panel-img img { width: 100%; display: block; }

.panel-fr {
  margin-top: 28px;
  font-family: "Cormorant Garamond", serif;
  font-style: italic;
  font-size: 26px;
  color: var(--gold);
  line-height: 1.2;
}
.panel-ja {
  margin-top: 6px;
  font-weight: 400;
  font-size: 20px;
  letter-spacing: 0.06em;
}
.panel-meta {
  margin-top: 14px;
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 0.04em;
}
.panel-desc {
  margin-top: 22px;
  font-size: 15px;
  line-height: 2.1;
  font-weight: 300;
  color: rgba(243,239,231,0.85);
}

/* ---------- 作品一覧 ---------- */
#mapOverlay {
  position: fixed;
  inset: 0;
  z-index: 25;
  background: rgba(10, 8, 7, 0.96);
  backdrop-filter: blur(10px);
  overflow-y: auto;
  padding: 30px clamp(20px, 5vw, 70px) 60px;
  animation: rise 0.4s ease both;
}
.map-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0 28px;
  border-bottom: 1px solid rgba(200,162,74,0.2);
  position: sticky; top: 0;
  background: rgba(10,8,7,0.96);
}
.map-head h2 {
  font-family: "Cormorant Garamond", serif;
  font-weight: 500;
  font-size: 30px;
  letter-spacing: 0.12em;
}
#mapClose {
  width: 44px; height: 44px;
  border: 1px solid rgba(255,255,255,0.2);
  background: transparent;
  color: var(--paper);
  font-size: 18px;
  cursor: pointer;
}
#mapClose:hover { border-color: var(--gold); color: var(--gold); }

.map-grid {
  margin-top: 30px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 26px;
}
.map-card { cursor: pointer; }
.map-card .thumb {
  width: 100%;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: #0c0a09;
  border: 1px solid rgba(255,255,255,0.08);
  transition: all 0.4s ease;
}
.map-card .thumb img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform 0.6s ease;
}
.map-card:hover .thumb { border-color: var(--gold); }
.map-card:hover .thumb img { transform: scale(1.06); }
.map-card .cap-fr {
  margin-top: 12px;
  font-family: "Cormorant Garamond", serif;
  font-style: italic;
  font-size: 17px;
  color: var(--gold);
}
.map-card .cap-ja {
  margin-top: 2px;
  font-size: 13px;
  color: var(--muted);
}

@media (max-width: 640px) {
  #artPanel { padding: 60px 24px 30px; }
  .controls-hint { gap: 16px; }
}
