/* ------------------------------------------------------------
   style.css
   GTA風HUDを意識した、視認性重視のオーバーレイUI。
   背景は完全透過でCanvasの上に重ねる。
------------------------------------------------------------ */

@font-face {
  font-family: 'Rajdhani';
  src: local('Rajdhani');
}

:root {
  --hud-bg: rgba(10, 12, 16, 0.72);
  --hud-border: rgba(255, 255, 255, 0.12);
  --accent: #3ac6f0;
  --accent-warn: #f1c40f;
  --accent-bad: #e74c3c;
  --text-main: #eef1f5;
  --text-dim: #9aa3ad;
  font-family: 'Segoe UI', 'Hiragino Sans', 'Yu Gothic', sans-serif;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0d0d10;
  color: var(--text-main);
  user-select: none;
}

.hidden {
  display: none !important;
}

#game-canvas {
  position: fixed;
  inset: 0;
  display: block;
  cursor: crosshair;
}

#ui-root {
  position: fixed;
  inset: 0;
  pointer-events: none;
  font-variant-numeric: tabular-nums;
}

#ui-root a, #ui-root button, #ui-root input, #ui-root select {
  pointer-events: auto;
}

/* ---------- Top bar ---------- */
.topbar {
  position: absolute;
  top: 14px;
  left: 14px;
  right: 14px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.hud-cluster {
  display: flex;
  gap: 10px;
}

.hud-chip {
  background: var(--hud-bg);
  border: 1px solid var(--hud-border);
  border-radius: 10px;
  padding: 8px 14px;
  backdrop-filter: blur(6px);
  font-size: 15px;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  gap: 6px;
}

.hud-chip .label {
  color: var(--text-dim);
  font-size: 11px;
  margin-right: 4px;
}

#hud-money {
  color: #7ee787;
  font-weight: 700;
}

#hud-fps {
  color: var(--text-dim);
  font-size: 11px;
}

.top-right-controls {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

/* ---------- Buttons ---------- */
.btn {
  background: var(--hud-bg);
  border: 1px solid var(--hud-border);
  color: var(--text-main);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
  backdrop-filter: blur(6px);
  transition: background 0.15s ease, transform 0.1s ease;
}
.btn:hover {
  background: rgba(255, 255, 255, 0.12);
}
.btn:active {
  transform: scale(0.97);
}
.btn-primary {
  background: var(--accent);
  color: #04222c;
  border-color: transparent;
  font-weight: 600;
}
.btn-primary:hover {
  background: #5ad4f5;
}

.badge {
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
}
.badge-ok {
  background: rgba(46, 204, 113, 0.18);
  color: #7ee787;
  border: 1px solid rgba(46, 204, 113, 0.4);
}
.badge-warn {
  background: rgba(241, 196, 15, 0.18);
  color: var(--accent-warn);
  border: 1px solid rgba(241, 196, 15, 0.4);
}

/* ---------- Minimap ---------- */
#minimap-wrap {
  position: absolute;
  top: 70px;
  right: 14px;
}
#minimap-canvas {
  width: 180px;
  height: 180px;
  border-radius: 10px;
  border: 1px solid var(--hud-border);
}

/* ---------- Bottom hints ---------- */
.bottom-hints {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
}
.hint-chip {
  background: var(--hud-bg);
  border: 1px solid var(--hud-border);
  border-radius: 20px;
  padding: 6px 16px;
  font-size: 13px;
  backdrop-filter: blur(6px);
}
#hud-interact-hint {
  display: none;
  color: var(--accent-warn);
  font-weight: 600;
}

.controls-legend {
  position: absolute;
  bottom: 18px;
  left: 18px;
  background: var(--hud-bg);
  border: 1px solid var(--hud-border);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.7;
  backdrop-filter: blur(6px);
}
.controls-legend strong {
  color: var(--text-main);
}

/* ---------- Dialogue panel ---------- */
/* Dialogue tabs */
.dlg-tabs {
  display: flex;
  border-bottom: 1px solid var(--hud-border);
  background: rgba(0, 0, 0, 0.15);
}
.dlg-tab {
  flex: 1;
  background: none;
  border: none;
  padding: 8px 12px;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}
