/**
 * 高知の広場と風の街 (Plaza of Kochi and Town of Wind)
 * ブランド高知 デザインシステム＆レスポンシブHUDスタイルシート (style.css)
 *
 * カラーパレット:
 * - 土佐和紙アイボリー: #faf6ee
 * - 炭スレート文字色: #1f2937
 * - 仁淀ブルー: #008db7
 * - 柏島シアン: #26bce0
 * - 土佐柚子ゴールド: #e6b422
 * - 土佐神社朱色: #c93a2b
 */

:root {
  --washi-bg: rgba(250, 246, 238, 0.94);
  --washi-solid: #faf6ee;
  --slate-text: #1f2937;
  --slate-muted: #4b5563;
  --niyodo-blue: #008db7;
  --niyodo-dark: #006989;
  --kashiwajima-cyan: #26bce0;
  --yuzu-gold: #e6b422;
  --shrine-red: #c93a2b;
  --font-serif: 'Shippori Mincho', serif;
  --font-sans: 'Zen Kaku Gothic New', sans-serif;
}

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

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-sans);
  color: var(--slate-text);
  background-color: #0c4a6e;
  user-select: none;
  -webkit-user-select: none;
}

#world-canvas {
  position: fixed;
   inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  z-index: 1;
  cursor: pointer;
}

/* =========================================================================
   1. 上部ステータスバー (Top Status HUD)
   ========================================================================= */
#top-hud {
  position: fixed;
  top: 8px;
  left: 12px;
  right: 12px;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px 10px;
  padding: 6px 14px;
  background: var(--washi-bg);
  border: 2px solid var(--niyodo-blue);
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.22);
  backdrop-filter: blur(8px);
  flex-wrap: wrap;
}

.brand-zone-block {
  display: flex;
  flex-direction: column;
  min-width: 190px;
}

#hud-zone-name {
  font-family: var(--font-serif);
  font-size: 0.98rem;
  font-weight: 800;
  color: var(--niyodo-dark);
}

#hud-zone-sub {
  font-size: 0.72rem;
  color: var(--slate-muted);
}

.status-metrics-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.metric-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #ffffff;
  border: 1px solid rgba(0, 141, 183, 0.28);
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
}

#player-name-input {
  border: 1px dashed var(--niyodo-blue);
  background: #f0f9ff;
  color: var(--slate-text);
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 0.78rem;
  padding: 1px 6px;
  border-radius: 8px;
  width: 145px;
}

.stamina-track {
  width: 68px;
  height: 9px;
  background: #e5e7eb;
  border-radius: 999px;
  overflow: hidden;
}

#hud-stamina-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--kashiwajima-cyan), var(--niyodo-blue));
  transition: width 0.25s ease;
}

.top-actions-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.hud-pill-btn,
#atmosphere-select {
  background: #ffffff;
  color: var(--slate-text);
  border: 1.5px solid var(--niyodo-blue);
  padding: 4px 10px;
  border-radius: 999px;
  font-family: var(--font-sans);
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}

.hud-pill-btn:hover,
.hud-pill-btn.active-pill {
  background: var(--niyodo-blue);
  color: #ffffff;
}

.critic-pill-btn {
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  border-color: #d97706;
  color: #78350f;
}

/* =========================================================================
   2. 左サイドパネル：瞬間移動ワープ＆クエストナビ (Left Side Panel)
   ========================================================================= */
#left-panel {
  position: fixed;
  top: 144px;
  left: 12px;
  width: 270px;
  max-height: calc(100vh - 265px);
  z-index: 15;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.hud-card {
  pointer-events: auto;
  background: var(--washi-bg);
  border: 1.5px solid rgba(0, 141, 183, 0.45);
  border-radius: 14px;
  padding: 10px 12px;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.16);
}

.hud-card-title {
  font-family: var(--font-serif);
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--niyodo-dark);
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.warp-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
}

.warp-btn {
  background: #ffffff;
  border: 1px solid rgba(0, 141, 183, 0.35);
  border-radius: 8px;
  padding: 5px 6px;
  font-family: var(--font-sans);
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--slate-text);
  text-align: left;
  cursor: pointer;
  transition: background 0.15s;
}

