* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background-color: #0d1117;
  font-family: "Hiragino Mincho ProN", "Yu Mincho", serif;
  color: #e6edf3;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* スクロール＆ピンチズーム対応ビューポート */
#viewport-scroll {
  width: 100vw;
  height: 100dvh;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  position: relative;
  background-color: #0d1117;
}

/* ステージラッパー */
#stage-wrapper {
  width: 1920px;
  height: 1080px;
  flex-shrink: 0;
  margin: auto;
  position: relative;
}

/* 仮想オフィス全体のコンテナ */
#office-stage {
  position: relative;
  width: 1920px;
  height: 1080px;
  transform-origin: top left;
  background-color: #1c2536;
  overflow: hidden;
  cursor: crosshair;
  touch-action: pan-x pan-y;
}

/* 背景動画 */
#bg-video {
  position: absolute;
  top: 0;
  left: 0;
  width: 1920px;
  height: 1080px;
  object-fit: cover;
  z-index: 0;
  pointer-events: none;
}

/* ドラッグ＆ドロップ中のハイライト */
#office-stage.drag-over::before {
  content: "ここにスプライトシートをドロップしてキャラ変更";
  position: absolute;
  inset: 20px;
  border: 4px dashed #e0c078;
  background: rgba(16, 20, 28, 0.78);
  color: #e0c078;
  font-size: 28px;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 90;
  pointer-events: none;
}

/* HD-2D風の空気感（ビネット効果） */
#office-stage::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 63% 48%, rgba(255, 180, 80, 0.08) 0%, rgba(10, 20, 40, 0.35) 100%);
  pointer-events: none;
  z-index: 50;
}

/* ==========================================================================
   画面下部中央：2段構成アイコンフローティングドック
   ========================================================================== */
#bottom-dock {
  position: fixed;
  bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 120;
  background: rgba(15, 20, 30, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(176, 141, 87, 0.75);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.75);
  border-radius: 20px;
  padding: 7px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  max-width: 96vw;
}

.dock-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  max-width: 100%;
  overflow-x: auto;
  touch-action: pan-x;
}

.dock-row::-webkit-scrollbar {
  height: 3px;
}

.dock-row::-webkit-scrollbar-thumb {
  background: #8c734b;
  border-radius: 2px;
}

.dock-group {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.dock-divider {
  width: 1px;
  height: 22px;
  background: rgba(140, 115, 75, 0.45);
  flex-shrink: 0;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid rgba(140, 115, 75, 0.55);
  background: rgba(33, 38, 45, 0.9);
  color: #f4efe6;
  font-size: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: transform 0.12s, background 0.15s, border-color 0.15s;
  flex-shrink: 0;
}

.icon-btn:hover {
  background: #30363d;
  border-color: #f0d080;
  transform: translateY(-2px);
}

.icon-btn:active {
  transform: scale(0.94);
}

.icon-btn.active {
  background: #c9a363;
  border-color: #fff2cc;
  color: #0d1117;
  box-shadow: 0 0 10px rgba(224, 192, 120, 0.6);
}

.icon-btn.fit-active {
  background: #2563eb;
  border-color: #93c5fd;
}

#bottom-dock input[type="file"] {
  display: none;
}

.icon-badge {
  background: rgba(23, 32, 48, 0.95);
  border: 1px solid #4b5d78;
  color: #93c5fd;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-family: Consolas, Monaco, monospace;
  white-space: nowrap;
  cursor: pointer;
  flex-shrink: 0;
}

.slider-item {
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(33, 38, 45, 0.8);
  border: 1px solid rgba(72, 79, 88, 0.6);
  border-radius: 999px;
  padding: 3px 10px;
  flex-shrink: 0;
}

.mini-icon {
  font-size: 13px;
  line-height: 1;
}

.mini-val {
  font-size: 11px;
  font-family: Consolas, Monaco, monospace;
  color: #e0c078;
  min-width: 24px;
  text-align: right;
}

input[type="range"] {
  accent-color: #e0c078;
  cursor: pointer;
  width: 72px;
  height: 4px;
}