.dlg-tab:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}
.dlg-tab.active {
  color: var(--accent);
  border-bottom: 2px solid var(--accent);
  background: rgba(255, 255, 255, 0.08);
}
.dlg-tab-content {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 250px;
  overflow: hidden;
}
.dlg-tab-content.hidden {
  display: none !important;
}

/* Nearby NPC list */
.nearby-npc-list {
  padding: 16px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 35vh;
}
.nearby-npc-item-btn {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--hud-border);
  border-radius: 8px;
  color: var(--text-main);
  text-align: left;
  cursor: pointer;
  transition: all 0.2s;
}
.nearby-npc-item-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--accent);
  transform: translateY(-1px);
}
.nearby-npc-item-info {
  display: flex;
  flex-direction: column;
}
.nearby-npc-item-name {
  font-weight: 600;
  font-size: 14px;
}
.nearby-npc-item-job {
  font-size: 11px;
  color: var(--text-dim);
}
.nearby-npc-item-dist {
  font-size: 12px;
  color: var(--accent);
  font-weight: 600;
}

#dialogue-panel {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(520px, 92vw);
  background: var(--hud-bg);
  border: 1px solid var(--hud-border);
  border-bottom: none;
  border-radius: 14px 14px 0 0;
  backdrop-filter: blur(10px);
  display: flex;
  flex-direction: column;
  max-height: 55vh;
}
#dialogue-panel.hidden {
  display: none;
}
.dlg-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--hud-border);
}
.dlg-header-info {
  display: flex;
  flex-direction: column;
}
#dialogue-npc-name {
  font-weight: 700;
  font-size: 16px;
}
#dialogue-npc-meta {
  font-size: 12px;
  color: var(--text-dim);
}
#dialogue-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
}
#dialogue-close:hover {
  color: var(--text-main);
}
#dialogue-log {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 120px;
}
.dlg-line {
  max-width: 85%;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.5;
}
.dlg-player {
  align-self: flex-end;
  background: var(--accent);
  color: #04222c;
}
.dlg-npc {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.1);
}
.dlg-system {
  align-self: center;
  color: var(--text-dim);
  font-size: 12px;
  background: none;
  padding: 2px;
}
#dialogue-thinking {
  align-self: flex-start;
  color: var(--text-dim);
  font-size: 12px;
  padding: 0 16px 6px;
}
#dialogue-thinking.hidden {
  display: none;
}
.dlg-actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 16px;
  border-top: 1px solid var(--hud-border);
  background: rgba(255, 255, 255, 0.02);
}
.dlg-action-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--hud-border);
  color: var(--text-main);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 11px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.dlg-action-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: var(--accent);
}
.dlg-action-btn.primary {
  background: rgba(58, 198, 240, 0.15);
  border-color: var(--accent);
  color: var(--accent);
}
.dlg-action-btn.primary:hover {
  background: rgba(58, 198, 240, 0.25);
}

.dlg-input-row {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--hud-border);
}
#dialogue-input {
  flex: 1;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--hud-border);
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--text-main);
  font-size: 14px;
  resize: none;
}
#dialogue-input:focus {
  outline: 1px solid var(--accent);
}

/* ---------- Settings modal ---------- */
.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-overlay.hidden {
  display: none;
}
.modal-box {
  background: #171a20;
  border: 1px solid var(--hud-border);
  border-radius: 14px;
  width: min(420px, 92vw);
  padding: 20px;
}
.modal-box h2 {
  margin: 0 0 4px;
  font-size: 18px;
}
.modal-desc {
  color: var(--text-dim);
  font-size: 12px;
  margin: 0 0 16px;
  line-height: 1.6;
}
.form-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}
.form-row label {
  font-size: 12px;
  color: var(--text-dim);
}
.form-row input, .form-row select {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--hud-border);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--text-main);
  font-size: 14px;
}
.form-row input:focus, .form-row select:focus {
  outline: 1px solid var(--accent);
}
.modal-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 16px;
  gap: 8px;
}
.modal-actions-right {
  display: flex;
  gap: 8px;
}
.settings-status {
  font-size: 12px;
  min-height: 16px;
}
.settings-status.ok { color: #7ee787; }
.settings-status.error { color: var(--accent-bad); }

/* ---------- Economy panel ---------- */
#economy-panel {
  position: absolute;
  top: 70px;
  left: 270px;
  width: 260px;
  max-height: 70vh;
  background: var(--hud-bg);
  border: 1px solid var(--hud-border);
  border-radius: 12px;
  backdrop-filter: blur(8px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  z-index: 10;
  pointer-events: auto;
}
#economy-panel.hidden {
  display: none;
}
#economy-panel-header {
  padding: 10px 14px;
  border-bottom: 1px solid var(--hud-border);
  font-weight: 700;
  font-size: 13px;
}
#economy-panel-body {
  overflow-y: auto;
  padding: 10px 14px;
  font-size: 12px;
  line-height: 1.6;
}