.warp-btn:hover {
  background: #e0f2fe;
  border-color: var(--niyodo-blue);
}

#quest-tracker-list {
  max-height: 175px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-right: 4px;
}

.quest-card {
  background: #ffffff;
  border-left: 4px solid var(--niyodo-blue);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 0.74rem;
}

.quest-card.quest-done {
  border-left-color: #16a34a;
  background: #f0fdf4;
  opacity: 0.86;
}

.quest-head {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 2px;
}

.quest-badge {
  background: #e0f2fe;
  color: var(--niyodo-dark);
  padding: 1px 6px;
  border-radius: 6px;
  font-weight: 800;
  font-size: 0.68rem;
}

.quest-desc {
  color: var(--slate-muted);
  line-height: 1.35;
}

/* =========================================================================
   3. 右サイド：チャットログ＆土佐エモートバー
   ========================================================================= */
#right-panel {
  position: fixed;
  top: 144px;
  right: 12px;
  width: 270px;
  z-index: 15;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

#chat-log {
  max-height: 110px;
  overflow-y: auto;
  font-size: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 6px;
}

.chat-row {
  background: rgba(255, 255, 255, 0.85);
  padding: 3px 7px;
  border-radius: 6px;
}

#chat-form {
  display: flex;
  gap: 4px;
}

#chat-input {
  flex: 1;
  border: 1px solid rgba(0, 141, 183, 0.45);
  border-radius: 8px;
  padding: 5px 8px;
  font-size: 0.76rem;
  font-family: var(--font-sans);
}

#emote-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.emote-chip {
  background: #ffffff;
  border: 1px solid rgba(230, 180, 34, 0.6);
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 0.7rem;
  font-weight: 700;
  cursor: pointer;
}

.emote-chip:hover {
  background: #fef3c7;
}

/* =========================================================================
   4. 下部アクションドック (Bottom Action Dock)
   ========================================================================= */
#bottom-dock {
  position: fixed;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: min(96vw, 940px);
}

#btn-context-action {
  background: linear-gradient(135deg, var(--niyodo-blue), var(--niyodo-dark));
  color: #ffffff;
  border: 2px solid #ffffff;
  border-radius: 999px;
  padding: 8px 22px;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 105, 137, 0.38);
  transition: transform 0.15s ease;
}

#btn-context-action.ctx-ready {
  background: linear-gradient(135deg, #d97706, #b45309);
  transform: scale(1.03);
}

.dock-buttons-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--washi-bg);
  border: 2px solid var(--niyodo-blue);
  border-radius: 18px;
  padding: 8px 12px;
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.25);
  flex-wrap: wrap;
}

.dock-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 108px;
  padding: 6px 10px;
  background: #ffffff;
  border: 1.5px solid rgba(0, 141, 183, 0.35);
  border-radius: 12px;
  cursor: pointer;
  font-family: var(--font-sans);
  transition: all 0.15s ease;
}

.dock-btn:hover {
  background: #e0f2fe;
  transform: translateY(-2px);
}

.dock-btn.dock-btn-active {
  background: linear-gradient(135deg, #008db7, #26bce0);
  color: #ffffff;
  border-color: #006989;
}

.dock-main {
  font-size: 0.82rem;
  font-weight: 800;
}

.dock-sub {
  font-size: 0.68rem;
  opacity: 0.85;
}

/* =========================================================================
   5. トースト通知バナー ＆ モーダルウィンドウ
   ========================================================================= */
#toast-banner {
  position: fixed;
  top: 146px;
  left: 50%;
  transform: translateX(-50%) translateY(-10px);
  z-index: 35;
  background: rgba(15, 23, 42, 0.92);
  color: #ffffff;
  border: 2px solid var(--yuzu-gold);
  border-radius: 999px;
  padding: 7px 20px;
  font-size: 0.82rem;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s ease;
  max-width: 600px;
  text-align: center;
}

#toast-banner.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

#modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(15, 23, 42, 0.62);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

#modal-backdrop.hidden {
  display: none;
}

.modal-window {
  background: var(--washi-solid);
  border: 3px solid var(--niyodo-blue);
  border-radius: 20px;
  width: min(940px, 96vw);
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: linear-gradient(90deg, var(--niyodo-dark), var(--niyodo-blue));
  color: #ffffff;
}

