* {
  box-sizing: border-box;
  user-select: none;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0b0f17;
  color: #e6edf7;
  font-family: 'Segoe UI', 'Hiragino Sans', 'Noto Sans JP', system-ui, sans-serif;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  touch-action: none;
}

.hud-root {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}

.panel {
  pointer-events: auto;
  background: rgba(12, 18, 30, 0.78);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(130, 175, 235, 0.28);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.42);
}

/* Top Left */
.hud-top-left {
  position: absolute;
  top: 12px;
  left: 12px;
  padding: 9px 11px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 245px;
}

.row-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.btn-link {
  color: #9dc8ff;
  text-decoration: none;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(88, 166, 255, 0.14);
  border: 1px solid rgba(88, 166, 255, 0.28);
}

.btn-link:hover {
  background: rgba(88, 166, 255, 0.28);
}

.badge-discover {
  font-size: 12px;
  font-weight: 700;
  color: #ffd866;
  background: rgba(255, 216, 102, 0.14);
  border: 1px solid rgba(255, 216, 102, 0.32);
  padding: 2px 9px;
  border-radius: 999px;
}

.seed-row {
  display: flex;
  align-items: center;
  gap: 5px;
}

.seed-label {
  font-size: 11px;
  font-weight: 700;
  color: #8aa5c7;
  letter-spacing: 0.05em;
}

#seedInput {
  width: 112px;
  padding: 3px 7px;
  border-radius: 6px;
  border: 1px solid rgba(140, 175, 220, 0.32);
  background: rgba(8, 12, 20, 0.85);
  color: #f0f6ff;
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

#seedInput:focus {
  outline: none;
  border-color: #62b0ff;
}

.toggle-row {
  display: flex;
  gap: 5px;
}

.btn-sm {
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid rgba(140, 175, 220, 0.28);
  background: rgba(30, 44, 68, 0.85);
  color: #dce8f7;
  font-size: 11.5px;
  font-weight: 600;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.btn-sm:hover {
  background: rgba(48, 72, 110, 0.92);
  border-color: #7ab8ff;
}

.btn-sm.is-active {
  background: rgba(58, 120, 210, 0.85);
  border-color: #93c8ff;
  color: #ffffff;
}

/* Top Center Compass */
.hud-compass {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 10px 5px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

#compassCanvas {
  display: block;
  width: 340px;
  height: 30px;
  border-radius: 6px;
  background: rgba(7, 11, 18, 0.72);
  border: 1px solid rgba(120, 160, 215, 0.2);
}

.compass-target {
  font-size: 11.5px;
  font-weight: 600;
  color: #ffd866;
  white-space: nowrap;
}

/* Top Right Minimap */
.hud-minimap {
  position: absolute;
  top: 12px;
  right: 12px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

#minimapCanvas {
  display: block;
  width: 160px;
  height: 160px;
  border-radius: 6px;
  border: 1px solid rgba(125, 165, 220, 0.28);
  background: #0d213d;
  image-rendering: pixelated;
}

.minimap-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.coords-text {
  font-size: 11px;
  color: #9cb3d1;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* Toast Banner */
.toast-banner {
  position: absolute;
  top: 78px;
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(14, 22, 38, 0.92);
  border: 1px solid rgba(255, 216, 102, 0.55);
  color: #ffe285;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55);
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  white-space: nowrap;
}

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

.toast-banner.warn {
  border-color: rgba(255, 110, 95, 0.72);
  color: #ffaba1;
}

/* Bottom Left Instruments & Mode Switcher */
.hud-bottom-left {
  position: absolute;
  bottom: 12px;
  left: 12px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: calc(100vw - 24px);
}

.instruments {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.inst-box {
  background: rgba(8, 13, 22, 0.76);
  border: 1px solid rgba(120, 160, 215, 0.22);
  border-radius: 7px;
  padding: 4px 9px;
  min-width: 74px;
  display: flex;
  flex-direction: column;
}

.inst-label {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #7d96b8;
}

.inst-val {
  font-size: 14px;
  font-weight: 700;
  color: #f0f6ff;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.mode-bar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.mode-btn {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 7px;
  border: 1px solid rgba(135, 175, 225, 0.26);
  background: rgba(24, 35, 54, 0.85);
  color: #bfd0e6;
  font-size: 12.5px;
  font-weight: 600;
  transition: transform 0.1s ease, background 0.12s ease, border-color 0.12s ease;
}

.mode-btn:hover {
  background: rgba(42, 62, 96, 0.92);
  border-color: #6ab4ff;
}

.mode-btn.active {
  background: linear-gradient(180deg, #327ae6 0%, #245ec0 100%);
  border-color: #9ed0ff;
  color: #ffffff;
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(47, 122, 229, 0.4);
}

.mode-btn .k {
  display: inline-block;
  padding: 0 5px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.35);
  font-size: 11px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: #ffd866;
}

.key-guide {
  font-size: 11.5px;
  color: #a9bedb;
  line-height: 1.4;
}

/* Big Map Modal */
.big-map-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 15, 0.68);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 25;
}

.big-map-backdrop.hidden {
  display: none;
}

.big-map-card {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.big-map-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.big-map-legend {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11.5px;
  color: #b8cae0;
}

.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 4px;
}

.dot-air { background: #60b5ff; }
.dot-town { background: #ff7766; }
.dot-light { background: #ffe46b; }
.dot-peak { background: #e89aff; }
.dot-player { background: #52ff9b; }

#bigMapCanvas {
  display: block;
  width: min(440px, 84vw);
  height: min(440px, 84vw);
  border-radius: 8px;
  border: 1px solid rgba(135, 175, 225, 0.3);
  background: #0d213d;
  image-rendering: pixelated;
}

@media (max-width: 820px) {
  .hud-compass {
    top: auto;
    bottom: 132px;
  }
  #compassCanvas {
    width: 260px;
  }
  .hud-minimap {
    padding: 6px;
  }
  #minimapCanvas {
    width: 116px;
    height: 116px;
  }
}