/* ---------- Player panel ---------- */
#player-panel {
  position: absolute;
  top: 70px;
  left: 14px;
  width: 240px;
  background: var(--hud-bg);
  border: 1px solid var(--hud-border);
  border-radius: 12px;
  backdrop-filter: blur(8px);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: auto;
  z-index: 10;
}
.player-panel-header {
  font-weight: 700;
  font-size: 14px;
  border-bottom: 1px solid var(--hud-border);
  padding-bottom: 6px;
  margin-bottom: 4px;
}
.player-stat {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
}
.player-stat-bar-container {
  display: grid;
  grid-template-columns: 50px 1fr 45px;
  align-items: center;
  gap: 6px;
  font-size: 11px;
}
.stat-bar {
  background: rgba(255, 255, 255, 0.1);
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  width: 100%;
  transition: width 0.2s ease;
}
.bar-fill.hunger { background: #e67e22; }
.bar-fill.energy { background: #f1c40f; }
.bar-fill.health { background: #2ecc71; }
.bar-fill.fuel { background: #f39c12; }

.inventory-section {
  border-top: 1px solid var(--hud-border);
  padding-top: 8px;
  margin-top: 4px;
}
.inv-title {
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 6px;
}
.inv-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 140px;
  overflow-y: auto;
  font-size: 11px;
}
.inv-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.04);
  padding: 4px 6px;
  border-radius: 4px;
}
.inv-item-name {
  font-weight: 600;
}
.inv-item-use-btn, .btn-sm {
  background: var(--accent);
  color: #04222c;
  border: none;
  border-radius: 4px;
  padding: 2px 6px;
  cursor: pointer;
  font-size: 10px;
  font-weight: bold;
  transition: background 0.15s;
}
.inv-item-use-btn:hover, .btn-sm:hover {
  background: var(--accent-hover);
}
.inv-item-actions {
  display: flex;
  gap: 4px;
  align-items: center;
}
.inv-item-use-btn:hover {
  background: #5ad4f5;
}
.econ-market, .econ-group {
  margin-bottom: 12px;
}
.econ-row {
  display: flex;
  justify-content: space-between;
  color: var(--text-dim);
}
.econ-building {
  margin: 6px 0;
  padding: 6px 8px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.1s;
}
.econ-building:hover {
  background: rgba(255, 255, 255, 0.12);
}
.econ-building.pinned {
  background: rgba(241, 196, 15, 0.12);
  border: 1px solid rgba(241, 196, 15, 0.4);
}
.econ-building-name {
  display: flex;
  justify-content: space-between;
  font-weight: 600;
}
.econ-cash {
  color: #7ee787;
  font-weight: 400;
}
.econ-building-detail {
  color: var(--text-dim);
  margin-top: 2px;
}

/* Scrollbar styling for panels */
#dialogue-log::-webkit-scrollbar,
#economy-panel-body::-webkit-scrollbar {
  width: 6px;
}
#dialogue-log::-webkit-scrollbar-thumb,
#economy-panel-body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.toast {
  background: rgba(30, 30, 40, 0.9);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-normal);
  padding: 12px 20px;
  border-radius: 8px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
  font-size: 14px;
  min-width: 250px;
  max-width: 400px;
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  pointer-events: auto;
}
.toast.show {
  opacity: 1;
  transform: translateY(0);
}
.toast.warn {
  border-left: 4px solid var(--accent-warn);
}
.toast.error {
  border-left: 4px solid #ff5555;
}
.toast.success {
  border-left: 4px solid #7ee787;
}