#modal-title {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-weight: 800;
}

#modal-close-btn {
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
  border: 1px solid #ffffff;
  border-radius: 999px;
  padding: 4px 14px;
  font-weight: 800;
  cursor: pointer;
}

#modal-body {
  padding: 18px 20px;
  overflow-y: auto;
}

.modal-intro-box {
  background: #ffffff;
  border: 1.5px solid rgba(0, 141, 183, 0.35);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 16px;
  line-height: 1.65;
  font-size: 0.9rem;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(275px, 1fr));
  gap: 14px;
}

.product-card {
  background: #ffffff;
  border: 1.5px solid rgba(0, 141, 183, 0.28);
  border-radius: 14px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.product-card.card-dim {
  opacity: 0.72;
}

.product-header {
  display: flex;
  gap: 12px;
  align-items: center;
}

.product-icon {
  width: 56px;
  height: 56px;
  object-fit: contain;
  background: #f8fafc;
  border-radius: 10px;
  padding: 4px;
  border: 1px solid #e2e8f0;
}

.jan-badge {
  display: inline-block;
  font-size: 0.68rem;
  background: #e0f2fe;
  color: var(--niyodo-dark);
  padding: 2px 7px;
  border-radius: 6px;
  font-weight: 700;
}

.price-tag {
  font-weight: 800;
  color: #b45309;
  font-size: 0.88rem;
}

.spec-line,
.buff-line,
.desc-line {
  font-size: 0.79rem;
  line-height: 1.5;
}

.buff-line {
  color: var(--niyodo-dark);
  background: #f0f9ff;
  padding: 6px 8px;
  border-radius: 8px;
}

.card-actions {
  margin-top: auto;
  padding-top: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.owned-pill {
  font-size: 0.76rem;
  font-weight: 700;
  color: #15803d;
}

.btn-primary {
  background: linear-gradient(135deg, var(--niyodo-blue), var(--niyodo-dark));
  color: #ffffff;
  border: none;
  border-radius: 10px;
  padding: 8px 14px;
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 800;
  cursor: pointer;
}

.btn-secondary {
  background: #fef3c7;
  color: #78350f;
  border: 1px solid #d97706;
  border-radius: 10px;
  padding: 7px 12px;
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 800;
  cursor: pointer;
}

/* =========================================================================
   6. モバイル仮想ジョイスティック ＆ レスポンシブメディアクエリ
   ========================================================================= */
#mobile-joystick-zone {
  position: fixed;
  bottom: 195px;
  left: 16px;
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: rgba(250, 246, 238, 0.55);
  border: 2px solid rgba(0, 141, 183, 0.75);
  z-index: 18;
  display: none;
  align-items: center;
  justify-content: center;
  touch-action: none;
}

#mobile-joystick-knob {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--niyodo-blue);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

@media (max-width: 900px) {
  #left-panel {
    width: 220px;
    top: 155px;
  }
  #right-panel {
    display: none;
  }
  #mobile-joystick-zone {
    display: flex;
  }
}

@media (max-width: 600px) {
  #top-hud {
    padding: 6px 10px;
    gap: 4px 6px;
  }
  #hud-zone-sub,
  #hud-speed-badge,
  #atmosphere-select {
    display: none;
  }
  .brand-zone-block {
    min-width: auto;
  }
  #hud-zone-name {
    font-size: 0.88rem;
  }
  .metric-pill {
    font-size: 0.7rem;
    padding: 2px 6px;
  }
  #player-name-input {
    width: 105px;
    font-size: 0.7rem;
  }
  .hud-pill-btn {
    font-size: 0.7rem;
    padding: 3px 8px;
  }
  #left-panel {
    top: 192px;
    left: 8px;
    width: calc(100vw - 16px);
  }
  #left-panel section:nth-child(2) {
    display: none;
  }
  #toast-banner {
    top: auto;
    bottom: 205px;
    font-size: 0.75rem;
    padding: 6px 14px;
    max-width: 92vw;
  }
  .dock-btn {
    min-width: 78px;
    padding: 5px 6px;
  }
  .dock-main {
    font-size: 0.72rem;
  }
  .dock-sub {
    display: none;
  }
}
