/* ========================================
   基本設定
======================================== */

:root {
  --bg: #161616;
  --text: #ffffff;
  --text-muted: rgba(255, 255, 255, 0.7);
  --panel-bg: rgba(255, 255, 255, 0.06);
  --panel-border: rgba(255, 255, 255, 0.35);
  --button-bg: rgba(255, 255, 255, 0.6);
  --button-bg-hover: rgba(255, 255, 255, 0.75);
  --file-button-bg: rgba(255, 255, 255, 0.12);
  --file-button-border: rgba(255, 255, 255, 0.28);
  --side-space: 24px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-pill: 999px;
  --font-xs: 10px;
  --font-sm: 11px;
  --font-md: 12px;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background-color: var(--bg);
}

body {
  font-family:
    "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Noto Sans JP", "Yu Gothic",
    "Meiryo", sans-serif;
  display: flex;
  flex-direction: column;
  color: var(--text);
}

/* ========================================
   ローディング
======================================== */

.loading {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  justify-content: center;
  align-items: center;
  background: #000;
  color: rgba(255, 255, 255, 0.9);
  text-align: center;
}

.loading.is-hidden {
  display: none;
}

.loading__inner {
  width: min(420px, 80vw);
}

.loading__text {
  font-size: 1.05rem;
  letter-spacing: 0.03em;
}

.bar {
  height: 10px;
  margin-top: 12px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.bar__fill {
  width: 0%;
  height: 100%;
  background: rgba(255, 255, 255, 0.85);
}

.countdown {
  margin-top: 12px;
  opacity: 0.75;
  font-size: 0.95rem;
}

/* ========================================
   3Dエリア
======================================== */

.hero-3d {
  position: relative;
  width: 100%;
  height: min(800px, 85vh);
  margin: 0 auto;
  overflow: hidden;
  background-color: #000;
}

#bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* ========================================
   3D補助UI
======================================== */

#coordDisplay {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 1000;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.55);
  color: var(--text);
  font-size: var(--font-md);
  font-family: monospace;
  border-radius: var(--radius-sm);
  pointer-events: none;
}

#miniMap {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 4;
  width: 160px;
  height: 160px;
  overflow: hidden;
  transform: scale(0.82);
  transform-origin: top left;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  backdrop-filter: blur(4px);
  background-color: var(--panel-bg);
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.12) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.12) 1px, transparent 1px);
  background-size: 20px 20px;
}

#playerMarker {
  position: absolute;
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-bottom: 10px solid #c4e5fe;
  transform-origin: 50% 70%;
}

#frontDoorMarker {
  position: absolute;
  width: 3px;
  height: 3px;
  background: #ff6b6b;
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

/* ========================================
   カメラ操作ボタン
======================================== */

.cam-controls {
  position: absolute;
  right: 24px;
  bottom: 24px;
  z-index: 3;
  display: grid;
  grid-template-columns: repeat(2, 56px);
  grid-template-rows: repeat(5, 56px);
  gap: 10px;
}

#moveFront {
  grid-column: 1;
  grid-row: 1;
}
#moveBack {
  grid-column: 2;
  grid-row: 1;
}
#moveLeft {
  grid-column: 1;
  grid-row: 2;
}
#moveRight {
  grid-column: 2;
  grid-row: 2;
}
#turnLeft {
  grid-column: 1;
  grid-row: 3;
}
#turnRight {
  grid-column: 2;
  grid-row: 3;
}
#viewToggle {
  grid-column: 1;
  grid-row: 4;
}
#frontDoorBtn {
  grid-column: 2;
  grid-row: 4;
}
#wireBtn {
  grid-column: 2;
  grid-row: 5;
}

.cam-btn,
#viewToggle,
#frontDoorBtn,
#wireBtn {
  width: 56px;
  height: 56px;
  border: none;
  border-radius: var(--radius-pill);
  background: var(--button-bg);
  color: #222;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  backdrop-filter: blur(6px);
}

.cam-btn:hover,
#viewToggle:hover,
#frontDoorBtn:hover,
#wireBtn:hover {
  background: var(--button-bg-hover);
}

.cam-btn:active,
#viewToggle:active,
#frontDoorBtn:active,
#wireBtn:active {
  transform: scale(0.96);
  background: var(--button-bg-hover);
}

/* ========================================
   ファイルUI
======================================== */

#fileInput {
  display: none;
}

.file-ui {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0 var(--side-space) 16px;
}