/* ==========================================================================
   ステージ上のエフェクト・NPC・会話ウィンドウ
   ========================================================================== */
.target-marker {
  position: absolute;
  width: 30px;
  height: 15px;
  border: 2px solid #f0d080;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  box-shadow: 0 0 10px #f0d080;
  animation: pulseRing 0.8s ease-out forwards;
  z-index: 2;
}

.target-marker.run {
  border-color: #38bdf8;
  box-shadow: 0 0 14px #38bdf8;
}

@keyframes pulseRing {
  0% {
    transform: translate(-50%, -50%) scale(0.4);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -50%) scale(1.7);
    opacity: 0;
  }
}

.dash-dust {
  position: absolute;
  width: 12px;
  height: 8px;
  background: rgba(230, 220, 200, 0.55);
  border-radius: 50%;
  pointer-events: none;
  transform: translate(-50%, -50%);
  animation: dustFade 0.45s ease-out forwards;
  z-index: 5;
}

@keyframes dustFade {
  0% {
    transform: translate(-50%, -50%) scale(0.6);
    opacity: 0.75;
  }
  100% {
    transform: translate(-50%, -95%) scale(1.8);
    opacity: 0;
  }
}

/* NPCのコンテナ */
.npc {
  position: absolute;
  width: 60px;
  height: 80px;
  cursor: pointer;
  z-index: 10;
  filter: drop-shadow(0 3px 5px rgba(0, 15, 35, 0.75)) contrast(1.05) brightness(0.98);
  transition: filter 0.08s;
}

.npc.hit-flash {
  filter: brightness(2.3) saturate(0.25) drop-shadow(0 0 12px #ef4444);
}

.npc::before {
  content: "";
  position: absolute;
  bottom: 2px;
  left: 50%;
  transform: translateX(-50%);
  width: 60%;
  height: 11px;
  background: rgba(10, 18, 30, 0.58);
  border-radius: 50%;
  filter: blur(2.5px);
  z-index: -1;
  transition: width 0.15s;
}

.npc.is-down::before {
  width: 86%;
  height: 10px;
}

.npc canvas {
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}

.status-badge {
  position: absolute;
  top: -24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 20, 30, 0.9);
  color: #f0e6d2;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 12px;
  border: 1px solid #8c734b;
  white-space: nowrap;
  pointer-events: none;
}

/* 会話ウィンドウ（2段ドックと重ならない高さに配置） */
#dialog-box {
  display: none;
  position: fixed;
  bottom: calc(118px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  width: 720px;
  max-width: 92vw;
  background: linear-gradient(180deg, rgba(16, 20, 28, 0.95) 0%, rgba(10, 12, 18, 0.98) 100%);
  border: 2px solid #a38958;
  box-shadow: 0 0 0 3px rgba(16, 20, 28, 0.85), 0 12px 30px rgba(0, 0, 0, 0.85);
  padding: 16px 24px;
  border-radius: 8px;
  color: #f4efe6;
  z-index: 110;
  cursor: pointer;
}

#dialog-name {
  font-size: 15px;
  color: #e0c078;
  margin-bottom: 6px;
  font-weight: bold;
  letter-spacing: 0.05em;
}

#dialog-text {
  font-size: 16px;
  line-height: 1.55;
  margin: 0;
}

/* ==========================================================================
   スマホ・タブレット向けレスポンシブ調整
   ========================================================================== */
@media (max-width: 900px) {
  #bottom-dock {
    padding: 6px 10px;
    gap: 5px;
    border-radius: 16px;
    max-width: 96vw;
  }

  .dock-row {
    justify-content: flex-start;
  }

  .icon-btn {
    width: 36px;
    height: 36px;
    font-size: 17px;
  }

  .slider-item {
    padding: 3px 8px;
  }

  input[type="range"] {
    width: 68px;
    height: 6px;
  }

  #dialog-box {
    bottom: calc(114px + env(safe-area-inset-bottom, 0px));
    padding: 12px 16px;
  }

  #dialog-name {
    font-size: 13px;
  }

  #dialog-text {
    font-size: 14px;
  }
}