.file-btn {
  appearance: none;
  border: 1px solid var(--file-button-border);
  border-radius: var(--radius-sm);
  background: var(--file-button-bg);
  color: var(--text);
  padding: 8px 12px;
  font: inherit;
  font-size: var(--font-md);
  line-height: 1;
  letter-spacing: 0.02em;
  white-space: nowrap;
  cursor: pointer;
}

.file-btn:hover {
  background: rgba(255, 255, 255, 0.22);
}

.file-btn:active {
  transform: scale(0.98);
}

#fileName {
  color: rgba(255, 255, 255, 0.85);
  font-size: var(--font-sm);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#dropOverlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.55);
  border: 3px dashed rgba(196, 229, 254, 0.9);
  color: var(--text);
  font-size: 24px;
  letter-spacing: 0.04em;
  text-align: center;
  pointer-events: none;
}

#dropOverlay.active {
  display: flex;
}

/* ========================================
   下部情報
======================================== */

.bottom-extra {
  flex: 1 0 auto;
  margin: 24px;
  color: var(--text);
}

.bottom-extra-title {
  margin: 0 0 12px 24px;
  color: var(--text);
  font-size: var(--font-xs);
  font-weight: 400;
  letter-spacing: 0.08em;
  text-align: left;
}

.bottom-extra-layout {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 16px;
  margin: 12px 0;
}

.bottom-extra-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px 24px;
  margin-left: 24px;
}

.bottom-extra-list {
  margin: 0;
  padding-left: 1.2em;
  color: var(--text);
  font-size: var(--font-xs);
  line-height: 1.4;
}

.bottom-extra-list li {
  margin: 0;
}

.no-bullet {
  list-style: none;
  padding-left: 0;
}

.bottom-extra-button {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 12px;
}

.bottom-extra-button a {
  display: inline-block;
  padding: 6px 14px;
  border: 1px solid var(--text);
  border-radius: 2px;
  color: var(--text);
  font-size: var(--font-xs);
  letter-spacing: 0.03em;
  text-decoration: none;
  white-space: nowrap;
  transition: 0.2s;
}

.bottom-extra-button a:hover {
  background: var(--text);
  color: #000;
}

/* ========================================
   免責文
======================================== */

.caution {
  margin: 12px 0 0 24px;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.7);
  line-height: 1.7;
  letter-spacing: 0.02em;
}

/* ========================================
   フッター
======================================== */

.site-footer {
  flex-shrink: 0;
  background: #161616;

  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 24px;
  padding: 16px 0;
}

.site-footer a {
  color: #ffffff;
  font-size: 12px;
  text-decoration: none;
  line-height: 1;
  letter-spacing: 0.04em;
}

.site-footer a:hover {
  opacity: 0.7;
}

/* ========================================
   レスポンシブ
======================================== */

@media (max-width: 768px) {
  .hero-3d {
    height: 62vh;
    min-height: 380px;
  }

  .cam-controls {
    right: 12px;
    bottom: 12px;
    grid-template-columns: repeat(2, 42px);
    grid-template-rows: repeat(5, 42px);
    gap: 7px;
  }

  .cam-btn,
  #viewToggle,
  #frontDoorBtn,
  #wireBtn {
    width: 42px;
    height: 42px;
    font-size: 14px;
  }

  #coordDisplay {
    top: 10px;
    right: 10px;
    padding: 6px 8px;
    font-size: 12px;
  }

  #miniMap {
    transform: scale(0.68);
  }

  .file-ui {
    gap: 6px;
    margin: 0 12px 16px;
  }

  .file-btn {
    padding: 8px 10px;
    font-size: 11px;
  }

  #fileName {
    flex: 1 1 100%;
    max-width: 100%;
    font-size: 10px;
  }

  #dropOverlay {
    font-size: 18px;
  }
}

@media (max-width: 640px) {
  .bottom-extra {
    margin: 24px 16px;
  }

  .bottom-extra-layout {
    grid-template-columns: 1fr;
    gap: 10px;
    margin: 12px 0;
  }

  .bottom-extra-title {
    margin-left: 24px;
  }

  .bottom-extra-columns {
    grid-template-columns: 1fr 1fr;
    gap: 2px 16px;
    margin-left: 24px;
  }

  .bottom-extra-button {
    justify-content: flex-start;
    margin: 12px 12px 12px 24px;
  }

  .disclaimer {
    margin: 12px 0 0 24px;
    font-size: 10px;
  }
}
